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 ...
随机推荐
- C/C++ extern “C“ 的问题
声明 文章中的部分代码引用来在: https://blog.csdn.net/u012234115/article/details/43272441 场景 今天在CSDN中看到了一篇关于 extern ...
- 关于RS485通讯TVS器件选择的经验
先说经验结论 如果你的RS485用于频繁热拔插, 比如作为手持终端使用, 且手持器与目标板非隔离, 那么使用6.8CA可能是更好的选择. 因为有热拔插会产生浪涌, 而且在非隔离的场合有些工业设备接地也 ...
- upload—labs
首先 常见黑名单绕过 $file_name = deldot($file_name);//删除文件名末尾的点上传 shell.php. $file_ext = strtolower($file_ext ...
- 《流畅的Python》 读书笔记 第8章_对象引用、可变性和垃圾回收
第8章_对象引用.可变性和垃圾回收 本章的主题是对象与对象名称之间的区别.名称不是对象,而是单独的东西 name = 'wuxianfeng' # name是对象名称 'wuxianfeng'是个st ...
- Python实现对word批量操作
Python在平时写写小工具真是方便快捷,Pyhon大法好. 以下所有代码都是找了好多网上的大佬分享的代码按照自己的需求改的. 调用的库为Python-docx.win32com.PyPDF2.xlw ...
- 数据库系列:RR和RC下,快照读的区别
数据库系列:MySQL慢查询分析和性能优化 数据库系列:MySQL索引优化总结(综合版) 数据库系列:高并发下的数据字段变更 数据库系列:覆盖索引和规避回表 数据库系列:数据库高可用及无损扩容 数据库 ...
- 【开源】int,long long去一边去:高精度大合集!
加法 \(add\) string add(string s1, string s2) { //时间复杂度 O(log n) string res = ""; int c = 0, ...
- python中面向对象有什么特点
一:问题 python中面向对象有什么特点? 二:回答 python同其他面向对象语言一样,有3个特征:封装.继承.重写 简单理解就是:封装:把一系列属性和操作封装到一个方法里面,这样想要实现某种效果 ...
- CON2 工单重估 效率提升
CON2 工单重估 效率提升 业务背景:月结CON2 每次只能允许一个进程操作 集团公司较多的话,很影响月结效率. SAP提供了专家模式程序 RKAZCON2 ,可以选平行运行 平行处理 需要选服 ...
- 向mq写消息
1.基础版本 import org.apache.rocketmq.client.producer.DefaultMQProducer; import org.apache.rocketmq.comm ...