I wanted a way to do some controlled tests of WAN acceleration products, using a production network. You can buy or rent commercial WAN emulators, but for my purposes it seemed like an improvised solution would suffice. I had a couple of Cisco 2800 routers, a switch, and an ESXi box in my lab that I could press into service, so I built a test network that looks like this:
R1 acts like the WAN router at a branch site. It has a QoS policy with a "shape average" statement on its "WAN" interface to change the bandwidth to whatever we want to test.
R2 simply NATs the test traffic onto an IP address in the production network, since I didn't feel like configuring a new production subnet just for the test.
The ESXi box is where the fun part lives: I created two vSwitches and connected one physical NIC to each. I then spun up a simple Ubuntu 12.04 VM with eth0 and eth1 connected to each of the two vSwitches, giving me a separate network connected to each Cisco router. I then enabled routing on the Linux VM and created the appropriate static routes to enable the test and production networks to communicate. Finally, I used the "netem" WAN emulator built into the Linux kernel to inject delay, jitter, and packet loss into the network. Voila -- a network de-optimizer!
For testing the WAN accelerators, we'll just install one in the test VLAN and one between the Linux router and R2.
Here are the basic steps required to set up the Linux de-optimizer, in case you want to try to build your own:
1) Basic Ubuntu 12.04 VM. I used 4GB RAM and 24GB disk, but you could get away with less.
2) sudo apt-get install openssh-server Install SSH server so you can still get to the VM from the test network when you break the rest of the test environment. Do this before you break something... ask me how I know. Don't forget to enable SSH on your lab routers too...
3) Turn off Network Manager so it doesn't mess with your static addressing and routing config: edit the file /etc/NetworkManager/NetworkManager.conf and change "managed=false" to "managed=true"
4) Configure static addressing on your two NICs by editing /etc/network/interfaces:
iface eth0 inet static
iface eth1 inet static
5) Reboot or restart networking.
6) Enable IPv4 routing:
sudo sysctl -w net.ipv4.ip_forward=1
7) Configure static routes for the production and test networks:
sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 184.108.40.206
sudo route add -net 192.168.222.0 netmask 255.255.255.0 gw 220.127.116.11
In this case 18.104.22.168/24 is the network connecting to R1, 22.214.171.124/24 connects to R2, and 192.168.222.0/24 is the test VLAN.
You may also need to delete other routes if they were autoconfigured.
8) After testing that everything works, add some latency:
sudo tc qdisc add dev eth0 root netem delay 50ms 5ms
Do a search for "Linux netem" for a wider array of commands to change delay, jitter, and packet loss.
With this setup, the routing configuration and WAN emulation settings will NOT persist after a reboot, so you can always reboot if you screw something up. Start over at step 6.