Open vSwitch系列之十 调用北向接口下发流表

Open vSwitch系列之一 Open vSwitch诞生
Open vSwitch系列之二 安装指定版本ovs
Open vSwitch系列之三 ovs-vsctl命令使用
Open vSwitch系列之四 ovs-ofctl命令使用
Open vSwitch系列之五 网桥特性功能配置
Open vSwitch系列之六 vlan隔离
Open vSwitch系列之七 meter表限速
Open vSwitch系列之八 vxlan隧道
Open vSwitch系列之九 Group表
Open vSwitch系列之十 调用北向接口下发流表
OpenvSwitch系列之十一 ovs-dpdk
postman介绍
在开发中,前端和后端是分开开发的,当后端开发完成之后会测试接口。Postman就是一个后端接口的测试工具,通过postman可以发送GET、POST、DELETE等请求。通过Postman可以调用控制器的北向接口,下发流表到交换机

GET请求
Get请求需要注意两点,第一请求方法是get,第二是URL

POST请求
POST请求需要注意三点:第一 请求方式是POST,第二URL,第三请求的body体。

Postman下发流表的标准格式
postman下发一条流表需要准备4个部分,分别是:
- 动作
- URL
- 身份认证
- body体
动作:PUT
URL:替换自己控制器的ip和交换机switch_id,还要注意flow_id即url最后一个参数,该参数要和body体中一致。
控制器ip:8181/restconf/config/opendaylight-inventory:nodes/node/你的交换机switch_id/flow-node-inventory:table/0/flow/flow6,
认证信息:Basic Auth, username: admin password:admin

body体:格式为 raw --> Json。body体里的内容就是流表的信息。

body体具体内容:
body体就是一个流表的具体内容,分为三大块:流表元数据、匹配、动作。
元数据:流表名字,id,优先级等
匹配:流表匹配规则,如经典匹配十二元组
动作:标准动作转发和丢弃

物理端口匹配
匹配进端口为1,动作是转发到222端口
ovs-ofctl add-flow br0 in_port=1,action=output:222
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_14
{
"flow": [
{
"id": "demo_14",
"flow-name": "demo_14",
"table_id": 0,
"match": {
"in-port": "1",
"ethernet-match": {
}
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"output-action": {
"output-node-connector": "222"
}
}
]
}
}
]
}
}
]
}
mac地址匹配
匹配源mac地址:78:45:c4:1c:ba:b9,目的mac地址:00:50:56:c0:00:08,动作是丢弃
ovs-ofctl add-flow br0 dl_src=78:45:c4:1c:ba:b9,dl_dst=00:50:56:c0:00:08,aciton=drop
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_four
{
"flow": [
{
"id": "demo_four",
"flow-name": "demo_four",
"table_id": 0,
"match": {
"ethernet-match": {
"ethernet-source": {
"mask": "ff:ff:ff:ff:ff:ff",
"address": "78:45:c4:1c:ba:b9"
},
"ethernet-destination": {
"mask": "ff:ff:ff:ff:ff:ff",
"address": "00:50:56:c0:00:08"
}
}
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"drop-action": {
}
}
]
}
}
]
}
}
]
}
ip地址匹配
匹配源ip地址为30.0.0.1/32,目的ip为30.0.0.2/32的流表,动作是转发到222端口
ovs-ofctl add-flow br0 ip,nw_src=30.0.0.1/32,nw_dst=30.0.0.2/32,aciton=output:222
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_14
{
"flow": [
{
"id": "demo_14",
"flow-name": "demo_14",
"table_id": 0,
"match": {
"ethernet-match": {
"ethernet-type": {
"type": "0x0800"
}
},
"ipv4-source": "30.0.0.1/32",
"ipv4-destination": "30.0.0.2/32"
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"output-action": {
"output-node-connector": "222"
}
}
]
}
}
]
}
}
]
}
udp端口匹配
匹配 源端口为112,目的端口为2321的UDP数据包,动作是转发到222端口。
ovs-ofctl add-flow br0 udp,udp_src=112,udp_dst=2321,action=output:222
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_13
{
"flow": [
{
"id": "demo_13",
"flow-name": "demo_13",
"table_id": 0,
"match": {
"ethernet-match": {
"ethernet-type": {
"type": "0x0800"
}
},
"ip-match": {
"ip-protocol": 17
},
"udp-destination-port": "2321",
"udp-source-port": "112"
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"output-action": {
"output-node-connector": "222"
}
}
]
}
}
]
}
}
]
}
tcp端口匹配
匹配源端口是888,目的端口是999的TCP流量,动作是转发到222端口
ovs-ofctl add-flow br0 tcp,tcp_src=888,tcp_dst=999,action=output:222
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_14
{
"flow": [
{
"id": "demo_14",
"flow-name": "demo_14",
"table_id": 0,
"match": {
"ethernet-match": {
"ethernet-type": {
"type": "0x0800"
}
},
"ip-match": {
"ip-protocol": 6
},
"tcp-destination-port": "999",
"tcp-source-port": "888"
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"output-action": {
"output-node-connector": "222"
}
}
]
}
}
]
}
}
]
}
meter表
meter表,限速为10k,超过限制的流量丢弃。
ovs-ofctl add-meter s1 meter=1,kbps,band=type=drop,rate=10 -O OpenFlow13
控制器ip:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/meter/1
{
"meter": {
"meter-id": "1",
"meter-name": "guestMeter",
"flags": "meter-kbps",
"meter-band-headers": {
"meter-band-header": {
"band-id": "0",
"meter-band-types": { "flags": "ofpmbt-drop" },
"drop-burst-size": "0",
"drop-rate": "10"
}
}
}
}
匹配进端口为1的流量,经过meter表限速,然后转发到2端口
ovs-ofctl add-flow s1 priority=200,in_port=1,action=meter:1,output:2 -O OpenFlow13
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/flow1
{
"flow": {
"id": "flow1",
"table_id": "0",
"priority": "120",
"name":"flow_name"
"match": {
"in-port":"1"
},
"instructions": {
"instruction": [
{
"order": "0",
"meter": { "meter-id": "1" }
},
{
"order": "1",
"apply-actions": {
"action": {
"order": "1",
"output-action": {
"output-node-connector": "2"
}
}
}
}
]
}
}
}
Open vSwitch系列之十 调用北向接口下发流表的更多相关文章
- Liferay 6.2 改造系列之十九:修改站点设置的表单内容
在/portal-master/portal-impl/src/portal.properties文件中,有如下配置: # # Input a list of sections that will b ...
- Redis系列(十二):数据结构SortedSet跳跃表中基本操作命令和源码解析
1.SkipList Redis的sortedSet数据结构是有序不重复的(索引为唯一的,数据(score)却可以重复), 跳表是redis的一个核心组件,也同时被广泛地运用到了各种缓存地实现当中,它 ...
- Open vSwitch系列之一 Open vSwitch诞生
Open vSwitch系列之一 Open vSwitch诞生 Open vSwitch系列之二 安装指定版本ovs 2006年,SDN诞生于美国GENI项目资助的斯坦福大学Clean Slate课题 ...
- Open vSwitch系列实验(一):Open vSwitch使用案例扩展实验
一.实验目的 通过python脚本调用OpenvSwitch命令: 学习Mininet基于python脚本创建拓扑的实现: 进一步深度使用“ovs-vsctl”命令直接控制Open vSwitch. ...
- Open vSwitch流表应用实战
本文参考:Open vSwitch流表应用实战 一个通过改变流表下发而实现的互相通信实验. 实验目的: 掌握Open vSwitch下发流表操作: 掌握添加.删除流表命令以及设备通信的原理. 原理:. ...
- CRL快速开发框架系列教程十二(MongoDB支持)
本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...
- CRL快速开发框架系列教程十(导出对象结构)
本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...
- Chrome浏览器扩展开发系列之十四
Chrome浏览器扩展开发系列之十四:本地消息机制Native messaging 时间:2015-10-08 16:17:59 阅读:1361 评论:0 收藏:0 ...
- Unity3D脚本中文系列教程(十六)
Unity3D脚本中文系列教程(十五) ◆ function OnPostprocessAudio (clip:AudioClip):void 描述:◆ function OnPostprocess ...
- Unity3D脚本中文系列教程(十五)
http://dong2008hong.blog.163.com/blog/static/4696882720140322449780/ Unity3D脚本中文系列教程(十四) ◆ LightRend ...
随机推荐
- JAVAweek8
编程,要学会将大问题逐渐分解成一个个小问题,逐步完成. 将整个程序分成若干个组件(分解) 将多次出现的相似功能设成独立的方法(模式识别.抽象.算法) 调试每个独立组件的健壮性(单元测试) 按照功能要求 ...
- Eclipse 安装 ABAP 插件报错 Microsoft Visual C++ 2013 (x64) 快速解决
去官网下载Microsoft Visual C++ 2013 (x64) 安装 Download Visual C++ Redistributable Packages for Visual St ...
- 自研、好用的ORM 读写分离功能使用
Fast Framework 作者 Mr-zhong 代码改变世界.... 一.前言 Fast Framework 基于NET6.0 封装的轻量级 ORM 框架 支持多种数据库 SqlServer O ...
- [CF1748D] ConstructOR
题目描述 You are given three integers $ a $ , $ b $ , and $ d $ . Your task is to find any integer $ x $ ...
- 【matlab混沌理论】1.5.洛伦兹模型的分析
洛伦兹方程用于生成y变量的图.这是对三种y初始条件敏感依赖的一个例子. 1.洛伦兹吸引子的y敏感依赖的着色图 input: % 洛伦兹方程用于生成y变量的图.x和z的初始条件保持不变,但y的初始条件在 ...
- springBoot——整合mybatis
spring整合mybatis springBoot整合mybaits 配置文件 spring: datasource: url: jdbc:mysql://localhost:3306/test d ...
- C++学习笔记二:变量与数据类型(整型)
1.int(整型数据): 1.1 进制的表示:十进制,八进制,16进制,二进制 int number1 = 15; // Decimal int number2 = 017; // Octal int ...
- python在使用过程中安装库的方法
背景: 在学习python的过程中难免会出现python解释器中没有所需要的库,这时我们就要自行的去安装这些库了:当然如果使用的anaconda集成环境的话在安装python一些依赖环境中会简单不少( ...
- MybatisPlus入门到进阶
1.创建一个SpringBoot项目 2.导入相关依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xs ...
- wpf 叫号系统
wpf 叫号系统 桌面版 wpf 叫号系统 C# .Net 4.8 WPF 数据库 SQLServer 2012 数据队列 Redis 日志 log4net 叫号系统客户端登陆 设置,职称设置,科室和 ...