RYU搭配mininet

参考:
http://blog.csdn.net/guizaijianchic/article/details/64438453
http://vcpu.me/mininet1/

启动mininet

sudo mn --topo single,3 --mac --controller remote --switch ovsk

启动Ryu控制器

cd /usr/local/lib/python2.7/dist-packages/ryu/app
ryu-manager --verbose simple_switch_13.py ofctl_rest.py rest_topology.py

这里写图片描述

ping之前交换机的流表:
这里写图片描述
mn中h1 ping h2之后,

{
    "1": [
        {
            "actions": [
                "OUTPUT:1"
            ],
            "byte_count": 1946,
            "cookie": 0,
            "duration_nsec": 340000000,
            "duration_sec": 78,
            "flags": 0,
            "hard_timeout": 0,
            "idle_timeout": 0,
            "length": 104,
            "match": {
                "dl_dst": "00:00:00:00:00:01",
                "dl_src": "00:00:00:00:00:02",
                "in_port": 2
            },
            "packet_count": 21,
            "priority": 1,
            "table_id": 0
        },
        {
            "actions": [
                "OUTPUT:2"
            ],
            "byte_count": 1904,
            "cookie": 0,
            "duration_nsec": 335000000,
            "duration_sec": 78,
            "flags": 0,
            "hard_timeout": 0,
            "idle_timeout": 0,
            "length": 104,
            "match": {
                "dl_dst": "00:00:00:00:00:02",
                "dl_src": "00:00:00:00:00:01",
                "in_port": 1
            },
            "packet_count": 20,
            "priority": 1,
            "table_id": 0
        },
        {
            "actions": [
                "OUTPUT:CONTROLLER"
            ],
            "byte_count": 182,
            "cookie": 0,
            "duration_nsec": 567000000,
            "duration_sec": 739,
            "flags": 0,
            "hard_timeout": 0,
            "idle_timeout": 0,
            "length": 80,
            "match": {},
            "packet_count": 3,
            "priority": 0,
            "table_id": 0
        }
    ]
}

匹配的是目标mac地址和源端口。
再来h1 ping h3之后,

{
    "1": [
        {
            "actions": [
                "OUTPUT:1"
            ],
            "byte_count": 1946,
            "cookie": 0,
            "duration_nsec": 420000000,
            "duration_sec": 302,
            "flags": 0,
            "hard_timeout": 0,
            "idle_timeout": 0,
            "length": 104,
            "match": {
                "dl_dst": "00:00:00:00:00:01",
                "dl_src": "00:00:00:00:00:02",
                "in_port": 2
            },
            "packet_count": 21,
            "priority": 1,
            "table_id": 0
        },
        {
            "actions": [
                "OUTPUT:2"
            ],
            "byte_count": 1904,
            "cookie": 0,
            "duration_nsec": 415000000,
            "duration_sec": 302,
            "flags": 0,
            "hard_timeout": 0,
            "idle_timeout": 0,
            "length": 104,
            "match": {
                "dl_dst": "00:00:00:00:00:02",
                "dl_src": "00:00:00:00:00:01",
                "in_port": 1
            },
            "packet_count": 20,
            "priority": 1,
            "table_id": 0
        },
        {
            "actions": [
                "OUTPUT:1"
            ],
            "byte_count": 1946,
            "cookie": 0,
            "duration_nsec": 732000000,
            "duration_sec": 41,
            "flags": 0,
            "hard_timeout": 0,
            "idle_timeout": 0,
            "length": 104,
            "match": {
                "dl_dst": "00:00:00:00:00:01",
                "dl_src": "00:00:00:00:00:03",
                "in_port": 3
            },
            "packet_count": 21,
            "priority": 1,
            "table_id": 0
        },
        {
            "actions": [
                "OUTPUT:3"
            ],
            "byte_count": 1904,
            "cookie": 0,
            "duration_nsec": 729000000,
            "duration_sec": 41,
            "flags": 0,
            "hard_timeout": 0,
            "idle_timeout": 0,
            "length": 104,
            "match": {
                "dl_dst": "00:00:00:00:00:03",
                "dl_src": "00:00:00:00:00:01",
                "in_port": 1
            },
            "packet_count": 20,
            "priority": 1,
            "table_id": 0
        },
        {
            "actions": [
                "OUTPUT:CONTROLLER"
            ],
            "byte_count": 364,
            "cookie": 0,
            "duration_nsec": 647000000,
            "duration_sec": 963,
            "flags": 0,
            "hard_timeout": 0,
            "idle_timeout": 0,
            "length": 80,
            "match": {},
            "packet_count": 6,
            "priority": 0,
            "table_id": 0
        }
    ]
}

发现增加了h1和h3之间的流表。

使用命令查看交换机中的流表

sudo ovs-ofctl dump-flows -O openflow13 s1

注:ovs-ofctl是命令行下的交换机管理工具。-O参数后面跟协议,s1表示交换机的id。
这里写图片描述
交换机依据优先级从大到小匹配流表项,其中priority(优先级)的值越大,越先被匹配。

猜你喜欢

转载自blog.csdn.net/caiqiiqi/article/details/79619934
ryu
今日推荐