基于RYU restful api实现的VLAN网络虚拟化
基于RYU restful api实现的VLAN网络虚拟化
前言
本次实验是基于OVS的VLAN虚拟化简易实践方案的进一步的实验,采用RYU restful api进行配置。本质上和上次实验没什么差,究其原因还是因为上次不能较好使用RYU的restful api,现在学会了就实践一把吧。
RESTFUL API 下发流表
工具
- postman
- ryu/app/gui_topolog/gui_topology.py
- ovs
- mininet
实验步骤
之前的实验步骤不在赘述,主要是用RYU的restful api下发push_vlan
ACTION
tip:记得一定要大写
| Actions | Description | Example |
|---|---|---|
| OUTPUT | Output packet from "port" | {"type": "OUTPUT", "port": 3} |
| COPY_TTL_OUT | Copy TTL outwards | {"type": "COPY_TTL_OUT"} |
| COPY_TTL_IN | Copy TTL inwards | {"type": "COPY_TTL_IN"} |
| SET_MPLS_TTL | Set MPLS TTL using "mpls_ttl" | {"type": "SET_MPLS_TTL", "mpls_ttl": 64} |
| DEC_MPLS_TTL | Decrement MPLS TTL | {"type": "DEC_MPLS_TTL"} |
| PUSH_VLAN | Push a new VLAN tag with "ethertype" | {"type": "PUSH_VLAN", "ethertype": 33024} |
| POP_VLAN | Pop the outer VLAN tag | {"type": "POP_VLAN"} |
| PUSH_MPLS | Push a new MPLS tag with "ethertype" | {"type": "PUSH_MPLS", "ethertype": 34887} |
| POP_MPLS | Pop the outer MPLS tag with "ethertype" | {"type": "POP_MPLS", "ethertype": 2054} |
| SET_QUEUE | Set queue id using "queue_id" when outputting to a port | {"type": "SET_QUEUE", "queue_id": 7} |
| GROUP | Apply group identified by "group_id" | {"type": "GROUP", "group_id": 5} |
| SET_NW_TTL | Set IP TTL using "nw_ttl" | {"type": "SET_NW_TTL", "nw_ttl": 64} |
| DEC_NW_TTL | Decrement IP TTL | {"type": "DEC_NW_TTL"} |
| SET_FIELD | Set a "field" using "value"(The set of keywords available for "field" is the same as match field) | See Example of set-field action |
| PUSH_PBB | Push a new PBB service tag with "ethertype"(Openflow1.3+) | {"type": "PUSH_PBB", "ethertype": 35047} |
| POP_PBB | Pop the outer PBB service tag(Openflow1.3+) | {"type": "POP_PBB"} |
| COPY_FIELD | Copy value between header and register(Openflow1.5+) | {"type": "COPY_FIELD", "n_bits": 32, "src_offset": 1, "dst_offset": 2, "src_oxm_id": "eth_src", "dst_oxm_id": "eth_dst"} |
| METER | Apply meter identified by "meter_id"(Openflow1.5+) | {"type": "METER", "meter_id": 3} |
| EXPERIMENTER | Extensible action for the experimenter(Set "base64" or "ascii" to "data_type" field) | {"type": "EXPERIMENTER", "experimenter": 101, "data": "AAECAwQFBgc=", "data_type": "base64"} |
| GOTO_TABLE | (Instruction) Setup the next table identified by "table_id" | {"type": "GOTO_TABLE", "table_id": 8} |
| WRITE_METADATA | (Instruction) Setup the metadata field using "metadata" and "metadata_mask" | {"type": "WRITE_METADATA", "metadata": 0x3, "metadata_mask": 0x3} |
| METER | (Instruction) Apply meter identified by "meter_id"(deprecated in Openflow1.5) | {"type": "METER", "meter_id": 3} |
| WRITE_ACTIONS | (Instruction) Write the action(s) onto the datapath action set | {"type": "WRITE_ACTIONS", actions":[{"type":"POP_VLAN",},{ "type":"OUTPUT", "port": 2}]} |
| CLEAR_ACTIONS | (Instruction) Clears all actions from the datapath action set |
Example of set-field action
$ curl -X POST -d '{
"dpid": 1,
"match":{
"dl_type": "0x8000"
},
"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": 4102 # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
},
{
"type": "OUTPUT",
"port": 2
}
]
}' http://localhost:8080/stats/flowentry/add
postman

ovs
sudo ovs-ofctl -O OpenFlow13 dump-flows s1
得到结果
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=2350.981s, table=0, n_packets=0, n_bytes=0, priority=1,in_port=1 actions=push_vlan:0x8100,set_field:4096->vlan_vid,output:2
总结
可以基于此写自动化脚本,不过还是有通过restful api层面,感觉还不是太好。下面搞一个不通过restful api层面的下发过程。
参考链接
基于RYU restful api实现的VLAN网络虚拟化的更多相关文章
- 基于Ryu REST API的VLAN实现
目录 0.预备知识 1.实验内容 2.编写脚本addflow.sh一步实现流表下发 3.使用api查看流表 4.实验结果 0.预备知识 ryu控制器的API文档:ryu.app.ofctl_rest ...
- python 全栈开发,Day95(RESTful API介绍,基于Django实现RESTful API,DRF 序列化)
昨日内容回顾 1. rest framework serializer(序列化)的简单使用 QuerySet([ obj, obj, obj]) --> JSON格式数据 0. 安装和导入: p ...
- 基于轻量型Web服务器Raspkate的RESTful API的实现
在上一篇文章中,我们已经了解了Raspkate这一轻量型Web服务器,今天,我们再一起了解下如何基于Raspkate实现简单的RESTful API. 模块 首先让我们了解一下"模块&quo ...
- 基于Node的PetShop,RESTful API以及认证
前篇 - 基本认证,用户名密码 后篇 - OAuth2 认证 由于宠物店的业务发展需要,我们需要一种更加便捷的方式来管理日益增多的宠物和客户.最好的方法就是开发一个APP,我可以用这个APP来添加.更 ...
- 使用 node-odata 轻松创建基于 OData 协议的 RESTful API
前言 OData, 相信身为.NET程序员应该不为陌生, 对于他的实现, 之前也有童鞋进行过介绍(见:这里1,这里2). 微软的WCF Data Service即采用的该协议来进行通信, ASP.NE ...
- 在Ubuntu上快速搭建基于Beego的RESTful API
最近在研究Go,打算基于Go做点Web API,于是经过初步调研,打算用Beego这个框架,然后再结合其中提供的ORM以及Swagger的集成,可以快速搭建一个RESTful API的网站. 下面是具 ...
- 基于querybuilder的可根据现有数据表自动生成Restful API的dotnet中间件
AutoApi 基于SqlKata Query Builder的可根据数据表自动生成Restful API的dotnet中间件 项目地址 Github Gitee 支持的数据库 MySql AutoA ...
- 基于Node的PetShop,oauth2认证RESTful API
前篇 - 基本认证,用户名密码 后篇 - OAuth2 认证 前文使用包passport实现了一个简单的用户名.密码认证.本文改用oauth2来实现更加安全的认证.全部代码在这里. OAUTH2 用户 ...
- 基于Spring Boot的RESTful API实践(一)
1. RESTful简述 REST是一种设计风格,是一组约束条件及原则,而遵循REST风格的架构就称为RESTful架构,资源是RESTful的核心,一个好的RESTful架构,通过URL就能很 ...
随机推荐
- 问题解决:Apache: You don't have permission to access / on this server
虚拟主机(Virtual Host)是指在一个机器上运行多个网络站点 (比如:www.company1.com和www.company2.com). 如果每个网络站点拥有不同的IP地址,则虚拟主机可以 ...
- CJOJ 【DP合集】最长上升序列2 — LIS2
题面 已知一个 1 ∼ N 的排列的最长上升子序列长度为 K ,求合法的排列个数. 好题(除了我想不出来我应该找不到缺点), 想一想最长上升子序列的二分做法, 接在序列后面或者替换. 所以对于每一个位 ...
- ceph 部署步骤和原理理解
1.ceph的官方源在国外,网速比较慢,此处添加ceph源为阿里源(每个节点上均执行) vim /etc/yum.repos.d/ceph.repo [Ceph] name=Ceph packages ...
- mysql中left join中的on条件 和 where条件区别
需要知道sql中关键字的执行顺序. FROM-> ON->JOIN-> WHERE->GROUP BY-> HAVING->SELECT-> DISTINCT ...
- windows linux hosts文件的配置,开发项目中域名跳转等。
我们通常都知道Windows中hosts文件(C:\Windows\System32\drivers\etc),用来映射域名的.linux上当然也有,一般在/etc/hosts下. 当工作的项目,在开 ...
- Centos7 安装ELK日志分析
1.安装前准备 借鉴:https://www.cnblogs.com/straycats/p/8053937.html 操作系统:Centos7 虚拟机 8G内存 jdk8+ 软件包下载:采用rp ...
- UWP ListView 绑定 单击 选中项 颜色
refer: https://www.cnblogs.com/lonelyxmas/p/7650259.html using System; using System.Collections.Gene ...
- 20155206《网络对抗》Web安全基础实践
20155206<网络对抗>Web安全基础实践 实验后问题回答 (1)SQL注入攻击原理,如何防御 攻击原理:SQL注入攻击就是通过把SQL命令插入到Web表单递交或输入域名或页面请求的查 ...
- 20155209林虹宇Exp4 恶意代码分析
Exp4 恶意代码分析 系统运行监控 使用schtasks指令监控系统运行 新建一个txt文件,然后将txt文件另存为一个bat格式文件 在bat格式文件里输入以下信息 然后使用管理员权限打开cmd, ...
- 20155328 网络攻防 实验五:MSF基础应用
20155328 网络攻防 实验五:MSF基础应用 实践内容及过程记录 一.Windows服务渗透攻击----ms08_067 攻击机:kali 靶机:WindowsXP(英文版) 第一步,分别查看攻 ...