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

如何使用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信息:
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

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值