go-libp2p icon indicating copy to clipboard operation
go-libp2p copied to clipboard

feat(simconn): Simulated Networks

Open MarcoPolo opened this issue 7 months ago • 6 comments
trafficstars

This adds a new Simulated Link to extend the Simulated UDP Packet conn. Simulated links can emulate bandwidth and latency over a connection, and can be used to connect two simulated conns together.

This also adds a simulated network helper to easily create a libp2p network and route the various links.

As-is, this works as a simple real-time simulator that may lose precision as computation gets bigger. The real benefit is when this is combined with Go 1.24's new testing/synctest package that allows the simulated network to run as a discrete event simulator. For this use case, only QUIC is supported.

This should serve to replace mocknet with a more accurate environment.

In draft until I clean up the tests a bit and use it a bit more.

MarcoPolo avatar Apr 03 '25 00:04 MarcoPolo