POX 可以说是 NOX 的同胞兄弟, 其是使用 python 语言开发的, 是一款快速的平台和网络原型的控制软件.
安装完后可以先体验一下
root@mininet-vm:/home/mininet/pox# ./pox.py openflow.of_01 --address=127.0.0.1
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
INFO:core:POX 0.2.0 (carp) is up.
在这里 pox.py 是程序的入口, openflow.of_01 库用来解释后面的参数, Pox 默认开启 6633 端口监听,
2. 在 address 后面指定 port.
root@mininet-vm:/home/mininet# ./pox/pox.py openflow.of_01 --address=127.0.0.1 --port=6667
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
INFO:core:POX 0.2.0 (carp) is up.
3. 运行组件, 即要用到的 app
root@mininet-vm:/home/mininet/pox# ./pox.py openflow.of_01 --address=127.0.0.1 --port=6666 py
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
INFO:core:POX 0.2.0 (carp) is up.
Ready.
POX>
在上面的 POX > 输入提示符中可以编辑 MSG 或者调用组件的接口.
4. 运行 Minine 连接 Pox 控制器.
- root@mininet-vm:/home/mininet# mn --controller=remote,ip=127.0.0.1,port=6666
- *** Creating network
- *** Adding controller
- *** Adding hosts:
- h1 h2
- *** Adding switches:
- s1
- *** Adding links:
- (h1, s1) (h2, s1)
- *** Configuring hosts
- h1 h2
- *** Starting controller
- c0
*** Starting 1 switches
s1 ...
- *** Starting CLI:
- root@mininet-vm:/home/mininet/pox# ./pox.py openflow.of_01 --address=127.0.0.1 --port=6666 py
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
INFO:core:POX 0.2.0 (carp) is up.
Ready.
- POX> INFO:openflow.of_01:[None 1] closed
- INFO:openflow.of_01:[00-00-00-00-00-01 2] connected
Pox 运行 l2_pairs 组件, 该组件可以抽取 packet_in 中的 dst_mac 和 src_mac, 根据源端口和目的端口下发的 flow entry 到 switch, 即工作在交换机模式.
Pox 端:
root@mininet-vm:/home/mininet/pox# ./pox.py openflow.of_01 --address=127.0.0.1 --port=8888 pox.forwarding.l2_pairs
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
INFO:forwarding.l2_pairs:Pair-Learning switch running.
INFO:core:POX 0.2.0 (carp) is up.
- INFO:openflow.of_01:[None 1] closed
- INFO:openflow.of_01:[00-00-00-00-00-01 2] connected
mininet 端:
- root@mininet-vm:/home/mininet# mn --controller=remote,ip=127.0.0.1,port=8888
- *** Creating network
- *** Adding controller
- *** Adding hosts:
- h1 h2
- *** Adding switches:
- s1
- *** Adding links:
- (h1, s1) (h2, s1)
- *** Configuring hosts
- h1 h2
- *** Starting controller
- c0
*** Starting 1 switches
s1 ...
*** Starting CLI:
查看下交换机的 flow entry, 可以发现无 flow entry
- mininet> dpctl dump-flows
- *** s1 ------------------------------------------------------------------------
- NXST_FLOW reply (xid=0x4):
使用 h1 ping h2, 发现出现了两条 flow entry.
mininet> h1 ping h2
- PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
- 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=50.7 ms
- 64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.043 ms
- 64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.127 ms
- 64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=0.075 ms
- ^C
- --- 10.0.0.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
- rtt min/avg/max/mdev = 0.043/12.747/50.745/21.938 ms
- mininet> dpctl dump-flows
- *** s1 ------------------------------------------------------------------------
- NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=453.315s, table=0, n_packets=5, n_bytes=434, idle_age=448, dl_src=8e:71:af:1f:ac:62,dl_dst=9e:c3:2e:b5:cd:4f actions=output:2
cookie=0x0, duration=453.277s, table=0, n_packets=6, n_bytes=476, idle_age=448, dl_src=9e:c3:2e:b5:cd:4f,dl_dst=8e:71:af:1f:ac:62 actions=output:1
来源: https://blog.csdn.net/qq_21127151/article/details/77927548