A couple of products I work on, SQLFire is one of them, have WAN features for linking different datacenters together with asynchronous replication. Whenever I tell people about it the first thing they ask is what happens if the same data is updated in both datacenters at the same time. I don’t really know all that well, so I wanted to tool that would help me learn more about it, I needed a WAN emulator.
I looked at a couple of WAN simulators, specifically WANem and Dummy Cloud. WANem gave me a pretty bad impression, it’s text UI is extremely buggy and I didn’t even notice that it is supposed to be driven by its Web UI. Maybe the rest of the product is better but I’m looking for something as simple as possible. Dummy Cloud looks pretty good, and is loaded with features. Too many features actually, for what I want, and the free version doesn’t let you do really high latencies. So I decided to roll my own. I packaged the results as the WANatronic 10001 virtual appliance you can run on VMware Workstation, and probably ESX and Fusion as well.
- Can work with nothing but a laptop (no actual network required).
- As small and lightweight as possible.
- Simple, as close to zero configuration as possible.
- Really cool name.
I think things turned out fairly well. Namely:
- Traffic sent directly to WANatronic 10001 is sent right back to whatever host it originated from. If you ping WANatronic 10001 you’re actually pinging yourself. Same with SSH, etc.
- Packaged as a VM needing 32MB and a download size of about 170MB, which unfortunately is small as far as virtual appliances go.
- There are 4 things you can configure. If you’re lazy and don’t configure anything, WANatronic 10001 will still work.
- That’s pronounced WAN-a-tron-ic ten-thousand-one in case you were wondering. Just try to forget that name. See? You can’t do it.
Using WANatronic 10001
Possibly the most interesting thing, and the thing I think I’ll use it most for, is simulating slow links on a single host. In this case there is nothing you need to do on your computer. In the screenshot above my WANatronic is at 10.24.0.13. Any traffic I send to that IP is sent right back to me. So if I have two processes on my host that I want talking slowly, let’s say one is on port 8000 and one is on port 9000, all I do is tell the first application that its peer is on 10.24.0.13:9000 and tell the second one its peer is on 10.24.0.13:8000. Done.
WANatronic can also function as a router-on-a-stick, all you need to do is route traffic through WANatronic. For example Google’s free DNS is located at 22.214.171.124. If you want to simulate being on a slow network between here and there run:
ip route add 126.96.36.199 via 10.24.0.13
Your IP address will be different from mine, check the console to see what it is. You may need to adjust that command based on your OS. With that set up, ping 188.8.131.52 to see the effect of latency and packet loss.
Last but not least, configuration is via the console since there is no way to remotely connect to WANatronic. Changes are automatically saved and applied.
Technical Mumbo Jumbo
WANatronic uses Ubuntu 8.04 JEOS as a base. I used this older distro to cut down on the size of the virtual appliance, which unfortunately is still huge. For the most part WANatronic is a very basic use of the iptables and tc utilities. The WANatronic source code is hosted on GitHub.
There is one exception that required a little bit of science. I really wanted any traffic sent to WANatronic to be NATted directly back to me. Without this I would need to use multiple network interfaces which I wanted to avoid. As far as I can tell there’s no way to do that with iptables, so I made a custom version of the iptables NETMAP target that would replace the packet’s destination address with its source address in PREROUTING. After that the packet is NATted so it appears to originate from WANatronic. This is the magic that lets you talk to yourself on what appears to be a very crappy link. Perfect for a demo that needs to reside completely on a single laptop.
Stuff It Doesn’t Do
Plenty of things really but things that come to my mind include:
- Static IPs (seems useful)
- Routing stuff like OSPF (not going to happen)
- Remote management (not sure it’s worth it)
- IPv6 (does anybody actually use that)
- Really fancy stuff like packet reordering (not likely)
If you’ve got comments or would like to see something let me know.
In case you scrolled to the bottom for a download link here it is again: WANatronic 10001.