This repository provides a simulated Restricted Cone NAT environment using Mininet and iptables, and Python scripts for UDP Hole Punching.
Note that only Linux is supported since Mininet depends on the Linux network namespaces.

Please ensure that Mininet is installed before using this repo. If not, refer to Download/Get Started With Mininet for installation instructions.
# Start up the topology and run the Mininet CLI.
$ sudo python3 udp-hole-punching/network.py
# Run server script (bootstrap node) in the background.
mininet> h0 python3 -u udp-hole-punching/server.py 0.0.0.0 9000 &
# Run client script at h1.
mininet> h1 python3 -u udp-hole-punching/client.py h0 9000 &
# Run client script at h2.
mininet> h2 python3 -u udp-hole-punching/client.py h0 9000 &
# See the logs by the server and clients.
mininet> h1 cat /tmp/udp-hole-punching.log
# See the iptable status of nat* nodes.
mininet> nat1 iptables -L -v -n
mininet> nat2 iptables -L -v -n
