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

来源:互联网 发布:cfree软件 编辑:程序博客网 时间:2024/05/16 09:49

如何使用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 0
原创粉丝点击