I would like to simulate packet delay and loss for UDP and TCP on Linux to measure the performance of an application. Is there a simple way to do this?
Join Stack Overflow to learn, share knowledge, and build your career.
|
|
|||||||||||||||||
|
|
netem leverages functionality already built into Linux and userspace utilities to simulate networks. This is actually what Mark's answer refers to, by a different name. The examples on their homepage already show how you can achieve what you've asked for:
Note that you should use |
|||||||||||||||||||||
|
|
For dropped packets I would simply use iptables and the statistic module.
Above will drop an incoming packet with a 1% probability. Be careful, anything above about 0.14 and most of you tcp connections will most likely stall completely. Take a look at man iptables and search for "statistic" for more information. |
|||||||||||||||||||||
|
|
One of my colleagues uses tc to do this. Refer to the man page for more information. You can see an example of its usage here. |
|||
|
|
|
iptables(8) has a statistics module that can be used to match every nth packet. To drop this packet, just append -j DROP. |
|||
|
|
|
This tutorial on networking physics simulations contains a C++ class in the sample code for simulating latency and packet loss in a UDP connection and may be of guidance. See the public latency and packetLoss variables of the Connection class found in the Connection.h file of the downloadable source code. |
||||
|
|
|
Haven't tried it myself, but this page has a list of plugin modules that run in Linux' built in iptables IP filtering system. One of the modules is called "nth", and allows you to set up a rule that will drop a configurable rate of the packets. Might be a good place to start, at least. |
|||
|
|
|
You can try http://snad.ncsl.nist.gov/nistnet/ It's quite old NIST project (last release 2005), but it works for me. |
|||
|
|
|
One of the most used tool in the scientific community to that purpose is DummyNet. Once you have installed the
In order to also introduce 50% of packet losses you have to run:
Here more details. |
||||
|
|
|
An easy to use network fault injection tool is Saboteur. It can simulate:
|
|||
|
|
protected by Community♦ Aug 14 '15 at 18:00
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?