المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : NAT Traversal in C# (P2P behind firewalls/NAT Routers), UDP Hole Punching



C# Programming
04-12-2009, 12:52 PM
Hello,

in the last few weeks i've read a lot about NAT Traversal and i searched after Tutorials and so on (i think i've read almost all what's there to read). On most webpages i've read about STUN, a protocol, which should help me to connect to another client behind a NAT-Router or a firewall. Now my question... if i understand STUN, STUN is ONLY there to give me the public IP-Address and the characterization of my NAT (Full Cone, OpenInternet and so on) here on CodeProject is a great tutorial for it. But so HOW can i connect with this informations to another client? Well OK, i have a server and there i save my informations about the peers (ID, STUN-Informations, favorite Port for UDP Connections) and if i have a OpenINternet-Client (directly plugged in to the internet, no router, no firewall) everything is really easy, because each listens on the specific favorite port.

But what's if my clients are behind a NAT, which gives a counting port number (for example, UDP connection to STUN-Server on Port 45001, to the Server 45002 and to the peers maybe 45003-60000). How can i find out on which port i can reach my peer? I know theres a technique called UDP Hole Punching, there both peers build up a connection to each other, but the Ports are my problem! Has somebody any idea, how to find out the ports of the peers? The peer2 must know on which port peer1 is connected and peer1 must know from which port peer2 wants to connect. Thats really tricky and i doesn't come further on this. I develope since a few days on it and yes, the server works, i can exchange all communication-information i want, but the connection between the peers itself, there i found no way to connect http://www.barakasoft.com/script/Forums/Images/smiley_dead.gif

Kind regards, i hope somebody has THE idea in this or has experience in this Traversal technologies.