[Topology]

 

 

 

We hope all the interfaces on each host can ping each other.

 

[Mininet Script:0629.py]

#!/usr/bin/python

 

from mininet.net import Mininet

from mininet.node import Controller, RemoteController, OVSKernelSwitch, OVSLegacyKernelSwitch, UserSwitch

from mininet.cli import CLI

from mininet.log import setLogLevel

from mininet.link import Link, TCLink

 

def topology():

    "Create a network."

    net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"

    h1 = net.addHost( 'h1')

    h2 = net.addHost( 'h2')

    h3 = net.addHost( 'h3')

    h4 = net.addHost( 'h4')

    s1 = net.addSwitch( 's1', listenPort=6673, mac='00:00:00:00:00:01' )

    s2 = net.addSwitch( 's2', listenPort=6674, mac='00:00:00:00:00:02' )

    s3 = net.addSwitch( 's3', listenPort=6675, mac='00:00:00:00:00:03' )

    c7 = net.addController( 'c7', controller=RemoteController, ip='127.0.0.1', port=6633 )

 

    print "*** Creating links"

    Link(h1, s1, intfName1='h1-eth0')

    Link(h1, s2, intfName1='h1-eth1')

    Link(h2, s1, intfName1='h2-eth0')

    Link(h3, s2, intfName1='h3-eth0')

    Link(h3, s3, intfName1='h3-eth1')

    Link(h4, s3, intfName1='h4-eth0')

    net.build()

    h1.cmd('ifconfig h1-eth0 10.0.10.1 netmask 255.255.255.255')

    h1.cmd('ifconfig h1-eth1 10.0.10.2 netmask 255.255.255.255')

    h1.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward") 

    h1.cmd("echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp")

    h1.cmd('ip route add 10.0.20.1/32 dev h1-eth0')

    h1.cmd('ip route add 10.0.30.1/32 dev h1-eth1')

    h1.cmd('ip route add 10.0.30.2/32 dev h1-eth1')

    h1.cmd('ip route add 10.0.40.1/32 dev h1-eth1')

    h2.cmd('ifconfig h2-eth0 10.0.20.1 netmask 255.255.255.255')

    h2.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")

    h2.cmd("echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp")

    h2.cmd('ip route add 10.0.10.1/32 dev h2-eth0')

    h2.cmd('ip route add 10.0.10.2/32 dev h2-eth0')

    h2.cmd('ip route add 10.0.20.1/32 dev h2-eth0')

    h2.cmd('ip route add 10.0.30.1/32 dev h2-eth0')

    h2.cmd('ip route add 10.0.30.1/32 dev h2-eth0')

    h2.cmd('ip route add 10.0.40.1/32 dev h2-eth0')

    h3.cmd('ifconfig h3-eth0 10.0.30.1 netmask 255.255.255.255')

    h3.cmd('ifconfig h3-eth1 10.0.30.2 netmask 255.255.255.255')

    h3.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")

    h3.cmd("echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp")

    h3.cmd('ip route add 10.0.10.1/32 dev h3-eth0')

    h3.cmd('ip route add 10.0.10.2/32 dev h3-eth0')

    h3.cmd('ip route add 10.0.20.1/32 dev h3-eth0')

    h3.cmd('ip route add 10.0.40.1/32 dev h3-eth1')

    h4.cmd('ifconfig h4-eth0 10.0.40.1 netmask 255.255.255.255')

    h4.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")

    h4.cmd("echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp")

    h4.cmd('ip route add 10.0.10.1/32 dev h4-eth0')

    h4.cmd('ip route add 10.0.10.2/32 dev h4-eth0')

    h4.cmd('ip route add 10.0.20.1/32 dev h4-eth0')

    h4.cmd('ip route add 10.0.30.1/32 dev h4-eth0')

    h4.cmd('ip route add 10.0.30.2/32 dev h4-eth0')

    h4.cmd('ip route add 10.0.40.1/32 dev h4-eth0')

 

    print "*** Starting network"

    c7.start()

    s1.start( [c7] )

    s2.start( [c7] )

    s3.start( [c7] )

    print "*** Running CLI"

    CLI( net )

    print "*** Stopping network"

    net.stop()

 

if __name__ == '__main__':

    setLogLevel( 'info' )

    topology()

 

[Execution]

 

 

Ping Test from h4. The other tests are similar.

 

 

Dr. Chih-Heng Ke (smallko@gmail.com)

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.