思路,在mininet模拟器上安装floodlight SDN控制器,通过floodlight观察控制器学习到的拓扑,以及下发产生的拓扑
1. mininet可以从https://github.com/mininet/openflow-tutorial/wiki 这个地方直接下载虚机镜像,比较方便,下载的ubuntu是14.04。导入到虚机启动后,参考文档熟悉mininet基本操作,熟悉openvswitch基本操作。
2.在mininet虚机上直接安装floodlight,安装方法:
1 2 3 4 5 6 7 8 9 10 |
sudo apt-get update sudo apt-get install build-essential default-jdk ant python-dev git clone git://github.com/floodlight/floodlight.git cd floodlight ant //下面命令为启动命令 java -jar target/floodlight.jar |
启动后用浏览器访问http://yourIP/ui/index.html 得到如下界面
然后启动mininet模拟一个openvswitch+host环境:
mn --topo tree,2 --mac --switch ovsk --controller=remote,ip=127.0.0.1,port=6653
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
root@mininet-vm:/home/mininet# mn --topo tree,2 --mac --switch ovsk --controller=remote,ip=127.0.0.1,port=6653 *** Creating network *** Adding controller *** Adding hosts: h1 h2 h3 h4 *** Adding switches: s1 s2 s3 *** Adding links: (s1, s2) (s1, s3) (s2, h1) (s2, h2) (s3, h3) (s3, h4) *** Configuring hosts h1 h2 h3 h4 *** Starting controller c0 *** Starting 3 switches s1 s2 s3 *** Starting CLI: |
注意端口是6653,这样ovs就通过floodlight的南向接口与控制器通信了
查看此时floodlight学习到的:
学习到的拓扑:
交换机2此时还没有任何flows,和命令输出一致:
1 2 |
root@mininet-vm:/home/mininet# ovs-ofctl dump-flows s2 NXST_FLOW reply (xid=0x4): |
下面从h1 ping h4 看看:
1 2 3 4 5 6 7 8 9 10 |
mininet> h1 ping 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=7.89 ms 64 bytes from 10.0.0.4: icmp_seq=2 ttl=64 time=0.217 ms 64 bytes from 10.0.0.4: icmp_seq=3 ttl=64 time=0.047 ms 64 bytes from 10.0.0.4: icmp_seq=4 ttl=64 time=0.045 ms 64 bytes from 10.0.0.4: icmp_seq=5 ttl=64 time=0.047 ms 64 bytes from 10.0.0.4: icmp_seq=6 ttl=64 time=0.062 ms 64 bytes from 10.0.0.4: icmp_seq=7 ttl=64 time=0.051 ms 64 bytes from 10.0.0.4: icmp_seq=8 ttl=64 time=0.047 ms |
floodlight将自动根据网络下发对应的flows给交换机:
1 2 3 4 5 |
root@mininet-vm:/home/mininet# ovs-ofctl dump-flows s2 NXST_FLOW reply (xid=0x4): cookie=0x20000000000000, duration=2.519s, table=0, n_packets=1, n_bytes=42, idle_timeout=5, idle_age=2, priority=1,arp,in_port=3,dl_src=00:00:00:00:00:04,dl_dst=00:00:00:00:00:01 actions=output:1 cookie=0x20000000000000, duration=2.514s, table=0, n_packets=2, n_bytes=196, idle_timeout=5, idle_age=0, priority=1,ip,in_port=3,dl_src=00:00:00:00:00:04,dl_dst=00:00:00:00:00:01,nw_src=10.0.0.4,nw_dst=10.0.0.1 actions=output:1 cookie=0x20000000000000, duration=2.517s, table=0, n_packets=2, n_bytes=196, idle_timeout=5, idle_age=0, priority=1,ip,in_port=1,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:04,nw_src=10.0.0.1,nw_dst=10.0.0.4 actions=output:3 |
这只是简单演示了sdn 控制器对网络的简单控制,可以基于floodlight接口开发更多的应用直接操纵底层网络,控制数据path。
文章评论