OpenDaylight-Boron學習筆記: 5 OpenFlowPlugin模組

來源:互聯網
上載者:User
環境及軟體版本說明

===

SN-Controller:

CPU: 2 Cores

RAM: 4GB

Disk: 32GB

Operating System: CentOS7 x86_64 1611(Linux 3.10.0-514) Infrastructure Server

IP1: 10.0.3.100/24 (Public Network)

IP2: 172.16.3.100/24 (SDN Network)

===

OpenDaylight: Boron

下載地址 參考文獻

OpenFlow Plugin Project User Guide

《OpenDaylight應用指南》(唐宏 等編著) 安裝OpenFlowPlugin模組

進入ODL的控制台karaf,執行以下命令安裝OpenFlowPlugin:

opendaylight-user@root>feature:install odl-openflowplugin-nxm-extensions odl-openflowplugin-flow-services-ui odl-openflowplugin-flow-services-rest odl-openflowplugin-flow-services odl-openflowplugin-southbound odl-openflowplugin-nsf-model odl-openflowplugin-drop-test odl-openflowplugin-app-table-miss-enforcer odl-openflowplugin-app-config-pusher odl-openflowplugin-app-topology odl-openflowplugin-app-bulk-o-matic odl-openflowplugin-app-notifications odl-openflowplugin-app-forwardingrules-manager odl-openflowplugin-app-forwardingrules-syncopendaylight-user@root>feature:install odl-openflowplugin-app-lldp-speaker-heopendaylight-user@root>feature:install odl-restconf-all odl-restconf odl-restconf-noauth
功能體驗 端到端庫存(End to End Inventory)

通過ODL庫存,可以查看到目前記錄的節點資訊。下面先使用Mininet建立一個簡單的拓撲:

Mininet虛擬機器參數: HostName:mininet-vm1 CPU: 2核 RAM: 4GB IP1:10.0.3.101(Public Network) IP2: 172.16.3.101(SDN Network)

mininet@mininet-vm1:~$ sudo mn --topo=single,2 --mac --controller=remote,ip=10.0.3.100,port=6633 --switch ovsk,protocols=OpenFlow13mininet> sh ovs-vsctl show918037ec-b307-45d7-a75a-f1ac4337d135    Bridge "s1"        Controller "tcp:10.0.3.100:6633"            is_connected: true        Controller "ptcp:6654"        fail_mode: secure        Port "s1"            Interface "s1"                type: internal        Port "s1-eth1"            Interface "s1-eth1"        Port "s1-eth2"            Interface "s1-eth2"    ovs_version: "2.0.2"

此時,往ODL發送下面Rest請求:

http://10.0.3.100:8181/restconf/operational/opendaylight-inventory:nodes/Method:GETHeaders:Accept : application/xml

發送請求後,按提示輸入相應的使用者名稱(admin)和密碼(admin)後,可以得到一個接近兩千多行的xml檔案,裡麵包含s1的相關資訊,包括連接埠、串連資訊等。因為內容過長,所以不貼出來了。還可以只輸出某個節點,展示該節點的資訊,如往ODL發送Rest請求,查看openflow:1(對應s1)節點的資訊:

http://10.0.3.100:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1Method:GETHeaders:Accept : application/xml

由於當前只有一個節點(s1),所以返回的內容與查詢所有節點的資訊的內容一樣。 端到端流(End to End Flows)

通過OpenFlow Plugin,可以使用Rest請求去添加、刪除和修改庫存節點的流表。接著上面的實驗環境,先在mininet-vm1裡的mn控制台查看s1的流表資訊:

mininet> sh ovs-ofctl -O OpenFlow13 dump-flows s1OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x2b00000000000000, duration=1689.737s, table=0, n_packets=5, n_bytes=322, priority=2,in_port=1 actions=output:2,CONTROLLER:65535 cookie=0x2b00000000000001, duration=1689.737s, table=0, n_packets=4, n_bytes=280, priority=2,in_port=2 actions=output:1,CONTROLLER:65535 cookie=0x2b00000000000000, duration=1691.669s, table=0, n_packets=0, n_bytes=0, priority=100,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0xa, duration=1691.688s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=0 actions=CONTROLLER:65535

往ODL控制器發送下面的Rest請求,對s1添加流表。

http://10.0.3.100:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1Method:PUTHeaders:Content-Type : application/xmlAccept : application/xmlAuthentication :Body:<?xml version="1.0" encoding="UTF-8" standalone="no"?><flow xmlns="urn:opendaylight:flow:inventory">    <priority>2</priority>    <flow-name>Foo</flow-name>    <match>        <ethernet-match>            <ethernet-type>                <type>2048</type>            </ethernet-type>        </ethernet-match>        <ipv4-destination>10.0.3.0/24</ipv4-destination>    </match>    <id>1</id>    <table_id>0</table_id>    <instructions>        <instruction>            <order>0</order>            <apply-actions>                <action>                   <order>0</order>                   <dec-nw-ttl/>                </action>            </apply-actions>        </instruction>    </instructions></flow>

這裡值得注意的是,Rest請求中table後的0和flow後面的1要分別和Body裡的和要對應起來。

發送請求後,會返回一個201 Created的狀態代碼。說明添加流表成功。在mininet-vm1的mn控制台中驗證:

mininet> sh ovs-ofctl -O OpenFlow13 dump-flows s1OFPST_FLOW reply (OF1.3) (xid=0x2):

此時發現,s1的流表變成了空。。這個我無法解釋,以為是之前某一步出現了問題,於是繼續下面的操作,打算重新再來一次:

mininet> exitmininet@mininet-vm1:~$ sudo mn -cmininet@mininet-vm1:~$ sudo ovs-vsctl show918037ec-b307-45d7-a75a-f1ac4337d135    ovs_version: "2.0.2"mininet@mininet-vm1:~$ sudo mn --topo=single,2 --mac --controller=remote,ip=10.0.3.100,port=6633 --switch ovsk,protocols=OpenFlow13mininet> pingall*** Ping: testing ping reachabilityh1 -> h2h2 -> h1*** Results: 0% dropped (2/2 received)mininet> sh ovs-ofctl -O OpenFlow13 dump-flows s1OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x2a00000000000009, duration=44.424s, table=0, n_packets=1, n_bytes=98, idle_timeout=600, hard_timeout=300, priority=10,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02 actions=output:2 cookie=0x2a00000000000008, duration=44.424s, table=0, n_packets=2, n_bytes=140, idle_timeout=600, hard_timeout=300, priority=10,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01 actions=output:1 cookie=0x0, duration=51.902s, table=0, n_packets=0, n_bytes=0, priority=2,ip,nw_dst=10.0.3.0/24 actions=dec_ttl cookie=0x2b00000000000002, duration=50.003s, table=0, n_packets=5, n_bytes=322, priority=2,in_port=1 actions=output:2,CONTROLLER:65535 cookie=0x2b00000000000003, duration=50.003s, table=0, n_packets=4, n_bytes=280, priority=2,in_port=2 actions=output:1,CONTROLLER:65535 cookie=0x2b00000000000001, duration=51.942s, table=0, n_packets=0, n_bytes=0, priority=100,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0x2b00000000000001, duration=51.974s, table=0, n_packets=0, n_bytes=0, priority=0 actions=drop

這時神奇的事情發生了。因為這時我還沒有向ODL發送添加流表的請求,卻發現,s1有上一次添加流表後的流表。難道之前不能顯示流表是因為mininet本身的一個bug??無法解釋。這時我決定再把添加的流表刪除看看:

http://10.0.3.100:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1Method:DELETEHeaders:Accept : application/xml

此時返回一個200 OK的狀態代碼。再在mininet-vm1的mn控制器中查看s1的流表。

mininet> sh ovs-ofctl -O OpenFlow13 dump-flows s1OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x2b00000000000002, duration=1866.44s, table=0, n_packets=5, n_bytes=322, priority=2,in_port=1 actions=output:2,CONTROLLER:65535 cookie=0x2b00000000000003, duration=1866.44s, table=0, n_packets=4, n_bytes=280, priority=2,in_port=2 actions=output:1,CONTROLLER:65535 cookie=0x2b00000000000001, duration=1868.379s, table=0, n_packets=0, n_bytes=0, priority=100,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0x2b00000000000001, duration=1868.411s, table=0, n_packets=0, n_bytes=0, priority=0 actions=drop

這時卻能發現那條流表沒有了。分析一下:一開始發送的Rest請求是加到MD-SAL的config配置裡的,至於為什麼加完後mn顯示不出來,可能是一個bug。也由於是因為加到config配置裡,所以當我第二次重做的時候,就會自動地把這一條流表加進來。可能可以這麼理解吧,在config配置裡的配置是永久生效的,而在operational配置裡的只是臨時生效的。然而後來我也試過,把Rest請求改為用operational配置,發現會得到沒有這個Rest介面,說明添加的流表只能加在config配置裡。另外,在刪除流表後,我又重新做了一次,發現發送Rest請求添加流表後,在mn裡再查看s1的流表,發現又可以顯示流表了,所以可以更加確定這應該是mininet的一個bug。

ODL官網給出了一些流表設定的xml範例:
ofp-example-flows 端到端拓撲(End to End Topology)

同樣繼續使用上面的實驗環境,使用下面的Rest請求可以看到當前的拓撲資訊:

http://10.0.3.100:8181/restconf/operational/network-topology:network-topology/Method:GETHeaders:Accept : application/xml

返回的xml裡,可以看到topology-id有4種,分別是: flow:1 netvirt:1 ovsdb:1 hwvtep:1

而目前的這4個topology-id中,只有flow:1有內容,其它3個都為空白。回想之前做OVSDB模組的相關實驗時,我覺得,當mn中的ovs只要一串連controller時,就會在flow:1中出現節點資訊,當mn設定好manager時,就會在ovsdb:1中出現節點資訊。至於其它2個暫時還沒有涉及到,所以還不知道什麼情況下這兩個topology-id會有內容。

端到端拓撲的內容官網也就只介紹這麼多,Rest請求也只提供查詢作用。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.