Open
Description
Context
Since #54, we have an initial implementation for our network simulation crate for MacOS, but we're still missing one for Linux. The simulation crate allows us to start simulated endpoints in Rust tests that we can then use to emulate a real world environment. The MacOS one uses dummynet
with some ifconfig
commands and a hacky localhost alias
to configure a simulated endpoint. We want to do the same for Linux, but luckily Linux has some better tools for these types of things:
ip
command: with theip
command, we can create network namespaces, virtual ethernet devices, dummy interfaces etc. I think dummy interfaces specifically will be most useful in the beginning (it's basically a separate localhost but with normal MTU for more accurate simulation).tc
command: thetc
(traffic-control) command can be used withnetem
(a kernel module) to shape traffic.
Some inspiration:
Other notes:
- These commands all require root access. Maybe there's a way to utilize network namespaces to not need root access? Also the
CAP_NET_ADMIN
capability allows us to do this stuff without root but I don't think it's useful when running tests. And granting capabilities also require root. - What other things can we do with network namespaces? A completely simulated p2p network where each peer is in its own namespace and can have its own latency, bandwidth and packet loss rates? This will need
veth
or virtual ethernet devices as well.