Exercise 3: Timestamp management - grupogita/ONOSP4-tutorial GitHub Wiki

In P4, metadata is defined as data generated during the execution of a program, which can be used to store information of interest associated with controller packet-in and packet-out such as the port of the data plane and the timestamp at which the packet was received [1][2].

The objective of this exercise is to successfully calculate the processing time of a switch by using metadata and timestamps in the P4 program and to identify to what extent the network parameters defined from the mininet topology affect the calculated time metric. You will use metadata, timestamps and programming logic to modify the P4 file to calculate the processing time of a neighbor switch.

You will have to modify the following files in this exercise:

  • topo.py located on the path ONOSP4-tutorial/Exercise-3/mininet/topo.py
  • main.p4 located on the path ONOSP4-tutorial/Exercise-3/p4src/main.p4
  • flows file located on the path ONOSP4-tutorial/Exercise-3/p4src/flows

Topology and Mininet

The exercise requires the creation of links between host H1 and Switch S1, host H2 and Switch S2 and between Switches S1 and S2. The following diagram shows the resulting topology:

The first task to be performed is to edit the "topo.py" file applying the knowledge acquired so far to build the topology illustrated above. Note that you will have to repeatedly change the channel bandwidth parameters in order to demonstrate their effect on the timing metric once the exercise is completed.

After performing the previous step, you can check the topology was created correctly using the following commands:

  • make app-build
  • make start
  • make mn-log

At the end of the last command, the CLI output is expected to look like the following code block:

1  docker logs -f mininet
2  *** Error setting resource limits. Mininet's performance may be affected
3  *** Creating network
4  *** Adding hosts:
5  h1 h2
6  *** Adding switches:
7  s1 s2
8  *** Adding links:
9  (s1, h1) (s2, h2)
10 *** Configuring hosts
11 h1 h2
12 *** Starting controller
13
14 *** Starting 1 switches
15 s1 stratum_bmv2 @ 50001
16 s2 stratum_bmv2 @ 50002
17 *** Starting CLI

Another way to check that the topology was successfully created is to use the command make mn-cli to access the mininet CLI. Then, you can use the net command to visualize the topology currently deployed on Mininet. You should see a CLI output similar to the following code block:

1 *** Attaching to Mininet CLI...
2 *** To detach press Ctrl-D (Mininet will keep running)
3 mininet> net
4 h1 h1-eth0: s1-eth1
5 h2 h2-eth0: s1-eth2
6 s1 lo: s1-eth1:h1-eth0
7 s2 lo: s2-eth1:h2-eth0

P4 program

Considering the approach followed in the P4 program developed in Exercise 1: first approach to the P4 development process, this exercise focuses on Egress Processing and it uses a custom packet header. This modified header is based on the structure of an Ethernet header with the following field description:

  • ingress_port: Port through which the frame enters to the Switch.
  • egress_port: Port through which the frame egresses to the Switch.
  • process_time_sw1: Time taken by the Switch S1 to process the frame.
  • process_time_sw2: Time taken by the Switch S2 to process the frame.

In order to complete this exercise, you have to modify the file "main.p4". The instructions can be found in the file with the comment code ”TO-DO”. The objective is to use logic statements to identify which Switch is processing the frame and calculate the time metrics to assign them to the process_time_sw1 and process_time_sw2 header fields.

NOTE: Use the above image as support for the resolution of the requested TO-DO.

References

[1] The P4 Language Consortium. $P4_{16}$ Language Specification version 1.2.3.

[2] The P4.org API Working Group. P4Runtime Specification version 1.3.0.