OSC Over The Internet (Outside Networks)
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
[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,
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.
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.
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.
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.
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
^ 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.
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?
http://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
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
To gst this, you should be able to open a terminal window and type
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.
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. :)
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
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.
hey startec, is there a chance that you post a working example, of corse not with personal data. thanks
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
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.
Hi there just to understand so you have to put "example.noip.org 8000" (whatever the proper account) in the udpsend object?
Forums > MaxMSP