首页 > 其他分享 >实验7:基于REST API的SDN北向应用实践

实验7:基于REST API的SDN北向应用实践

时间:2022-11-02 21:37:06浏览次数:44  
标签:tagged vlan frame VLAN REST API 33024 SDN type

一、实验目的

  1. 能够编写程序调用OpenDaylight REST API实现特定网络功能;
  2. 能够编写程序调用Ryu REST API实现特定网络功能。

二、实验环境

  1. 下载虚拟机软件Oracle VisualBox或VMware;
  2. 在虚拟机中安装Ubuntu 20.04 Desktop amd64,并完整安装Mininet、OpenDaylight(Carbon版本)、Postman和Ryu;

三、实验要求

(一)基本要求

编写Python程序,调用OpenDaylight的北向接口实现以下功能

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

 

 

(2) 下发指令删除s1上的流表数据。

 

 

 

 

(3) 下发硬超时流表,实现拓扑内主机h1和h3网络中断20s。

 

4) 获取s1上活动的流表数。

 

 

 

 

编写Python程序,调用Ryu的北向接口实现以下功能

(1) 实现上述OpenDaylight实验拓扑上相同的硬超时流表下发。

 

 

 

 

 

(2) 参考Ryu REST API的文档,基于VLAN实验的网络拓扑,编程实现相同的VLAN配置。

  1. 提示:拓扑生成后需连接Ryu,且Ryu应能够提供REST API服务

VLAN_IDHosts
0 h1 h3
1 h2 h4

 

 拓扑代码topo.py

curl -X POST -d '{
"dpid": 1,
"priority": 1,
"match":{
"in_port": 1
},
"actions":[
{
"type": "PUSH_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "SET_FIELD",
"field": "vlan_vid", # Set VLAN ID
"value": 4096 # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
},
{
"type": "OUTPUT",
"port": 3
}
]
}' http://localhost:8080/stats/flowentry/add

curl -X POST -d '{
"dpid": 1,
"priority": 1,
"match":{
"in_port": 2
},
"actions":[
{
"type": "PUSH_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "SET_FIELD",
"field": "vlan_vid", # Set VLAN ID
"value": 4097 # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
},
{
"type": "OUTPUT",
"port": 3
}
]
}' http://localhost:8080/stats/flowentry/add

curl -X POST -d '{
"dpid": 1,
"priority": 1,
"match":{
"vlan_vid": 0
},
"actions":[
{
"type": "POP_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "OUTPUT",
"port": 1
}
]
}' http://localhost:8080/stats/flowentry/add

curl -X POST -d '{
"dpid": 1,
"priority": 1,
"match":{
"vlan_vid": 1
},
"actions":[
{
"type": "POP_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "OUTPUT",
"port": 2
}
]
}' http://localhost:8080/stats/flowentry/add

curl -X POST -d '{
"dpid": 2,
"priority": 1,
"match":{
"in_port": 1
},
"actions":[
{
"type": "PUSH_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "SET_FIELD",
"field": "vlan_vid", # Set VLAN ID
"value": 4096 # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
},
{
"type": "OUTPUT",
"port": 3
}
]
}' http://localhost:8080/stats/flowentry/add

curl -X POST -d '{
"dpid": 2,
"priority": 1,
"match":{
"in_port": 2
},
"actions":[
{
"type": "PUSH_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "SET_FIELD",
"field": "vlan_vid", # Set VLAN ID
"value": 4097 # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
},
{
"type": "OUTPUT",
"port": 3
}
]
}' http://localhost:8080/stats/flowentry/add

curl -X POST -d '{
"dpid": 2,
"priority": 1,
"match":{
"vlan_vid": 0
},
"actions":[
{
"type": "POP_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "OUTPUT",
"port": 1
}
]
}' http://localhost:8080/stats/flowentry/add

curl -X POST -d '{
"dpid": 2,
"priority": 1,
"match":{
"vlan_vid": 1
},
"actions":[
{
"type": "POP_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "OUTPUT",
"port": 2
}
]
}' http://localhost:8080/stats/flowentry/add

 

 

(三)个人感想

本次实验让我学会能够编写程序调用OpenDaylight REST API实现特定网络功能和调用Ryu REST API实现特定网络功能。本次实验比较困难,不仅是因为对实验不了解,同时还有许多小问题,比如在下发指令删除流表时,会出现权限不够或者链接过多的问题,输入代码前要加上sudo或者清理缓存并重启电脑,如果已经删除流表后再次删除会有返回值但会报错。第二个实验之前要清除缓存,否则会出现报错。本次实验不仅学会调用OpenDaylight REST API实现特定网络功能和Ryu REST API实现特定网络功能,还了复习了关于Ryu的运行方面的操作命令,以及关于.sh脚本的命令。

 

标签:tagged,vlan,frame,VLAN,REST,API,33024,SDN,type
From: https://www.cnblogs.com/SRABTS/p/16852513.html

相关文章

  • 实验7:基于REST API的SDN北向应用实践
    (一)基本要求:1.编写Python程序,调用OpenDaylight的北向接口实现以下功能1)利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight:2)下发指令删除s1上的流表数据:delete.py......
  • 实验7:基于REST API的SDN北向应用实践
    (一)基本要求1.编写Python程序,调用OpenDaylight的北向接口实现以下功能(1)利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight;启动ODL:./distribution-karaf-0.6.4-Ca......
  • 实验7:基于REST API的SDN北向应用实践
    实验7:基于RESTAPI的SDN北向应用实践一、实验目的1.能够编写程序调用OpenDaylightRESTAPI实现特定网络功能;2.能够编写程序调用RyuRESTAPI实现特定网络功能。二、实......
  • 实验7:基于REST API的SDN北向应用实践
    #delete.pyimportrequestsfromrequests.authimportHTTPBasicAuthif__name__=="__main__":url='http://127.0.0.1:8181/restconf/config/opendaylight-in......
  • 实验7:基于REST API的SDN北向应用实践
    一、实验目的1.能够编写程序调用OpenDaylightRESTAPI实现特定网络功能;2.能够编写程序调用RyuRESTAPI实现特定网络功能。二、实验环境1.下载虚拟机软件OracleVisua......
  • 实验7:基于REST API的SDN北向应用实践
    实验要求(一)基本要求编写Python程序,调用OpenDaylight的北向接口实现以下功能(1)利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight;(2)下发指令删除s1上的流表数据......
  • 实验7:基于REST API的SDN北向应用实践
    实验7:基于RESTAPI的SDN北向应用实践一、实验目的能够编写程序调用OpenDaylightRESTAPI实现特定网络功能;能够编写程序调用RyuRESTAPI实现特定网络功能。二、实验......
  • 实验7:基于REST API的SDN北向应用实践
    实验7:基于RESTAPI的SDN北向应用实践一、实验目的能够编写程序调用OpenDaylightRESTAPI实现特定网络功能;能够编写程序调用RyuRESTAPI实现特定网络功能。二、实......
  • 实验7:基于REST API的SDN北向应用实践
    (一)基本要求1.编写Python程序,调用OpenDaylight的北向接口实现以下功能(1)利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight;生成拓扑:sudomn--topo=single,3--......
  • 实验7:基于REST API的SDN北向应用实践
    一.将所有本实验相关文件保存在目录/home/用户名/学号/lab7/中二.(一)只需要提交实现相应Python代码和执行结果截图,其余文字请勿赘述;(二)不做必须要求,有完成的同学请提交Pyth......