一、搭建拓撲網絡
搭建了三層的二叉樹結構網絡,開啓SimpleSwitch3.py沒法完成pingall聯通測試,因而將拓撲結構更改成簡單的line,四個交換機(OF13)連成一線,每一個交換機下掛兩個主機,依次h1--h8ide
s1 = net.addSwitch('s1', cls=OVSKernelSwitch, protocols='OpenFlow13', mac='00:00:00:00:00:11')
s2 = net.addSwitch('s2', cls=OVSKernelSwitch, protocols='OpenFlow13', mac='00:00:00:00:00:12')測試
s3 = net.addSwitch('s3', cls=OVSKernelSwitch, protocols='OpenFlow13', mac='00:00:00:00:00:13')
s4 = net.addSwitch('s4', cls=OVSKernelSwitch, protocols='OpenFlow13', mac='00:00:00:00:00:14')rest
h1 = net.addHost('h1', ip='10.0.0.1', defaultRoute=None, mac='00:00:00:00:00:01')
h2 = net.addHost('h2', ip='10.0.0.2', defaultRoute=None, mac='00:00:00:00:00:02')
h3 = net.addHost('h3', ip='10.0.0.3', defaultRoute=None, mac='00:00:00:00:00:03')
h4 = net.addHost('h4', ip='10.0.0.4', defaultRoute=None, mac='00:00:00:00:00:04')
h5 = net.addHost('h5', ip='10.0.0.5', defaultRoute=None, mac='00:00:00:00:00:05')
h6 = net.addHost('h6', ip='10.0.0.6', defaultRoute=None, mac='00:00:00:00:00:06')
h7 = net.addHost('h7', ip='10.0.0.7', defaultRoute=None, mac='00:00:00:00:00:07')
h8 = net.addHost('h8', ip='10.0.0.8', defaultRoute=None, mac='00:00:00:00:00:08')
net.addLink(s1, h1)
net.addLink(s1, h2)
net.addLink(s2, h3)
net.addLink(s2, h4)
net.addLink(s3, h5)
net.addLink(s3, h6)
net.addLink(s4, h7)
net.addLink(s4, h8)
net.addLink(s1, s2)
net.addLink(s2, s3)
net.addLink(s3, s4)
blog
二、開啓ryu控制器接口
命令:sudo ryu-manager --observe-links simple_switch_13.py ofctl_rest.py rest_topology.py
ofctl_rest.py:爲了以後下發、查看流表預留的接口ip
三、進行連通性測試get
利用pingall命令,在mininet界面測試拓撲的聯通情況it
四、利用Postman查看各交換機流表io
查看各端口鏈接狀況,爲邏輯隔離作好預備工做(瞭解主機與交換機連接的端口狀況,下發流表時心中有數)
五、邏輯隔離
5.一、測試DELETE方法
在Postman Url欄輸入 http://127.0.0.1:8080/stats/flowentry/clear/1 方法選擇爲DELETE
,即刪除S1上的全部流表,所以h1與h2會與外界斷絕聯繫,用pingall測試:
成功。
5.二、測試Modify命令(POST)方法
流表下發成功(斷絕2號交換機來自一號端口的尋找7號主機的信息,講動做集設爲空),測試pingall
成功。
繼續測試,修改1號交換機上來自1端口尋找8號主機的信息(下圖)和2號主機上h3尋找h8消息(未貼圖)
mininet測試:
成功。
六、總結
經過以上方法可實現簡單的邏輯隔離功能。