Have questions? Stuck? Please check our FAQ for some common questions and answers.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 24 Next »

Updated Trellis+P4 tutorial material

The content of this page is for users who already have some experience with ONOS and Trellis and wish to learn how to use those with P4 devices.

If you are getting started with ONOS and Trellis we suggest you start with the following slides and exercises:

Trellis+P4 Tutorial (Presented at ONF Connect, Dec 2018): http://bit.ly/trellis-p4-slides.


Environment:

Prerequisites (ONOS, Docker)

Before starting, make sure to have ONOS on your physical machine. To download, build and run ONOS, follow this guide: Developer Quick Start

Make also sure that Docker is installed and you can run Docker containers in your machine (Install Docker).

In this guide we will refer to ${WORKSPACE} as the environment variable of your workspace, where we suppose also ONOS has been downloaded. Define it on your .bashrc file or make sure that is defined in all your terminal windows.

P4-Mininet Docker container

We provide a convenient Docker container with Mininet and BMv2 already installed (P4mn on Docker Hub).

To pull the container, type the following command in a terminal window on your machine:

pull p4mn container
$ docker pull opennetworking/p4mn

Get Trellis "routing" repository

To try fabric.p4 with BMv2, you will need a custom Mininet script distributed as part of the Trellis "routing" repository:

To clone the repository, type the following commands in a terminal window on your machine:

Clone Trellis routing repository
cd ${WORKSPACE}
git clone https://github.com/opennetworkinglab/routing/


Network configuration for this mininet topology:

Reference: https://wiki.opencord.org/pages/viewpage.action?pageId=3014916

In Trellis, we run every switch as router, each router needs a mac address and multiple interface configurations.

Interface config:

Interface config
"Device-id/port-number" : {
    "interfaces" : [
        {
            "name": "interface name",
            "ips" : [ "10.0.1.254/24" ],
            "vlan-untagged": 10
        }
    ]
}
  • Name: Interface name, can be empty or unset;

  • ips: List of IP addresses for this interface, it can be the default gateway of the host;

  • VLAN config, it can be: vlan-untagged only, vlan-tagged only or vlan-tagged + vlan-native.

    • vlan-untagged (integer): this interface consumes untagged packet only and it belongs to a specific vlan;

    • vlan-tagged (integer array): this interface can consumes specific tagged vlans;

    • vlan-native (integer): if an untagged consumes by this port, and this is an interface with vlan-tagged setup, device will use this vlan for internal use;


Example of Segment Routing device settings:

device config
"Device-id" : {
    "segmentrouting" : {
        "name" : "Device name",
        "ipv4NodeSid" : 123,
        "ipv4Loopback" : "192.168.0.123",
        "ipv6NodeSid" : 223,
        "ipv6Loopback" : "2000::c0a8:0223",
        "routerMac" : "00:00:00:00:01:23",
        "isEdgeRouter" : true,
        "adjacencySids" : []
     }
}
  • Name: Name for segment routing device;

  • ipv4(6)NodeSid: Global unique id for IP loopback, it is used as MPLS label in forwarding;

  • ipv4(6)Loopback: Router loopback IP address, it should not be part of same same subnet defined on dataplane interface;

  • routerMac: Globally unique Mac address. It will be used to reply ARP requests for router IP or interface IP;

  • isEdgeRouter: true if this device is edge/leaf, otherwise false;

  • adjacencySids: Reserved, put empty array for now.

Topology:

Host view:

In the demo Mininet topology, we set the gateway of the hosts to the IP of the interface of the leaf switch. For example, the gateway of Host 1 will be 10.0.2.254.

Steps:

In this tutorial, we need 3 terminal windows for:

  • ONOS karaf process (from now on it will be called T1)

  • ONOS shell (T2), identified by onos> shell

  • Docker P4+Mininet emulator (T3), identified by mininet> shell

  • Utility (T4)

So, first of all, open 4 terminal windows on your machine.

In T1 run ONOS with the following commands:

$ cd ${WORKSPACE}/onos
$ ONOS_APPS=drivers,openflow,netcfghostprovider,segmentrouting,fpm,dhcprelay,routeradvertisement,t3,hostprobingprovider,drivers.bmv2,pipelines.fabric
$ bazel run onos-local -- clean


In T2 connect to the ONOS shell running the following command:

$ onos localhost

Now check that the apps are correctly active. You should see something similar to the output shown below:

onos> apps -a -s
*   9 org.onosproject.drivers              1.13.0.SNAPSHOT Default Drivers
*  35 org.onosproject.generaldeviceprovider 1.13.0.SNAPSHOT General Device Provider
*  36 org.onosproject.protocols.grpc       1.13.0.SNAPSHOT gRPC Protocol Subsystem
*  37 org.onosproject.protocols.p4runtime  1.13.0.SNAPSHOT P4Runtime Protocol Subsystem
*  38 org.onosproject.p4runtime            1.13.0.SNAPSHOT P4Runtime Provider
*  39 org.onosproject.drivers.p4runtime    1.13.0.SNAPSHOT P4Runtime Drivers
*  42 org.onosproject.proxyarp             1.13.0.SNAPSHOT Proxy ARP/NDP
*  44 org.onosproject.hostprovider         1.13.0.SNAPSHOT Host Location Provider
*  45 org.onosproject.lldpprovider         1.13.0.SNAPSHOT LLDP Link Provider
*  73 org.onosproject.pipelines.basic      1.13.0.SNAPSHOT Basic Pipelines
*  84 org.onosproject.route-service        1.13.0.SNAPSHOT Route Service Server
*  95 org.onosproject.protocols.gnmi       1.13.0.SNAPSHOT gNMI Protocol Subsystem
*  96 org.onosproject.drivers.gnmi         1.13.0.SNAPSHOT gNMI Drivers
* 108 org.onosproject.pipelines.fabric     1.13.0.SNAPSHOT Fabric Pipeline
* 120 org.onosproject.segmentrouting       1.13.0.SNAPSHOT Segment Routing
* 121 org.onosproject.drivers.bmv2         1.13.0.SNAPSHOT BMv2 Drivers


From T3, now push the network configuration:

$ cd ${WORKSPACE}/routing/trellis
$ onos-netcfg localhost trellisp4.json


Now ONOS is running, the needed apps are correctly running and the network configuration is pushed in ONOS, we are ready to run the emulated Trellis topology on P4+Mininet Docker container.


In T3 start the previously downloaded Docker container with the topology available in the "routing" repository.

The mininet topology of trellisp4.py python script is the one presented above with:

  • 2 by 2 leaf-spine topology using 4 BMv2 devices

  • 4 bidirectional links between leaf and spine

  • 4 hosts, 2 hosts per leaf device

You can run the topology with the following command on T3:

$ docker run --rm -it --privileged -v /tmp/p4mn:/tmp \
	-v${WORKSPACE}/routing:/routing -w/routing/trellis \
	--name p4trellis --hostname p4trellis \
	-p 50001-50030:50001-50030 \
	--env PYTHONPATH=/root \
	--entrypoint python opennetworking/p4mn:stable trellisp4.py --onos-ip 127.0.0.1

The output should look like something like this:

Unable to contact the remote controller at 127.0.0.1:6653
Unable to contact the remote controller at 127.0.0.1:6633
Setting remote controller to 127.0.0.1:6653
*** Error setting resource limits. Mininet's performance may be affected.
*** Creating network
*** Adding hosts:
h1 h2 h3 h4
*** Adding switches:
s204 s205 s226 s227
*** Adding links:
(h1, s204) (h2, s204) (h3, s205) (h4, s205) (s226, s204) (s226, s205) (s227, s204) (s227, s205)
*** Configuring hosts
h1 h2 h3 h4
*** Starting controller	
c0
*** Starting 4 switches
s204 .........⚡️ simple_switch_grpc @ 50001
s205 .........⚡️ simple_switch_grpc @ 50002
s226 ......⚡️ simple_switch_grpc @ 50003
s227 .....⚡️ simple_switch_grpc @ 50004

*** Starting CLI:
mininet>


Since the Mininet Python script running inside the Container is not able to contact the ONOS controller (as you can see from the first 2 rows of the output above), we need to submit the Network Configuration on our own using the onos-netcfg command as we have done before.

To do so, on T4, run the following commands:

$ cd /tmp/p4mn
$ onos-netcfg localhost bmv2-s204-netcfg.json
$ onos-netcfg localhost bmv2-s205-netcfg.json
$ onos-netcfg localhost bmv2-s226-netcfg.json
$ onos-netcfg localhost bmv2-s227-netcfg.json

On T1 (Onos Karaf process) you should see that ONOS received the configuration and has configured the device.

To check we can run the following commands on T2 (onos shell):

onos> devices -s
id=device:bmv2:204, available=true, role=MASTER, type=SWITCH, driver=bmv2:org.onosproject.pipelines.fabric
id=device:bmv2:205, available=true, role=MASTER, type=SWITCH, driver=bmv2:org.onosproject.pipelines.fabric
id=device:bmv2:226, available=true, role=MASTER, type=SWITCH, driver=bmv2:org.onosproject.pipelines.fabric
id=device:bmv2:227, available=true, role=MASTER, type=SWITCH, driver=bmv2:org.onosproject.pipelines.fabric
onos> links
src=device:bmv2:204/1, dst=device:bmv2:226/1, type=DIRECT, state=ACTIVE, expected=false
src=device:bmv2:204/2, dst=device:bmv2:227/1, type=DIRECT, state=ACTIVE, expected=false
src=device:bmv2:205/1, dst=device:bmv2:226/2, type=DIRECT, state=ACTIVE, expected=false
src=device:bmv2:205/2, dst=device:bmv2:227/2, type=DIRECT, state=ACTIVE, expected=false
src=device:bmv2:226/1, dst=device:bmv2:204/1, type=DIRECT, state=ACTIVE, expected=false
src=device:bmv2:226/2, dst=device:bmv2:205/1, type=DIRECT, state=ACTIVE, expected=false
src=device:bmv2:227/1, dst=device:bmv2:204/2, type=DIRECT, state=ACTIVE, expected=false
src=device:bmv2:227/2, dst=device:bmv2:205/2, type=DIRECT, state=ACTIVE, expected=false

Now you should be able to ping the hosts from the Mininet shell (T3):

mininet> h1 ping h2
PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data.
64 bytes from 10.0.2.2: icmp_seq=1 ttl=63 time=2.90 ms
64 bytes from 10.0.2.2: icmp_seq=2 ttl=63 time=1.86 ms
...
mininet> h3 ping h4
PING 10.0.3.2 (10.0.3.2) 56(84) bytes of data.
64 bytes from 10.0.3.2: icmp_seq=1 ttl=63 time=3.69 ms
64 bytes from 10.0.3.2: icmp_seq=2 ttl=63 time=1.29 ms
...

If any host was not discovered by ONOS, try send arp request by using arping tool from Mininet shell (T3):

mininet> h1 arping 10.0.2.254


Hosts should be learned by ONOS

onos> hosts
id=00:AA:00:00:00:01/None,
 mac=00:AA:00:00:00:01, locations=[device:bmv2:204/3], vlan=None, ip(s)=[10.0.2.1], provider=of:org.onosproject.provider.host, configured=false
id=00:AA:00:00:00:02/None,
 mac=00:AA:00:00:00:02, locations=[device:bmv2:204/4], vlan=None, ip(s)=[10.0.2.2], provider=of:org.onosproject.provider.host, configured=false
id=00:AA:00:00:00:03/None,
 mac=00:AA:00:00:00:03, locations=[device:bmv2:205/3], vlan=None, ip(s)=[10.0.3.1], provider=of:org.onosproject.provider.host, configured=false
id=00:AA:00:00:00:04/None,
 mac=00:AA:00:00:00:04, locations=[device:bmv2:205/4], vlan=None, ip(s)=[10.0.3.2], provider=of:org.onosproject.provider.host,  configured=false

If any host was not discovered by ONOS, try send arp request by using arping tool from mininet shell:

mininet> h1 arping 10.0.2.254

Routing and bridging rule should be installed by ONOS after host been detected and hosts should be able to ping each other:

mininet> pingallfull
<...skip debug logs...>
*** Results:
 h1->h2: 1/1, rtt min/avg/max/mdev 1.267/1.267/1.267/0.000 ms
 h1->h3: 1/1, rtt min/avg/max/mdev 3.384/3.384/3.384/0.000 ms
 h1->h4: 1/1, rtt min/avg/max/mdev 4.708/4.708/4.708/0.000 ms
 h2->h1: 1/1, rtt min/avg/max/mdev 1.381/1.381/1.381/0.000 ms
 h2->h3: 1/1, rtt min/avg/max/mdev 3.138/3.138/3.138/0.000 ms
 h2->h4: 1/1, rtt min/avg/max/mdev 3.983/3.983/3.983/0.000 ms
 h3->h1: 1/1, rtt min/avg/max/mdev 3.446/3.446/3.446/0.000 ms
 h3->h2: 1/1, rtt min/avg/max/mdev 3.315/3.315/3.315/0.000 ms
 h3->h4: 1/1, rtt min/avg/max/mdev 1.388/1.388/1.388/0.000 ms
 h4->h1: 1/1, rtt min/avg/max/mdev 3.345/3.345/3.345/0.000 ms
 h4->h2: 1/1, rtt min/avg/max/mdev 4.479/4.479/4.479/0.000 ms
 h4->h3: 1/1, rtt min/avg/max/mdev 1.302/1.302/1.302/0.000 ms
mininet>


  • No labels