Re: UDP Hole Punching Demo

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"Hans Peter Gerdes" <noemail@xxxxxxxxxx> wrote in message
news:OfadcZV2GHA.328@xxxxxxxxxxxxxxxxxxxxxxx
Pete,
thanks for answer.
I searching for a sample source, because i am not a Socket and NAT
specialist, but i can read a lot out of the source. ;-)

Not that this is .NET specific (so this is pretty off-topic here), but here
are some resources that you may find helpful.

Winsock FAQ (.NET sockets are basically just Winsock with .NET wrapper):
http://tangentsoft.net/wskfaq/
Also, the FAQ covers a variety of basic UDP techniques with samples.

A paper that was recently presented on the topic:
http://www.usenix.org/events/usenix05/tech/general/full_papers/ford/ford_html/index.html
Note: the basic idea behind hole punching is simple...two peers both contact
a common third-party, who then provides destination information to each
peer. The peers then attempt to contact each other...in most cases, as long
as they use the same IP address and port that the common third-party was
using for each, the NAT router will route the UDP datagrams appropriately.

Wikipedia even has an article on the topic:
http://en.wikipedia.org/wiki/UDP_hole_punching

Of course, MSDN has some sample code with respect to use of UDP sockets in
..NET. But UDP sockets are pretty straight-forward. Make a datagram and a
Socket to send with, use SendTo to send it to a particular address (IP and
port), and use ReceiveFrom to receive a datagram from someone else.

One final comment: IMHO, hole-punching is not a very good technique to rely
on. There is talk of creating a standard that NAT routers can follow, but
IMHO the existing standard of Universal Plug-and-Play addresses these issues
reasonably well without relying on undefined behavior from the NAT router
(and I'd guess that at least as many NAT routers implement UPnP as can be
relied upon to support hole-punching).

Pete


.



Relevant Pages

  • Semantics of SO_REUSEADDR and P2P TCP NAT traversal
    ... I'm working on implementing a TCP NAT traversal scheme for a P2P ... port they are listening on, ... but this is transient - only one of the two sockets at each end ...
    (Linux-Kernel)
  • Re: NAT implementation in an IM driver
    ... OK, the OP can implement divert sockets in the IM driver, and then do the ... NAT work in user mode - but raw sockets are not enough for this. ...
    (microsoft.public.development.device.drivers)
  • Re: NAT is not a mechanism for securing a network.. but.. HELP!
    ... For years I have heard people claim that NAT could be ... > They debunk the myth that a NAT router provides as strong security as ... I went to a site that did ping testing with the ... I see the WG responding to the in the WatchGuard syslog by using ...
    (comp.security.firewalls)
  • Re: DNS cache poisoning - Wake up everyone!
    ... attack against a lonely client Mac cowering behind a NAT router. ... That's not the attack you need to be worrying about. ... they don't do recursive DNS do they? ...
    (uk.comp.sys.mac)
  • Re: Would a firewall prevent Sasser worm?
    ... >you are saying that NAT is a perfectly good firewall for a home ... A NAT router provides adequate protection for home users. ... These devices are designed to block inbound connections while allowing ...
    (comp.security.firewalls)