Mininet:如何在两台交换机之间进行两台主机的通信

问题描述 投票:0回答:1

我在python中使用mininet制作一个简单的脚本。我想通过两个交换机(比如s1和s2)进行通信两个主机(比如说h1和h2)。当h1尝试ping h2时,h2 IP地址的ARP解析请求会跨越两个交换机之间的链路,但不会到达其他主机。

这是拓扑:

H1 ------------- S1 ------------- S2 ------------ H2

Ip H1 10.10.0.1/24 Mac H1 00:00:00:10:00:01 Ip H2 10.10.0.2/24 Mac H2 00:00:00:10:00:02

def networkTest():

    net = Mininet( topo=None,
               build=False )


    s1 = net.addHost('s1', cls=Node)
    s2 = net.addHost('s2', cls=Node)

    h1 = net.addHost('h1', cls=Host, mac='00:00:10:10:00:01')
    h2 = net.addHost('h2', cls=Host, mac='00:00:10:10:00:02')

    Link(s1, h1, intfName1='s1-eth0')
    Link(s2, h2, intfName1='s2-eth0')
    Link(s1, s2, intfName1='s1-eth1')

    net.build()

    for controller in net.controllers:
        controller.start()

    h1.cmd('ip addr add 10.10.0.1/24 dev h1-eth0')
    h1.cmd('ip link set h1-eth0 up')

    h2.cmd('ip addr add 10.10.0.2/24 dev h2-eth0')
    h2.cmd('ip link set h2-eth0 up')

    s1.cmd('brctl addbr br0')
    s1.cmd('brctl addif br0 s1-eth0')
    s1.cmd('brctl addif br0 s1-eth1')
    s1.cmd('ip link set br0 up')

    s2.cmd('brctl addbr br1')
    s2.cmd('brctl addif br1 s2-eth0')
    s2.cmd('ip link set br1 up')

    CLI(net)
    net.stop()

在mininet CLI里面我在h1上打开一个xterm并尝试ping h2

ping 10.10.0.2

但答案是

From 10.10.0.1 icmp_seq = 1 Destination Host Unreachable
python mininet
1个回答
0
投票

我认为你的主机没有通过任何控制器连接。确保您的主机与您可以找到的任何控制器(Opendaylight,Floodlight等)连接。只需在mininet上键入pingall all。它应该显示如下:

h1 ---> h2 h3 h2 ---> h1 h3 h3 ---> h1 h2-

© www.soinside.com 2019 - 2024. All rights reserved.