OSC Over The Internet (Outside Networks)

    Mar 01 2013 | 8:49 am
    I am wondering if any of you know a way that I could have Max on one computer send and receive OSC data with another computer, also running Max.
    I know there is UDP Send, which I have used, but only for computers on my own network.
    Also, I know there is the net.tcp.send object, and am wondering if that is what I should use? If so, what IP address would I use, if say, I am on a wireless network which has one external IP, but using a computer that also has an internal IP.
    Ultimately I want to use this in M4L, so that a user in one state could control parameters on a computer in other state.
    Also, why isn't TCP used all the time, it seems like UDP is much more ubiquitous on local networks.
    Thanks a lot

    • Mar 01 2013 | 11:39 am
      [udpsend] and [udpreceive] are your friends. There's no difference whether you use them on a local or a non-local network.
      To answer your question related to TCP vs. UDP, you should google for the two protocols and you'll see (I suggest Wikipedia). The basic difference between the two protocols is that the UDP protocol doesn't care whether your messages reached the destination or not (in fact, it doesn't even check whether the destination address actually exists or not), whereas with TCP the sender will receive a confirmation from the receiver that the packet has been successfully transmitted, and if not, it will automatically attempt to re-send your message again. Because of this, with TCP, you are guaranteed that the receiver will get your messages in the exact order in which you sent them, whereas with UDP the order of the arrival of the packages is not guaranteed.
      Why would anybody in Earth use UDP if it's so bad and unreliable compared to TCP, you might ask? Well, since UDP doesn't perform any additional check, it requires less bandwidth (you have to realize that with TCP you'll generate a confirmation package in the reverse direction for each message that you send), and also, because it won't wait for delayed messages (you need to do this with TCP to guarantee the arrival ordering), in most cases, it performs faster. When you stream a lot of information where you might actually not care if some parts of the stream just disappear, then you usually go with UDP, otherwise, you normally use TCP.
      However, either UDP or TCP, if you go outside your local network, you need to make sure that firewalls etc. won't block you and that the proper port forwardings are set up in your local routers (see Wikipedia etc. for more info on this) on both sides, otherwise you might end up with a broken connection.
      Hope this helps,
    • Mar 01 2013 | 4:09 pm
      TCP is also connection-based, so the setup and teardown is a bit more complicated. (For UDP you just start firing, or listening for, packets.)
      For what it's worth (and it's many years since I took a networking class) TCP doesn't have to acknowledge every packet sent, so long as it can acknowledge the most recent of an uninterrupted sequence. It's protecting against reordering for packets travelling across the Internet where the routing may change from packet to packet; on a single LAN that shouldn't matter.
    • Mar 01 2013 | 10:15 pm
      Thank you for your detailed explanation, I was hoping to hear from you specifically on this, as you seem to know a lot.
      I am preparing to give it a shot with [udpsend] (how do you make the text do that BTW?) but I am concerned with going outside my local network. It will assuredly be Mac to Mac, and I know how to check both my internal and external IP, but they are so different. For instance, my internal IP is almost always, 192.168.1.XXX and when i ask google it is usually something quite different, such as 76.171.97.XXX
      I guess I will send it to the external IP and make sure I completely understand port forwarding, which I do not right now. Am I correct to believe that port forwarding is the away around internal/external static/dynamic ip addressing issues?
      Also, if I am using UDP on a known port and IP, in theory, couldn't anyone with access to the internet send OSC messages to my machine (in theory wreaking havoc) on my live set?
      Thanks again, your contributions to the forum are great cassiel.
    • Mar 02 2013 | 6:39 pm
      You need to send to the external IP of the router that's looking after the destination LAN - and that router needs to be set up to do reverse-NAT (port forwarding) so that incoming packets are routed to the appropriate host on the LAN.
      Yes, if your external IPs are globally routable, anyone on the Internet could send packets to the destination. You should firewall the destination router so that it'll only forward packets originating from the external-facing IP of the source router.
    • Mar 03 2013 | 11:30 am
      Oh, and as an aside: if you use a TCP protocol then you probably won't have to worry about routing the packets back to the client machine: routers generally do reverse packet routing on responses.
    • Mar 04 2013 | 1:13 am
      Thank you again cassiel. I believe you are located in the UK or somewhere outside the US (where I am located) so the rules may be different but I am wondering about something else.
      My ISP only provides static IP addresses to businesses, so I do not think I can get a static IP. I use OS X and read several "How To" guides on setting up a static IP, (like this http://www.howtogeek.com/howto/22161/how-to-set-up-a-static-ip-in-mac-os-x/)
      only to realize (after breaking my LAN network setup) that I have to get a static IP address from my IP, and that I can't just type in some static IP address (at least I think that is correct).
      I was told the dynamic ip leases are usually about a month so I am guessing that my external IP will remain the same for about a month before switching, long enough to connect via UDPsend with another computer. Do you think this is correct?
      Also, does Max even have a TCPSend object? It is very straightforward to use UDP, as you pointed out, but you also pointed out some benefits to using TCP, and, in your last post, again mentioned using TCP. I know you recommended UDP, I am just wondering what max object I would use for TCP if I wanted to try that way as well.
      One last thing on which I would like your opinion. I have heard more than one person say OSC is a "UDP Protocol" basically saying that you couldn't use TCP to send OSC data. This doesn't seem to make any sense, but here it is http://www.frieder-weiss.de/eyecon/Manual/udp-osc.htm
      Again, I see why UDP seems standard, just wondering if it could be done with TCP
    • Mar 04 2013 | 2:24 am
      ^ This should sort you for an internet-facing static IP. There are other tools / services, but this is the one I've used in the past with decent results.
      The term for this is Dynamic DNS. It's free (in this instance) - don't go giving your ISP cash money for this.
    • Mar 04 2013 | 11:04 am
      Thank you Johnny, I have a noip account now. Here is my question about this:
      If I make my account http://www.example.noip.org and I plan to use port 8000, well UDPSend needs an IP address right? I don't think I can send osc messages to http://www.example.noip.org:8000 because that is not an IP address but rather a URL. Am I mistaken here?
    • Mar 04 2013 | 12:52 pm
      www.example.noip.org is a server name that will resolve to an IP address, presumably your external address if you set everything up properly.
      From a max network object, you should be able to enter as the args
      www.example.noip.org 8000
      However, although I'm not familiar with noip.org (I use dyndns.org for this sort of thing), I would have thought that if you got the subdomain 'example.noip.org' then that will be sufficient, you won't need the www prefix so your args would be
      example.noip.org 8000
      To gst this, you should be able to open a terminal window and type
      ping example.noip.org
      Even though you might not get a response if the ping service is blocked, it should immediately display the IP address to which it is trying to connect and that should be your external IP address if you configured everything properly.
    • Mar 04 2013 | 7:31 pm
      ^ This.
      You get something like "mydomain.noip.org" and it all plays out as above once you configure everything correctly. Port-forwarding, UPnP, whatever it takes - firewall config etc.
      dhjdhjdhj, nice catch. :)
    • Mar 05 2013 | 2:36 am
      Wow. to all of you, thank you very much for the help. I just tested my idea (just sending a fader's values from one device to another on separate networks) and it worked! (Hopefully bigger things to come).
      It is correct, example.no-ip.org (then the port number) is all that is needed.
      Interestingly at first there was about 3 seconds of latency but quickly that dropped to under a second.
      One remaining question, cassiel mentioned "You should firewall the destination router so that it'll only forward packets originating from the external-facing IP of the source router."
      How can I do that? I looked at the setup for my (destination router, where I setup port forwarding) and I can't find any place to do it. Is there a firewall program. You guys have helped so much. Thank you
    • Mar 05 2013 | 11:52 am
      I don't know what kind of router you're using, but most of them include some kind of firewall. You want to make sure that you only accept UDP packets on the incoming port if they come from your transmitting address.
    • Jan 08 2014 | 4:26 pm
      hey startec, is there a chance that you post a working example, of corse not with personal data. thanks
    • Mar 08 2014 | 6:48 pm
      @Mr Good,
      It is really straightforward if you follow the helpful posts by others (above). All it would be is a udpreceive and a certain port number, I choose 8080 and, on the other computer, a udpsend with the computer's ip address, and the same port. You can then send just about any message into the udpsend and it would theoretically come out the udpreceive
      Note, the message needs to be sent to the external ip address.
      I am betting you are using a router, possibly a wireless one. The hardest part is configuring the port forwarding so that the messages sent to port 8080 get forwarded to the local ip address of the receiving computer. Not the sending of the actual max messages.
    • Nov 16 2014 | 2:03 pm
      Hi there just to understand so you have to put "example.noip.org 8000" (whatever the proper account) in the udpsend object?
    • Apr 08 2015 | 4:03 am
      Alright I think I understand everything outlined in this thread. Let me attempt to summarize. Please correct me if I have anything wrong. First thing is to set up port forwarding on our routers, like this
      and then we just use the external IP address which can be found at a site like
      the only thing is that IP address can change and if you don't want to have to look it up every time you can get an account at noIP.com where you will get a single domain name to use instead. You download a program
      that detects changes in your IP address and keeps it linked with your domain name.