Simulation Slow Connectivity

How would your application behave with DSL, UMTS or Satellite connectivity? Simulate different network connection bandwidths, delay and packet loss and analyze the impact on your IoT application.  View Source

Connectivity is often the most important piece when it comes to IoT devices. Have you ever been in the situation when things work our perfectly fine on the developer’s desk and lab but fail randomly when deployed in the field? Believe it or not, connectivity plays a much large role when it comes to reliability of IoT devices. Using unreliable protocols such as UDP will save your bandwidth, but will require your application to adapt for potential packet loss or out of order deliveries.

Usual connection medium for IoT device gateways is often UMTS/GPRS. Is there a way you could simulate the speed of such devices while connected to WLAN or wired ethernet? Seems like there is one, thanks to the Linux tc command.

Introducing slow script

Slow script, originally developed by people at Modus create, utilizes linux tc command to modify the traffic shaping at egress and ingress. An excellent description of the tc command may be found at If it sounds too cryptic, don’t worry. The slow command is extremely user friendly. So let’s begin.

Test your existing latency

Start your Raspberry Pi and connect with the Internet network. In this example we will use hello IoT project which emulates a Raspberry pi and provides you a web based workspace to run your application. Once your Raspberry Pi is up, let’s ping to google and notice the latency.

As we can see, the latency is around 6ms which is ok for now. This may be different in your setup. Let’s add additional latency to this with slow command.

Get Slow script

Download slow command to your board and add execution right to the script

sudo chmod +x slow

Now le’t run the slow command with default arguments

sudo ./slow
Adding new queuing discipline
# tc qdisc add dev eth0 root handle 1: htb default 12
# tc class add dev eth0 parent 1:1 classid 1:12 htb rate 100kbps ceil 100kbps
# tc qdisc add dev eth0 parent 1:12 netem delay 350ms loss 0%

The command with default argument will simulate a 100 kbps connection with 350ms of latency. This corresponds to a UMTS connection. Now let’s try once again to measure the latency with Google.

The ping latency has substiantially increased to more than 350 ms. In order to reset things back to normal, run following

sudo ./slow reset

And things will be back to the normal.

What are the other options

Slow command has a plethora of network settings to choose from. You could even create a random packet loss with slow command.

slow 3G # Slow network on default eth0 down to 3G wireless speeds>>
slow 3G -l 600ms -p 10% # slow network on eth0 and setup latency to 600ms packetloss to 10%
slow reset # Reset connection for default eth0 to normal
slow vsat –latency=500ms # Simulate satellite internet with a high latency
slow dsl -b 1mbps # Simulate DSL with a slower speed than the default
slow modem-56k -d eth0 # Simulate a 56k modem on the eth1 device. eth0 is unchanged.

Remember that the slow command will also affect your SSH connectivity and and service on top of SSH such as SCP or SSHFS. So make sure to reset the connection once you have finished the tests by using command slow reset

Liked the guide? Have some feeedback ?
Your feedback is very motivating for us. Please don’t forget to leave your comments in our forum below.