We were really intrigued by the presentation at web3 summit by Matthew Hodgson showcasing their meshsim tool used to visualize how matrix servers propagate messages in a delayed network by spinning up instrumented docker images on a local network. So we were immediately interested when the libp2p guys showed interest in extending the tool to be used in testing the gossip protocol.

There are a lot of awesome products being built on libp2p and it would be great if this tool could help all those devs.

What it does

The app lets you create a graph representing nodes in a p2p network. The graph topology is reconstructed on the networking layer by introducing latency or bandwidth restrictions in the underlying network. After building a topology the nodes can then bootstrap a message-passing protocol and then message sending can be simulated from the UI with the ability to alter the message size.

How we built it

Based on the meshim tool by [matrix], but heavily extended in order to support potentially any p2p client specification with little effort in the future by implementing a Provider. The UI was also upgraded to also include message send simulation which was done in a cumbersome way through shell scripts before.

We also had to define an agent that connects to the libp2p daemon and communicate via protobuf messages. This control interface has to ensure that the network topology is reflected at the libp2p level in the peer definition.

Challenges we ran into

Distributed systems are tricky to debug especially when you're running a python server that's connected with 10 docker images each running a python server of their own and a specific p2p node implementation (libp2p or synapse), and all talking to each other asynchronously with different failure modes.

It was also hard at times to keep the whole system in our heads because we had to essentially create an abstraction layer over this and set tight boundaries between services and the provider abstraction layers.

Accomplishments that we're proud of

It works! It's a major overhaul of the existing project without introducing any breaking changes. It can also be easily extended to simulate more specific types of p2p networks and their interactions. Also if this really proves to be helpful to the folks building eth2.0 that would be most awesome.

What we learned

  • Libp2p is pretty cool.
  • Protobuf encoding isn't as straightforward as initially thought.
  • Good planning is key.
  • It's not straightforward to abstract/generalize something that wasn't written with that in mind

What's next for Meshsim

  • Update readme
  • Merge upstream
  • Better node orchestration: wait for nodes to be only before applying network topology changes. Batch changes better.
  • Better feedback of the network state in the UI
  • Merge upstream
  • More granular topic / room configuration
  • Provider specific message simulation configuration
  • Fine control over nodes / edges
  • UI overhaul

Built With

Share this project: