您的位置:首页 > Web前端 > JavaScript

如何使用Postman控制ODL查看和下发流表(流表格式为JSON)

2017-04-07 21:49 991 查看
如何使用Postman控制ODL查看和下发流表

准备工作

Chrome浏览器安装Postman插件。

OpenDaylight (版本Boron-SR2)启动完毕,并安装好需要的插件

使用mininet创建网络拓扑:

sudo mn –controller=remote,ip=127.0.0.1 –topo linear,2

补充:

sudo mn –switch ovs,protocol=OpenFlow13 –controller=remote,ip=127.0.0.1,port=6653

使用该命令创建网络拓扑时,由于没有指定拓扑的结构,使用pingall命令时,无法进行通信。





下发流表:

URI:http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0

选择“PUT”方法。



{
"table": [
{
"id": "0",
"flow": [
{
"id": "0",
"match": {
"in-port": "1",
"vlan-match": {
"vlan-id": {
"vlan-id-present": "true",
"vlan-id": "20"
}
}
},
"instructions": {
"instruction": [
{
"apply-actions": {
"action": [
{
"output-action": {
"output-node-connector": "3",
"max-length": "65535"
},
"order": "1"
},
{
"pop-vlan-action": {},
"order": "0"
}
]
},
"order": "0"
}
]
},
"buffer_id": "65535",
"installHw": "true",
"barrier": "true",
"strict": "true",
"priority": "160",
"idle-timeout": "0",
"hard-timeout": "0",
"table_id": "0"
}
]
}
]
}


点击”Send”发送。

Postman返回的Http Status code信息:



查看OVS上流表是否添加成功:

输入查看流表信息的命令:

I:ovs-ofctl dump-flows s1



II:在web浏览器中输入:http://192.168.1.157:8181/restconf/operational/opendaylight-inventory:nodes



其中flow_id字段发生了变化,并非之前设定的值10。

再下发一条流表项:

Authorization

Type:Basic Auth

Headers:

Content-Type:application/json

Accept:application/json

Authorization:Basic

Body:

raw

JSON(application/json)

{
"table":[
{
"id":"0",
"flow":[
{
"id":"0x13",
"match":{
"ethernet-match":
{
"ethernet-type":
{
"type":2048
}
}
},
"instructions": {
"instruction":
{
"apply-actions": {
"action": [
{
"dec-nw-ttl": { },
"order": "1"
}
]
},
"order": "0"
}
},
"buffer_id": "6553",
"installHw": "true",
"barrier": "true",
"strict": "true",
"priority": "164",
"idle-timeout": "0",
"hard-timeout": "0",
"table_id": "0"
}
]
}
]
}


在OVS中查看添加上的流表项:



流表已经添加成功!但是之前添加的流表项被覆盖掉了,原因未知!

参考资料:

http://www.sdnlab.com/16824.html

http://www.sdnlab.com/15173.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: