Skip to content

1) Usage

Ariel Góes de Castro edited this page May 31, 2022 · 2 revisions

About

In this page, you will find a detailed explanation about how the P7 configuration files are defined and how to use the methods/parameters to set a customized topology for your testbed.

P7 configuration

The user needs to define the topology and link configuration. It is possible to define all the network elements that will be emulated with the corresponding parameters.

The topology generation template is defined in main.py . Using this script, are generated the necessary files of P7.

The output of the topology generation script is composed of three files:

  • P4 program
    • Contains the P4 code structure, including the emulated links and devices.
    • From the main script are mapped the principal parameters for the network emulation.
  • Interfaces configuration
    • To successfully run the switch, the chassis configuration must be set.
    • This file contains all the port configurations, including the speed, operational mode, and others (see Section Interfaces configuration).
  • Tables information
    • This file contains the information of the P4 tables that will be configured.

Topology Generation

The main.py file allows the user to specify a customized topology. See the available commands/parameters to customize the network topology:

First, we need to initialize the generator object:

generate_p7 = generator('main')

We can define the IP and port of Stratum with addstratum. If it runs in the local device, it can be set with the management IP and default port 9559.

generate_p7.addstratum("192.168.110.238:9559")

The recirculation port is defined by default in port 68. But, it is possible to define other ports as loopback ports (refer to Tofino architecture documentation):

generate_p7.addrec_port(68)

With addswitch, we can define the number of internal devices that we will emulate. This item is not mandatory. If we do not define any switch, the emulated network will represent a link.

generate_p7.addswitch("sw1")

With addhost, we define the hosts with a physical connection with the switch. It is necessary to define the characteristics of the port.

addhost(name, port, D_P, speed_bps, AU, FEC, vlan)

where:

  • name: name of the host.
  • port: the physical port number.
  • D_P: the id of the port.
  • speed_bps: the speed in bps (e.g., 100000000000 -> 100Gbps).
  • AU: automatic negotiation True/False.
  • FEC: FEC mode enables True/False.
  • vlan: vlan id for P7 processing.
generate_p7.addhost("h1",19, 20, 100000000000, "False", "False", 1920)
generate_p7.addhost("h2",20, 28, 100000000000, "False", "False", 1920)

With addlink, we define the internal links in the network. It is necessary to define the emulated characteristic of the link.

addlink(node1, node2, bw, pkt_loss, latency)

where:

  • node1: name of the first node.
  • node2: name of the second node
  • bw: bandwidth limit in bps (e.g., 1000000000 -> 1Gbps). Bw is considered just for the first defined link.
  • pkt_loss: percentage of packet loss.
  • latency: latency of the network in milliseconds. The value of the link will be set on both sides (bidirectional latency). RTT will be two times this value.
  • jitter variation: jitter variation in ms.
  • jitter probability: probability of variation in percentage.
generate_p7.addlink("h1","sw1", 100000000000, 0, 5)  
generate_p7.addlink("sw1","h2", 100000000000, 0, 5)

Here is an example of a single link (no switch) definition:

generate_p7.addlink("h1","h2", 100000000000, 0, 5)

In parallel with the P7 processing, it is possible to define VLANS that are not processed by P7 and are directly forwarder.

Using addvlan_port and a similar structure of addhost we define additional VLAN.

addvlan_port(port,D_P,speed_bps,AU,FEC)

where:

  • port: the physical port number.
  • D_P: the id of the port.
  • speed_bps: the speed in bps (e.g., 100000000000 -> 100Gbps).
  • AU: automatic negotiation True/False.
  • FEC: FEC mode enables True/False.
generate_p7.addvlan_port(7, 180, 100000000000, "False", "False")
generate_p7.addvlan_port(16, 0, 100000000000, "False", "False")

In addition of adding a VLAN port, it is necessary to ad the VLAN link:

addvlan_link(D_P1, D_P2, vlan)

where:

  • D_P1: First port id.
  • D_P2: Second port id.
  • vlan: VLAN id.
generate_p7.addvlan_link(180,0, 716)

Finally, we generate the P7 files.

generate_p7.generate_chassis()
generate_p7.generate_p4rt()
generate_p7.generate_p4code()

Generated Files

P4 program (p7/p7_default.p4)

This file is the P4 code and is auto-generated at main.py by gen_p4.py. The number of switches is defined by the length of the vector name_sw - declared at data.py - which appends an entry whenever there is a call for the function addswitch(name) in main.py.

Interfaces configuration (chassis_config.pb.txt)

This file is auto-generated and contains information such as port configurations, speed, operational mode, node id, and others.

port_config

Also, there are advanced vendor-specific configuration parameters (e.g., Tofino)
image

Tables information (p4rt.py)

This file contains information about the user-provided entries to populate the existing match+action tables.

First, we connect P4Runtime to Stratum through a grpc connection, which will be responsible to populate the tables (grpc_addr='192.168.110.238:9559'). Then, we create an object (te) to insert our table entries as shown below.

image

For example, the first line in the image says we want to perform an action named match from table v_lan when the v_lan id is equal to 1920 (te.match['vid'] = '1920') and the ingress port is equal to 20 (te.match['ingress_port'] = '20'). In this case, we set the outgoing port to 28 (te.action['port'] = '28').