Skip to content

Instantly share code, notes, and snippets.

@zelig
Last active March 1, 2024 12:46
Show Gist options
  • Save zelig/64dbc3ed45867f51efceffefe11360df to your computer and use it in GitHub Desktop.
Save zelig/64dbc3ed45867f51efceffefe11360df to your computer and use it in GitHub Desktop.
p2p network similation, testing and monitoring framework

see slides of a talk on the p2p network similation, testing and monitoring framework http://swarm-gateways.net/bzz:/e5fbcaad92ede8a429896ff91d5653510a16a2cf86061697648340d32bbe40a8/

p2p: network testing framework and protocol abstraction ethereum/go-ethereum#3102

Overview

The purpose of this work is to have a comprehensive and modular network testing suite, which is able to drive test harnesses for p2p network behaviour. This includes simulations as well as cluster tests on an actual network.

  • set up network models, to control, measure, test, benchmark network behaviour
  • provide single peer with mock peer 'network' for protocol (module) unit testing
  • provide various simulated test network environments with the same testing interface
  • http server with REST API to the network controllers to serve as backend to cluster dashboards, simulations, visualisations

Context and Motivation

The context and motivation is coming from wanting a proper test environment for syncing, connectivity or even higher level network behaviour (latency benchmarks) for swarm given the following issues:

  • syncing rewrite
  • testing and fixing edge cases with kademlia overlay topology bootstrapping
  • integration whisper/pss in status/raiden
  • implementing and testing crash proof of custody
  • implenenting and testing receipt passting, storage insurance logic, litigation
  • implementing scan and repair for erasure coding

Network model and adapters

  • the models use a network adapter to abstract out underlay connectivity implementation
  • network model adapters include
    • rlpx
    • SimNet inprocess simulation
    • p2p.server inprocess simulation (p2p server dial/listen are using msgpipes)
    • multinode local cluster (communicate via IPC) test module
    • multinode remote cluster (comminicate via IPC test module and ssh)

Explore:

  • multinetwork adapter
  • IPFS/libp2p adapter

Events in the Journal

  • event logged as entries in a journal, can be replayed (on a different network type)
  • connectivity journal, message passing journal
  • dynamic network visualisation using the REST Api (example with mocked journal)
  • journal can be replayed to get a snapshot (connectivity or storage/msg passing)
  • snapshots are portable across network types so can setup/bootstrap simulations

Demo:

  • simple connectivity visualisation with mock generated journal
  • network controller GET -> UpdateeCy(journal)

Journal controller:

  • run history as a journal subscribing to events
  • reset, record
  • Read: without constraints, it reads all the events in the buffer,
  • TimedRead: replay with acceleration (for simulation/visualisation) faithful to intervals
  • Scheduler: play waiting for actual or fake event time
  • UI to manually construct test setups

Test drivers

  • snapshots are used to setup initial states
  • journal can be used to schedule drive network scenarios
  • trigger/expect testing pattern for p2p message exchange for protocol unit testing
  • trigger/expect pattern for unicast and multicast overlay routing (how pss and whisper will be tested)
  • suite of controllers provide a resourceful REST API to query and dynamically change the network, trigger events and query metrics (using the metrics package)
  • The messengers can be used to meter bandwidth, throughput
  • latency benchmarks could be simulated using parameters based on a real network measurements

UI

  • connectivity and message passing visualisations using cytoscape.js http://js.cytoscape.org/
  • cluster management and monitoring dashboard
  • UI for simulation and aggregate stats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment