Atrium ONOS based Router测试环境的搭建方法

关于Atrium项目的简介

Atrium

  • 2015年6月,开放网络基金会(ONF)正式推出了一个自上而下、完整的开源SDN实现平台——Atrium,旨在帮助网络运营商更容易的部署SDN。
  • 目前Atrium共有两个版本(15/A和16/A),最新的16/A是2016年2月16号发布
  • 16/A版本相对于15/A的改进在于
  • 控制平面除了ONOS外,还新加了对Opendaylight的支持
  • Atrium Router with ONOS除了BGP外,还实验性地加入了IGP(例如OSPF/ISIS)
  • 新加了为数据中心服务的Leaf-Spine的网络解决方案
  • 本文关注的,是Atrium-ONOS 16/A的BGP speaker的测试环境搭建

Atrium-ONOS

  • 该方案的目的,就是让ONOS和Quagga配合,使得openflow交换机表现的就像是一台运行BGP协议的路由器
  • 测试如下图所示
Atrium ONOS based Router测试环境的搭建方法_第1张图片
Paste_Image.png
  • Atrium VM通过eth0和交换机建立OpenFlow通道,进行OpenFlow协议报文的交互和流表的下发
  • Quagga通过eth1(经过安装VM的服务器的物理网卡桥接),和交换机的业务口相连
  • 因为多个BGP peer的报文交互都要通过eth1进行,因此用子接口和vlan来区分,例如本例中,vlan100表示peer1,untag表示peer2

Atrium虚拟机的安装

准备工作

  • 需要用到的设备:一台Linux服务器
  • 从Atrium的github官网下载的Atrium-16A的镜像文件Atrium_ONOS_2016_A.ova
  • 在服务器上启动VirtualBox,并打开这个ova文件
  • 可以看到启动的VM拥有两张网卡,硬盘20G占用率100%
  • 通过将VM的eth0/eth1置于两个bridge上,使得VM可以通过服务器和外界通信
  • VM的eth0配置管理IP(和默认网关),就可以ssh登陆了,用户名/密码=admin/atriumonos
  • VM的eth1不需要配置IP

VM硬盘扩容

  • 如果不扩容,就无法创建文件,也就无法编译运行了
  • 对ova文件做如下操作,从20G扩容为30G
[centec@R1C2 atrium]$ VBoxManage clonehd Atrium_ONOS_2016_A-disk1.vmdk clone.vdi --format vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'vdi'. UUID: 6506c71a-c7d2-49c9-96bd-f4fe20e12f3f
[centec@R1C2 atrium]$ 
[centec@R1C2 atrium]$ VBoxManage modifyhd clone.vdi --resize 30720 #size in MB (30 GB) 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
  • virtualbox新建一个虚机,删除默认的硬盘控制器,新加SCSI硬盘控制器,加载clone.vdi


    Atrium ONOS based Router测试环境的搭建方法_第2张图片
    Paste_Image.png
  • 启动虚机后做如下操作

admin@atrium16A:~$ sudo swapoff /dev/sda5
admin@atrium16A:~$ sudo fdisk /dev/sda

Command (m for help): d
Partition number (1-5): 5

Command (m for help): d
Partition number (1-5): 2

Command (m for help): d
Selected partition 1

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-62914559, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-62914559, default 62914559): 
Using default value 62914559

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
admin@atrium16A:~$ 
admin@atrium16A:~$ sudo touch /forcefsck
admin@atrium16A:~$ sudo reboot
  • 重启后
admin@atrium16A:~$ sudo resize2fs /dev/sda1
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/sda1 is now 7864064 blocks long.

admin@atrium16A:~$ 
  • 然后再次重启,查看硬盘容量
admin@atrium16A:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        30G   19G  9.5G  67% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            2.0G  8.0K  2.0G   1% /dev
tmpfs           396M  428K  396M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            2.0G     0  2.0G   0% /run/shm
none            100M     0  100M   0% /run/user

网络设置

  • 在重启前,需要在Virtualbox中设置虚机的网络
  • 虚机加载后会有两个网口,Quagga会使用adapter2(eth1)来和交换机通信
  • 这个接口的混杂模式要设置成allow all,以便接收带vlan的报文


    Atrium ONOS based Router测试环境的搭建方法_第3张图片
    Paste_Image.png

使用正确的cell

  • 一个cell就是一个ONOS脚本运行环境参数的集合,本例使用默认的atrium_router
root@atrium16A:~# cell atrium_router
ONOS_CELL=atrium_router
OCI=127.0.0.1
OC1=127.0.0.1
OCN=127.0.0.1
ONOS_APPS=drivers,openflow,vrouter
ONOS_GROUP=admin
ONOS_NIC=127.0.0.*
ONOS_SCENARIOS=/home/admin/onos/tools/test/scenarios
ONOS_USER=admin
ONOS_WEB_PASS=rocks
ONOS_WEB_USER=onos
root@atrium16A:~# 

Atrium环境的搭建

环境的搭建分为两种,一种是设备全部用软件模拟的,还有一种是使用物理设备

软件模拟环境的搭建

修改network-cfg.json

  • 文件位于目录~/Applications/config/
  • 该文件夹下已经有两个示例文件network-cfg.json.fabric.hw和network-cfg.json.fabric.mn
  • 其中network-cfg.json.router.hw适用于物理交换机,network-cfg.json.router.mn适用于软件交换机
  • 本例中使用network-cfg.json.router.mn,复制后不需要做修改
admin@atrium16A:~/Applications/config$ cp network-cfg.json.router.mn network-cfg.json
admin@atrium16A:~/Applications/config$ 
admin@atrium16A:~/Applications/config$ more network-cfg.json
admin@atrium16A:~/Applications/config$ more network-cfg.json
{
     "devices" : {
          "of:0000000000000001" : {
              "basic" : {
                      "driver" : "softrouter"
                }
          }
    },


    "ports" : {
        "of:0000000000000001/1" : {
            "interfaces" : [
                {
                    "ips" : [ "192.168.10.101/24" ],
                    "mac" : "00:00:00:00:00:01",
                    "vlan" : "100"
                }
            ]
        },
        "of:0000000000000001/2" : {
            "interfaces" : [
                {
                    "ips" : [ "192.168.20.101/24" ],
                    "mac" : "00:00:00:00:00:02"
                }
            ]
        }
    },
    "apps" : {
        "org.onosproject.router" : {
            "bgp" : {
                "bgpSpeakers" : [
                    {
                        "connectPoint" : "of:0000000000000001/3",
                        "peers" : [
                            "192.168.10.1",
                            "192.168.20.1"
                        ]
                    }
                ]
            },
            "router" : {
                "controlPlaneConnectPoint" : "of:0000000000000001/3",
                "ospfEnabled" : "true",
                "pimEnabled" : "true"
            }
        }
    }
}

admin@atrium16A:~/Applications/config$ 
  • 可以看到设置涉及到openflow交换机的dpid,以及Quagga的BGP的配置

软件模拟环境的启动和验证

  • 启动ONOS(后面称终端A)
admin@atrium16A:~/Applications/config$ ok clean
Creating local cluster configs for IP 127.0.0.1...
Staging builtin apps...
Customizing apps to be auto-activated: drivers,openflow,vrouter...
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 '' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '' or type 'system:shutdown' or 'logout' to shutdown ONOS.

onos> 
  • VM上新开一个终端(后面称终端B),启动route-test脚本并让它保持在后台运行
admin@atrium16A:~$ sudo ./router-test.py &  
  • 此时在终端A上,可以查看到softswitch已经连上
onos> devices
id=of:0000000000000001, available=true, role=MASTER, type=SWITCH, mfr=Stanford University, Ericsson Research and CPqD Research, hw=OpenFlow 1.3 Reference Userspace Switch, sw=May 21 2015 08:32:26, serial=1, managementAddress=127.0.0.1, protocol=OF_13, driver=softrouter, name=of:0000000000000001, channelId=127.0.0.1:49415
onos> 
  • 在终端B上,可以看到启动的mininet实例,登陆密码默认都是sdnip
admin@atrium16A:~$ ps -ef | grep mininet
root     20033 20029  0 22:09 pts/12   00:00:00 bash --norc -is mininet:c0           
root     20039 20029  0 22:09 pts/13   00:00:00 bash --norc -is mininet:host1      #peer1后面的主机 
root     20043 20029  0 22:09 pts/14   00:00:00 bash --norc -is mininet:host2      #peer2后面的主机
root     20047 20029  0 22:09 pts/15   00:00:00 bash --norc -is mininet:peer1      # peer router 1,和qh建立BGP连接
root     20049 20029  0 22:09 pts/16   00:00:00 bash --norc -is mininet:peer2      # peer router 2,和qh建立BGP连接
root     20051 20029  0 22:09 pts/17   00:00:00 bash --norc -is mininet:qh           # Quagga linux主机,提供IP/BGP协议栈服务
root     20055 20029  0 22:09 pts/18   00:00:00 bash --norc -is mininet:root1
root     20057 20029  0 22:09 pts/19   00:00:00 bash --norc -is mininet:router     # 用CPqD交换机实例化出的router
admin    20324 16304  0 22:16 pts/1    00:00:00 grep --color=auto mininet
admin@atrium16A:~$ 
  • 在终端B上,切换到qh,然后登陆Quagga并查看BGP的peer
admin@atrium16A:~$ ./mininet/util/m qh
ONOS_CELL=atrium_router
OCI=127.0.0.1
OC1=127.0.0.1
OCN=127.0.0.1
ONOS_APPS=drivers,openflow,vrouter
ONOS_GROUP=admin
ONOS_NIC=127.0.0.*
ONOS_SCENARIOS=/home/admin/onos/tools/test/scenarios
ONOS_USER=admin
ONOS_WEB_PASS=rocks
ONOS_WEB_USER=onos
root@atrium16A:~# 
root@atrium16A:~# 
root@atrium16A:~# telnet localhost 2605
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Hello, this is Quagga (version 0.99.24.1).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password: 
qh> en
qh# 
qh# show ip bgp
qh# show ip bgp su
qh# show ip bgp summary 
BGP router identifier 1.1.1.11, local AS number 65000
RIB entries 3, using 336 bytes of memory
Peers 2, using 9136 bytes of memory

Neighbor        V         AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.10.1    4 65001     314     315        0    0    0 00:15:33        1
192.168.20.1    4 65002     313     316        0    0    0 00:15:33        1

Total number of neighbors 2
qh# 
  • 终端B切换到peer1,查看BGP路由,发现本端的1.0.0.0/16网段已经宣告,并且学习到peer1那边的2.0.0.0/16网段
root@atrium16A:~# ./mininet/util/m peer1
ONOS_CELL=atrium_router
OCI=127.0.0.1
OC1=127.0.0.1
OCN=127.0.0.1
ONOS_APPS=drivers,openflow,vrouter
ONOS_GROUP=admin
ONOS_NIC=127.0.0.*
ONOS_SCENARIOS=/home/admin/onos/tools/test/scenarios
ONOS_USER=admin
ONOS_WEB_PASS=rocks
ONOS_WEB_USER=onos
root@atrium16A:~# 
root@atrium16A:~# telnet localhost 2605
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Hello, this is Quagga (version 0.99.24.1).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password: 
peer1> en
peer1# show ip bgp
peer1# show ip bgp 
BGP table version is 0, local router ID is 1.0.0.254
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
              i internal, r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0/16       0.0.0.0                  0         32768 i
*> 2.0.0.0/16       192.168.10.101                         0 65000 65002 i

Total number of prefixes 2
peer1# 
  • 终端B切换到host1,去ping host2
root@atrium16A:~# ./mininet/util/m host1
ONOS_CELL=atrium_router
OCI=127.0.0.1
OC1=127.0.0.1
OCN=127.0.0.1
ONOS_APPS=drivers,openflow,vrouter
ONOS_GROUP=admin
ONOS_NIC=127.0.0.*
ONOS_SCENARIOS=/home/admin/onos/tools/test/scenarios
ONOS_USER=admin
ONOS_WEB_PASS=rocks
ONOS_WEB_USER=onos
root@atrium16A:~# 
root@atrium16A:~# ping 2.0.0.1
PING 2.0.0.1 (2.0.0.1) 56(84) bytes of data.
64 bytes from 2.0.0.1: icmp_req=1 ttl=62 time=0.776 ms
64 bytes from 2.0.0.1: icmp_req=2 ttl=62 time=0.678 ms
64 bytes from 2.0.0.1: icmp_req=3 ttl=62 time=0.493 ms
^C
--- 2.0.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.493/0.649/0.776/0.117 ms
root@atrium16A:~# 
  • 终端A上查看ONOS的流表
onos> flows
deviceId=of:0000000000000001, flowRuleCount=21
    id=460000488fb8ff, state=ADDED, bytes=60, packets=1, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:2, ETH_TYPE:arp, VLAN_VID:-1], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER, OUTPUT:3], deferred=[], transition=None, cleared=false, metadata=null}
    id=460000488fc51b, state=ADDED, bytes=60, packets=1, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:1, ETH_TYPE:arp, VLAN_VID:100], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER, OUTPUT:3], deferred=[], transition=None, cleared=false, metadata=null}
    id=46000048906477, state=ADDED, bytes=0, packets=0, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:2, ETH_TYPE:ipv4, VLAN_VID:-1, IP_PROTO:89], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:3], deferred=[], transition=None, cleared=false, metadata=null}
    id=46000048907093, state=ADDED, bytes=0, packets=0, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:1, ETH_TYPE:ipv4, VLAN_VID:100, IP_PROTO:89], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:3], deferred=[], transition=None, cleared=false, metadata=null}
    id=460000b1f09f85, state=ADDED, bytes=50170, packets=613, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:1, ETH_DST:00:00:00:00:00:01, ETH_TYPE:ipv4, VLAN_VID:100, IPV4_DST:192.168.10.101/32], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:3], deferred=[], transition=None, cleared=false, metadata=null}
    id=460000b1f09fc3, state=ADDED, bytes=59538, packets=748, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:3, ETH_SRC:00:00:00:00:00:01, ETH_TYPE:ipv4, VLAN_VID:100, IPV4_SRC:192.168.10.101/32], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:1], deferred=[], transition=None, cleared=false, metadata=null}
    id=460000b1f51f3e, state=ADDED, bytes=56425, packets=746, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:2, ETH_DST:00:00:00:00:00:02, ETH_TYPE:ipv4, VLAN_VID:-1, IPV4_DST:192.168.20.101/32], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:3], deferred=[], transition=None, cleared=false, metadata=null}
    id=460000b1f51f5d, state=ADDED, bytes=56427, packets=745, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:3, ETH_SRC:00:00:00:00:00:02, ETH_TYPE:ipv4, VLAN_VID:-1, IPV4_SRC:192.168.20.101/32], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:2], deferred=[], transition=None, cleared=false, metadata=null}
    id=460000c7d63a3b, state=ADDED, bytes=60, packets=1, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:3, ETH_SRC:00:00:00:00:00:01, ETH_TYPE:arp, VLAN_VID:100, ARP_SPA:192.168.10.101], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER, OUTPUT:1], deferred=[], transition=None, cleared=false, metadata=null}
    id=460000c7d653a9, state=ADDED, bytes=60, packets=1, duration=1115, priority=40001, tableId=0, appId=org.onosproject.cpredirect, payLoad=null, selector=[IN_PORT:3, ETH_SRC:00:00:00:00:00:02, ETH_TYPE:arp, VLAN_VID:-1, ARP_SPA:192.168.20.101], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER, OUTPUT:2], deferred=[], transition=None, cleared=false, metadata=null}
    id=20000487f4dd5, state=ADDED, bytes=0, packets=0, duration=1115, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:lldp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, cleared=false, metadata=null}
    id=20000487f5c1f, state=ADDED, bytes=0, packets=0, duration=1115, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:bddp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, cleared=false, metadata=null}
    id=20000488eb5db, state=ADDED, bytes=0, packets=0, duration=1115, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:arp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, cleared=false, metadata=null}
    id=45000048262824, state=ADDED, bytes=0, packets=0, duration=1115, priority=32768, tableId=0, appId=org.onosproject.router, payLoad=null, selector=[IN_PORT:2, ETH_DST:00:00:00:00:00:02, ETH_TYPE:ipv4, VLAN_VID:-1], treatment=DefaultTrafficTreatment{immediate=[], deferred=[], transition=TABLE:1, cleared=false, metadata=null}
    id=45000048262843, state=ADDED, bytes=0, packets=0, duration=1115, priority=32768, tableId=0, appId=org.onosproject.router, payLoad=null, selector=[IN_PORT:3, ETH_DST:00:00:00:00:00:02, ETH_TYPE:ipv4, VLAN_VID:-1], treatment=DefaultTrafficTreatment{immediate=[], deferred=[], transition=TABLE:1, cleared=false, metadata=null}
    id=45000048263421, state=ADDED, bytes=0, packets=0, duration=1115, priority=32768, tableId=0, appId=org.onosproject.router, payLoad=null, selector=[IN_PORT:1, ETH_DST:00:00:00:00:00:01, ETH_TYPE:ipv4, VLAN_VID:100], treatment=DefaultTrafficTreatment{immediate=[VLAN_POP], deferred=[], transition=TABLE:1, cleared=false, metadata=null}
    id=4500004826345f, state=ADDED, bytes=0, packets=0, duration=1115, priority=32768, tableId=0, appId=org.onosproject.router, payLoad=null, selector=[IN_PORT:3, ETH_DST:00:00:00:00:00:01, ETH_TYPE:ipv4, VLAN_VID:100], treatment=DefaultTrafficTreatment{immediate=[VLAN_POP], deferred=[], transition=TABLE:1, cleared=false, metadata=null}
    id=4700004642a9bd, state=ADDED, bytes=2214, packets=29, duration=1115, priority=0, tableId=0, appId=org.onosproject.driver.SoftRouterPipeline, payLoad=null, selector=[], treatment=DefaultTrafficTreatment{immediate=[NOACTION], deferred=[], transition=None, cleared=false, metadata=null}
    id=450000236433e5, state=ADDED, bytes=0, packets=0, duration=1108, priority=180, tableId=1, appId=org.onosproject.router, payLoad=null, selector=[ETH_TYPE:ipv4, IPV4_DST:1.0.0.0/16], treatment=DefaultTrafficTreatment{immediate=[ETH_SRC:00:00:00:00:00:01, ETH_DST:00:00:00:00:10:01, VLAN_PUSH:vlan, VLAN_ID:100, VLAN_PCP:0, OUTPUT:1], deferred=[], transition=None, cleared=false, metadata=null}
    id=45000025190c84, state=ADDED, bytes=0, packets=0, duration=1108, priority=180, tableId=1, appId=org.onosproject.router, payLoad=null, selector=[ETH_TYPE:ipv4, IPV4_DST:2.0.0.0/16], treatment=DefaultTrafficTreatment{immediate=[ETH_SRC:00:00:00:00:00:02, ETH_DST:00:00:00:00:20:01, OUTPUT:2], deferred=[], transition=None, cleared=false, metadata=null}
    id=4700004642a9be, state=ADDED, bytes=0, packets=0, duration=1115, priority=0, tableId=1, appId=org.onosproject.driver.SoftRouterPipeline, payLoad=null, selector=[], treatment=DefaultTrafficTreatment{immediate=[NOACTION], deferred=[], transition=None, cleared=false, metadata=null}
onos> 

一些说明

  • ONOS首先下发的默认流表,会保证peer1/peer2能够和Quagga进行正常的ARP交互和BGP的连接建立
  • Quagga通过BGP从其它AS学习到新的网段后(例如1.0.0.0/16),会通告给ONOS,ONOS会下发对应的流表,保证发往目的网段的流量会发往该路由通告的来源端口,并做必要的报文编辑,例如
id=450000236433e5, state=ADDED, bytes=0, packets=0, duration=1108, priority=180, tableId=1, appId=org.onosproject.router, payLoad=null, selector=[ETH_TYPE:ipv4, IPV4_DST:1.0.0.0/16], treatment=DefaultTrafficTreatment{immediate=[ETH_SRC:00:00:00:00:00:01, ETH_DST:00:00:00:00:10:01, VLAN_PUSH:vlan, VLAN_ID:100, VLAN_PCP:0, OUTPUT:1], deferred=[], transition=None, cleared=false, metadata=null}
  • 测试完毕后用脚本停止Quagga和其它的mininet实例
root@atrium16A:~# sudo ./router-cleanup.sh 

硬件环境的启动和验证

环境搭建

  • 将原来拓扑中的switch/peer/host用实际的物理设备代替
  • 记录连线关系

硬件交换机的设置

  • 在硬件交换机上配置好控制器的信息(VM的IP和port:6653)
  • 其它必要配置(例如支持的OpenFlow协议,需要支持1.3)

修改network-cfg.json

  • 复制network-cfg.json.router.hw
admin@atrium16A:~/Applications/config$ cp network-cfg.json.router.hw network-cfg.json
  • 对network-cfg.json文件对照交换机和连线进行修改(dpid/port/vlan),mac不用修改

开发适用于硬件交换机的driver

  • 已经提交并被Atrium接收的driver文件,放在下面的目录
admin@atrium16A:~/onos/drivers/default/src/main/java/org/onosproject/driver/pipeline$ 
  • 因为各家的交换机对于流表级数以及各级流表适用范围存在差异,因此一般来说各款产品的driver都是不同的
  • 例如新加支持盛科网络V580交换机的CentecV580Pipeline.java放在该目录下

修改onos-drivers.xml

  • 该xml文件位于
admin@atrium16A:~/onos/drivers/default/src/main/resources$
  • 这个文件描述了ONOS获取交换机信息后,如何匹配进而选择对应的driver,例如增加如下字段
    
        

重新编译

  • 对driver做了改动后,需要重新编译
admin@atrium16A:~/onos$ mvn install
  • 如果编译通过,会看到如下显示
......
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 08:12 min
[INFO] Finished at: 2016-07-08T15:19:51-07:00
[INFO] Final Memory: 185M/674M
[INFO] ------------------------------------------------------------------------
admin@atrium16A:~/onos$ 

启动和验证

  • 启动ONOS的步骤没有变化
  • ONOS上查看交换机信息和使用的Pipeline
onos> devices
id=of:0000001e080a5607, available=true, role=MASTER, type=SWITCH, mfr=2004-2016 Centec Networks Inc, hw=20Q4Z, sw=5.0.3xxx
onos> 
onos> log:display | grep Pipeline
2016-07-11 23:59:57,258 | INFO  |  server boss #17 | OpenflowPipelineFactory          | 167 - org.onosproject.onos-of-ctl - 1.5.0.SNAPSHOT | OpenFlow SSL disabled
2016-07-11 23:59:57,363 | INFO  | ice-operations-6 | CentecV580Pipeline               | 164 - org.onosproject.onos-drivers - 1.5.0.SNAPSHOT | Provisioned drop rules in both tables
onos> 
  • 启动Quagga需要用另外一个脚本
admin@atrium16A:~$ sudo ./router-deploy.py &
  • 启动后可以查看mininet实例,少了host和peer,但是多了一个s1
admin@atrium16A:~$ ps -ef | grep mininet
root     23695 23691  0 14:10 pts/18   00:00:00 bash --norc -is mininet:c0
root     23701 23691  0 14:10 pts/19   00:00:00 bash --norc -is mininet:qh
root     23705 23691  0 14:10 pts/20   00:00:00 bash --norc -is mininet:root1
root     23710 23691  0 14:10 pts/21   00:00:00 bash --norc -is mininet:s1
admin    23818 21388  0 14:10 pts/8    00:00:00 grep --color=auto mininet
admin@atrium16A:~$ 
  • 这个s1是一个虚拟的二层交换机,它将Quagga的qh-eth1和VM的eth1连接连接起来,这样Quagga就可以和外界做报文交互了
  • 查看Quagga学习到的1.0.0.0/16和2.0.0.0/16网段有没有在OpenFlow交换机上添加正确处理的流表,如果有问题,就需要继续调试pipeline文件了
  • 最后两边的host能够互相ping通,测试通过。

本文首发于SDNLAB http://www.sdnlab.com/17472.html

你可能感兴趣的:(Atrium ONOS based Router测试环境的搭建方法)