sdn第七次上机实验

(1) 利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight;

(2) 编写Python程序,调用OpenDaylight的北向接口下发指令删除s1上的流表数据。
`def http_detele(url):
url = url
headers = {'Content-Type': 'application/json'}
resp = requests.delete(url, headers=headers, auth=HTTPBasicAuth('admin', 'admin'))
return resp

if name == 'main':
url = 'http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/'
with open('test.json') as f:
jstr = f.read()
resp = http_detele(url)
print(resp.content)(3) 编写Python程序,调用OpenDaylight的北向接口下发硬超时流表,实现拓扑内主机h1和h3网络中断20s。import requests
from requests.auth import HTTPBasicAuth
def http_put(url,jstr):
url= url
headers = {'Content-Type':'application/json'}
resp = requests.put(url,jstr,headers=headers,auth=HTTPBasicAuth('admin', 'admin'))
return resp

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('206.json') as f:
jstr = f.read()
resp = http_put(url,jstr)
print (resp.content)`

(4) 编写Python程序,调用OpenDaylight的北向接口获取s1上活动的流表数。
`import requests
import json
from requests.auth import HTTPBasicAuth
def http_get(url):
url= url
headers = {'Content-Type':'application/json'}
resp = requests.get(url,headers=headers,auth=HTTPBasicAuth('admin','admin'))
return resp

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'
with open('206.json') as f:
jstr = f.read()
resp = http_get(url)
print(resp.content)(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('206-Ryu-1.json') as f:
jstr = f.read()
resp = http_post(url,jstr)
print (resp.content)`
(2) 利用Mininet平台搭建下图所示网络拓扑,要求支持OpenFlow 1.3协议,主机名、交换机名以及端口对应正确。拓扑生成后需连接Ryu,且Ryu应能够提供REST API服务。

实验心得:这次实验难度挺大的,也基本都是看同学的代码然后一点一点做的,对sdn还是有点陌生的,希望下次能够更顺利完成。

posted @ 2021-10-26 16:43  Venturezz  阅读(6)  评论(0)    收藏  举报