Ouroboros Tutorial 03

From Ouroboros
Jump to navigation Jump to search
Ouroboros Tutorial 03

Ouroboros can be configured using a config file in TOML format (requires libtomlc99 to be installed when building the prototype).

Copy/paste the text below and store it as a file, we named it tut03.conf and saved it in /etc/ouroboros/, which is the default used for O7s configurations.

###  Ouroboros configuration file Tutorial 03
[name.oping-server]
prog=["/usr/bin/oping"]
args=["--listen"]

[local.local-ipcp]
bootstrap="local-layer" 
reg=["uni-1", "uni-2", "unicast-layer"]

[unicast.uni-1]
bootstrap="unicast-layer"
autobind=true
reg=["oping-server"]

[unicast.uni-2]
enrol="unicast-layer"
conn=["uni-1"]

The configuration file is in TOML format (we may add support for other formats in the future). This demo will create a local Layer and then a 2-node unicast Layer on top, just like in Tutorial 02 to support the oping application.

It has 4 stanza:

  1. name.oping-server: This creates a service name, in this case the name is oping-server. Note that if we wanted to name the service oping.server it would need quotes like this [name."oping.server"]. That name will be served by all instances of the oping binary (located at /usr/bin/oping). We specify the args option to start oping automatically (see below).
  2. local.local-ipcp: The IRMd will start a local IPCP called local-ipcp. We also specify a bootstrap option to start a new Layer called local-layer. We will be running 2 unicast IPCPs on top, named uni-1 and uni-2. Both of these will also listen to the anycast name unicast-layer.
  3. unicast.uni-1: The IRMd will start a unicast IPCP called uni-1. We also specify it will bootstrap a new network Layer called unicast-layer. The autobind option will bind it to both the IPCP name ("uni-1") as the anycast layer name ("unicast-layer"). We register the oping server application on this node.
  4. unicast.uni-2: The IRMd will start a unicast IPCP called uni-1. This IPCP will not bootstrap, but enroll in the unicast-layer and then connect (creating both management and data transfer flow) to create a forwarding adjacency with "uni-1".

Instead of logging to standard output, we will use the system log, which is Ouroboros' default. Use your preferred way to view the system log. We use journalctl

$ sudo journalctl --identifier=irmd --follow            #short form: sudo journalctl -t irmd -f

In a different window, start the irmd using the config file and without the --stdout option:

$ sudo irmd --config /etc/ouroboros/tut03.conf

This will load the configuration and will set up the same network that we created in the second tutorial.

Now, we will ping an oping server from the client over that unicast-layer. In the previous two tutorials, we first started the server, but O7s can start a server automatically. This is the auto feature of the irm bind program CLI tool. In the configuration file, this feature is enabled by specifying an args line for a service name. In our configuration example, we defined that the service name oping-server is bound to program /usr/bin/oping and can be automatically started if needed with the argument --listen (the short form is -l).

Just start a client towards oping-server:

$ oping -n oping-server -c 10
Pinging oping-server with 64 bytes of data (10 packets):

64 bytes from oping-server: seq=0 time=1.223 ms
64 bytes from oping-server: seq=1 time=0.885 ms
64 bytes from oping-server: seq=2 time=0.988 ms
<snip>
64 bytes from oping-server: seq=9 time=0.819 ms

--- oping-server ping statistics ---
10 packets transmitted, 10 received, 0 out-of-order, 0% packet loss,  time: 10003.173 ms
rtt min/avg/max/mdev = 0.705/0.877/1.223/0.144 ms

The window where we started the IRMd will log the server output:

Ouroboros ping server started.
New flow 64.
Received 64 bytes on fd 64.
Received 64 bytes on fd 64.
<snip>
Received 64 bytes on fd 64.
Flow 64 timed out.

When the IRMd auto-instantiates a program, it will log this event as:

Nov 05 17:58:38 phonetria irmd[3820]: Flow request arrived for oping-server.
Nov 05 17:58:38 phonetria irmd[3820]: Instantiated /usr/bin/oping as process 3961.
Nov 05 17:58:38 phonetria irmd[3820]: Process 3961 inherits name oping-server from program oping.