Skip to content

Ouroboros Network Demos

Marcin Szamotulski edited this page Sep 30, 2022 · 1 revision

The Ouroboros-Network demo application can show case a few milestones of the ouroboros-network suite:

  • Multiplexing layer: which allows to run multiple mini-protocols over a single bearer (unix socket in this demo);
  • PingPong, ChainSync and BlockFetch protocols, developed using session type framework typed-protocols;
  • protocol pipelining which is achieved within the session type framework;
  • multiplexing two ping pong protocols;
  • the chain sync protocol;
  • the block fetch protocol multiplexed with the chain sync protocol; Downloading blocks from multiple peers, prioritisation of peers from whom a peer can download blocks.

PingPong demo

Run pingpong demo server

cabal new-run ouroboros-network-framework:demo-ping-pong -- pingpong server

In another terminal you can run a client which will send ping messages to the server with

cabal new-run ouroboros-network-framework:demo-ping-pong -- pingpong client

In both terminals you will see

Send (ClientAgency TokIdle,MsgPing)
Recv (ServerAgency TokBusy,MsgPong)
Send (ClientAgency TokIdle,MsgPing)
Recv (ServerAgency TokBusy,MsgPong)
Send (ClientAgency TokIdle,MsgPing)
Recv (ServerAgency TokBusy,MsgPong)
Send (ClientAgency TokIdle,MsgPing)
Recv (ServerAgency TokBusy,MsgPong)
Send (ClientAgency TokIdle,MsgPing)
Recv (ServerAgency TokBusy,MsgPong)
Send (ClientAgency TokIdle,MsgDone)

You can also run a pipelined pingpong client:

cabal new-run ouroboros-network-framework:demo-ping-pong -- pingpong client-pipelined

This time you the MsgPing messages will be sent without waiting for responses (see protocol-pipelining wiki):

Send (ClientAgency TokIdle,MsgPing)
Send (ClientAgency TokIdle,MsgPing)
Send (ClientAgency TokIdle,MsgPing)
Send (ClientAgency TokIdle,MsgPing)
Send (ClientAgency TokIdle,MsgPing)
Recv (ServerAgency TokBusy,MsgPong)
Recv (ServerAgency TokBusy,MsgPong)
Recv (ServerAgency TokBusy,MsgPong)
Recv (ServerAgency TokBusy,MsgPong)
Recv (ServerAgency TokBusy,MsgPong)
Send (ClientAgency TokIdle,MsgDone)

PingPong2 Demo

This will multiplex two ping pong protocols through a single unix socket.

You can run the server with

cabal new-run ouroboros-network-framework:demo-ping-pong -- pingpong2 server

and a client with

cabal new-run ouroboros-network-framework:demo-ping-pong -- pingpong2 client

The output from the client will be something like:

(1,Send (ClientAgency TokIdle,MsgPing))
(2,Send (ClientAgency TokIdle,MsgPing))
(1,Recv (ServerAgency TokBusy,MsgPong))
(1,Send (ClientAgency TokIdle,MsgPing))
(2,Recv (ServerAgency TokBusy,MsgPong))
(2,Send (ClientAgency TokIdle,MsgPing))
(1,Recv (ServerAgency TokBusy,MsgPong))
(1,Send (ClientAgency TokIdle,MsgPing))
(2,Recv (ServerAgency TokBusy,MsgPong))
(2,Send (ClientAgency TokIdle,MsgPing))
(1,Recv (ServerAgency TokBusy,MsgPong))
(1,Send (ClientAgency TokIdle,MsgPing))
(2,Recv (ServerAgency TokBusy,MsgPong))
(2,Send (ClientAgency TokIdle,MsgPing))
(1,Recv (ServerAgency TokBusy,MsgPong))
(1,Send (ClientAgency TokIdle,MsgPing))
(2,Recv (ServerAgency TokBusy,MsgPong))
(2,Send (ClientAgency TokIdle,MsgPing))
(1,Recv (ServerAgency TokBusy,MsgPong))
(1,Send (ClientAgency TokIdle,MsgDone))
(2,Recv (ServerAgency TokBusy,MsgPong))
(2,Send (ClientAgency TokIdle,MsgDone))

There are two client-server pairs communicating, each pair is indicated by 1 or 2.

ChainSync Demo

Run a single chain sync protocol, you can run a server with:

cabal new-run ouroboros-network:demo-chain-sync -- chainsync server ./chain-sync.sock

and a client with

cabal new-run ouroboros-network:demo-chain-sync -- chainsync client ./chain-sync.sock

BlockFetch Demo

Mulitplex chain sync and block fetch protcols over a single unix socket. You can run a server with:

cabal new-run ouroboros-network:demo-chain-sync -- blockfetch server ./block-fetch.sock

and a client with:

cabal new-run ouroboros-network:demo-chain-sync -- blockfetch client ./block-fetch.sock