ONOS SDN-IP Tutorial

This article uses a different approach from the official documentation about SDN-IP. The official documentation use all in one VM, I try to split the component inside the VM.

prerequisite:

In GNS3, create topology like this:

So, where is the SDN Topology? SDN topology is inside the mininet node. I try to summary that network inside mininet to make it not too complicated.

Configure IP Address

The first thing to do is to set the IP Address in all router and node who needs it and do some BGP Routing.

Internal BGP Speaker

quagga-InternalBGPSpeaker# conf t
quagga-InternalBGPSpeaker(config)# interface eth0
quagga-InternalBGPSpeaker(config-if)# no sh
quagga-InternalBGPSpeaker(config-if)# ip address 101.0.0.1/24
quagga-InternalBGPSpeaker(config-if)# ip address 201.0.0.1/24
quagga-InternalBGPSpeaker(config-if)# interface eth1
quagga-InternalBGPSpeaker(config-if)# no sh
quagga-InternalBGPSpeaker(config-if)# ip address 11.0.0.1/24
quagga-InternalBGPSpeaker(config-if)# exit
quagga-InternalBGPSpeaker(config)# 
quagga-InternalBGPSpeaker(config)# router bgp 100
quagga-InternalBGPSpeaker(config-router)# bgp router-id 11.0.0.1
quagga-InternalBGPSpeaker(config-router)# neighbor 11.0.0.2 remote-as 100
quagga-InternalBGPSpeaker(config-router)# neighbor 11.0.0.2 port 2000
quagga-InternalBGPSpeaker(config-router)# 
quagga-InternalBGPSpeaker(config-router)# neighbor 101.0.0.2 remote-as 200
quagga-InternalBGPSpeaker(config-router)# neighbor 201.0.0.2 remote-as 300
quagga-InternalBGPSpeaker(config-router)# 
quagga-InternalBGPSpeaker(config-router)# do wr
Building Configuration...
Configuration saved to /etc/quagga/zebra.conf
Configuration saved to /etc/quagga/ripd.conf
Configuration saved to /etc/quagga/ripngd.conf
Configuration saved to /etc/quagga/ospfd.conf
Configuration saved to /etc/quagga/ospf6d.conf
Configuration saved to /etc/quagga/bgpd.conf
Configuration saved to /etc/quagga/isisd.conf
Configuration saved to /etc/quagga/babeld.conf
[OK]
quagga-InternalBGPSpeaker(config-router)# do show int eth0
Interface eth0 is up, line protocol detection is disabled
  index 12 metric 0 mtu 1500 
  flags: <UP,BROADCAST,RUNNING,MULTICAST>
  HWaddr: 1e:5b:2a:d3:9c:b3
  inet 101.0.0.1/24 broadcast 101.0.0.255
  inet 201.0.0.1/24 broadcast 201.0.0.255
  inet6 fe80::1c5b:2aff:fed3:9cb3/64
quagga-InternalBGPSpeaker(config-router)# do show int eth1
Interface eth1 is up, line protocol detection is disabled
  index 15 metric 0 mtu 1500 
  flags: <UP,BROADCAST,RUNNING,MULTICAST>
  HWaddr: 86:da:36:62:84:e1
  inet 11.0.0.1/24 broadcast 11.0.0.255
  inet6 fe80::84da:36ff:fe62:84e1/64
quagga-InternalBGPSpeaker(config-router)#

hey? why we need to add 11.0.0.2 (ONOS Controller) into BGP Neighbor? because ONOS need to translate BGP into OpenFlow.

Quagga2

quagga-2# conf t
quagga-2(config)# interface eth0
quagga-2(config-if)# no sh
quagga-2(config-if)# ip address 201.0.0.2/24
quagga-2(config-if)# interface eth1
quagga-2(config-if)# no sh
quagga-2(config-if)# ip address 2.2.2.1/24
quagga-2(config-if)# exit
quagga-2(config)# 
quagga-2(config)# router bgp 300
quagga-2(config-router)# bgp router-id 2.2.2.1
quagga-2(config-router)# network 2.2.2.0/24
quagga-2(config-router)# neighbor 201.0.0.1 remote-as 100
quagga-2(config-router)# 
quagga-2(config-router)# do wr
Building Configuration...
Configuration saved to /etc/quagga/zebra.conf
Configuration saved to /etc/quagga/ripd.conf
Configuration saved to /etc/quagga/ripngd.conf
Configuration saved to /etc/quagga/ospfd.conf
Configuration saved to /etc/quagga/ospf6d.conf
Configuration saved to /etc/quagga/bgpd.conf
Configuration saved to /etc/quagga/isisd.conf
Configuration saved to /etc/quagga/babeld.conf
[OK]
quagga-2(config-router)# do show int eth0
Interface eth0 is up, line protocol detection is disabled
  index 14 metric 0 mtu 1500 
  flags: <UP,BROADCAST,RUNNING,MULTICAST>
  HWaddr: 6a:33:6f:9d:ff:83
  inet 201.0.0.2/24 broadcast 201.0.0.255
  inet6 fe80::6833:6fff:fe9d:ff83/64
quagga-2(config-router)#

Quagga1

quagga-1# conf t
quagga-1(config)# interface eth0
quagga-1(config-if)# no sh
quagga-1(config-if)# ip address 101.0.0.2/24
quagga-1(config-if)# interface eth1
quagga-1(config-if)# no sh
quagga-1(config-if)# ip address 1.1.1.1/24
quagga-1(config-if)# exit
quagga-1(config)# 
quagga-1(config)# router bgp 200
quagga-1(config-router)# bgp router-id 1.1.1.1
quagga-1(config-router)# network 1.1.1.0/24
quagga-1(config-router)# neighbor 101.0.0.1 remote-as 100
quagga-1(config-router)# 
quagga-1(config-router)# do wr
Building Configuration...
Configuration saved to /etc/quagga/zebra.conf
Configuration saved to /etc/quagga/ripd.conf
Configuration saved to /etc/quagga/ripngd.conf
Configuration saved to /etc/quagga/ospfd.conf
Configuration saved to /etc/quagga/ospf6d.conf
Configuration saved to /etc/quagga/bgpd.conf
Configuration saved to /etc/quagga/isisd.conf
Configuration saved to /etc/quagga/babeld.conf
[OK]
quagga-1(config-router)# do show int eth0
Interface eth0 is up, line protocol detection is disabled
  index 11 metric 0 mtu 1500 
  flags: <UP,BROADCAST,RUNNING,MULTICAST>
  HWaddr: 4e:da:58:18:96:f8
  inet 101.0.0.2/24 broadcast 101.0.0.255
  inet6 fe80::4cda:58ff:fe18:96f8/64

ONOS

sudo nano /etc/network/interfaces
...
auto ens4
iface ens4 inet static
address 11.0.0.2
netmask 255.255.255.0
network 11.0.0.0
...

sudo ifup ens4
ubuntu@ubuntu:~$ ping 11.0.0.1
PING 11.0.0.1 (11.0.0.1) 56(84) bytes of data.
64 bytes from 11.0.0.1: icmp_seq=1 ttl=64 time=8.06 ms
64 bytes from 11.0.0.1: icmp_seq=2 ttl=64 time=0.567 ms
64 bytes from 11.0.0.1: icmp_seq=3 ttl=64 time=0.521 ms
64 bytes from 11.0.0.1: icmp_seq=4 ttl=64 time=0.599 ms
^C
--- 11.0.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 0.521/2.438/8.066/3.249 ms
ubuntu@ubuntu:~$ ping 11.0.0.2
PING 11.0.0.2 (11.0.0.2) 56(84) bytes of data.
64 bytes from 11.0.0.2: icmp_seq=1 ttl=64 time=0.058 ms
64 bytes from 11.0.0.2: icmp_seq=2 ttl=64 time=0.040 ms
64 bytes from 11.0.0.2: icmp_seq=3 ttl=64 time=0.024 ms
^C
--- 11.0.0.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.024/0.040/0.058/0.015 ms

Install ONOS

sudo su
sudo apt-get install -y default-jre
sudo adduser sdn --system --group
cd /opt
wget http://repo1.maven.org/maven2/org/onosproject/onos-releases/2.0.0/onos-2.0.0.tar.gz
tar -vxzf onos-2.0.0.tar.gz
mv onos-2.0.0 onos
sudo chown -R sdn:sdn onos
sudo cp /opt/onos/init/onos.initd /etc/init.d/onos
sudo cp /opt/onos/init/onos.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable onos
sudo systemctl start onos
http://192.168.123.76:8181/onos/ui/index.html
user : onos
password : rocks

The installation method is referred to this article. Enter ONOS CLI and active these following apps

ubuntu@ubuntu:/opt$ /opt/onos/bin/onos
Warning: Permanently added '[localhost]:8101' (RSA) to the list of known hosts.
Welcome to Open Network Operating System (ONOS)!
     ____  _  ______  ____     
    / __ \/ |/ / __ \/ __/   
   / /_/ /    / /_/ /\ \     
   \____/_/|_/\____/___/     
                               
Documentation: wiki.onosproject.org      
Tutorials:     tutorials.onosproject.org 
Mailing lists: lists.onosproject.org     

Come help out! Find out how at: contribute.onosproject.org 

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'logout' to exit ONOS session.

ubuntu@root > app activate org.onosproject.config                               
> app activate org.onosproject.proxyarp
> app activate org.onosproject.sdnip
> app activate org.onosproject.openflow
> app activate org.onosproject.openflow-base
> app activate org.onosproject.openflow-message
Activated org.onosproject.config
Activated org.onosproject.proxyarp
Activated org.onosproject.sdnip
Activated org.onosproject.openflow
Activated org.onosproject.openflow-base
Activated org.onosproject.openflow-message
ubuntu@root > apps -a -s                                                        
*   6 org.onosproject.optical-model        2.0.0    Optical Network Model
*   7 org.onosproject.intentsynchronizer   2.0.0    Intent Synchronizer
*  13 org.onosproject.hostprovider         2.0.0    Host Location Provider
*  14 org.onosproject.yang                 2.0.0    YANG Compiler and Runtime
*  15 org.onosproject.config               2.0.0    Dynamic Configuration
*  28 org.onosproject.drivers              2.0.0    Default Drivers
*  44 org.onosproject.openflow-base        2.0.0    OpenFlow Base Provider
*  48 org.onosproject.route-service        2.0.0    Route Service Server
*  60 org.onosproject.proxyarp             2.0.0    Proxy ARP/NDP
*  61 org.onosproject.lldpprovider         2.0.0    LLDP Link Provider
*  94 org.onosproject.sdnip                2.0.0    SDN-IP
* 124 org.onosproject.openflow             2.0.0    OpenFlow Provider Suite
* 172 org.onosproject.openflow-message     2.0.0    Control Message Stats Provider
ubuntu@root >                                                                   

Install and configure Mininet

Install mininet

sudo apt install mininet

we know that this interface in mininet

  • ens3 is the management network
  • ens4 connect into BGP Internal Speaker
  • ens5 connect into ASN 200
  • ens6 connect into ASN 300

lets create SDN Topology (3 switch) and connect ens4,5, and 6 into the topology.

nano sdnip.py
#!/usr/bin/python

# ens3 ke controller
# ens4 ke internal speaker
# ens5 ke external bgp200
# ens6 ke external bgp300

from mininet.net import Mininet
from mininet.node import RemoteController, OVSSwitch
from mininet.cli import CLI
from mininet.link import Intf
from mininet.log import setLogLevel, info

def myNetwork():
    net = Mininet( topo=None,controller=RemoteController,switch=OVSSwitch)

    info( '*** Add Controller\n')
    net.addController('c0', ip='192.168.123.76', port=6633)

    info( '*** Add switches\n')
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')

    Intf( 'ens4', node=s1 )
    Intf( 'ens5', node=s2 )
    Intf( 'ens6', node=s3 )

    info( '*** Add links\n')
    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(s1, s3)

    info( '*** Starting network\n')
    net.start()
    CLI(net)
    net.stop()

if __name__ == '__main__':
    setLogLevel( 'info' )
    myNetwork()

Run the python script

ubuntu@ubuntu:~$ sudo python sdnip.py 
*** Add Controller
*** Add switches
*** Add links
*** Starting network
*** Configuring hosts

*** Starting controller
c0 
*** Starting 3 switches
s1 s2 s3 ...
*** Starting CLI:
mininet> 

Let’s check on ONOS

Create SDN-IP Configuration

I think this is the hardest part for this tutorial, different topology will change all of the configurations, but i will give you a basic understanding.

{
    "apps" : {
        "org.onosproject.router" : {
            "bgp" : {
                "bgpSpeakers" : [
                    {
                        "name" : "speaker1",
                        "connectPoint" : "of:xxxxxxxxxxxxxxxx/port-number",	// switch openflow ID where Internal BGP Connected with the port number
                        "peers" : ["101.0.0.2","201.0.0.2"]			//  ip address external peer bgp
                    }
                ]
            }
        }
    },
    "ports" : {
        "of:xxxxxxxxxxxxxxxx/port-number" : {
            "interfaces" : [
                {
                    "ips"  : [ "101.0.0.1/24" ],				// ip address internal bgp speaker (ASN 200)
                    "mac"  : "aa:aa:aa:aa:aa:aa"				// mac address from quagga1 (ASN 200)
                }
            ]
        },
        "of:xxxxxxxxxxxxxxxx/port-number" : {
            "interfaces" : [
                {
                    "ips"  : [ "201.0.0.1/24" ],				// ip address internal bgp speaker (ASN 300)
                    "mac"  : "aa:aa:aa:aa:aa:aa"				// mac address from quagga2 (ASN 300)
                }
            ]
        }

    }
}

so the configuration is (in ONOS node):

cd /opt/onos/config
sudo nano network-cfg.json
{
    "apps" : {
        "org.onosproject.router" : {
            "bgp" : {
                "bgpSpeakers" : [
                    {
                        "name" : "speaker1",
                        "connectPoint" : "of:0000000000000001/1",
                        "peers" : ["101.0.0.2","201.0.0.2"]
                    }
                ]
            }
        }
    },
    "ports" : {
        "of:0000000000000002/1" : {
            "interfaces" : [
                {
                    "ips"  : [ "101.0.0.1/24" ],
                    "mac"  : "4e:da:58:18:96:f8"
                }
            ]
        },
        "of:0000000000000003/1" : {
            "interfaces" : [
                {
                    "ips"  : [ "201.0.0.1/24" ],
                    "mac"  : "6a:33:6f:9d:ff:83"
                }
            ]
        }

    }
}

Post into ONOS

curl --user onos:rocks -X POST -H "Content-Type: application/json" http://192.168.123.76:8181/onos/v1/network/configuration/ -d @/opt/onos/config/network-cfg.json

Check ONOS

Welcome to Open Network Operating System (ONOS)!
     ____  _  ______  ____     
    / __ \/ |/ / __ \/ __/   
   / /_/ /    / /_/ /\ \     
   \____/_/|_/\____/___/     
                               
Documentation: wiki.onosproject.org      
Tutorials:     tutorials.onosproject.org 
Mailing lists: lists.onosproject.org     

Come help out! Find out how at: contribute.onosproject.org 

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'logout' to exit ONOS session.

ubuntu@root > apps -a -s                                                        
*   6 org.onosproject.optical-model        2.0.0    Optical Network Model
*   7 org.onosproject.intentsynchronizer   2.0.0    Intent Synchronizer
*  13 org.onosproject.hostprovider         2.0.0    Host Location Provider
*  14 org.onosproject.yang                 2.0.0    YANG Compiler and Runtime
*  15 org.onosproject.config               2.0.0    Dynamic Configuration
*  28 org.onosproject.drivers              2.0.0    Default Drivers
*  44 org.onosproject.openflow-base        2.0.0    OpenFlow Base Provider
*  48 org.onosproject.route-service        2.0.0    Route Service Server
*  60 org.onosproject.proxyarp             2.0.0    Proxy ARP/NDP
*  61 org.onosproject.lldpprovider         2.0.0    LLDP Link Provider
*  94 org.onosproject.sdnip                2.0.0    SDN-IP
* 124 org.onosproject.openflow             2.0.0    OpenFlow Provider Suite
* 172 org.onosproject.openflow-message     2.0.0    Control Message Stats Provider
ubuntu@root > netcfg                                                            
{
  "hosts" : { },
  "ports" : {
    "of:0000000000000002/1" : {
      "interfaces" : [ {
        "ips" : [ "101.0.0.1/24" ],
        "mac" : "4e:da:58:18:96:f8"
      } ]
    },
    "of:0000000000000003/1" : {
      "interfaces" : [ {
        "ips" : [ "201.0.0.1/24" ],
        "mac" : "6a:33:6f:9d:ff:83"
      } ]
    }
  },
  "links" : { },
  "apps" : {
    "org.onosproject.router" : {
      "bgp" : {
        "bgpSpeakers" : [ {
          "name" : "speaker1",
          "connectPoint" : "of:0000000000000001/1",
          "peers" : [ "101.0.0.2", "201.0.0.2" ]
        } ]
      }
    },
    "org.onosproject.provider.lldp" : {
      "suppression" : {
        "deviceTypes" : [ "ROADM", "OTN", "FIBER_SWITCH", "OPTICAL_AMPLIFIER", "OLS", "TERMINAL_DEVICE" ],
        "annotation" : "{\"no-lldp\":null}"
      }
    }
  },
  "layouts" : { },
  "devices" : { },
  "regions" : { }
}
ubuntu@root > interfaces                                                        
(unamed): port=of:0000000000000002/1 ips=[101.0.0.1/24] mac=4E:DA:58:18:96:F8
(unamed): port=of:0000000000000003/1 ips=[201.0.0.1/24] mac=6A:33:6F:9D:FF:83
ubuntu@root > bgp-neighbors                                                     
BGP neighbor is 11.0.0.1, remote AS 100, local AS 100
  Remote router ID 11.0.0.1, IP /11.0.0.1:37228, BGP version 4, Hold time 180
  Remote AFI/SAFI IPv4 Unicast YES Multicast NO, IPv6 Unicast NO Multicast NO
  Local  router ID 11.0.0.2, IP /11.0.0.2:2000, BGP version 4, Hold time 180
  Local  AFI/SAFI IPv4 Unicast YES Multicast NO, IPv6 Unicast NO Multicast NO
  4 Octet AS Capability: Advertised Received
ubuntu@root > routes                                                            
B: Best route, R: Resolved route

Table: ipv4
B R  Network            Next Hop        Source (Node)
> *  1.1.1.0/24         101.0.0.2       BGP (11.0.0.2)
> *  2.2.2.0/24         201.0.0.2       BGP (11.0.0.2)
   Total: 2

Table: ipv6
B R  Network            Next Hop        Source (Node)
   Total: 0

ubuntu@root > intents -s                                                        

Intent type                Total     Installed     Withdrawn        Failed    InstallReq     Compiling    Installing   Recompiling   WithdrawReq   Withdrawing  UnknownState
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
All                           14            14             0             0             0             0             0             0             0             0             0
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
MultiPointToSinglePoint        2             2             0             0             0             0             0             0             0             0             0
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PointToPoint                  12            12             0             0             0             0             0             0             0             0             0
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ubuntu@root >

Testing

Check routing table in quagga

quagga-2# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel,
       > - selected route, * - FIB route

B>* 1.1.1.0/24 [20/0] via 201.0.0.1, eth0, 00:00:51
C>* 2.2.2.0/24 is directly connected, eth1
C>* 127.0.0.0/8 is directly connected, lo
C>* 201.0.0.0/24 is directly connected, eth0

quagga-1# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel,
       > - selected route, * - FIB route

C>* 1.1.1.0/24 is directly connected, eth1
B>* 2.2.2.0/24 [20/0] via 101.0.0.1, eth0, 00:01:24
C>* 101.0.0.0/24 is directly connected, eth0
C>* 127.0.0.0/8 is directly connected, lo

Give VPLS IP Address

PC-1> ip 1.1.1.2 255.255.255.0 1.1.1.1
Checking for duplicate address...
PC1 : 1.1.1.2 255.255.255.0 gateway 1.1.1.1

PC-1> ping 2.2.2.2
84 bytes from 2.2.2.2 icmp_seq=1 ttl=62 time=4.162 ms
84 bytes from 2.2.2.2 icmp_seq=2 ttl=62 time=4.727 ms
84 bytes from 2.2.2.2 icmp_seq=3 ttl=62 time=3.382 ms
84 bytes from 2.2.2.2 icmp_seq=4 ttl=62 time=2.737 ms
^C
PC-1> 
PC-2> ip 2.2.2.2 255.255.255.0 2.2.2.1
Checking for duplicate address...
PC1 : 2.2.2.2 255.255.255.0 gateway 2.2.2.1

PC-2> ping 1.1.1.1
84 bytes from 1.1.1.1 icmp_seq=1 ttl=63 time=2.606 ms
84 bytes from 1.1.1.1 icmp_seq=2 ttl=63 time=2.429 ms
84 bytes from 1.1.1.1 icmp_seq=3 ttl=63 time=2.866 ms
84 bytes from 1.1.1.1 icmp_seq=4 ttl=63 time=2.520 ms
^C
PC-2> 

Comments are closed.