Direct Client2Client behind NAT w/o router config!

Blitz3D Forums/Blitz3D Programming/Direct Client2Client behind NAT w/o router config!

Andy UK(Posted 2005) [#1]
If anyone is interested in UDP blitz networking client to client with NAT autodetect and 99% NAT traversal without any configuration of the NAT/Router or client, i can list a full description of whats involved, but only if people want it as its alot to type and i hate typing!


Naughty Alien(Posted 2005) [#2]
..type it..I'm interested..


BlitzSupport(Posted 2005) [#3]
Yeah, this would be handy to know as it seems to be quite an obstacle otherwise...


Andy UK(Posted 2005) [#4]
i actually discovered this by accident while programing my live audio network. picture the scinario where 2 clients, each behind it's own NAT/Router want to send/recieve data between eachother. imagine both clients are listening for data on udp port 8000. assuming both clients know eachothers ip addresses and the ports they are listening on, simply opening port 8000 on each router is enough to let them both communicate. supprisingly enough most people dont know how to open ports on routers and this will almost deffinatly limmit the prospective user audience, not good if your hoping to make money from your new network application. when a client behind a nat sends data outside of its local network, the port number its sent on is decided by the nat and not the application that is sending for example, client 1 sends data to client 2 on port 8000, if client 2 is not behind a nat it should get the data no problem. now heres the interesting bit, client 2 recieves the data but for some reason it recieved the data from client 1's internet ip on port 62000. why? here's why http://www.brynosaurus.com/pub/net/p2pnat/ as long as client 2 knows what ip and port client 1 sent from, replying to this ip/port will work because thats what NAT's are supposed to do. If the nat on client 1's network recieves a message from the ip it sent to on port 62000, it accepts the packet. the next important bit is to make sure all the clients who want to communicat directly with eachother know eachothers external ip/NAT port. this is as simple as hosting a server that records clients ip/ports and passes them on to other clients on the network. obviously the server must not be behind a nat, but if it is, you can open the port its listening on, on the router. sorry im at work and trying to dodge the boss while i type this, the link will actually make sense as just reading this back to myself, im baffled. so to recap, if u send a packet to a client on port 8000, the recieving client cannot send back to your ip on the same port because your nat sent the message from a different port, as long as u know this port u can reply.


Andy UK(Posted 2005) [#5]
i think i might make an interactive demo/tutorial for my first code archive entry :)


Carolinaaa(Posted 2006) [#6]
Hello Andy, i'm very interested to know how to traverse nat routers without needing to configure them; could you post a pice of code of how to do it? thank you.


Wings(Posted 2006) [#7]
Interesting indeed. But How dose client 1 know to check port 62000 cause client 1 is listening on port 8000 ?

this i must test out indeed tonoght..


t3K|Mac(Posted 2006) [#8]
this is a german text (for those germans here, like me) about the same thing: http://www.heise.de/security/artikel/82054