UDP hole punching with ofxNetwork

Hi,

I have been searching to trying to find a way to do UDP hole punching with ofxNetwork or something similar. Has anyone done this before or know how to do this. I can easily send messages within the local network but I need to get out side the local network and set up a udp multi-client server to talk to a bunch of mobile devices and I don’t really know where to begin other then google but I can’t find much information on how to do this. Or does someone have a better way around doing this. Potentially the server will have to talk to thousands of mobile devices.

Any information would be appreciated.

Thanks,
Nick

What is your current network setup? If your server/of app is on an internal network, can you just configure port forwarding on the gateway that links the internal network to the internet?

I wont have access to the router to do that thats the issue.

You’ll still need a server on the internet that the of app can talk to, and the clients connect to. I don’t know it just sounds like the sort of thing that is going to cause you grief in the long run as its a bit of a hacky solution.

What exactly are you having trouble with? As I understanding, if you have your app (A) behind a gateway (G), a server on the internet (S) and a client ©, it goes like this:

  1. A connects to S and waits
  2. C connects to S
  3. S tells C the IP and Port of G, as well as the port C should listen on for data.
  4. C sends a packet to G, where it gets dropped
  5. S tells A the address of C and the port (from 3) C is expecting.
  6. A sends a packet to C using the destination port

Because udp is stateless, the gateway will be none the wiser and now pass packets between A and C

The biggest assumption is the gateways/routers/firewalls that A and C are behind allow outgoing udp connections. You can work around it by finding ports that are allowed out but it starts getting tricky there, especially if you’re not really sure of the setup for some arbitrary client C.

There is some pretty well documented socket code here http://www.rapapaing.com/blog/?p=24

The thing is if you have have a server on the internet that both clients and your apps are talking too, it might be better to put part of the processing on the server and have the clients and app communicate via that.

So lets just say your clients are reporting location, and your app is plotting them in real time. Write a service on the server that accepts client connections and records their current location data, and have another service running on it for the app to use that gets a big list of all currently reported client locations and does its magic based on that.

Why use UDP for a setup like this? This more hole digging than punching :stuck_out_tongue:

UDP hole punching is not even supported in all NAT implementations. If I were you I would look at something like zeromq.

Rg,

Arnaud