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

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

时间:2022-11-02 20:45:20浏览次数:34  
标签:tagged vlan frame VLAN REST API 33024 SDN type

实验7:基于REST APISDN北向应用实践

一、实验目的

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

二、实验环境

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

三、实验要求

(一)基本要求

  1. 编写Python程序,调用OpenDaylight的北向接口实现以下功能
    (1) 利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight;

 

 

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

 

 

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

 

 

 

 

 

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

 

 

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

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

    使用命令打开Ryu控制器

   ryu-manager ryu.app.simple_switch_13 ryu.app.ofctl_rest

重新创建拓扑

sudo mn --topo=single,3 --mac --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13

 

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

Topo.py代码

 

运行topo.py

sudo mn --custom topo.py --topo mytopo --mac --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13

删除流表

 

 

#####sh1.sh
# 将主机1,2发送来的包打上vlan标记
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

# 将主机3,4发送来的包取出vlan标记
 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

# 将主机3,4发送来的包打上vlan标记
 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

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

 

VLAN_ID

Hosts

0

h1 h3

1

h2 h4

(二)进阶要求

OpenDaylight或Ryu任选其一,编程实现查看前序VLAN实验拓扑中所有节点(含交换机、主机)的名称,以及显示每台交换机的所有流表项。

(三)实验总结

通过本次实验,进一步学习了用OpenDaylight和Ryu的rest API来实现特定的网络功能。这次实验中是由几个小实验组成的,做完一个做下一个的时候,要记得把前一次的拓扑清空。实验中要记得先把流表清空。还有curl的下载,按照百度的方法用wget来下载,下载了好几次都不行,最后用命令行里的提示,利用命令sudo apt install curl才下载成功。

 

 

 

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

相关文章

  • 实验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......
  • apifox生成kubernetes-api文档
    前言:尽管多数时候,我们都是通过客户端库(如client-go),而非原生的API进行来操作kubernetes资源,但是对于学习API库,能够直接操作显然再好不过了。通过apifox,我们能够实现这个目的......
  • 实验7:基于REST API的SDN北向应用实践
    实验7:基于RESTAPI的SDN北向应用实践一、实验目的能够编写程序调用OpenDaylightRESTAPI实现特定网络功能;能够编写程序调用RyuRESTAPI实现特定网络功能。二、实验......
  • Eotalk Vol.04 : 如何安全开放 API 数据?
    ......
  • 实验7:基于REST API的SDN北向应用实践
    实验目的能够编写程序调用OpenDaylightRESTAPI实现特定网络功能;能够编写程序调用RyuRESTAPI实现特定网络功能。实验要求(一)基本要求编写Python程序,调用OpenDayl......
  • 开源API探测管理工具-apimonitor
    目录一、apimonitor1.apimonitor简介2.apimonitor功能3.技术架构4.运行环境5.代码及文档地址二、部署步骤1.拉取代码2.修改数据库建表sql3.前往mysql建库并导入建......
  • ghidra api之currentProgram
    ['ADDED_VARIABLE_STORAGE_MANAGER_VERSION','ANALYSIS_OPTIONS_MOVED_VERSION','ANALYSIS_PROPERTIES','ANALYSIS_START_DATE','ANALYSIS_START_DATE_FORMAT','ANALY......
  • BAPI_OUTB_DELIVERY_CHANGE 删除DN
    """回滚数据删除DN,CLEAR:l_header_data_chg,l_header_control_chg.l_header_data_chg-deliv_numb=delivery.l_......