
Netem: linux network emulator - signa11
https://wiki.linuxfoundation.org/networking/netem
======
songgao
Shameless plug: I made a wireless network emulator [0] for my dissertation.
It's a userspace implementation with a lot of extra user/kernel context
switches for every packet, so too slow for emulating latencies and only deals
with packet loss. But it takes wireless congestions into consideration, and
can emulate CSMA/CA. For one node this wouldn't make a difference, but for
multiple nodes where interference is a problem, it's a bit more realistic than
just setting arbitrary packet loss.

[0] [https://github.com/squirrel-land/squirrel](https://github.com/squirrel-
land/squirrel)

EDIT: typos

------
pwnna
From my experience working with netem and tc, it seemed like a great tool for
testing purposes but I could not find any good documentations on it. As a
result, I never really fully understood the relationship between qdisc, netem,
the filter chains, and so on. At the time I read [1] (and chapters after it)
but I wasn't able to comprehend it as I think I just lack the in depth
networking knowledge needed.

Does anyone know of any good resources to learn this stuff more
systematically?

Now that said (and without being too self-promotional), I did manage to make
an OpenWRT package[2] that allows WiFi clients to select different
speeds/latencies/packet loss settings to emulate different connections (3G,
bad/lossy connections, etc). This was particularly good for testing web apps
on devices that don't have the ability to emulate networks and it provides a
simpler way to do it than the official way by Apple/Google, imo.

[1]:
[http://lartc.org/howto/lartc.qdisc.terminology.html](http://lartc.org/howto/lartc.qdisc.terminology.html)

[2]:
[https://github.com/shuhaowu/trafficcop](https://github.com/shuhaowu/trafficcop)

~~~
kevhito
> ... but I could not find any good documentations on it.

Completely agree. I wanted to set up some simple traffic shaping on gcp and
aws nodes my students will be using for some networking projects. I've used
both netem and tc in the past, years ago, but I found the documentation still
seems just as abysmal. The netem documentation in particular is impenetrable.
It seems to sit at just the anti-sweet spot between being "low level",
explaining in detail how the implementation actually accomplishes things, and
"high level", explaining abstractions and concepts of how one might use the
tool. The user is left with a mishmash of both, with no way to see how all the
various extremely picky implementation details fit together into any kind of
coherent usable system. In the end, I am left with the feeling that the code
is probably a collection of hacks and spaghetti with no clear vision or goal
of how anything works, and the documentation is just a reflection of that.

------
bloat
Saboteur is a good tool for some quick and dirty network testing.

It's a wrapper around Netem's tc interface, which makes things a bit easier to
understand.

[https://github.com/tomakehurst/saboteur](https://github.com/tomakehurst/saboteur)

------
jtchang
Super cool. Looks a lot like dummynet in FreeBSD!

------
pjc50
If you need to build your own network emulator for unusual purposes, have a
look at the TUN/TAP system.

I was able to build a network device connected to a Verilog simulation
(running in Verilator), allowing a simulated device to communicate with a real
host. This avoided the lengthy build times and user contention of running it
on the real target FPGA, which was in an expensive device we only had one of.

------
epx
Used it in my master dissertation. Great tool.

------
nialv7
This question might be off-topic, but shouldn't this be called a network
"simulator"?

~~~
teh_klev
I guess it depends on your viewpoint:

[https://english.stackexchange.com/questions/111787/what-
is-t...](https://english.stackexchange.com/questions/111787/what-is-the-
difference-between-simulate-and-emulate)

[http://stackoverflow.com/questions/1584617/simulator-or-
emul...](http://stackoverflow.com/questions/1584617/simulator-or-emulator-
what-is-the-difference#1584701)

[https://www.quora.com/What-is-the-difference-between-a-
simul...](https://www.quora.com/What-is-the-difference-between-a-simulator-
and-an-emulator-2?share=1)

I'm going to go out on a limb and say it's definitely an emulator:

[https://en.wikipedia.org/wiki/Network_emulation](https://en.wikipedia.org/wiki/Network_emulation)

vs

[https://en.wikipedia.org/wiki/Network_simulation](https://en.wikipedia.org/wiki/Network_simulation)

------
ragix
I've used this to emulate bad dslam uplinks. either on the bras or mitm. It
works well.

