diff options
author | Lewis Marshall <lewis@lmars.net> | 2017-09-25 16:08:07 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-09-25 16:08:07 +0800 |
commit | 9feec51e2dd754819e5c730ac5985d28d57adb48 (patch) | |
tree | 32b07b659cf7d0b4c1a7da67b5c49daf7a10a9d3 /p2p/simulations/examples/README.md | |
parent | 673007d7aed1d2678ea3277eceb7b55dc29cf092 (diff) | |
download | dexon-9feec51e2dd754819e5c730ac5985d28d57adb48.tar dexon-9feec51e2dd754819e5c730ac5985d28d57adb48.tar.gz dexon-9feec51e2dd754819e5c730ac5985d28d57adb48.tar.bz2 dexon-9feec51e2dd754819e5c730ac5985d28d57adb48.tar.lz dexon-9feec51e2dd754819e5c730ac5985d28d57adb48.tar.xz dexon-9feec51e2dd754819e5c730ac5985d28d57adb48.tar.zst dexon-9feec51e2dd754819e5c730ac5985d28d57adb48.zip |
p2p: add network simulation framework (#14982)
This commit introduces a network simulation framework which
can be used to run simulated networks of devp2p nodes. The
intention is to use this for testing protocols, performing
benchmarks and visualising emergent network behaviour.
Diffstat (limited to 'p2p/simulations/examples/README.md')
-rw-r--r-- | p2p/simulations/examples/README.md | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/p2p/simulations/examples/README.md b/p2p/simulations/examples/README.md new file mode 100644 index 000000000..822a48dcb --- /dev/null +++ b/p2p/simulations/examples/README.md @@ -0,0 +1,39 @@ +# devp2p simulation examples + +## ping-pong + +`ping-pong.go` implements a simulation network which contains nodes running a +simple "ping-pong" protocol where nodes send a ping message to all their +connected peers every 10s and receive pong messages in return. + +To run the simulation, run `go run ping-pong.go` in one terminal to start the +simulation API and `./ping-pong.sh` in another to start and connect the nodes: + +``` +$ go run ping-pong.go +INFO [08-15|13:53:49] using sim adapter +INFO [08-15|13:53:49] starting simulation server on 0.0.0.0:8888... +``` + +``` +$ ./ping-pong.sh +---> 13:58:12 creating 10 nodes +Created node01 +Started node01 +... +Created node10 +Started node10 +---> 13:58:13 connecting node01 to all other nodes +Connected node01 to node02 +... +Connected node01 to node10 +---> 13:58:14 done +``` + +Use the `--adapter` flag to choose the adapter type: + +``` +$ go run ping-pong.go --adapter exec +INFO [08-15|14:01:14] using exec adapter tmpdir=/var/folders/k6/wpsgfg4n23ddbc6f5cnw5qg00000gn/T/p2p-example992833779 +INFO [08-15|14:01:14] starting simulation server on 0.0.0.0:8888... +``` |