Configure a node as a switch


  sudo apt-get install bridge-utils




  (n1 ==> switch)

|       |       |

|       |       |

n2     n3     n4





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


from import Mininet

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

from mininet.cli import CLI

from mininet.log import setLogLevel

from 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')

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

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

    h4 = net.addHost( 'h4', mac='00:00:00:00:00:04', ip='' )

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

    print "*** Creating links"

    Link(h1, h2)

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

    Link(h1, h4, intfName1='h1-eth2')

    h1.cmd("sudo ifconfig h1-eth0 0")

    h1.cmd("sudo ifconfig h1-eth1 0")

    h1.cmd("sudo ifconfig h1-eth2 0")

    h1.cmd("sudo ifconfig h1-eth3 0")

    h1.cmd("sudo brctl addbr mybr")

    h1.cmd("sudo brctl addif mybr h1-eth0")

    h1.cmd("sudo brctl addif mybr h1-eth1")

    h1.cmd("sudo brctl addif mybr h1-eth2")

    h1.cmd("sudo ifconfig mybr up")


    print "*** Running CLI"

    CLI( net )

    print "*** Stopping network"



if __name__ == '__main__':

    setLogLevel( 'info' )






Dr. Chih-Heng Ke (

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan