1. 程式人生 > 其它 >拓端tecdat|R語言ARIMA整合模型預測時間序列分析

拓端tecdat|R語言ARIMA整合模型預測時間序列分析

實驗7:基於REST API的SDN北向應用實踐
一、實驗目的
1.能夠編寫程式呼叫OpenDaylight REST API實現特定網路功能;
2.能夠編寫程式呼叫Ryu REST API實現特定網路功能。
二、實驗環境
1.下載虛擬機器軟體Oracle VisualBox或VMware;
2.在虛擬機器中安裝Ubuntu 20.04 Desktop amd64,並完整安裝Mininet、OpenDaylight(Carbon版本)、Postman和Ryu;
三、實驗要求
(一)基本要求
1.OpenDaylight
(1) 利用Mininet平臺搭建下圖所示網路拓撲,並連線OpenDaylight;

(2) 編寫Python程式,呼叫OpenDaylight的北向介面下發指令刪除s1上的流表資料。
import requests
from requests.auth import HTTPBasicAuth
if name

== "main":
url = 'http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/'
headers = {'Content-Type': 'application/json'}
res = requests.delete(url, headers=headers, auth=HTTPBasicAuth('admin', 'admin'))
print (res.content)
(3) 編寫Python程式,呼叫OpenDaylight的北向介面下發硬超時流表,實現拓撲內主機h1和h3網路中斷20s。
import requests
from requests.auth import HTTPBasicAuth

if name == "main":
url = 'http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/flow/1'
with open("./flowtable.json") as f:
jstr = f.read()
headers = {'Content-Type': 'application/json'}
res = requests.put(url, jstr, headers=headers, auth=HTTPBasicAuth('admin', 'admin'))
print (res.content)
(4) 編寫Python程式,呼叫OpenDaylight的北向介面獲取s1上活動的流表數。
import requests
from requests.auth import HTTPBasicAuth

if name == "main":
url = 'http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/opendaylight-flow-table-statistics:flow-table-statistics'
headers = {'Content-Type': 'application/json'}
res = requests.get(url,headers=headers, auth=HTTPBasicAuth('admin', 'admin'))
print (res.content)
2.Ryu
(1) 編寫Python程式,呼叫Ryu的北向介面,實現上述OpenDaylight實驗拓撲上相同的硬超時流表下發。
import requests
from requests.auth import HTTPBasicAuth
def http_post(url,jstr):
url= url
headers = {'Content-Type':'application/json'}
resp = requests.post(url,jstr,headers=headers)
return resp

if name == "main":
url='http://127.0.0.1:8080/stats/flowentry/add'
with open('flowtable2.json') as f:
jstr = f.read()
resp = http_post(url,jstr)
print (resp.content)
(2) 利用Mininet平臺搭建下圖所示網路拓撲,要求支援OpenFlow 1.3協議,主機名、交換機名以及埠對應正確。拓撲生成後需連線Ryu,且Ryu應能夠提供REST API服務。


(3) 整理一個Shell指令碼,參考Ryu REST API的文件,利用curl命令,實現和實驗2相同的VLAN。

實驗總結
本次實驗較為困難,需要多操作多理解。