如何 运行 此拓扑然后 ping 所有主机。我需要启动哪个开关以及应该对其进行哪些更改
How to run this topology and then pingall the hosts. which switch I need to start and what changes should be made to it
# !/usr/bin/env python
from mininet.net import Mininet, CLI
from mininet.node import RemoteController, OVSKernelSwitch, UserSwitch, Host
from mininet.link import TCLink,Link
from mininet.term import makeTerms, makeTerm, runX11
import argparse
import subprocess
net = Mininet(controller=RemoteController, switch=OVSKernelSwitch, link=TCLink)
h1 = net.addHost ( 'h1', mac = '00:00:00:00:00:01', ip = '10.0.0.10' )
h2 = net.addHost ( 'h2', mac = '00:00:00:00:00:02', ip = '10.0.0.20' )
h3 = net.addHost ( 'h3', mac = '00:00:00:00:00:03', ip = '10.0.0.30' )
h4 = net.addHost ( 'h4', mac = '00:00:00:00:00:04', ip = '10.0.0.40' )
h5 = net.addHost ( 'h5', mac = '00:00:00:00:00:05', ip = '10.0.0.50' )
h6 = net.addHost ( 'h6', mac = '00:00:00:00:00:06', ip = '10.0.0.60' )
h7 = net.addHost ( 'h7', mac = '00:00:00:00:00:07', ip = '10.0.0.70' )
s1 = net.addSwitch ( 's1', cls = OVSKernelSwitch, protocols = 'OpenFlow13' )
s2 = net.addSwitch ( 's2', cls = OVSKernelSwitch, protocols = 'OpenFlow13' )
s3 = net.addSwitch ( 's3', cls = OVSKernelSwitch, protocols = 'OpenFlow13' )
s4 = net.addSwitch ( 's4', cls = OVSKernelSwitch, protocols = 'OpenFlow13' )
net.addLink( s1, s2, port1=1, port2=1)
net.addLink( s2, s3, port1=2, port2=2)
net.addLink( s1, s4, port1=2, port2=1)
net.addLink( s3, s4, port1=3, port2=2)
net.addLink( s1, s3, port1=3, port2=1)
net.addLink( s3, h6)
net.addLink( s3, h4)
net.addLink( s3, h5)
net.addLink( s3, h7)
net.addLink( h1, s1)
net.addLink( h2, s1)
net.addLink( h3, s1)
net.addController('c0')
net.start()
CLI(net)
net.stop()
我正在使用 mininet,而 pingall 在使用 simple_switch13 时仅提供 h1 和 h2 之间的连接,没有任何更改,所以我应该使用哪个开关或应该进行哪些更改
你的拓扑中有一个循环。如果我们通过注释掉几个链接来打破循环...
net.addLink( s1, s2, port1=1, port2=1)
net.addLink( s2, s3, port1=2, port2=2)
net.addLink( s1, s4, port1=2, port2=1)
#net.addLink( s3, s4, port1=3, port2=2)
#net.addLink( s1, s3, port1=3, port2=1)
...然后 pingall
对所有主机成功:
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3 h4 h5 h6 h7
h2 -> h1 h3 h4 h5 h6 h7
h3 -> h1 h2 h4 h5 h6 h7
h4 -> h1 h2 h3 h5 h6 h7
h5 -> h1 h2 h3 h4 h6 h7
h6 -> h1 h2 h3 h4 h5 h7
h7 -> h1 h2 h3 h4 h5 h6
*** Results: 0% dropped (42/42 received)
如果您希望此拓扑与环路一起使用,则需要使用支持 spanning tree protocol (STP) 的交换机,例如 ryu.app.simple_switch_stp_13
。如果使用该开关启动 ryu
控制器并等待端口进入 FORWARD
状态:
# ryu-manager ryu.app.simple_switch_stp_13
...lots of output...
...30 seconds later...
[STP][INFO] dpid=0000000000000002: [port=1] ROOT_PORT / FORWARD
[STP][INFO] dpid=0000000000000002: [port=2] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=4] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=1] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=6] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=5] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=2] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=3] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=1] ROOT_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=5] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=6] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=7] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=4] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=3] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=2] NON_DESIGNATED_PORT / BLOCK
[STP][INFO] dpid=0000000000000004: [port=1] ROOT_PORT / FORWARD
[STP][INFO] dpid=0000000000000004: [port=2] NON_DESIGNATED_PORT / BLOCK
然后 pingall
即使在您的拓扑中有循环也会成功。
# !/usr/bin/env python
from mininet.net import Mininet, CLI
from mininet.node import RemoteController, OVSKernelSwitch, UserSwitch, Host
from mininet.link import TCLink,Link
from mininet.term import makeTerms, makeTerm, runX11
import argparse
import subprocess
net = Mininet(controller=RemoteController, switch=OVSKernelSwitch, link=TCLink)
h1 = net.addHost ( 'h1', mac = '00:00:00:00:00:01', ip = '10.0.0.10' )
h2 = net.addHost ( 'h2', mac = '00:00:00:00:00:02', ip = '10.0.0.20' )
h3 = net.addHost ( 'h3', mac = '00:00:00:00:00:03', ip = '10.0.0.30' )
h4 = net.addHost ( 'h4', mac = '00:00:00:00:00:04', ip = '10.0.0.40' )
h5 = net.addHost ( 'h5', mac = '00:00:00:00:00:05', ip = '10.0.0.50' )
h6 = net.addHost ( 'h6', mac = '00:00:00:00:00:06', ip = '10.0.0.60' )
h7 = net.addHost ( 'h7', mac = '00:00:00:00:00:07', ip = '10.0.0.70' )
s1 = net.addSwitch ( 's1', cls = OVSKernelSwitch, protocols = 'OpenFlow13' )
s2 = net.addSwitch ( 's2', cls = OVSKernelSwitch, protocols = 'OpenFlow13' )
s3 = net.addSwitch ( 's3', cls = OVSKernelSwitch, protocols = 'OpenFlow13' )
s4 = net.addSwitch ( 's4', cls = OVSKernelSwitch, protocols = 'OpenFlow13' )
net.addLink( s1, s2, port1=1, port2=1)
net.addLink( s2, s3, port1=2, port2=2)
net.addLink( s1, s4, port1=2, port2=1)
net.addLink( s3, s4, port1=3, port2=2)
net.addLink( s1, s3, port1=3, port2=1)
net.addLink( s3, h6)
net.addLink( s3, h4)
net.addLink( s3, h5)
net.addLink( s3, h7)
net.addLink( h1, s1)
net.addLink( h2, s1)
net.addLink( h3, s1)
net.addController('c0')
net.start()
CLI(net)
net.stop()
我正在使用 mininet,而 pingall 在使用 simple_switch13 时仅提供 h1 和 h2 之间的连接,没有任何更改,所以我应该使用哪个开关或应该进行哪些更改
你的拓扑中有一个循环。如果我们通过注释掉几个链接来打破循环...
net.addLink( s1, s2, port1=1, port2=1)
net.addLink( s2, s3, port1=2, port2=2)
net.addLink( s1, s4, port1=2, port2=1)
#net.addLink( s3, s4, port1=3, port2=2)
#net.addLink( s1, s3, port1=3, port2=1)
...然后 pingall
对所有主机成功:
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3 h4 h5 h6 h7
h2 -> h1 h3 h4 h5 h6 h7
h3 -> h1 h2 h4 h5 h6 h7
h4 -> h1 h2 h3 h5 h6 h7
h5 -> h1 h2 h3 h4 h6 h7
h6 -> h1 h2 h3 h4 h5 h7
h7 -> h1 h2 h3 h4 h5 h6
*** Results: 0% dropped (42/42 received)
如果您希望此拓扑与环路一起使用,则需要使用支持 spanning tree protocol (STP) 的交换机,例如 ryu.app.simple_switch_stp_13
。如果使用该开关启动 ryu
控制器并等待端口进入 FORWARD
状态:
# ryu-manager ryu.app.simple_switch_stp_13
...lots of output...
...30 seconds later...
[STP][INFO] dpid=0000000000000002: [port=1] ROOT_PORT / FORWARD
[STP][INFO] dpid=0000000000000002: [port=2] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=4] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=1] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=6] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=5] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=2] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000001: [port=3] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=1] ROOT_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=5] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=6] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=7] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=4] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=3] DESIGNATED_PORT / FORWARD
[STP][INFO] dpid=0000000000000003: [port=2] NON_DESIGNATED_PORT / BLOCK
[STP][INFO] dpid=0000000000000004: [port=1] ROOT_PORT / FORWARD
[STP][INFO] dpid=0000000000000004: [port=2] NON_DESIGNATED_PORT / BLOCK
然后 pingall
即使在您的拓扑中有循环也会成功。