本篇研究是探討使用openvswitch與Controller之間的關聯,前者主要是針對Openswitch所提供的OpenFlow協定介面去做設定,後者由Ryu所提供的API介面去做設定,以下分別針對這兩種模式來達到控制Data Flow的效果
[方式一]
由圖可知我們主要是針對Southbound的介面去做設定
# 簡單執行mininet拓墣
mn –topo=single,3 –mac –controller=remote
會發現無法Ping通,為什麼?
無法ping通host
# 操作Flow Table
sh ovs-ofctl dump-flows s1 查看s1的flow table
s1的flow table是空的
# 操作Flow Table
sh ovs-ofctl add-flow s1 “priority=0,action=normal" 新增s1的flow table
插入flow table後檢查有無正確被新增進去
此時就可以互相ping到其他host
h1 h2 h3 的主機可互相ping通了
# 新增flow 讓目的地IP是10.0.0.1的封包丟棄
sh ovs-ofctl del-flows s1 清除s1的flow table
sh ovs-ofctl add-flow s1 “priority=0,action=normal"
sh ovs-ofctl add-flow s1 “priority=100,eth_type=0x800,ip_dst=10.0.0.1,action=drop"
[PS]:
priority: 該flow的優先權,越高優先執行
eth_type: 採用何種通訊協定 0x800 表示TCP協定
ip_dst: 目的IP位址
action: 符合此規則的動作,drop表丟棄此封包
和h1有關的flow被block起來,因此不會通
# 新增flow 讓目的地MAC是00:00:00:00:00:02的封包丟棄
sh ovs-ofctl del-flows s1 清除s1的flow table
sh ovs-ofctl add-flow s1 “priority=0,action=normal"
sh ovs-ofctl add-flow s1 “priority=100,eth_type=0x800,dl_dst=00:00:00:00:00:02,action=drop"
和h2有關的flow被block起來,因此不會通
[方法二]
由圖可以本方法是針對northbound 的介面去做設定
# 執行POX Controller 和 Mininet
[POX]
./pox.py forwarding.l2_learning # 執行L2的flow table學習機制
[Mininet]
mn –topo=single,3 –mac –controller=remote
# 由於有連接POX Controller且有flow table學習機制,故host可相互ping通
# 分析各flow,所有flow路徑都被記錄在flow table中
# ICMP/ IP / MAC block實驗
複製l2_learning.py檔案,由該檔案進行更改程式碼
l2_learning.py 放置於pox/forwarding 目錄底下
# ICMP block 實驗
新增以下程式碼,並執行pox controller 和 mininet ,進行互ping實驗
# IP block 實驗
新增以下程式碼,並執行pox controller 和 mininet ,進行互ping實驗
python是很嚴格要求排版,注意同一個區塊的頭要對其,否則會被判定錯誤喔 !!
# MAC block 實驗
新增以下程式碼,並執行pox controller 和 mininet ,進行互ping實驗