P2P-Over-MiddleBoxes-Demo
A simple demo of P2P communication over middle boxes such as NAT
compile:
make
run:
./server host port
./client
>>> help
FAQ
It doesn't work
UDP hole punching works only if both of the peers' NAT types are Cone NAT
.
How to check whether my NAT is cone NAT
There're tools for manually check the external NAT's type in tools. For example:
-
- cd tools && make
-
- run
tools/udp_server 2222
andtools/udp_server 3333
on your public server.
- run
-
- run
tools/udp_client
on your client
- run
-
- (
udp_client
) sendto server:2222 text
- (
-
- (
udp_client
) sendto server:3333 text
- (
-
- check your server output to see the output.
example server output:
$ ./tools/udp_server 3333
UDP bind on 0.0.0.0:3333
recv 4 bytes from [172.16.47.71:14781]: text
$ ./tools/udp_server 2222
UDP bind on 0.0.0.0:2222
recv 4 bytes from [172.16.47.71:14781]: text
For cone NAT, the from
part should be the same.
My NAT is cone NAT, but it still doesn't work
If your two peers are behind the same NAT, this NAT must support LOOPBACK TRANSMISSION
to forward messages. You can test it by using the utils(udp_server/udp_client
) in tools