This tutorial is to run Segment Routing application in ONOS on a 2x2 leaf-spine topology built with Mininet.
Experiment Environment
I have run this test successfully on Ubuntu 16.04 with ONOS 1.12 and 1.14 two versions.
Install And Run ONOS
Refer to ONOS Wiki.
Enable Command onos-netcfg
Source this file to use command onos-netcfg
.
1 | $ sourc $ONOS_ROOT/tools/dev/bash_profile |
Or you can simply add the line in .bashrc
.
Enable ONOS Applications
Enable necessary applications in ONOS shell.
1 | onos> app activate drivers,openflow,netcfghostprovider,segmentrouting |
Or you can simply add the following line in .bashrc
.
1 | export ONOS_APPS='drivers,openflow,netcfghostprovider,segmentrouting' |
Install Mininet
Refer to Mininet Github page.
2x2 Leaf-Sping Topology
In this practice, we will run our segment routing application on 2x2 leaf-spine topology as the following picture.
Each leaf switches are attached with two hosts. The two subnets are 10.6.1.0/24 and 10.6.2.0/24.
ONOS Configuration
We are required to configure three network elements in ONOS - devices, ports and hosts.
Devices
1 | "devices" : { |
To config the switches as segment routers the following settings are needed to do.
of:0000000000000191
: Datapath ID (DPID) - ONOS uses this ID to configure corresponding switches.segmentrouting
: Segment routing application specific parametersname
: name of the switchipv4NodeSid
: Node segment IDipv4Lookback
: IP address of the loopback interface of the switchrouterMac
: MAC address of the loopback interface - In this implementation, this MAC address is used as src/dst MAC address in Ethernet headers for communication to other switches, instead of using the interface-MAC addresses.isEdgeRouter
: The flag to determine the edge routeradjacencySids
: Adjacency segment ID - This is not used in this practice.basic
: Basic parametersdriver
: Driver of the switch
Ports
1 | "ports" : { |
The following is needed to configure links between segment routers and hosts.
of:0000000000000101/3
: Datapath Id and the port numberips
: IP of the host which is connected to the switch and it’s subnetvlan-untagged
: VLAN tag number
Hosts
1 | "hosts" : { |
The following is needed to configure hosts.
00:00:00:00:00:01/-1
: Host MAC address and VLAN tag number - In this case, -1 means no VLAN tagips
: Host IPlocations
: The datapath and port number to which the host attaches
The configuration file are shown below.
1 | { |
Load the configuration.
1 | $ onos-netcfg <onos_ip> <config_file> |
Run Mininet
Here is the topology script to run in Mininet.
1 | # 2-by-2 leaf-spine topology |
Run Mininet.
1 | $ sudo mn --switch=ovs,protocols=OpenFlow13 --custom=topo.py --topo=mytopo --controller=remote,127.0.0.1:6653 |
Mininet will create a 2x2 leaf-spine fabric with OpenFlow1.3 enabled Open vSwitches and connect to the ONOS controller running at localhost.
Test
We can run pingall
at Mininet shell and verify the connectivity between all hosts.
Check OpenFlow Table
Check flow tables in switches.
1 | $ ovs-ofctl -O OpenFlow13 dump-flows <bridge> |
Check group tables in switches.
1 | $ ovs-ofctl -O OpenFlow13 dump-groups <bridge> |
See the Open vSwitch Manual for more details.
To run the commands shell Mininet shell, type the following.
1 | mininet> 2001 ovs-ofctl -O OpenFlow13 dump-flows "2001" |
Trace the flow tables and group tables and you can see switches push and pop MPLS labels.
Here are some points I got.
- In this practice, switches did perform segment routing using MPLS labels to route.
- For packets crossing subnets, the leaf switch would only push MPLS labels of the egress edge switch, which was
ipv4NodeSid
we set in device configuration. - As the packets arrived at spine switches, MPLS labels were popped. The reason was that for this 2x2 leaf-spine fabric, spine switches were called penultimate hop and would perform labels popping to reduce the load at egress switches.
- Since labels were popped at penultimate switches, the egress switches only needed to do IP table lookup without MPLS lookup, solving the Egress LSR Double Lookup problem.
The following picture shows labels of each flow in this practice.
Update
After tracing the flows installed by Segment Routing application, configuration for hosts is not truly necessary. Segment Routing uses flow rules to match the subnet under switches, which is already included in port configuration, but not Ethernet or IP addresses.
Configuration with hosts omitted has been tested and packets could be correctly forwarded.