3 Hosts




mininet script



   Experiment to connect three hosts together without switch.     H1---H2---H3


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', mac='00:00:00:00:00:01', ip='' )

    h2 = net.addHost( 'h2', mac='00:00:00:00:00:02', ip='' )

    h3 = net.addHost( 'h3', mac='00:00:00:00:00:03', ip='' )

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

    print "*** Creating links"

    Link(h1, h2)

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


    h2.cmd('ifconfig h2-eth1 netmask')

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

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

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

    h1.cmd("sudo ip route add via dev h1-eth0")

    h3.cmd("sudo ip route add via dev h3-eth0")


    print "*** Running CLI"

    CLI( net )

    print "*** Stopping network"



if __name__ == '__main__':

    setLogLevel( 'info' )





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

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan