What's the easiest way to set up a simulated network with ISP-style NAT? Preferably without buying dedicated hardware for the purpose, and preferably reproducible for other developers.

Usecase: I am developing a P2P system, and need a reasonably representative environment to test my software in, and how well it deals with shitty residential networking configurations.

I'm a developer, not a network engineer, so my knowledge of networks is limited to a developer perspective and I don't have the spoons to learn it in-depth.

Boosts appreciated :boost_requested:

Follow

@joepie91 I am in the same situation as you and I hate to say it but I have come to the conclusion that there's no substitute for the real thing.

In terms of simulating just the NAT part, the default networking configurations of Libvirt VMs and Docker containers should get you there. So for example, you could test two containers which are on different docker "bridged" networks, and see if you can get them to talk P2P in the usual way: the two will rendezvous somewhere like a STUN server, exchange each-others source ports, and then attempt to connect to each-other via UDP.

So for example:

* container A decides "I will create a socket with source port 12345"
* container B decides "I will create a socket with source port 43211"
* they exchange that info with eachother
* container A opens a UDP socket to the docker bridge IP address with source port 12345 and destination port 43211
* container B opens a UDP socket to the docker bridge IP address with source port 43211 and destination port 12345

To be honest I've never tried this, I have no idea if it will work but based on my somewhat limited understanding, it _should_ work for initial prototyping.

However the problem I see is that when it comes time to polish the application, you will run into situations where every home router is slightly different. I'm not aware of any tools which can simulate that. So far I have simply tried to deploy apps in as many different home networks as possible, those of my friends and family.

Sign in to participate in the conversation
Pixietown

Small server part of the pixie.town infrastructure. Registration is closed.