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(优先级)的值越大,越先被匹配。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值