this documentation is incomplete. Reach out to @zborffs for questions.
This is a Python package for (1) simulating and (2) testing the performance of lossy networks.
Specifically, this package can do the following:
- Enforce a network interface on machine to have a set (average/standard deviation) (ingress/egress) bandwidth.
- Enforce a network interface on machine to have a set (average/standard deviation) egress loss rate.
- Enforce a network interface on machine to have a set (average/standard deviation) egress delay.
- Determine a target network connection's bandwidth, latency, loss rate, and reordering rate.
- Simulate a lossy network between ROS1/2 nodes on the same host machine by interfering with whatever interface ROS1/2 is using (based on your system setup).
- Simulate a lossy network between multiple docker containers on the same host machine by interfering with docker's virtual network interfaces.
- Stress test an actual network of devices (such as between robots and a ground station) by limiting ingress bandwidth at the ground station. This is useful if you don't want to modify or cannot modify the robot's code to add this software package. You can simply run this code on the ground station and see what happens to the performance of the system when subjected to lossy network conditions.
- Stress test an actual network of devices (such as between robots and a ground station) by limiting egress bandwidth, delay, and loss rate from the robots. This is useful if you want to simulate very specific or particularly severe network conditions.
Install tc
, iperf3
, and ping
.
sudo apt install -y iproute2 iperf3 net-tools iputils-ping
Clone the most recent commit from the main
branch to get the latest stable release!
git clone git@github.com:UMD-CDCL/py_lossy_network.git
Install pip
. Then run
cd py_lossy_network
pip3 install -r requirements.txt # if pip maps to python3, then run "pip install -r requirements.txt"
To run the main program, just run:
python3 lossy_network.py
You should see the following prompt:
List of Available Commands:
quit:
Description: quits program
help:
Description: shows list of commands
show <INTERFACE>:
Description: shows all `tc` filter rules on network interface <INTERFACE>
Example: show eth0
del <INTERFACE>:
Description: deletes all `tc` filter rules on network interface <INTERFACE>
Example: del eth0
set_egress <INTERFACE> bw <MEAN_BANDWIDTH> <STD_DEV_BANDWIDTH> burst <BURST> latency <LATENCY> loss <MEAN_LOSS> <STD_DEV_LOSS> delay <MEAN_DELAY> <STD_DEV_DELAY>
Description: sets the egress bandwidth limit, burst limit, maximum latency, loss rate, and delay
Example: set_egress docker0 bw 500kbit 25kbit burst 32kbit latency 500ms loss 5% 0% delay 250ms 10ms
Example: set_egress docker0 bw 25mbit 0kbit burst 64kbit latency 5s loss 0% 0% delay 0ms 0ms
Example: set_egress docker0 bw 500kbit 25kbit burst 1mbit latency 250ms loss 0.5% 5% delay 10ms 50ms
set_ingress <INTERFACE> bw <MEAN_BANDWIDTH> <STD_DEV_BANDWIDTH> burst <BURST>
Description: sets the ingress bandwidth limit and burst limit
Example: set_ingress docker0 bw 500kbit 10kbit burst 32kbit
Example: set_ingress docker0 bw 25mbit 0mbit burst 64kbit
Example: set_ingress docker0 bw 500kbit 1mbit burst 1mbit
"sender <SERVER_IP>":
Description: initiates data collection with the host system as the sender of data
Example: sender 172.17.0.2
"receiver":
Description: initiates data collection with the host system as the receiver of data
Example: receiver
>
- Bandwidth: the number of bits per second a given network connection can "handle" without the network saturating.
- Ingress/Egress Traffic: Ingress traffic is incoming traffic. Ingress traffic is all the information a given network interface on a machine is receiving. Egress traffic is outgoing traffic. Egress traffic is all the information a given interface is sending.
- Ingress/Egress Bandwidth: Ingress bandwidth is like "download speed". Egress bandwidth is like "upload speed".
- Loss Rate: The percentage of packets or datagrams dropped.
- Delay: Sometimes called "latency" (though the "latency" parameter in this tool means something else). This is the time it takes a packet to leave a network interface on the transmitting device and enter the network interface on the receiving device.
iperf3
Documentationiperf3
is an amazing tool. look through the docs and see what it can do!
iperf
tutorial- outdated reference. but it explains how
iperf
andiperf3
"work" and how it should be complemented by other tools to get a more holistic picture of network health.
- outdated reference. but it explains how
iperf3
video tutorial- good explainer. follow along and learn some useful commands!
sar
Documentationsar
is not actively being used by this tool, but maybe one day it will. it can be used to monitor network interface stats upstream from thetc
rules.
sar
Examples- see how this guy is using
sar
. i found this to be more clear than the official documentation forsar
.
- see how this guy is using
tc
Documentation- documentation for
tc
, the tool that THIS tool is built on. It is a thorough and clear document. Must read!
- documentation for
tc-tbf
Documentation- documentation for
tc-tbf
- documentation for
tc-police
Documentation- documentation for
tc-police
- documentation for
tc-netem
Documentation- documentation for
tc-netem
- documentation for
tc
examples- see a few examples of how to use
tc
to shape network traffic
- see a few examples of how to use
tc
fundamentals video- this guy explains fundamental concepts of
tc
and how it works
- this guy explains fundamental concepts of
docker
compatibility- want to use this tool in a docker container? Well follow this tutorial to find out how!