1.安装Karaf,MVN(新版MVN不是必须了)
http://archive.apache.org/dist/karaf/3.0.8/apache-karaf-3.0.8.tar.gz
http://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
mkdir ~/Applications
tar -zxvf apache-karaf-3.0.8.tar.gz -C ~/Applications/
tar -zxvf apache-maven-3.3.9-bin.tar.gz -C ~/Applications/
2.安装install Oracle Java 8 及MVN
1. Download and Extract JDK package, such as jdk-8u131-linux-x64.tar.gz,
and you can see new directory /home/yourname/jdk1.8.0_131
2. Add two environment variables into ~/.bashrc or /etc/profile:
export JAVA_HOME=/home/yourname/jdk1.8.0_131
export PATH=${JAVA_HOME}/bin:$PATH
3.获取ONOS
git clone https://gerrit.onosproject.org/onos
另外可从github下载源码,下载地址
https://github.com/opennetworkinglab/onos
4.设置环境
export M2_HOME=$HOME/Applications/apache-maven-3.3.9
export PATH=$M2_HOME/bin:$PATH
export ONOS_ROOT=$HOME/onos
export KARAF_ROOT=$HOME/Applications/apache-karaf-3.0.8
export PATH=$KARAF_ROOT/bin:$PATH
if [ -d $ONOS_ROOT/tools/dev ]; then
. $ONOS_ROOT/tools/dev/bash_profile
fi
5.构建
cd $ONOS_ROOT
tools/build/onos-buck build onos --show-output
新的2.0版需要bazel来构建,可以check out为老版本
git checkout 1.14.1
在本地开发机启动onos:
cd $ONOS_ROOT
ok clean
或tools/build/onos-buck run onos-local -- clean debug
onos-karaf clean
查看openflow端口是否打开:
netstat -anput|grep 6633
6.mininet连接ONOS做为控制器
$ sudo mn --topo tree,depth=2,fanout=3 --mac --controller=remote,ip=127.0.0.1,port=6633
7.To attach to the ONOS CLI console, run:
$ $ONOS_ROOT/tools/test/bin/onos localhost
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 'system:shutdown' or 'logout' to shutdown ONOS.
onos> devices
id=of:0000000000000001, available=true, local-status=connected 39m56s ago, role=MASTER, type=SWITCH, mfr=Nicira, Inc., hw=Open vSwitch, sw=2.5.2, serial=None, driver=ovs, channelId=127.0.0.1:33252, managementAddress=127.0.0.1, protocol=OF_13
id=of:0000000000000002, available=true, local-status=connected 39m56s ago, role=MASTER, type=SWITCH, mfr=Nicira, Inc., hw=Open vSwitch, sw=2.5.2, serial=None, driver=ovs, channelId=127.0.0.1:33258, managementAddress=127.0.0.1, protocol=OF_13
id=of:0000000000000003, available=true, local-status=connected 39m56s ago, role=MASTER, type=SWITCH, mfr=Nicira, Inc., hw=Open vSwitch, sw=2.5.2, serial=None, driver=ovs, channelId=127.0.0.1:33256, managementAddress=127.0.0.1, protocol=OF_13
id=of:0000000000000004, available=true, local-status=connected 39m56s ago, role=MASTER, type=SWITCH, mfr=Nicira, Inc., hw=Open vSwitch, sw=2.5.2, serial=None, driver=ovs, channelId=127.0.0.1:33254, managementAddress=127.0.0.1, protocol=OF_13
onos> links
src=of:0000000000000002/4, dst=of:0000000000000001/1, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000001/3, dst=of:0000000000000004/4, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000004/4, dst=of:0000000000000001/3, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000001/1, dst=of:0000000000000002/4, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000001/2, dst=of:0000000000000003/4, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000003/4, dst=of:0000000000000001/2, type=DIRECT, state=ACTIVE, expected=false
mininet> links
s1-eth1<->s2-eth4 (OK OK)
s1-eth2<->s3-eth4 (OK OK)
s1-eth3<->s4-eth4 (OK OK)
s2-eth1<->h1-eth0 (OK OK)
s2-eth2<->h2-eth0 (OK OK)
s2-eth3<->h3-eth0 (OK OK)
s3-eth1<->h4-eth0 (OK OK)
s3-eth2<->h5-eth0 (OK OK)
s3-eth3<->h6-eth0 (OK OK)
s4-eth1<->h7-eth0 (OK OK)
s4-eth2<->h8-eth0 (OK OK)
s4-eth3<->h9-eth0 (OK OK)
mininet> dpctl dump-flows
*** s1 ------------------------------------------------------------------------
NXST_FLOW reply (xid=0x4):
cookie=0x10000c42e0660, duration=1.399s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=40000,arp actions=CONTROLLER:65535
cookie=0x10000190260d7, duration=1.398s, table=0, n_packets=4, n_bytes=324, idle_age=1, priority=40000,dl_type=0x88cc actions=CONTROLLER:65535
cookie=0x10000adc87f7a, duration=1.396s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=5,ip actions=CONTROLLER:65535
cookie=0x100006a526acd, duration=1.396s, table=0, n_packets=4, n_bytes=324, idle_age=1, priority=40000,dl_type=0x8942 actions=CONTROLLER:65535
cookie=0x10000f1040206, duration=1.396s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=5,arp actions=CONTROLLER:65535
*** s2 ------------------------------------------------------------------------
NXST_FLOW reply (xid=0x4):
cookie=0x10000984d6c82, duration=1.394s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=5,arp actions=CONTROLLER:65535
cookie=0x100002f8d46be, duration=1.394s, table=0, n_packets=1, n_bytes=81, idle_age=1, priority=40000,dl_type=0x88cc actions=CONTROLLER:65535
cookie=0x10000a8ca7e32, duration=1.394s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=40000,arp actions=CONTROLLER:65535
cookie=0x100005f500291, duration=1.394s, table=0, n_packets=1, n_bytes=81, idle_age=1, priority=40000,dl_type=0x8942 actions=CONTROLLER:65535
cookie=0x100009e4a103f, duration=1.394s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=5,ip actions=CONTROLLER:65535
*** s3 ------------------------------------------------------------------------
NXST_FLOW reply (xid=0x4):
cookie=0x100008118b503, duration=1.447s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=5,arp actions=CONTROLLER:65535
cookie=0x10000a0b249d1, duration=1.447s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=5,ip actions=CONTROLLER:65535
cookie=0x10000068c0d36, duration=1.447s, table=0, n_packets=2, n_bytes=162, idle_age=1, priority=40000,dl_type=0x88cc actions=CONTROLLER:65535
cookie=0x10000fe3dbf3b, duration=1.447s, table=0, n_packets=2, n_bytes=162, idle_age=1, priority=40000,dl_type=0x8942 actions=CONTROLLER:65535
cookie=0x1000090985895, duration=1.436s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=40000,arp actions=CONTROLLER:65535
*** s4 ------------------------------------------------------------------------
NXST_FLOW reply (xid=0x4):
cookie=0x10000ae14ea27, duration=1.416s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=5,arp actions=CONTROLLER:65535
cookie=0x10000f2317b70, duration=1.416s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=40000,arp actions=CONTROLLER:65535
cookie=0x10000f83ba517, duration=1.415s, table=0, n_packets=1, n_bytes=81, idle_age=1, priority=40000,dl_type=0x8942 actions=CONTROLLER:65535
cookie=0x100001bd2055c, duration=1.414s, table=0, n_packets=0, n_bytes=0, idle_age=1, priority=5,ip actions=CONTROLLER:65535
cookie=0x100006ab365e9, duration=1.414s, table=0, n_packets=1, n_bytes=81, idle_age=1, priority=40000,dl_type=0x88cc actions=CONTROLLER:65535
onos> flows
deviceId=of:0000000000000001, flowRuleCount=5
id=10000190260d7, state=ADDED, bytes=133650, packets=1650, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:lldp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=100006a526acd, state=ADDED, bytes=133650, packets=1650, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:bddp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000c42e0660, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:arp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000adc87f7a, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=5, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:ipv4], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000f1040206, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=5, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:arp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
deviceId=of:0000000000000002, flowRuleCount=5
id=100002f8d46be, state=ADDED, bytes=44550, packets=550, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:lldp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=100005f500291, state=ADDED, bytes=44550, packets=550, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:bddp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000a8ca7e32, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:arp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000984d6c82, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=5, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:arp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=100009e4a103f, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=5, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:ipv4], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
deviceId=of:0000000000000003, flowRuleCount=5
id=10000068c0d36, state=ADDED, bytes=44550, packets=550, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:lldp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=1000090985895, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:arp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000fe3dbf3b, state=ADDED, bytes=44550, packets=550, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:bddp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=100008118b503, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=5, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:arp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000a0b249d1, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=5, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:ipv4], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
deviceId=of:0000000000000004, flowRuleCount=5
id=100006ab365e9, state=ADDED, bytes=44550, packets=550, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:lldp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000f2317b70, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:arp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000f83ba517, state=ADDED, bytes=44550, packets=550, duration=1705, liveType=UNKNOWN, priority=40000, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:bddp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=100001bd2055c, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=5, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:ipv4], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
id=10000ae14ea27, state=ADDED, bytes=0, packets=0, duration=1705, liveType=UNKNOWN, priority=5, tableId=0, appId=org.onosproject.core, payLoad=null, selector=[ETH_TYPE:arp], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:CONTROLLER], deferred=[], transition=None, meter=None, cleared=true, metadata=null}
我们可以看出mininet里links命令除去主机和交换机之间的链路,和onos的links命令是能够对应的。onos> flows和mininet> dpctl dump-flows也是。
也可以直接用$ dpctl dump-flows tcp:127.0.0.1:6654(这里是s1)命令来查看流表
先用ovs-vsctl查看虚拟交换机的监听端口
$ sudo ovs-vsctl show
、2b05a0c0-015b-44cd-8ce8-d540d9f551c4
Bridge "s3"
Controller "ptcp:6656"
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port "s3-eth2"
Interface "s3-eth2"
Port "s3-eth1"
Interface "s3-eth1"
Port "s3"
Interface "s3"
type: internal
Port "s3-eth4"
Interface "s3-eth4"
Port "s3-eth3"
Interface "s3-eth3"
Bridge "s1"
Controller "ptcp:6654"
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port "s1-eth1"
Interface "s1-eth1"
Port "s1-eth2"
Interface "s1-eth2"
Port "s1"
Interface "s1"
type: internal
Port "s1-eth3"
Interface "s1-eth3"
Bridge "s4"
Controller "tcp:127.0.0.1:6633"
is_connected: true
Controller "ptcp:6657"
fail_mode: secure
Port "s4-eth2"
Interface "s4-eth2"
Port "s4-eth4"
Interface "s4-eth4"
Port "s4-eth1"
Interface "s4-eth1"
Port "s4"
Interface "s4"
type: internal
Port "s4-eth3"
Interface "s4-eth3"
Bridge "s2"
Controller "tcp:127.0.0.1:6633"
is_connected: true
Controller "ptcp:6655"
fail_mode: secure
Port "s2-eth4"
Interface "s2-eth4"
Port "s2-eth2"
Interface "s2-eth2"
Port "s2-eth3"
Interface "s2-eth3"
Port "s2-eth1"
Interface "s2-eth1"
Port "s2"
Interface "s2"
type: internal
ovs_version: "2.5.2"
$ dpctl dump-flows tcp:127.0.0.1:6654
stats_reply (xid=0x533c0333): flags=none type=1(flow)
cookie=281479020282374, duration_sec=730s, duration_nsec=459000000s, table_id=0, priority=5, n_packets=0, n_bytes=0, idle_timeout=0,hard_timeout=0,arp,actions=CONTROLLER:65535
cookie=281477892308858, duration_sec=730s, duration_nsec=459000000s, table_id=0, priority=5, n_packets=0, n_bytes=0, idle_timeout=0,hard_timeout=0,ip,actions=CONTROLLER:65535
cookie=281475396296919, duration_sec=730s, duration_nsec=459000000s, table_id=0, priority=40000, n_packets=711, n_bytes=57591, idle_timeout=0,hard_timeout=0,dl_type=0x88cc,actions=CONTROLLER:65535
cookie=281476760496845, duration_sec=730s, duration_nsec=459000000s, table_id=0, priority=40000, n_packets=711, n_bytes=57591, idle_timeout=0,hard_timeout=0,dl_type=0x8942,actions=CONTROLLER:65535
cookie=281478268061280, duration_sec=730s, duration_nsec=459000000s, table_id=0, priority=40000, n_packets=0, n_bytes=0, idle_timeout=0,hard_timeout=0,arp,actions=CONTROLLER:65535
这里cookie和mininet> dpctl dump-flows是一样的(如281479020282374=0x10000f1040206),只不过是用十进制来表示。
开始时候onos>hosts输出为空,在mininet里主机都ping一遍就会被onos发现。
onos> hosts
id=00:00:00:00:00:01/None, mac=00:00:00:00:00:01, location=of:0000000000000002/1, vlan=None, ip(s)=[10.0.0.1], configured=false
id=00:00:00:00:00:02/None, mac=00:00:00:00:00:02, location=of:0000000000000002/2, vlan=None, ip(s)=[10.0.0.2], configured=false
id=00:00:00:00:00:03/None, mac=00:00:00:00:00:03, location=of:0000000000000002/3, vlan=None, ip(s)=[10.0.0.3], configured=false
id=00:00:00:00:00:04/None, mac=00:00:00:00:00:04, location=of:0000000000000003/1, vlan=None, ip(s)=[10.0.0.4], configured=false
id=00:00:00:00:00:05/None, mac=00:00:00:00:00:05, location=of:0000000000000003/2, vlan=None, ip(s)=[10.0.0.5], configured=false
id=00:00:00:00:00:06/None, mac=00:00:00:00:00:06, location=of:0000000000000003/3, vlan=None, ip(s)=[10.0.0.6], configured=false
id=00:00:00:00:00:07/None, mac=00:00:00:00:00:07, location=of:0000000000000004/1, vlan=None, ip(s)=[10.0.0.7], configured=false
id=00:00:00:00:00:08/None, mac=00:00:00:00:00:08, location=of:0000000000000004/2, vlan=None, ip(s)=[10.0.0.8], configured=false
id=00:00:00:00:00:09/None, mac=00:00:00:00:00:09, location=of:0000000000000004/3, vlan=None, ip(s)=[10.0.0.9], configured=false
路径
onos> paths of:0000000000000001 of:0000000000000004
of:0000000000000001/2-of:0000000000000002/2==>of:0000000000000002/3-of:0000000000000003/2==>of:0000000000000003/3-of:0000000000000004/2; cost=3.0
如果$ sudo mn --topo linear,4 --mac --controller=remote,ip=127.0.0.1,port=6633
s1到s4路径要经过s2和s3
onos> paths of:0000000000000002 of:0000000000000004
of:0000000000000002/4-of:0000000000000001/1==>of:0000000000000001/3-of:0000000000000004/4; cost=2.0
拆除(建立)虚拟交换机的连接
mininet> link s1 s2 down
mininet> h1 ping -c 2 h4
PING 10.0.0.4 (10.0.0.4) 56(84) bytes of data.
--- 10.0.0.4 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1030ms
onos> links
src=of:0000000000000001/3, dst=of:0000000000000004/4, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000004/4, dst=of:0000000000000001/3, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000001/2, dst=of:0000000000000003/4, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000003/4, dst=of:0000000000000001/2, type=DIRECT, state=ACTIVE, expected=false
重新建立连接
mininet> link s1 s2 up
mininet> h1 ping -c 2 h4
PING 10.0.0.4 (10.0.0.4) 56(84) bytes of data.
64 bytes from 10.0.0.4: icmp_seq=1 ttl=64 time=14.9 ms
64 bytes from 10.0.0.4: icmp_seq=2 ttl=64 time=0.762 ms
--- 10.0.0.4 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.762/7.853/14.945/7.092 ms
onos> links
src=of:0000000000000001/3, dst=of:0000000000000004/4, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000002/4, dst=of:0000000000000001/1, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000004/4, dst=of:0000000000000001/3, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000001/1, dst=of:0000000000000002/4, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000001/2, dst=of:0000000000000003/4, type=DIRECT, state=ACTIVE, expected=false
src=of:0000000000000003/4, dst=of:0000000000000001/2, type=DIRECT, state=ACTIVE, expected=false
使用intents比简单的使用流表项去编程网络的好处是:intents可以跟踪网络的状态,并且为了满足你的intention对网络进行重新配置。例如:如果某处的link断开了,intent框架可以变更(reroute)你的intent(也就是你的流表)到另外可用的路径上。但是,如果没有另外可用的路径该怎么办呢?在这种情况下,intent将进入失败状态,并且保持这种状态直到出现一个可用的路径。
onos> add-host-intent 00:00:00:00:00:01/-1 00:00:00:00:00:09/-1
Host to Host intent submitted:
HostToHostIntent{id=0x0, key=0x0, appId=DefaultApplicationId{id=3, name=org.onosproject.cli}, priority=100, resources=[00:00:00:00:00:01/None, 00:00:00:00:00:09/None], selector=DefaultTrafficSelector{criteria=[]}, treatment=DefaultTrafficTreatment{immediate=[NOACTION], deferred=[], transition=None, meter=None, cleared=false, metadata=null}, constraints=[LinkTypeConstraint{inclusive=false, types=[OPTICAL]}], resourceGroup=null, one=00:00:00:00:00:01/None, two=00:00:00:00:00:09/None}
onos> intents
Id: 0x0
State: INSTALLED
Key: 0x0
Intent type: HostToHostIntent
Application Id: org.onosproject.cli
Resources: [00:00:00:00:00:01/None, 00:00:00:00:00:09/None]
Treatment: [NOACTION]
Constraints: [LinkTypeConstraint{inclusive=false, types=[OPTICAL]}]
Source host: 00:00:00:00:00:01/None
Destination host: 00:00:00:00:00:09/None
onos> intents -i
Id: 0x0
State: INSTALLED
Key: 0x0
Intent type: HostToHostIntent
Application Id: org.onosproject.cli
Resources: [00:00:00:00:00:01/None, 00:00:00:00:00:09/None]
Treatment: [NOACTION]
Constraints: [LinkTypeConstraint{inclusive=false, types=[OPTICAL]}]
Source host: 00:00:00:00:00:01/None
Destination host: 00:00:00:00:00:09/None
Installable: [FlowRuleIntent{id=0x3, key=0x0, appId=DefaultApplicationId{id=96, name=org.onosproject.net.intent}, resources=[DefaultLink{src=of:0000000000000002/4, dst=of:0000000000000001/1, type=DIRECT, state=ACTIVE, expected=false}, DefaultLink{src=of:0000000000000001/3, dst=of:0000000000000004/4, type=DIRECT, state=ACTIVE, expected=false}], flowRule=[DefaultFlowRule{id=600000e3184ab0, deviceId=of:0000000000000004, priority=100, selector=[IN_PORT:4, ETH_DST:00:00:00:00:00:09, ETH_SRC:00:00:00:00:00:01], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:3], deferred=[], transition=None, meter=None, cleared=false, metadata=null}, tableId=0, created=1495979689127, payLoad=null}, DefaultFlowRule{id=6000009caef945, deviceId=of:0000000000000001, priority=100, selector=[IN_PORT:1, ETH_DST:00:00:00:00:00:09, ETH_SRC:00:00:00:00:00:01], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:3], deferred=[], transition=None, meter=None, cleared=false, metadata=null}, tableId=0, created=1495979689127, payLoad=null}, DefaultFlowRule{id=60000023ebd357, deviceId=of:0000000000000002, priority=100, selector=[IN_PORT:1, ETH_DST:00:00:00:00:00:09, ETH_SRC:00:00:00:00:00:01], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:4], deferred=[], transition=None, meter=None, cleared=false, metadata=null}, tableId=0, created=1495979689127, payLoad=null}], resourceGroup=null}, FlowRuleIntent{id=0x4, key=0x0, appId=DefaultApplicationId{id=96, name=org.onosproject.net.intent}, resources=[DefaultLink{src=of:0000000000000004/4, dst=of:0000000000000001/3, type=DIRECT, state=ACTIVE, expected=false}, DefaultLink{src=of:0000000000000001/1, dst=of:0000000000000002/4, type=DIRECT, state=ACTIVE, expected=false}], flowRule=[DefaultFlowRule{id=6000005e7112cc, deviceId=of:0000000000000004, priority=100, selector=[IN_PORT:3, ETH_DST:00:00:00:00:00:01, ETH_SRC:00:00:00:00:00:09], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:4], deferred=[], transition=None, meter=None, cleared=false, metadata=null}, tableId=0, created=1495979689127, payLoad=null}, DefaultFlowRule{id=6000008bf33a8c, deviceId=of:0000000000000001, priority=100, selector=[IN_PORT:3, ETH_DST:00:00:00:00:00:01, ETH_SRC:00:00:00:00:00:09], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:1], deferred=[], transition=None, meter=None, cleared=false, metadata=null}, tableId=0, created=1495979689127, payLoad=null}, DefaultFlowRule{id=600000f42b1dbe, deviceId=of:0000000000000002, priority=100, selector=[IN_PORT:4, ETH_DST:00:00:00:00:00:01, ETH_SRC:00:00:00:00:00:09], treatment=DefaultTrafficTreatment{immediate=[OUTPUT:1], deferred=[], transition=None, meter=None, cleared=false, metadata=null}, tableId=0, created=1495979689127, payLoad=null}], resourceGroup=null}]
8.GUI
地址:http://localhost:8181/onos/ui
或
tools/test/bin/onos-gui localhost
ONOS Core REST API
http://127.0.0.1:8181/onos/v1/docs/index.html
默认用户名密码:karaf
来源
https://wiki.onosproject.org/display/test/Building+ONOS
来源:oschina
链接:https://my.oschina.net/u/2245781/blog/898974