Skip to content

msg-sim Linux implementation #58

Open
@mempirate

Description

@mempirate

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 the ip 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: the tc (traffic-control) command can be used with netem (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.

Metadata

Metadata

Assignees

Labels

A-simArea: SimulationC-featureCategory: Feature

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions