To investigate how apps behave with a poor network connection, it's useful to be able to introduce controlled amounts of latency, jitter, and packet loss in a test environment.
For example, you might want to make a Skype for Business video call and see what happens as the network connection quality degrades and recovers.
This blog provides a step-by-step guid to create a degraded Windows network, entirely in software on your PC.
We run Windows in a virtual machine (VM) that connects directly to a Ubuntu VM and then through the Ubuntu VM to the Internet.
You need the ability to run VMs and connect them via networking. This can be done with software such as Microsoft Hyper-V, VMware Workstation, or Oracle Virtual Box.
You need at least two VMs: one running Windows, where you run the software whose connection you want to degrade, and one running Ubuntu where the network connection will be degraded.
1. Configure your Windows VM
a. One network card - host-only
2. Configure your Ubuntu VM
a. First network card 'eth0' - host-only
b. Second network card 'eth1' - providing internet connectivity (e.g. bridged)
3. In Windows
a. Set the network default gateway of to the IP address of eth0 on the Ubuntu VM
b. Set the subnet mask to 255.255.255.0
c. Set the DNS to 8.8.8.8 / 8.8.4.4
4. In Ubuntu
a. Add the following line to /etc/sysctl.conf
i. net.ipv4.ip_forward = 1
b. Run the following commands
i. sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
ii. sudo iptables -A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iii. sudo iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
5. In Windows, verify that you can connect to the internet
a. tracert google.com
b. You should see the IP address of eth0 on the Ubuntu VM as the first hop
You run commands on the Ubuntu machine.
• Add Latency: sudo tc qdisc add dev eth0 root netem delay 154ms
• Add Jitter: sudo tc qdisc add dev eth0 root netem delay 100ms 10ms distribution normal
• Add Packet Loss: sudo tc qdisc add dev eth0 root netem loss 10%
• Show degradations: sudo tc qdisc show
• Remove all degradation: sudo tc qdisc dev dev eth0 root
Be judicious with introducing poor quality!
Sometimes you may not get the test results you want. If the quality is too low, apps might just give up.
To test apps with low quality, you might need to carefully tune the amount of network degradation to see what happens - e.g. reduction in video or audio quality.