Network issues emulation using WANem

The picture to attract attention One of the TestLab² customers recently asked for a detailed test of his custom installer with optional run-time downloads on various Internet connections. It was a pleasant surprise to see that our default wired and wireless connections are too good to cause any issues with the downloader, so we went for special tools. For some reason, software emulators are way less popular then hardware ones (which are cool, of course, but totally out of budget).

One of them became a favorite: WANem. I’d like to make an overview of it and provide a quick start-up tutorial.

What is WANem?

It’s a special Linux live CD based on knoppix and netem, aimed to emulate various networking issues in a universal, routing-based approach.

WANem uses human-readable rules, which can be set up as manually (through a dedicated CLI) or using a web interface.

How WANem can be actually used?

I recommend using a virtualization platform of your choice, and just booting a small VM using WANem Live CD.

Alternatively, if you use VMWare products — you can directly download WANem appliance. Further tutorial is based on a LiveCD approach.

Preparation

Create a new virtual machine with enough NICs to replicate the necessary configuration. 1 CPU core and 256Mb ram would be just fine. Set up a downloaded WANem iso file as a boot source, power the VM on and confirm boot from CD.

Either accept automatic DHCP configuration or skip it (and then set up the IP configuration manually).

A setup script creates perc user and asks for a password. You’ll be able to use it via SSH. After user creation completes, you can drop direct VM console and use SSH (default port is 22) with the credentials from previous step.

After successful authorization you’ll face the dedicated WANem CLI. Start with a simple help command, which lists the available commands with a brief description:

  • help, lists available commands
  • about, version number and ©™
  • clear, clears the screen
  • reset, resets the IP configuration to default values and restarts daemons
  • shutdown, immediate shutdown
  • restart, immediate restart
  • status, shows current WANem status (IP addresses, routes, daemon states)
  • wanemreset, drops all internal WANem rules in case you’ve messed up with configuration and can’t work through a web interface
  • assign, set up an IP configuration manually
  • quit, from WANem CLI to system shell

wanem 1 Now you can open http://eth0 IP address/WANem/ in your browser and see the WANem web interface. The following functions are available:

  • WANalyzer — a simple connectivity testing tool, which shows the following results: http://i.imgur.com/XCbOj.png
  • Basic Mode — a simple configuration mode, which allows to set up bandwidth limitation and packet processing delay
  • Advanced Mode allows to fine-tune any details of the connection emulation, as well as the temporal distribution options
  • Save/Restore allows to save and load rules via plain text files (sample format)

Operability check

wanem 2 To ensure, that WANem operates correctly you should start from setting up a simple emulation rule, like ISDN 128 kbps bandwidth limitation and added latency of 500 ms.
After saving the rule you should tell a target machine with your test app to route its traffic through WANem:

  • Windows: route add 0.0.0.0 mask 0.0.0.0 WANemIPaddress
  • Debian: route add default gw WANemIPaddress eth0
  • Other operating systems: http://tinyurl.com/4yovdph

After that you should do a simple traceroute from target machine to, say, google.com and ensure that the first hop is WANem and the packet delivery latency is about 500ms.

Fine-tuning

wanem 3 After the Basic mode validation you’re sure, that routing works correctly. Now it’s time to dive deeper and make our emulation more realistic. First of all, we should set various temporal distribution options to randomize issues occurrence a little bit.
Also, you can set up disconnect/reconnect occurrence distribution, and average downtime. A few terms, which I needed to check for myself:

  • MTTF — mean time to failure
  • MTTR — mean time to recover [after the failure]
  • Jitter, in IP networking, basically means a difference (in milliseconds) between latency of delivery for two selected packets. You can find more details in RFC 3393.

A few more features: you can emulate connection existence but with zero data packages pass-through, set up a percentage of lost or corrupted packets.
WANem allows working with more than one NIC simultaneously so you’re basically limited only by your imagination and physical throughput to set up any networking configuration.

WANem alternatives

There are a few Windows products:

If you have MacOS and XCode 4.1/4.2 — you can use Network Link Conditioner bundled with XCode.

Conclusions

Clean, easy-to-use and effective tool. I expected to see some logs and analytics at the WANem side, but I suppose they can be generated by some third-party tools.
A few profiles we use for emulation: CDMA EV-DO rev.A, EDGE.
Official website: wanem.sourceforge.net/, distributive size ~400Mb
Latest version: 2.3, 15.03.2011

Posted by Alexander on Friday, September 09, 2011