• ovs & ryu & mininet


    [root@kunpeng82 mininet]# ryu --version
    ryu 4.34
    [root@kunpeng82 mininet]#

    [root@kunpeng82 ryu-master]# find ./ -name simple_switch_13.py
    ./ryu/app/simple_switch_13.py
    ./build/lib/ryu/app/simple_switch_13.py
    [root@kunpeng82 ryu-master]# cd ryu/app/
    [root@kunpeng82 app]# ryu-manager --verbose simple_switch_13.py ofctl_rest.py rest_topology.py
    loading app simple_switch_13.py
    loading app ofctl_rest.py
    loading app rest_topology.py
    require_app: ryu.topology.switches is required by rest_topology
    loading app ryu.controller.ofp_handler
    loading app ryu.topology.switches
    loading app ryu.controller.ofp_handler
    instantiating app None of DPSet
    creating context dpset
    creating context wsgi
    instantiating app simple_switch_13.py of SimpleSwitch13
    instantiating app ofctl_rest.py of RestStatsApi
    instantiating app rest_topology.py of TopologyAPI
    instantiating app ryu.controller.ofp_handler of OFPHandler
    instantiating app ryu.topology.switches of Switches
    BRICK dpset





    [root@kunpeng82 mininet]# mn --controller=remote,ip=127.0.0.1,port=6653 *** Creating network *** Adding controller *** Adding hosts: h1 h2 *** Adding switches: s1 *** Adding links: (h1, s1) (h2, s1) *** Configuring hosts h1 h2 *** Starting controller c0 *** Starting 1 switches s1 ... *** Starting CLI: mininet>

     

    http://10.10.16.82:8080/stats/desc/1

     

    [root@kunpeng82 custom]# vi test.py
    #!/user/bin/env python
    from mininet.topo import Topo
    class MyTopo(Topo):
        def build(self):
            left=[]
            left.append(self.addHost("h1"))
            left.append(self.addHost("h2"))
            right=[]
            right.append(self.addHost("h3"))
            right.append(self.addHost("h4"))
            switchs=[]
            switchs.append(self.addSwitch("s1"))
            switchs.append(self.addSwitch("s2"))
    
            self.addLink(left[0],switchs[0])
            self.addLink(left[1],switchs[0])
            self.addLink(right[0],switchs[1])
            self.addLink(right[1],switchs[1])
            self.addLink(switchs[0],switchs[1])
    
    
    topos={'mytopo':(lambda : MyTopo())}
    "test.py" [New] 22L, 648C written
    [root@kunpeng82 custom]#  mn --controller=remote,ip=127.0.0.1,port=6653 --custom test.py --topo mytopo
    *** Creating network
    *** Adding controller
    *** Adding hosts:
    h1 h2 h3 h4 
    *** Adding switches:
    s1 s2 
    *** Adding links:
    (h1, s1) (h2, s1) (h3, s2) (h4, s2) (s1, s2) 
    *** Configuring hosts
    h1 h2 h3 h4 
    *** Starting controller
    c0 
    *** Starting 2 switches
    s1 s2 ...
    *** Starting CLI:
    mininet>  pingall
    *** Ping: testing ping reachability
    h1 -> h2 h3 h4 
    h2 -> h1 h3 h4 
    h3 -> h1 h2 h4 
    h4 -> h1 h2 h3 
    *** Results: 0% dropped (12/12 received)
    mininet> 
    http://10.10.16.82:8080/stats/switches

    http://10.10.16.82:8080/stats/flow/1
    {"1": [{"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 238, "duration_sec": 264, "duration_nsec": 728000000, "packet_count": 3, "length": 104, "flags": 0, "actions": ["OUTPUT:1"], "match": {"in_port": 2, "dl_src": "ba:61:1d:41:32:b8", "dl_dst": "2e:1c:03:0e:97:18"}, "table_id": 0}, {"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 140, "duration_sec": 264, "duration_nsec": 724000000, "packet_count": 2, "length": 104, "flags": 0, "actions": ["OUTPUT:2"], "match": {"in_port": 1, "dl_src": "2e:1c:03:0e:97:18", "dl_dst": "ba:61:1d:41:32:b8"}, "table_id": 0}, {"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 238, "duration_sec": 264, "duration_nsec": 711000000, "packet_count": 3, "length": 104, "flags": 0, "actions": ["OUTPUT:1"], "match": {"in_port": 3, "dl_src": "42:d8:65:f5:84:82", "dl_dst": "2e:1c:03:0e:97:18"}, "table_id": 0}, {"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 140, "duration_sec": 264, "duration_nsec": 709000000, "packet_count": 2, "length": 104, "flags": 0, "actions": ["OUTPUT:3"], "match": {"in_port": 1, "dl_src": "2e:1c:03:0e:97:18", "dl_dst": "42:d8:65:f5:84:82"}, "table_id": 0}, {"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 238, "duration_sec": 264, "duration_nsec": 694000000, "packet_count": 3, "length": 104, "flags": 0, "actions": ["OUTPUT:1"], "match": {"in_port": 3, "dl_src": "82:cb:85:fa:1a:09", "dl_dst": "2e:1c:03:0e:97:18"}, "table_id": 0}, {"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 140, "duration_sec": 264, "duration_nsec": 691000000, "packet_count": 2, "length": 104, "flags": 0, "actions": ["OUTPUT:3"], "match": {"in_port": 1, "dl_src": "2e:1c:03:0e:97:18", "dl_dst": "82:cb:85:fa:1a:09"}, "table_id": 0}, {"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 238, "duration_sec": 264, "duration_nsec": 675000000, "packet_count": 3, "length": 104, "flags": 0, "actions": ["OUTPUT:2"], "match": {"in_port": 3, "dl_src": "42:d8:65:f5:84:82", "dl_dst": "ba:61:1d:41:32:b8"}, "table_id": 0}, {"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 140, "duration_sec": 264, "duration_nsec": 672000000, "packet_count": 2, "length": 104, "flags": 0, "actions": ["OUTPUT:3"], "match": {"in_port": 2, "dl_src": "ba:61:1d:41:32:b8", "dl_dst": "42:d8:65:f5:84:82"}, "table_id": 0}, {"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 238, "duration_sec": 264, "duration_nsec": 658000000, "packet_count": 3, "length": 104, "flags": 0, "actions": ["OUTPUT:2"], "match": {"in_port": 3, "dl_src": "82:cb:85:fa:1a:09", "dl_dst": "ba:61:1d:41:32:b8"}, "table_id": 0}, {"priority": 1, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 140, "duration_sec": 264, "duration_nsec": 655000000, "packet_count": 2, "length": 104, "flags": 0, "actions": ["OUTPUT:3"], "match": {"in_port": 2, "dl_src": "ba:61:1d:41:32:b8", "dl_dst": "82:cb:85:fa:1a:09"}, "table_id": 0}, {"priority": 0, "cookie": 0, "idle_timeout": 0, "hard_timeout": 0, "byte_count": 4756, "duration_sec": 280, "duration_nsec": 242000000, "packet_count": 66, "length": 80, "flags": 0, "actions": ["OUTPUT:CONTROLLER"], "match": {}, "table_id": 0}]}
    [root@kunpeng82 devuser]# ovs-vsctl show
    ec7f002f-352c-476c-8348-5f2c86c8194f
        Bridge "s1"
            Controller "ptcp:6654"
            Controller "tcp:127.0.0.1:6653"
                is_connected: true
            fail_mode: secure
            Port "s1-eth2"
                Interface "s1-eth2"
            Port "s1-eth3"
                Interface "s1-eth3"
            Port "s1-eth1"
                Interface "s1-eth1"
            Port "s1"
                Interface "s1"
                    type: internal
        Bridge "br0"
            Port "br0"
                Interface "br0"
                    type: internal
        Bridge "s2"
            Controller "ptcp:6655"
            Controller "tcp:127.0.0.1:6653"
                is_connected: true
            fail_mode: secure
            Port "s2-eth1"
                Interface "s2-eth1"
            Port "s2-eth2"
                Interface "s2-eth2"
            Port "s2-eth3"
                Interface "s2-eth3"
            Port "s2"
                Interface "s2"
                    type: internal
        ovs_version: "2.12.0"
    [root@kunpeng82 devuser]#
    mininet> pingall
    *** Ping: testing ping reachability
    h1 -> h2 h3 h4 
    h2 -> h1 h3 h4 
    h3 -> h1 h2 h4 
    h4 -> h1 h2 h3 
    *** Results: 0% dropped (12/12 received)
    mininet> 
    [root@kunpeng82 devuser]# mn
    *** Creating network
    *** Adding controller
    *** Adding hosts:
    h1 h2 
    *** Adding switches:
    s1 
    *** Adding links:
    (h1, s1) (h2, s1) 
    *** Configuring hosts
    h1 h2 
    *** Starting controller
    c0 
    *** Starting 1 switches
    s1 ...
    *** Starting CLI:
    mininet>  h1 ping -c1 h2
    PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
    64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=56.3 ms
    
    --- 10.0.0.2 ping statistics ---
    mininet> c0 ifconfig
    br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet6 fe80::4a57:2ff:fe64:e7ac  prefixlen 64  scopeid 0x20<link>
    Bridge "s1"
            Controller "tcp:127.0.0.1:6653"
                is_connected: true
            Controller "ptcp:6654"
            fail_mode: secure
            Port "s1-eth1"
                Interface "s1-eth1"
            Port "s1"
                Interface "s1"
                    type: internal
            Port "s1-eth2"
                Interface "s1-eth2"
        ovs_version: "2.12.0"
    mininet>  h1 ping -c1 h2
    PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
    64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=27.9 ms
    
    --- 10.0.0.2 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 27.933/27.933/27.933/0.000 ms
    mininet> 
    [root@kunpeng82 devuser]# tcpdump -en -i s1-eth1
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on s1-eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
    04:19:05.351105 e6:47:6c:1c:37:ff > 76:e5:f9:33:ee:a7, ethertype IPv4 (0x0800), length 98: 10.0.0.1 > 10.0.0.2: ICMP echo request, id 49794, seq 1, length 64
    04:19:05.378990 76:e5:f9:33:ee:a7 > e6:47:6c:1c:37:ff, ethertype IPv4 (0x0800), length 98: 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 49794, seq 1, length 64
    04:19:08.807438 da:ef:fd:00:f4:cf > 33:33:00:00:00:02, ethertype IPv6 (0x86dd), length 70: fe80::d8ef:fdff:fe00:f4cf > ff02::2: ICMP6, router solicitation, length 16
    04:19:10.407444 e6:47:6c:1c:37:ff > 76:e5:f9:33:ee:a7, ethertype ARP (0x0806), length 42: Request who-has 10.0.0.2 tell 10.0.0.1, length 28
    04:19:10.434746 76:e5:f9:33:ee:a7 > e6:47:6c:1c:37:ff, ethertype ARP (0x0806), length 42: Request who-has 10.0.0.1 tell 10.0.0.2, length 28
    04:19:10.434763 e6:47:6c:1c:37:ff > 76:e5:f9:33:ee:a7, ethertype ARP (0x0806), length 42: Reply 10.0.0.1 is-at e6:47:6c:1c:37:ff, length 28
    04:19:10.447963 76:e5:f9:33:ee:a7 > e6:47:6c:1c:37:ff, ethertype ARP (0x0806), length 42: Reply 10.0.0.2 is-at 76:e5:f9:33:ee:a7, length 28
  • 相关阅读:
    git指令-撤销修改
    git指令-管理修改
    jquery高级
    jquery
    sql的练习题
    git指令-工作区和暂存区
    java-多线程安全-锁
    oracle习题-emp表查询练习
    java-异常进阶-包的使用
    oracle-函数总结
  • 原文地址:https://www.cnblogs.com/dream397/p/12944856.html
Copyright © 2020-2023  润新知