Skip to content

marlinprotocol/p2psim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p2psim

CI Status stability-experimental

This is a work in progress.

Simulate custom p2p overlay network protocols for comparing performance across various designs. The simulation is determinsitic, configurable and runs to completion quicker than if the events were run in real-time.

Background

libp2p specifies a baseline pubsub protocol and builds the floodsub, gossipsub and the episub protocols on top of the baseline protocol. These and similar protocols are commonly used for communication in blockchain applications at the network layer. The performance of such an application not only depends on the variations introduced to the existing protocols but also on the numerous parameters the protocols are configured by. Simulating the peer to peer overlay network communication enables protocol designers to fine tune both the algortihm as well as its parameters for application specific use cases.

Discrete Event Simulations are better suited for the usecase in the prototype phase because of

  • Higher reproducibility allowing better debugging of the protocol
  • Easier setup and deployment because the application is single threaded and makes no use of actual network resources
  • Faster time to completion since the events are simulated on logical time and not real-time

Evaluation metrics

Some of the important metrics that help evaluate the performance are

  • Message delay: This metric represents the mean delay for a message to reach a node. Lower delay implies quicker consensus which can inturn help reduce forks.
  • Bandwidth consumption: This metric represents the mean bytes transferred over the network inorder to transfer a particular message. Keep in mind that messages may reach some nodes more than once and that those messages still consume bandwidth.
  • Network reachability: This metric indicates how far the messages reach over the network. Typically, the messages reach all the nodes and henceforth most protocols have a 100% reachability.

Build and Usage

make p2psim

A binary, named p2psim is placed in the build directory relative to the current directory.

The binary takes several configuration options, simulates a pubsub network protocol in accordance with the options passed via the configuration file and outputs statistics that indicate the protocol's network performance.

Supported config formats: TOML

./build/p2psim -c config.toml

Configuration Schema

Path Description Type Example Default Additional Constraints
run_duration Duration for which the simulation is run duration "1h"
(1 hour)
Required Must be positive
total_peers Total number of nodes simulated in the network integer 1024 Required Must be at least 2
seen_ttl Duration for which the pubsub framework retains past messages duration "5m"
(5 mins)
"2m" Must be positive
block_interval Expected time to generate the next block duration "15s" Required Must be positive
gossipsub.heartbeat_interval Interval between consecutive gossips duration "1m" "1s" Must be positive
gossipsub.D Desired degree for the mesh integer 6 Must be positive
gossipsub.Dlow Lower bound for the degree of a node integer 4 Must be positive and
not more than D
gossipsub.Dhigh Upper bound on the degree of a node integer 12 Must be no less than D
gossipsub.Dlazy Number of peers to gossip to integer 6 Must be positive
gossipsub.history_length Number of heartbeat intervals the messages are cached for integer 5 Must be positive
gossipsub.history_gossip Number of heartbeat intervals for which the gossip is emitted integer 3 Must be positive

Example Configuration

FloodSub

run_duration = "1h"
total_peers = 1024
seen_ttl = "5m"
block_interval = "15s"

GossipSub

run_duration = "1h"
total_peers = 1024
seen_ttl = "5m"
block_interval = "15s"

[gossipsub]
heartbeat_interval = "1m"
Dhigh = 8

Arch

arch

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published