如何用postman 配置环境控制ODL对queue做限速配置

如何用postman控制ODL对queue做限速配置 - 简书
如何用postman控制ODL对queue做限速配置
OVS的QoS配置和queue的配置存储在OVSDB中。利用OpenDaylight提供的OVSDB南向接口,可以对OVSDB配置QoS/Queue策略,并应用到接口上
安装了postman的Chrome浏览器,用到的URL参考/resources/commons/Qos-and-Queue-Collection.json.postman_collection,下载后可以导入到postman,方便使用
Mininet(v2.2.1),OVS(v2.4.1),启动后创建bridge:s1,并添加了两个port(s1-eth1,s1-eth2)到s1上
Opendaylight(Beryllium-SR3),启动后安装
&feature:install odl-ovsdb-southbound-impl-ui
ODL-VM的IP是10.10.33.239,Mininet的IP是10.10.11.220
Mininet OVSDB连接到ODL
可以用OVSDB主动模式或是被动模式,本文使用被动模式,Mininet上打开6640端口监听
# ovs-vsctl set-manager ptcp:6640
ODL上添加node信息
Action=POST
"network-topology:node":[
"node-id": "ovsdb://10.10.11.220:6640",
"connection-info": {
"ovsdb:remote-port": 6640,
"ovsdb:remote-ip": "10.10.11.220"
查看连接状态
# netstat -apn | grep 6640
22598/java
0 10.10.33.239:44982
10.10.11.220:6640
ESTABLISHED 22598/java
# ovs-vsctl show
32db576f-cfb5-401a-b061-1acb912b997e
Manager "ptcp:6640"
is_connected:true
查看获取的bridge的信息
Action=GET
注意URL中node后面的"/"用"%2F"代替
获取的内容很多,包括bridge:s1还有s1-eth1/s1-eth2的信息,就不贴了
向queue-entries中添加QUEUE-1
Action=PUT
"ovsdb:queues": [
"queue-id": "QUEUE-1",
"queues-other-config": [
"queue-other-config-key": "max-rate",
"queue-other-config-value": "10"
类似地再添加QUEUE-2
Action=PUT
"ovsdb:queues": [
"queue-id": "QUEUE-2",
"queues-other-config": [
"queue-other-config-key": "max-rate",
"queue-other-config-value": "20"
获取分配给两个queue的uuid
Action=GET
"ovsdb:queues": [
"queue-id": "QUEUE-1",
"queues-external-ids": [
"queues-external-id-key": "opendaylight-iid",
"queues-external-id-value": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:queues[ovsdb:queue-id='QUEUE-1']"
"queues-other-config": [
"queue-other-config-key": "max-rate",
"queue-other-config-value": "10"
"queue-uuid": "e7c0d4a-ae24-bbd61f9b721d"
所以QUEUE-1的uuid="e7c0d4a-ae24-bbd61f9b721d"
类似地,获取QUEUE-2的uuid="e6b797c6-a-bee8-c67d54e23990"
将两条queue的配置加到QoS entry
Action=PUT
"ovsdb:qos-entries": [
"qos-id": "QOS-1",
"queue-list": [
"queue-number": "1",
"queue-uuid": "e7c0d4a-ae24-bbd61f9b721d"
"queue-number": "2",
"queue-uuid": "e6b797c6-a-bee8-c67d54e23990"
即queue_1使用QUEUE-1策略,queue_2使用QUEUE-2策略
获取QOS的uuid
Action=GET
"ovsdb:qos-entries": [
"qos-id": "QOS-1",
"qos-type": "ovsdb:qos-type-base",
"queue-list": [
"queue-number": 2,
"queue-uuid": "e6b797c6-a-bee8-c67d54e23990",
"queue-ref": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:queues[ovsdb:queue-id='QUEUE-2']"
"queue-number": 1,
"queue-uuid": "e7c0d4a-ae24-bbd61f9b721d",
"queue-ref": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:queues[ovsdb:queue-id='QUEUE-1']"
"qos-uuid": "6d2df68d-7f9d-4ff1-912c-dbac7e6bcec4",
"qos-external-ids": [
"qos-external-id-key": "opendaylight-iid",
"qos-external-id-value": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:qos-entries[ovsdb:qos-id='QOS-1']"
所以QOS-1的uuid="6d2df68d-7f9d-4ff1-912c-dbac7e6bcec4"
将QOS-1应用到termination-point s1-eth1上
Action=PUT
"network-topology:termination-point": [
"ovsdb:name": "s1-eth1",
"tp-id": "s1-eth1",
"qos": "6d2df68d-7f9d-4ff1-912c-dbac7e6bcec4"
获取s1-eth1的信息
Action=GET
"termination-point": [
"tp-id": "s1-eth1",
"ovsdb:ingress-policing-burst": 0,
"ovsdb:port-uuid": "3327f25e-d329-41bc-f9222c5",
"ovsdb:name": "s1-eth1",
"ovsdb:interface-uuid": "72bcdcaf-1c64-4b03-b4e0-4d02e49020cd",
"ovsdb:ifindex": 20,
"ovsdb:ofport": 1,
"ovsdb:ingress-policing-rate": 0,
"ovsdb:port-external-ids": [
"external-id-key": "opendaylight-iid",
"external-id-value": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640/bridge/s1']/network-topology:termination-point[network-topology:tp-id='s1-eth1']"
"ovsdb:qos-entry": [
"qos-key": 1,
"qos-ref": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:qos-entries[ovsdb:qos-id='QOS-1']"
"ovsdb:qos": "6d2df68d-7f9d-4ff1-912c-dbac7e6bcec4"
可以看到QOS-1已经应用成功
从s1-eth1去掉QOS-1
Action=PUT(不是DELETE)
"network-topology:termination-point": [
"ovsdb:name": "s1-eth1",
"tp-id": "s1-eth1"
删除queue entry
Action= DELETE
No content
删除QOS entry
Action= DELETE
No content
关于queue rate
上述操作相当于CLI
ovs-vsctl set port s1-eth1 qos=@newqos -- --id=@newqos create qos \
type=linux-htb queues:1=@newqueue1 queues:2=@newqueue2 \
-- --id=@newqueue1 create queue other-config:max-rate=10 \
-- --id=@newqueue2 create queue other-config:max-rate=20
另外可以对qos配置max-rate,就是port shaping
也可以对Queue配置min-rate,格式参考max-rate的配置
在OpenFlow的Spec中明确定义,min_rate/max_rate配置的数值应该是出口带宽千分之一的倍数
/* Max-Rate queue property description. */
struct ofp_queue_desc_prop_max_rate {
uint16_ /* OFPQDPT_MAX_RATE. */
uint16_ /* Length is 8. */
uint16_ /* In 1/10 &1000 -& disabled. */
uint8_t pad[2]; /* 64-bit alignment */
但是在实际配置中,还要看系统的具体实现来确定配置的数值
关于queue-get-config命令的说明
OVS提供了命令queue-get-config来获取指定接口上各个queue的限速配置
但是Mininet上始终获取不到具体数值
# ovs-ofctl queue-get-config s1 s1-eth1
OFPT_QUEUE_GET_CONFIG_REPLY (xid=0x4): port=1
交换机厂商在porting OVS的时候,需要注意完善。
本文首发与SDNLAB
网络,交换,路由,SDN
个人微信号:ljyfree
Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智能路由,微代理,控制总线)。分布式系统的协调导致了样板模式, 使用Spring Cloud开发人员可以快速地支持实现这些模式的服务和应用程序。他们将在任何分布式...
3.7 Nova compute计算节点的部署 o图解Nova cpmpute o o src=&http://cdn.oldboyedu.com/wp-content/uploads/2016/02/wpid-ea05df3ef42...
cs.AI - 人工智能cs.AR - 硬件体系结构cs.CL - 计算与语言cs.CV - 机器视觉与模式识别cs.CY - 计算与社会cs.DC - 分布式、并行与集群计算cs.HC - 人机接口cs.IR - 信息检索cs.IT - 信息论cs.LG - 自动学习cs...
背景 一年多以前我在知乎上答了有关LeetCode的问题, 分享了一些自己做题目的经验。 张土汪:刷leetcode是什么样的体验? 慢慢有一些赞和感谢, 备受鼓舞, 于是我把所做过的题目用一个script跑了一下,编辑成一篇文章。这个总结页面是这么规划的: 题目名称(答案...
Design and Evaluation of Learning Algorithms for Dynamic Resource Management in Virtual Networks Rashid Mijumbi*, Juan-Luis Gorricho*, Jo...
在这个世界上,任何一个人的力量都是渺小的,只有团结起来力量才会变得强大! 从接触这份工作也就几个月,最先学到的就是团对力量!每天最重要的不是个人业绩怎样,而是整个团队怎么样,在店里我们是一个整体,有共同的目标,只有团结起来,互相协作,彼此信任,才能精彩的完成每一项工作! 其...
日 多云 懒洋洋的斜阳 打在我伸不直的肩膀 一个人透过她的车窗 在看我,一直看我 姑娘,下班后眼神别慌 家的方向在北 迷失不了只要红灯变亮 少了血色的嘴唇 补几口鸡翅膀的油就能吸引眼光 大姐,你看起来像刚出战场 眼镜滑到鼻尖和牙齿抵抗 淑女卷发躲在耳后委屈...
一$.extend:1.一个参数为jquery本身添加全局函数,this对象指向jquery本身2.多个参数,可以扩展内容二$.fn.extend:为jquery对象添加方法,在这个函数中,this对象指向运行时获取到的jquery对象数组(先获得一个对象,这个对象以数组的...
继今年8月18日发现【今日巡城】中山六路骑楼被破坏后,广州老城受保护建筑被破坏的悲剧重演。预保护线索屡被破坏,原因为何? 9月8日,文保志愿者@NicNg发现,广州市荔湾区十八甫南路89号、十八甫南路112号,现场搭棚施工,但并未挂出规划许可证,涉嫌违法施工。 两处房屋均受...
// 都是开启服务器! sudo apachectl -k start sudo apachectl start // 1.配置服务器根路径! ---&别人通过网页访问的时候,本台计算机上的文件夹! // 打开服务器所在的目录 cd /etc/apache2/ // 打开需...依据《网络安全法》,为保障您的账户安全和正常使用,请尽快完成手机号验证!
OpenDaylight(以下简写为ODL)的Lithium(锂)版本的最新版Lithium-SR2已经与日发布,具体详情可参考ODL官网。Lithium(锂)版本发布至今已经发布了二个版本,即Lithium-SR1与Lithium-SR2。下载链接地址为https://www.opendaylight.org/software/downloads/lithium-sr2。官网中分别共享了版本、安装向导、用户向导、开发者向导手册,可进行下载学习。
1 OpenDayLight的简单应用
1.1ODL控制器与Mininet的连接
ODL的Lithium(锂)版本已安装成功且已安装基本的OpenFlow功能组件。接下来将通过Mininet模拟网络设备简单地验证ODL的功能,包括拓扑、链路发现、交换机管理等等。
打开装有Mininet的设备,执行命令创建模拟拓扑并连接ODL,本文实现安装ODL的主机IP地址为127.0.0.1:(此命令为建立支持OpenFlow1.3协议的拓扑)
# sudo mn --switch ovs,protocol=OpenFlow13 --controller=remote,ip=127.0.0.1,port=6633
登录后显示ODL锂版本最新界面,如下两图分别是Topology界面和Nodes界面:
1.2Postman安装及使用方法
如下图所述,OpenFlowplugin不能像controller那样通过浏览器直接查看和使用其提供的功能。OpenFlowplugin获取当前交换机的连接状态以及下发流表都需要手动发送http的put/get请求。使用的工具是google的Chromium浏览器(Windows上的chrome浏览器)所提供的“Postman rest client”插件。在Ubuntu中通过包管理中心可以下载Chromium Web Browser,如下图所示:
下载安装完Chromium后,使用Tools-&Extensions进入Chromium的扩展下载页面,搜索Postman,选择Postman rest api,点击“下载”,下载前需要注册Google账号。下载完成后,可在如下界面看到Postman已经安装好。
注:由于Google服务在大陆地区被禁,可能导致谷歌的插件市场无法访问,那么就只能下载第三方插件,然后在安装到Chromium浏览器中,具体方法如下:
1.百度搜索Postman-REST-Client_v0.8.1,下载Postman插件。下载地址:
http://download.csdn.net/detail/u00395
2.打开Chromium浏览器,点击右上角菜单按钮,如图所示进入应用中心。
按照下图所写出的顺序即步骤1 2 3将下载好的Postman插件导入到Chromium浏览器中。
安装好Postman之后打开Chromium浏览器按如下步骤打开。
2 OpenDayLight流表操作
2.1获取交换机信息
Response message body:
Description
Openflow Switch id
“Openflow:1”
Manufacturer description
“Nicira, Inc. ”
Hardware description
“Open vSwitch”
Software description
“2.3. 0”
serial_num
Serial number
Human readable description of datapath
ODL获取交换机信息的界面在Yang UI中,具体节点为:Yang UI API opendaylight-inventory operational nodes node{id} 点击node{id},在下方出现的path中输入Node id(在主页面的Nodes中找,本机id为openflow:1),提交方式为GET,点击Send发出消息,则交换机信息则会出现在path下方。
在Postman中获取交换机信息的方法:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如下]
如下图,在URL地址中输入:
http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1
此处需要填写Headers,前两项内容如图所示,第三项Authorization需要填写ODL的用户名密码,一般情况下都为admin,点击1处输入admin之后点击2处,则3处会自动生成一串以Basic为开头的密码字符。
设置完成之后点击Send,获取的结果如下图所示:
如上图所示,openflow:1表示有一个openflow节点连接到controller,
&switch-features&里面代表连接上来的交换机的feature信息。
注:官方wiki上面对获取交换机信息功能有更详细的介绍(但官方给出的wiki上提供的方法有时也不一定都能完全实现,这里仅提供参考,以实际试验的为准),地址如下:
https://wiki.opendaylight.org/view/OpenDaylightOpenFlowPlugin::End_toEndInventory
2.2获取flow table信息
2.2.1获取table统计信息
Response message body(OpenFlow1.3):
Description
Openflow Switch id
Openflow:1
Table ID to put the flow in.(int)
active_count
Number of active entries
lookup_count
Number of packets looked up in table
matched_count
Number of packets that hit table
在Postman中获取table统计信息的方法:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如下]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/opendaylight-flow-table-statistics:flow-table-statistics
统计信息如下图:
2.2.2获取所有flow entry统计信息
Response message body:
Description
Openflow Switch id
Openflow:1
packet_count
Number of packets in flows
flow_count
Number of flows
byte_count
Number of bytes in flows
在Postman中获取flow统计信息的方法:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如下]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/opendaylight-flow-statistics:aggregate-flow-statistics
统计信息如下图:
2.2.3获取单条flow entry信息
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1(注意:如要获取不同flow table的信息只需在URL中更改相应的tableid和flow id的值即可。如果想要获取整个tableid为0的信息,则只需输入table_id即可。)
提交方式:GET
统计信息如下图:
2.3获取group table信息
2.3.1获取group统计信息
Response message body:
Description
Openflow Switch id
Openflow:1
Group identifier(int)
Length of this entry
Number of flows or groups that directly forward to this group
packet_count
Number of packets processed by group
byte_count
Number of bytes processed by group
duration_sec
Time group has been alive in seconds
duration_nsec
Time group has been alive in nanoseconds beyond duration_sec
bucket_stats
struct ofp_bucket_counter
-packet_count
Number of packets processed by bucket
-byte_count
Number of bytes processed by bucket
在Postman中获取group统计信息的方法:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如下]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:group/100/opendaylight-group-statistics:group-statistics
统计信息如下图:
2.3.2获取单条group entry信息
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/group/0(注意:如要获取不同group table的信息只需在URL中更改相应的group_id即可)
提交方式:GET
2.4获取meter table信息
2.4.1获取meter统计信息
Response message body:
Description
Openflow Switch id
Openflow:1
Group identifier(int)
Length of this entry
Number of flows or groups that directly forward to this group
packet_count
Number of packets processed by group
byte_count
Number of bytes processed by group
duration_sec
Time group has been alive in seconds
duration_nsec
Time group has been alive in nanoseconds beyond duration_sec
bucket_stats
struct ofp_bucket_counter
-packet_count
Number of packets processed by bucket
-byte_count
Number of bytes processed by bucket
在Postman中获取meter统计信息的方法:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如下]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:meter/1/opendaylight-meter-statistics:meter-statistics
统计信息如下图:
2.4.2获取单条meter entry信息
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/meter/0(注意:如要获取不同meter table的信息只需在URL中更改相应的meter_id即可)
提交方式:GET
2.5Flow table
Response message body:
Description
Openflow Switch id
Openflow:1
Flow identifier(int)
Table ID to put the flow in.(int)
Matching precedence of the flow entry.(int)
Opaque controller-issued identifier.(int)
cookie_mask
Mask used to restrict the cookie bits that
must match.(int)
Buffered packet to apply to,or OFP_NO_BUFFER.(int)
OFP_NO_BUFFER
idle-timeout
Idle time before discarding(seconds).(int)
hard-timeout
Max time before discarding(seconds)(int)
Flow’s name.
Fields to match (dict)
&in-port&0&/in-port&
Wildcarded
instructions
To modify the action set or pipeline processing.
&dec-nw-ttl/&
2.5.1添加一条流表
OpenDayLight Flows功能:该模块的功能主要实现静态流表添加,下发,删除及修改等功能。(注:只是静态流表,不包括动态生成的流表)
ODL下发flow table的界面也在Yang UI中,具体节点为:Yang UI API opendaylight-inventory config nodes node{id} table{id} flow{id}
如下两图所示,为ODL控制器下发flow entry的界面。按照给出的字段可以下发所需的flow entry。
注:需要说明的是,目前OpenDayLight Lithium SR2版本中下发flow entry时的instruction字段中的apply-action-case所列举的action并没有得到很好的支持,即并不是每个action都可以被下发的交换机中,例如controller-action-case、flood-action-case等。比如下发copy-ttl-in-case提示成功下发并且抓包显示已抓到flowadd消息,flowadd中的ofinstruction list里也有ofactioncopyttlin动作,但查看交换机流表的时显示并没有此条流表。又比如下发set-dl-type-action-case,提示成功下发并且可以抓到flowadd消息,但是查看其of_instruction list时确并没有此action。查看交换机流表显示有此条流表,但是actions=drop。其中只有大约15中action可以被正确下发到交换机中。具体有哪些可以被成功下发,会在本文最后详细列出,仅供参考。
在Postman中通过config方式下发flow entry的方法:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1 (注意:如果是下发多条flow entry每次下发需要更改flow id的值,相应的URL地址中的table/0/flow/1中的1就是所对应的flow id,也需要修改。)
提交方式:PUT
Use Body:
&?xml version="1.0" encoding="UTF-8" standalone="no"?&
&flow xmlns="urn:opendaylight:flow:inventory"&
&ethernet-match&
&ethernet-type&
&type&2048&/type&
&/ethernet-type&
&/ethernet-match&
&ipv4-destination&10.0.0.1/24&/ipv4-destination&
&instructions&
&instruction&
&order&0&/order&
&apply-actions&
&order&0&/order&
&dec-nw-ttl/&
&/apply-actions&
&/instruction&
&/instructions&
&table_id&0&/table_id&
&id&1&/id&
&hard-timeout&12&/hard-timeout&
&cookie&1&/cookie&
&idle-timeout&34&/idle-timeout&
&flow-name&lihao&/flow-name&
&priority&1&/priority&
123456789101112131415161718192021222324252627282930
Use Body:&?xml version="1.0" encoding="UTF-8" standalone="no"?&&flow xmlns="urn:opendaylight:flow:inventory"&&&&&&match&&&&&&&&&&ethernet-match&&&&&&&&&&&&&&ethernet-type&&&&&&&&&&&&&&&&&&type&2048&/type&&&&&&&&&&&&&&/ethernet-type&&&&&&&&&&/ethernet-match&&&&&&&&&&ipv4-destination&10.0.0.1/24&/ipv4-destination&&&&&&/match&&&&&&instructions&&&&&&&&&&instruction&&&&&&&&&&&&&&order&0&/order&&&&&&&&&&&&&&apply-actions&&&&&&&&&&&&&&&&&&action&&&&&&&&&&&&&&&&&&&&&&order&0&/order&&&&&&&&&&&&&&&&&&&&&&dec-nw-ttl/&&&&&&&&&&&&&&&&&&/action&&&&&&&&&&&&&&/apply-actions&&&&&&&&&&/instruction&&&&&&/instructions&&&&&&table_id&0&/table_id&&&&&&id&1&/id&&&&&&hard-timeout&12&/hard-timeout&&&&&&cookie&1&/cookie&&&&&&idle-timeout&34&/idle-timeout&&&&&&flow-name&lihao&/flow-name&&&&&&priority&1&/priority&&/flow&
With JSON:
首先输入Headers:
Content-Type: application/json
Accept: application/json
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1 (注意:如果是下发多条flow entry每次下发需要更改flow id的值,相应的URL地址中的table/0/flow/1中的1就是所对应的flow id,也需要修改。)
提交方式:PUT
Use Body:
"id": "1",
"match": {
"ethernet-match": {
"ethernet-type": {
"type": "0x0800"
"ipv4-destination": "10.0.0.1/24"
"instructions": {
"instruction": [
"apply-actions": {
"action": [
"dec-nw-ttl": {},
"order": "0"
"order": "0"
"flow-name": "lihao",
"priority": "1",
"idle-timeout": "20",
"hard-timeout": "20",
"cookie": "1",
"table_id": "0"
12345678910111213141516171819202122232425262728293031323334353637
Use Body:{"flow": [{"id": "1","match": {"ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.1/24"},"instructions": {"instruction": [{"apply-actions": {"action": [{"dec-nw-ttl": {},"order": "0"}]},"order": "0"}]},"flow-name": "lihao","priority": "1","idle-timeout": "20","hard-timeout": "20","cookie": "1","table_id": "0"}]}
以上下发的都为流表cookie为1,table id为0,flow-name为lihao,优先级为1,match字段为匹配目的IP地址10.0.0.1,action为减少ttl。
查询下发flow entry的命令为:
# ovs-ofctl dump-flows s1 -O OpenFlow13
成功下发流表如下图:
注:官方wiki上面对flow table功能有更详细的介绍(但官方给出的wiki上提供的方法有时也不一定都能完全实现,这里仅提供参考,以实际试验的为准),
地址如下:
https://wiki.opendaylight.org/view/OpenDaylightOpenFlowPlugin:EndtoEndFlows
在Postman中通过RPC方式下发flow entry的方法:
与通过config操作流表不同的是,通过rpc方式操作流表,只需要交换机的id即可,即openflow:1。flow name和flow id都不需要。
With XML:
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operations/sal-flow:add-flow
提交方式: POST
&?xml version="1.0" encoding="UTF-8" standalone="no"?&
&input xmlns="urn:opendaylight:flow:service"&
&node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node&
&cookie&1&/cookie&
&flags&SEND_FLOW_REM&/flags&
&hard-timeout&0&/hard-timeout&
&idle-timeout&0&/idle-timeout&
&installHw&false&/installHw&
&ethernet-match&
&ethernet-type&
&type&2048&/type&
&/ethernet-type&
&/ethernet-match&
&ipv4-destination&10.0.0.1/24&/ipv4-destination&
&instructions&
&instruction&
&order&0&/order&
&apply-actions&
&output-action&
&output-node-connector&openflow:1:2&/output-node-connector&
&/output-action&
&order&0&/order&
&/apply-actions&
&/instruction&
&/instructions&
&priority&1&/priority&
&strict&false&/strict&
&table_id&0&/table_id&
123456789101112131415161718192021222324252627282930313233
&?xml version="1.0" encoding="UTF-8" standalone="no"?&&input xmlns="urn:opendaylight:flow:service"&&& &node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node&&& &cookie&1&/cookie&&& &flags&SEND_FLOW_REM&/flags&&& &hard-timeout&0&/hard-timeout&&& &idle-timeout&0&/idle-timeout&&& &installHw&false&/installHw&&& &match&&&&&&ethernet-match&&&&& &ethernet-type&&&&&&& &type&2048&/type&&&&& &/ethernet-type&&&&&&/ethernet-match&&&&&&ipv4-destination&10.0.0.1/24&/ipv4-destination&&& &/match&&& &instructions&&&&&&instruction&&&&& &order&0&/order&&&&& &apply-actions&&&&&&& &action&&&&&&&&& &output-action&&&&&&&&&&& &output-node-connector&openflow:1:2&/output-node-connector&&&&&&&&& &/output-action&&&&&&&&& &order&0&/order&&&&&&& &/action&&&&& &/apply-actions&&&&&&/instruction&&& &/instructions&&& &priority&1&/priority&&& &strict&false&/strict&&& &table_id&0&/table_id&&/input&
以上下发的流表都为cookie为1,tableid为0,优先级为1,match字段为匹配目的IP地址10.0.0.1,action为output-action,即2口输出。
2.5.2修改一条流表
在Postman中通过config方式修改flow entry的方法:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1
提交方式:PUT
Use Body:
要修改的流表中的tableid,flowid,cookie,idletimeout,hardtimeout,flags,counters和duration都要保持不变,其他字段则可以被修改。
在Postman中通过RPC方式修改flow table的方法:
通过rpc方式操作流表,原始的Content十分重要。无论是对流表的添加,修改还是删除都需要用到原始的Content。一条通过rpc方式下发的流表如果想要被正确修改,流表的match,priority,table id,cookie都不能改变。方法如下:
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operations/sal-flow:update-flow
提交方式: POST
Content:(通过rpc方式修改流表需将按照其格式输入原始流表的匹配信息,然后再输入更新过后的流表)
&?xml version="1.0" encoding="UTF-8" standalone="no"?&
&input xmlns="urn:opendaylight:flow:service"&
&node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node&
&original-flow&
&cookie&1&/cookie&
&flags&SEND_FLOW_REM&/flags&
&hard-timeout&0&/hard-timeout&
&idle-timeout&0&/idle-timeout&
&installHw&false&/installHw&
&priority&1&/priority&
&ethernet-match&
&ethernet-type&
&type&2048&/type&
&/ethernet-type&
&/ethernet-match&
&ipv4-destination&10.0.0.1/24&/ipv4-destination&
&table_id&0&/table_id&
&/original-flow&
&updated-flow&
&cookie&1&/cookie&
&hard-timeout&0&/hard-timeout&
&idle-timeout&0&/idle-timeout&
&flags&SEND_FLOW_REM&/flags&
&priority&1&/priority&
&ethernet-match&
&ethernet-type&
&type&2048&/type&
&/ethernet-type&
&/ethernet-match&
&ipv4-destination&10.0.0.1/24&/ipv4-destination&
&instructions&
&instruction&
&order&0&/order&
&apply-actions&
&dec-nw-ttl/&
&order&0&/order&
&/apply-actions&
&/instruction&
&/instructions&
&table_id&0&/table_id&
&/updated-flow&
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
&?xml version="1.0" encoding="UTF-8" standalone="no"?&&input xmlns="urn:opendaylight:flow:service"& &node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node& &original-flow&&& &cookie&1&/cookie&&& &flags&SEND_FLOW_REM&/flags&&& &hard-timeout&0&/hard-timeout&&& &idle-timeout&0&/idle-timeout&&& &installHw&false&/installHw&&& &priority&1&/priority&&& &match&&&&& &ethernet-match&&&&&&& &ethernet-type&&&&&&&&& &type&2048&/type&&&&&&& &/ethernet-type&&&&& &/ethernet-match&&&&& &ipv4-destination&10.0.0.1/24&/ipv4-destination&&& &/match&&& &table_id&0&/table_id& &/original-flow& &updated-flow&&& &cookie&1&/cookie&&& &hard-timeout&0&/hard-timeout&&& &idle-timeout&0&/idle-timeout&&& &flags&SEND_FLOW_REM&/flags&&& &priority&1&/priority&&& &match&&&&& &ethernet-match&&&&&&& &ethernet-type&&&&&&&&& &type&2048&/type&&&&&&& &/ethernet-type&&&&& &/ethernet-match&&&&& &ipv4-destination&10.0.0.1/24&/ipv4-destination&&& &/match&&& &instructions&&&&& &instruction&&&&&&& &order&0&/order&&&&&&& &apply-actions&&&&&&&&& &action&&&&&&&&&&& &dec-nw-ttl/&&&&&&&&&&& &order&0&/order&&&&&&&&& &/action&&&&&&& &/apply-actions&&&&& &/instruction&&& &/instructions&&& &table_id&0&/table_id& &/updated-flow&&/input&
以上命令为将cookie=1,table=0,优先级为0,action为在2口输出的流表修改为cookie=1,table=0,优先级为0,action为减少ttl的值。除了action字段被修改其他字段均保持不变。
查询修改后的flow table的命令为:
# ovs-ofctl dump-flows s1 -O OpenFlow13
修改前后的流表如下两图:
2.5.3删除一条流表
在Postman中通过config方式删除flow entry的方法:
通过获取交换机的流表信息,查询要删除流表的tableid和flowid。提交方式为DELETE,则可无需输入流表内容即可删除流表,在YANG UI中也只需要URL即可删除。具体命令如下:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1(通过获取交换机的流表信息,查询要删除流表的tableid和flowid。在URL中输入相应的tableid和flowid)
提交方式:DELETE
在Postman中通过RPC方式删除flow table的方法:
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operations/sal-flow:remove-flow
提交方式: POST
rpc方式删除流表只需匹配流表的match,priority,table id,cookie即只要在Content中输入相应格式的以上字段就能够把流表删除。如果不全部匹配以上字段,则有可能将其它流表删除。因此通过rpc方式删除流表必须严格按照匹配相应字段删除流表的原则。
以上两种方式都为将tableid为0,flowid为1的流表删除。
2.6Group table
Response message body:
Description
Openflow Switch id
Openflow:1
Group identifier(int)
One of OFPGT_* (string)
Struct ofp_bucket
Relative weight of bucket (Only defined for select groups)
-watch_port
Port whose state affects whether this bucket is live (Only required for fast failover groups)
-watch_group
Group whose state affects whether this bucket is live (Only required for fast failover groups)
0 or more actions associated with the bucket (list of dict)
Group Table不是一个Flow Table。它是一个动作组的集合。一个动作组称之为group entry。它的结构如下:
当flow entry中有ofpactiongroup时,将指明该flow entry选择执行的group table的ID。结构为:
2.6.1添加一条Group Entry
(1)在Postman中通过config方式下发group entry的方法:
ODL下发group的界面在Yang UI中,具体节点为:Yang UI API opendaylight-inventory config nodes node{id} group{group id}
找到ODL控制器下发group的界面。按照给出的字段可以下发所需的group即可。
注:需要说明的是,目前OpenDayLight Lithium SR2版本中下发group entry时的action list字段中所列举的action并没有得到很好的支持,即并不是每个action都可以被下发的交换机中,例如controller-action-case、flood-action-case等。其中只有大约15中action可以被正确下发到交换机中。这与flow table中的action一致,不能在flow table中下发的action也不能在group table中被下发。具体有哪些可以被成功下发,会在本文最后详细列出,仅供参考。
在Postman中通过config方式下发group entry的方法:
输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/group/1 (注意:如果是下发多条group,每次下发需要更改groupid的值,相应的URL地址中的/group/1中的1就是所对应的groupid,也需要修改。)
提交方式:PUT
Use Body:
&?xml version="1.0" encoding="UTF-8" standalone="no"?&
&group xmlns="urn:opendaylight:flow:inventory"&
&group-type&group-all&/group-type&
&set-field&
&ipv4-source&10.0.0.1/24&/ipv4-source&
&/set-field&
&order&0&/order&
&bucket-id&0&/bucket-id&
&/buckets&
&barrier&false&/barrier&
&group-name&lihao&/group-name&
&group-id&1&/group-id&
123456789101112131415161718
&?xml version="1.0" encoding="UTF-8" standalone="no"?&&group xmlns="urn:opendaylight:flow:inventory"&&&&&&group-type&group-all&/group-type&&&&&&buckets&&&&&&&&&&bucket&&&&&&&&&&&&&&action&&&&&&&&&&&&&&&&&&set-field&&&&&&&&&&&&&&&&&&&&ipv4-source&10.0.0.1/24&/ipv4-source&&&&&&&&&&&&&&&&&&/set-field&&&&&&&&&&&&&&&&&&order&0&/order&&&&&&&&&&&&&&/action&&&&&&&&&&&&&&bucket-id&0&/bucket-id&&&&&&&&&&/bucket&&&&&&/buckets&&&&&&barrier&false&/barrier&&&&&&group-name&lihao&/group-name&&&&&&group-id&1&/group-id&&/group&
With JSON:
首先输入Headers:
Content-Type: application/json
Accept: application/json
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/group/1 (注意:如果是下发多条group每次下发需要更改group-id的值,相应的URL地址中的group/1中的1就是所对应的group-id,也需要修改。)
提交方式:PUT
Use Body:
"group": [
"group-type": "group-all",
"group-id": "1",
"group-name": "lihao",
"barrier": "false",
"buckets": {
"bucket": [
"bucket-id": "0",
"action": [
"set-nw-src-action": {
"ipv4-address": "10.0.0.1/24"
"order": "0"
12345678910111213141516171819202122232425
{"group": [{"group-type": "group-all","group-id": "1","group-name": "lihao","barrier": "false","buckets": {"bucket": [{"bucket-id": "0","action": [{"set-nw-src-action": {"ipv4-address": "10.0.0.1/24"},"order": "0"}]}]}}]}
在Postman中通过RPC方式下发group的方法:
With XML:
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operations/sal-group:add-group
提交方式: POST
&?xml version="1.0" encoding="UTF-8" standalone="no"?&
&input xmlns="urn:opendaylight:group:service"&
&barrier&false&/barrier&
&group-id&1&/group-id&
&group-name&lihao&/group-name&
&group-type&group-all&/group-type&
&set-field&
&ipv4-source&10.0.0.1/24&/ipv4-source&
&/set-field&
&order&0&/order&
&bucket-id&0&/bucket-id&
&/buckets&
&node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node&
12345678910111213141516171819
&?xml version="1.0" encoding="UTF-8" standalone="no"?&&input xmlns="urn:opendaylight:group:service"&&& &barrier&false&/barrier&&& &group-id&1&/group-id&&& &group-name&lihao&/group-name&&& &group-type&group-all&/group-type&&& &buckets&&&&&&& &bucket&&&&&&&&&&& &action&&&&&&&&&&&&&&& &set-field&&&&&&&&&&&&&&&&& &ipv4-source&10.0.0.1/24&/ipv4-source&&&&&&&&&&&&&&& &/set-field&&&&&&&&&&&&&&& &order&0&/order&&&&&&&&&&& &/action&&&&&&&&&&& &bucket-id&0&/bucket-id&&&&&&& &/bucket&&& &/buckets&&& &node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node&&/input&
以上下发的group都为group-id为1,group-name为lihao,bucket字段中的action为匹配目的IP地址10.0.0.1。
查询下发group entry的命令为:
# ovs-ofctl dump-groups s1 -O OpenFlow13
成功下发流表如下图:
(2)除上述添加group流表以外,还可以通过Python-Requests实现ODL对OVS的流表下发,通过借助Python的Requests库,可以方便的完成调用ODL Restful API的流表PUT操作。
对于Python requests模块的安装,直接使用pip install requests即可安装。
创建桥br0,为给br0添加group流表:
# ovs-vsctl add-br br0
# ovs-vsctl set bridge br0 protocols=OpenFlow13
&# ovs-vsctl add-br br0# ovs-vsctl set bridge br0 protocols=OpenFlow13
将JSON字段的流表描述存入文件,供后面调用
$ cat odl.json
"group": [
"group-type": "group-all",
"group-id": "1",
"buckets": {
"bucket": [
"bucket-id": "0",
"action": [
"order": "0",
"set-field": {
"ethernet-match": {
"ethernet-destination": {
"address": "00:00:00:00:00:05"
"order": "1',
"set-field": {
"ipv4-destination": "192.168.100.105/32"
"order": "2",
"output-action": {
"output-node-connector": "5"
"bucket-id": "1",
"action": [
"order": "0",
"set-field": {
"ethernet-match": {
"ethernet-destination": {
"address": "00:00:00:00:00:06"
"order": "1",
"set-field": {
"ipv4-destination": "192.168.100.106/32"
"order": "2",
"output-action": {
"output-node-connector": "6"
"bucket-id": "2",
"action": [
"order": "0",
"set-field": {
"ethernet-match": {
"ethernet-destination": {
"address": "00:00:00:00:00:07"
"order": "1",
"set-field": {
"ipv4-destination": "192.168.100.107/32"
"order": "2",
"output-action": {
"output-node-connector": "7"
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
$ cat odl.json{ "group": [&&&& {&&&&&&&& "group-type": "group-all",&&&&&&&& "group-id": "1",&&&&&&&& "buckets": {&&&&&&&&&&&& "bucket": [&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&& "bucket-id": "0",&&&&&&&&&&&&&&&&&&&& "action": [&&&&&&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&& "order": "0",&&&&&&&&&&&&&&&&&&&&&&&&&&&& "set-field": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "ethernet-match": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "ethernet-destination": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "address": "00:00:00:00:00:05"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&& },&&&&&&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&& "order": "1',&&&&&&&&&&&&&&&&&&&&&&&&&&&& "set-field": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "ipv4-destination": "192.168.100.105/32"&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&& },&&&&&&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&& "order": "2",&&&&&&&&&&&&&&&&&&&&&&&&&&&& "output-action": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "output-node-connector": "5"&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&& ]&&&&&&&&&&&&&&&& },&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&& "bucket-id": "1",&&&&&&&&&&&&&&&&&&&& "action": [&&&&&&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&& "order": "0",&&&&&&&&&&&&&&&&&&&&&&&&&&&& "set-field": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "ethernet-match": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "ethernet-destination": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "address": "00:00:00:00:00:06"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&& },&&&&&&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&& "order": "1",&&&&&&&&&&&&&&&&&&&&&&&&&&&& "set-field": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "ipv4-destination": "192.168.100.106/32"&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&& },&&&&&&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&& "order": "2",&&&&&&&&&&&&&&&&&&&&&&&&&&&& "output-action": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "output-node-connector": "6"&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&& ]&&&&&&&&&&&&&&&& },&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&& "bucket-id": "2",&&&&&&&&&&&&&&&&&&&& "action": [&&&&&&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&& "order": "0",&&&&&&&&&&&&&&&&&&&&&&&&&&&& "set-field": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "ethernet-match": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "ethernet-destination": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "address": "00:00:00:00:00:07"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&& },&&&&&&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&& "order": "1",&&&&&&&&&&&&&&&&&&&&&&&&&&&& "set-field": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "ipv4-destination": "192.168.100.107/32"&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&& },&&&&&&&&&&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&& "order": "2",&&&&&&&&&&&&&&&&&&&&&&&&&&&& "output-action": {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "output-node-connector": "7"&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&&&&&&& ]&&&&&&&&&&&&&&&& }&&&&&&&&&&&& ]&&&&&&&& }&&&& } ]}
‘Content-Type’:’application/json’
Basic Authentication: admin/admin
下面是编写下发group流表的代码
新建odl_http.py 脚本文件,编写下面代码,代码编写完成后执行odl_http.py脚本:
$ cat odl_http.py
#!/usr/bin/env python
import requests
from requests.auth import HTTPBasicAuth
def http_post(url,jstr):
headers = {'Content-Type':'application/json'}
resp = requests.put(url,jstr,headers=headers,auth=HTTPBasicAuth('admin', 'admin'))
return resp
if __name__ == "__main__":
url = 'http://10.10.11.80:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:/flow-node-inventory:group/1'
with open('odl.json') as f:
jstr = f.read()
resp = http_post(url,jstr)
print resp.content
123456789101112131415161718
$ cat odl_http.py&&&&&&#!/usr/bin/env python&import requestsfrom requests.auth import HTTPBasicAuth&def http_post(url,jstr):&&&&url= url&&&&headers = {'Content-Type':'application/json'}&&&&resp = requests.put(url,jstr,headers=headers,auth=HTTPBasicAuth('admin', 'admin'))&&&&return resp&&&& &&&&if __name__ == "__main__":&&&&url = 'http://10.10.11.80:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:/flow-node-inventory:group/1'&&&&with open('odl.json') as f:&&&&&&&&jstr = f.read()&&&&resp = http_post(url,jstr)&&&&print resp.content
抓取报文如下
OVS查看流表,期望的group已经被添加成功。
# ovs-ofctl dump-groups br0 -O openflow13
OFPST_GROUP_DESC reply (OF1.3) (xid=0x2):
group_id=1,type=all,bucket=weight:0,set_field:00:00:00:00:00:05-&eth_dst,set_field:192.168.100.105-&ip_dst,output:5,bucket=weight:0,set_field:00:00:00:00:00:06-&eth_dst,set_field:192.168.100.106-&ip_dst,output:6,bucket=weight:0,set_field:00:00:00:00:00:07-&eth_dst,set_field:192.168.100.107-&ip_dst,output:7
&# ovs-ofctl dump-groups br0 -O openflow13OFPST_GROUP_DESC reply (OF1.3) (xid=0x2): group_id=1,type=all,bucket=weight:0,set_field:00:00:00:00:00:05-&eth_dst,set_field:192.168.100.105-&ip_dst,output:5,bucket=weight:0,set_field:00:00:00:00:00:06-&eth_dst,set_field:192.168.100.106-&ip_dst,output:6,bucket=weight:0,set_field:00:00:00:00:00:07-&eth_dst,set_field:192.168.100.107-&ip_dst,output:7
注:官方wiki上面对group table功能有更详细的介绍(但官方给出的wiki上提供的方法有时也不一定都能完全实现,这里仅提供参考,以实际试验的为准),地址如下:
https://wiki.opendaylight.org/view/OpenDaylightOpenFlowPlugin:EndtoEndGroups
2.6.2修改一条Group Entry
修改group entry只需保持group的group-id不变,修改原group表的相应内容即可。比如将4.6.1下发的group entry中的action修改为2口输出,两种操作方法如下:
在Postman中通过config方式修改group entry的方法:
输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/group/1
提交方式:PUT
Use Body:
&?xml version="1.0" encoding="UTF-8" standalone="no"?&
&group xmlns="urn:opendaylight:flow:inventory"&
&group-type&group-all&/group-type&
&output-action&
&output-node-connector&openflow:1:2&/output-node-connector&
&/output-action&
&order&0&/order&
&bucket-id&0&/bucket-id&
&/buckets&
&barrier&false&/barrier&
&group-name&lihao&/group-name&
&group-id&1&/group-id&
123456789101112131415161718
&?xml version="1.0" encoding="UTF-8" standalone="no"?&&group xmlns="urn:opendaylight:flow:inventory"&&&&&&group-type&group-all&/group-type&&&&&&buckets&&&&&&&&&&bucket&&&&&&&&&&& &action&&&&&&&&&&&&&&&&output-action&&&&&&&&&&&&&&& &output-node-connector&openflow:1:2&/output-node-connector&&&&&&&&&&&&&&&&/output-action&&&&&&&&&&&&&&&&&&order&0&/order&&&&&&&&&&&&&&/action&&&&&&&&&&&&&&bucket-id&0&/bucket-id&&&&&&&&&&/bucket&&&&&&/buckets&&&&&&barrier&false&/barrier&&&&&&group-name&lihao&/group-name&&&&&&group-id&1&/group-id&&/group&
在Postman中通过RPC方式修改group entry的方法:
With XML:
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operations/sal-group:update-group
提交方式: POST
&?xml version="1.0" encoding="UTF-8" standalone="no"?&
&input xmlns="urn:opendaylight:group:service"&
&barrier&false&/barrier&
&group-id&1&/group-id&
&group-name&lihao&/group-name&
&group-type&group-all&/group-type&
&output-action&
&output-node-connector&openflow:1:2&/output-node-connector&
&/output-action&
&order&0&/order&
&bucket-id&0&/bucket-id&
&/buckets&
&node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node&
12345678910111213141516171819
&?xml version="1.0" encoding="UTF-8" standalone="no"?&&input xmlns="urn:opendaylight:group:service"&&& &barrier&false&/barrier&&& &group-id&1&/group-id&&& &group-name&lihao&/group-name&&& &group-type&group-all&/group-type&&& &buckets&&&&&&& &bucket&&&&&&&&&&& &action&&&&&&&&&&&&& &output-action&&&&&&&&&&&&&&& &output-node-connector&openflow:1:2&/output-node-connector&&&&&&&&&&&&& &/output-action&&&&&&&&&&&&&&& &order&0&/order&&&&&&&&&&& &/action&&&&&&&&&&& &bucket-id&0&/bucket-id&&&&&&& &/bucket&&& &/buckets&&& &node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node&&/input&
2.6.3删除一条Group Entry
在Postman中通过config方式删除group entry的方法:
通过在控制台输入ovs-ofctl dump-groups s1 -O OpenFlow13命令查询所要删除group的groupid或者通过获取交换机的group entry信息查询要删除group entry的group_id。提交方式为DELETE,则可无需输入group entry的内容即可删除group,在YANG UI中也只需要URL即可删除。具体命令如下:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/group/1
提交方式:DELETE
在Postman中通过rpc方式删除group table的方法:
首先输入Headers:
Content-Type: application/xml
Accept: application/xml
Authorization: [方法如上]
在URL地址栏中输入以下命令:
http://127.0.0.1:8181/restconf/operations/sal-group:remove-group
提交方式:POST
rpc方式删除group entry只需匹配group entry的group-id,group-name,group-type即只要在Content中输入相应格式的以上字段就能够把group entry删除。不必再把bucket字段写入Content中。如删除4.6.1所下发的group entry,操作如下:
&?xml version="1.0" encoding="UTF-8" standalone="no"?&
&input xmlns="urn:opendaylight:group:service"&
&barrier&false&/barrier&
&group-id&1&/group-id&
&group-name&lihao&/group-name&
&group-type&group-all&/group-type&
&node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node&
&?xml version="1.0" encoding="UTF-8" standalone="no"?&&input xmlns="urn:opendaylight:group:service"&&& &barrier&false&/barrier&&& &group-id&1&/group-id&&& &group-name&lihao&/group-name&&& &group-type&group-all&/group-type&&& &node xmlns:inv="urn:opendaylight:inventory"&/inv:nodes/inv:node[inv:id="openflow:1"]&/node&&/input&
2.7Meter table
Response message body:
Description
Openflow Switch id
Openflow:1
Bitmap of OFPMF_* flags (list)
[“KBPS”]
Meter identifier(int)
struct ofp_meter_band_header
One of OFPMBT_* (string)
Rate for this band (int)
– burst_size
Size of bursts (int)
一个meter table包含若干计量表项,确定每个流量的计数。单位流量的计量可以使 OpenFlow 实现各种简单的 QoS 业务,如限速,并且可以结合每个端口队列来实现复杂的QoS 框架,如 DiffServ。Meter table的结构如下:
经过本人的一些实验与测试发现Meter table在OpenDayLight Lithum SR2版本中不能成功下发。至于不能成功下发的原因目前不得而知,有可能是最新版本的ODL出现的bug导致的,也有可能是ODL与OpenFlow1.3协议没有很好的兼容的原因,我也会在后续的工作中去验证。
注:官方wiki上面对meter table功能有更详细的介绍(但官方给出的wiki上提供的方法有时也不一定都能完全实现,这里仅提供参考,以实际试验的为准),地址如下:
https://wiki.opendaylight.org/view/OpenDaylightOpenFlowPlugin:End_toEndMeters
3 ODL目前支持下发的action列表
以下能够成功下发的action仅为本人实验成功,不代表ODL只支持这些action,还有待后续的继续研究。
1.dec-nw-ttl-case
2.set-nw-src-action-case
3.set-nw-dst-action-case
4.set-nw-ttl-action-case
5.dec-mpls-ttl-case
6.pop-vlan-action-case
7.set-dl-src-action-case
8.set-dl-dst-action-case
9.set-mpls-ttl-action-case
10.set-field-case
11.output-action-case
12.set-queue-action-case
13.set-vlan-id-action-case
14.set-vlan-pcp-action-case
15.strip-vlan-action-case
作者简介:
本文作者系北京工业大学计算机学院李昊同学(OpenDaylight群()@北京-Sandman),现研二在读。
同时,感谢盛科网络SDN交换机产品线测试主管刘敬一对2.6章节通过Python requests编写脚本的方式对添加Group流表的补充
本站原创文章仅代表作者观点,不代表SDNLAB立场。所有原创内容版权均属SDNLAB,欢迎大家转发分享。但未经授权,严禁任何媒体(平面媒体、网络媒体、自媒体等)以及微信公众号复制、转载、摘编或以其他方式进行使用,转载须注明来自 SDNLAB并附上本文链接。
本文链接:
VPC既是一种云,也是一种网络模式,本文作…数据中心应用范围愈加广泛,应用需求不断…本章分为两节,第一节介绍数据平面开发套…本文系普林斯顿大学的两位教授关于自动驾…本节从命令行开始讲起,使用openstack命令…
获取验证码
获取验证码
微信公众号:搜索"SDNLAB"或扫描上面的二维码。
没有帐号?

我要回帖

更多关于 postman 配置代理 的文章

 

随机推荐