Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Linux - Simulating Degraded Network Conditions

DZone's Guide to

Linux - Simulating Degraded Network Conditions

When testing an application or service, it can be very useful to simulate degraded network conditions. This allows you to see how they might perform for users.

· Agile Zone
Free Resource

Reduce testing time & get feedback faster through automation. Read the Benefits of Parallel Testing, brought to you in partnership with Sauce Labs.

When testing an application or service, it can be very useful to simulate degraded network conditions. This allows you to see how they might perform for real users. Testing on a controlled LAN is not always realistic, since the LAN has much different network properties than a real user would experience over a WAN.

I will give examples using 2 tools that alter a network interface's properties. The tools are: NetEm and Wondershaper.

NetEm is an enhancement of the Linux traffic control facilities that allows you to add delay, packet loss, duplication, corruption, reordering, and more to outgoing packets from a specified network interface. NetEm is controlled by the command line tool tc, which is part of the iproute2 package and included in most Linux distros.

Wondershaper is a traffic shaping script that allows you to throttle network transfers on a specified network interface. This is useful for testing latency when bandwidth is limited.



Examples:

tc/NetEm:

add fixed 250ms delay to all outgoing packets on Ethernet interface eth1:

$ sudo tc qdisc add dev eth1 root netem delay 250ms

turn it off:

$ sudo tc qdisc del dev eth1 root netem 



Wondershaper:

limit bandwidth of eth1 interface to 256kbps upload and 128kbps download:

$ sudo wondershaper eth1 256 128

turn it off:

$ sudo wondershaper clear eth1

The Agile Zone is brought to you in partnership with Sauce Labs. Discover how to optimize your DevOps workflows with our cloud-based automated testing infrastructure.

Topics:
agile ,python ,testing ,linux

Published at DZone with permission of Corey Goldberg, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}