Example #1
0
    def build( self ):
        print "Build network based on our topology."

        net = Mininet( topo=None, build=False, link=TCLink, ipBase=self.minieditIpBase )
 
        net.controllers = self.addControllers()
        
        # Make nodes
        print "Getting Hosts and Switches."
        for widget in self.widgetToItem:
            name = widget[ 'text' ]
            tags = self.canvas.gettags( self.widgetToItem[ widget ] )
            nodeNum = int( name[ 1: ] )
            if 'Switch' in tags:
                net.addSwitch( name )
            elif 'Host' in tags:
                ipBaseNum, prefixLen = netParse( self.minieditIpBase )
                ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum)
                net.addHost( name, ip=ip )
            else:
                raise Exception( "Cannot create mystery node: " + name )

        # Make links
        print "Getting Links."
        for link in self.links.values():
            ( src, dst, linkopts ) = link
            srcName, dstName = src[ 'text' ], dst[ 'text' ]
            src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
            net.addLink(src, dst, **linkopts)

        self.printInfo()
        # Build network (we have to do this separately at the moment )
        net.build()

        return net
def simpleTest():
    "Create and test a simple network"
    net = Mininet()
    #c0 = net.addController('c0',POXBridge)
    c0 = net.addController('c0',RemoteController)
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2',dpid='0000000000000012')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 =net.addHost('h3')
    h4 = net.addHost('h4')
    l11= net.addLink(h1,s1)
    l22= net.addLink(h2,s2)
    l33= net.addLink(h3,s3)
    l44= net.addLink(h4,s4)

    l12= net.addLink(s1,s2)
    l23= net.addLink(s2,s3)
    l2f= net.addLink(s2,s4)
    net.start()
    h1.intfList()[0].setIP('10.43.21.1/24')
    h2.intfList()[0].setIP('10.43.21.2/24')
    h3.intfList()[0].setIP('10.43.21.3/24')
    h4.intfList()[0].setIP('10.43.21.4/24')
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    print "Testing network connectivity"
    CLI(net)
    net.stop()
Example #3
0
def createTreeTopo():


    net = Mininet( controller=RemoteController)

    info( '*** Adding controller\n' )
    net.addController( 'c0', controller=RemoteController,ip="127.0.0.1",port=6633 )
    # Add hosts and switches
    host1 = net.addHost( 'h1' )
    host2 = net.addHost( 'h2' )

    edgeSwitch1 = net.addSwitch( 's3' )
    edgeSwitch2 = net.addSwitch( 's4' )
    aggrSwitch1 = net.addSwitch( 's5' )
    aggrSwitch2 = net.addSwitch( 's6' )
    coreSwitch = net.addSwitch( 's7' )

    # Add links
    net.addLink( host1, edgeSwitch1 )
    net.addLink( edgeSwitch1, aggrSwitch1 )
    net.addLink( aggrSwitch1, coreSwitch )
    net.addLink( coreSwitch, aggrSwitch2 )
    net.addLink( aggrSwitch2, edgeSwitch2 )
    net.addLink( edgeSwitch2, host2 )


    info( '*** Starting network\n')
    net.start()

    info( '*** Running CLI\n' )
    CLI( net )

    info( '*** Stopping network' )
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )
 
    print "*** Creating nodes"
    s1 = net.addSwitch( 's1', listenPort=6634, mac='00:00:00:00:00:01' )
    s4 = net.addSwitch( 's4', listenPort=6635, mac='00:00:00:00:00:04' )
    s6 = net.addSwitch( 's6', listenPort=6636, mac='00:00:00:00:00:06' )
    h2 = net.addHost( 'h2', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    h3 = net.addHost( 'h3', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    h4 = net.addHost( 'h4', mac='00:00:00:00:00:04', ip='10.0.0.4/8' )
    #c7 = net.addController( 'c5', controller=RemoteController, ip='127.0.0.1', port=6633 )
    c7 = net.addController( 'c5', controller=RemoteController, ip='192.168.59.105', port=6633 )
         
 
    print "*** Creating links"
    net.addLink(s1, h2, 1, 0)
    net.addLink(s1, s4, 2, 1)
    net.addLink(s4, h4, 3, 0)
    net.addLink(s4, s6, 2, 1)
    net.addLink(s6, h3, 2, 0)    
 
    print "*** Starting network"
    net.build()
    s1.start( [c7] )
    s4.start( [c7] )
    s6.start( [c7] )
    c7.start()
 
    print "*** Running CLI"
    CLI( net )
 
    print "*** Stopping network"
    net.stop()
Example #5
0
def main():
    net = Mininet( controller = None )

    # add hosts
    h1 = net.addHost( 'h1', ip = '172.16.10.1/24' )
    h2 = net.addHost( 'h2', ip = '172.16.10.2/24' )

    # add switch 1
    sw1 = net.addSwitch( 'sw1', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, pcap_dump = False )

    # add switch 2
    sw2 = net.addSwitch('sw2')

    # add links
    if StrictVersion(VERSION) <= StrictVersion('2.2.0') :
        net.addLink( sw1, h1, port1 = 1 )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2 )
        net.addLink( sw2, h2, port1 = 1 )
    else:
        net.addLink( sw1, h1, port1 = 1, fast=False )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2, fast=False )
        net.addLink( sw2, h2, port1 = 1, fast=False )

    net.start()
    CLI( net )
    net.stop()
Example #6
0
def myNet():

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

    linkopt = dict(bw=1000)
    # Add hosts and switches
    h1 = net.addHost("h1", ip="10.0.0.1", mac="00:00:00:00:00:01")
    h2 = net.addHost("h2", ip="10.0.0.2", mac="00:00:00:00:00:02")
    s1 = net.addSwitch("s1", cls=UserSwitch)  # tora
    s2 = net.addSwitch("s2", cls=UserSwitch)  # ingress a
    s3 = net.addSwitch("s3", cls=UserSwitch)  # eopa
    s4 = net.addSwitch("s4", cls=UserSwitch)  # nwa
    s5 = net.addSwitch("s5", cls=UserSwitch)  # eopb
    s6 = net.addSwitch("s6", cls=UserSwitch)  # ingress b
    s7 = net.addSwitch("s7", cls=UserSwitch)  # torb

    # Add links
    net.addLink(h1, s1, bw=1000)
    net.addLink(s1, s2, bw=1000)
    net.addLink(s2, s3, bw=1000)
    net.addLink(s3, s4, bw=1000)
    net.addLink(s4, s5, bw=1000)
    net.addLink(s5, s6, bw=1000)
    net.addLink(s6, s7, bw=1000)
    net.addLink(s7, h2, bw=1000)

    net.build()

    CLI(net)
    net.stop()
def myTopo():
    net = Mininet(switch=OVSKernelSwitch)
    net.addController('controller01',controller=RemoteController,ip=ofc_ip, port=ofc_port)

    spine1 = net.addSwitch(spine1_name, dpid=spine1_dpid)
    leaf1  = net.addSwitch(leaf1_name,  dpid=leaf1_dpid)
    leaf2  = net.addSwitch(leaf2_name,  dpid=leaf2_dpid)

    host1 = net.addHost(host1_name, ip=host1_ip)
    host2 = net.addHost(host2_name, ip=host2_ip)
    host3 = net.addHost(host3_name, ip=host3_ip)
    host4 = net.addHost(host4_name, ip=host4_ip)

    net.addLink(spine1, leaf1)
    net.addLink(spine1, leaf2)

    net.addLink(leaf1, host1)
    net.addLink(leaf1, host2)

    net.addLink(leaf2, host3)
    net.addLink(leaf2, host4)

    net.start()
    print "Dumping node connections"
    dumpNodeConnections(net.switches)
    dumpNodeConnections(net.hosts)

    ofp_version(spine1, ['OpenFlow13'])
    ofp_version(leaf1,  ['OpenFlow13'])
    ofp_version(leaf2,  ['OpenFlow13'])

    CLI(net)
    net.stop()
Example #8
0
def testRemoteNet( remote='ubuntu2', link=RemoteGRELink ):
    "Test remote Node classes"
    print( '*** Remote Node Test' )
    net = Mininet( host=RemoteHost, switch=RemoteOVSSwitch, link=link )
    c0 = net.addController( 'c0' )
    # Make sure controller knows its non-loopback address
    Intf( 'eth0', node=c0 ).updateIP()
    print( "*** Creating local h1" )
    h1 = net.addHost( 'h1' )
    print( "*** Creating remote h2" )
    h2 = net.addHost( 'h2', server=remote )
    print( "*** Creating local s1" )
    s1 = net.addSwitch( 's1' )
    print( "*** Creating remote s2" )
    s2 = net.addSwitch( 's2', server=remote )
    print( "*** Adding links" )
    net.addLink( h1, s1 )
    net.addLink( s1, s2 )
    net.addLink( h2, s2 )
    net.start()
    print( 'Mininet is running on', quietRun( 'hostname' ).strip() )
    for node in c0, h1, h2, s1, s2:
        print( 'Node', node, 'is running on', node.cmd( 'hostname' ).strip() )
    net.pingAll()
    CLI( net )
    net.stop()
Example #9
0
def emptyNet():

    "Create an empty network and add nodes to it."

    net = Mininet( controller=lambda a: RemoteController(a, ip='128.208.125.60' ))

    info( '*** Adding controller\n' )
    net.addController( 'c0' )

    info( '*** Adding hosts\n' )
    h1 = net.addHost( 'h1', ip='10.0.0.1' )
    h2 = net.addHost( 'h2', ip='10.0.0.2' )

    info( '*** Adding switch\n' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )
    s5 = net.addSwitch( 's5' )

    info( '*** Creating links\n' )
    net.addLink( h1, s3 )
    net.addLink( h2, s5 )
    net.addLink( s3 , s4 )
    net.addLink( s4 , s5 )

    info( '*** Starting network\n')
    net.start()

    info( '*** Running CLI\n' )
    CLI( net )

    info( '*** Stopping network' )
    net.stop()
Example #10
0
def DeltaNetwork():
#Make topology
	net = Mininet(topo=None, controller=None, build=False)

#Add switch
	s0 = net.addSwitch('s0', dpid='00:00:00:00:00:01')
	s1 = net.addSwitch('s1') # for connection with DELTA

#Add hosts
	h1 = net.addHost('h1', ip='10.0.0.1', mac='00:00:00:00:00:11')
	h2 = net.addHost('h2', ip='10.0.0.2', mac='00:00:00:00:00:22')

#Add links
	net.addLink(s0, h1)
	net.addLink(s0, h2)

	net.addLink(s1, h1, intfName2='eth0')
	
#	net.build()
	net.start()

#Add hardware interface to switch1 
	s1.attach('eth0')

#Set ip
	h1.cmd("ifconfig eth0 10.0.2.13 netmask 255.255.255.0")
	
#connect a controller
	os.system("sudo ovs-vsctl set-controller s0 tcp:"+sys.argv[1]+":"+sys.argv[2])

	CLI(net)
	net.stop()
Example #11
0
def emptyNet():

    "Create an empty network and add nodes to it."

    net = Mininet( controller=Controller )

    info( '*** Adding controller\n' )
    net.addController( 'c0', controller=RemoteController, ip='127.0.0.1', port=6633 )

    info( '*** Adding hosts\n' )
    h1 = net.addHost( 'h1' )
    h2 = net.addHost( 'h2' )

    info( '*** Adding switch\n' )
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )

    info( '*** Creating links\n' )
    net.addLink( h1, s1 )
    net.addLink( h2, s3 )
    net.addLink( s1, s2 )
    net.addLink( s2, s3 )
    net.addLink( s3, s4 )
    net.addLink( s4, s1 )

    info( '*** Starting network\n')
    net.start()

    info( '*** Running CLI\n' )
    CLI( net )

    info( '*** Stopping network' )
    net.stop()
Example #12
0
def createStaticRouterNetwork():
    info( '*** Creating network for Static Router Example\n' )

    # Create an empty network.
    net = Mininet(controller=RemoteController, switch=OVSKernelSwitch)
    net.addController('c0')

    # Creating nodes in the network.
    h0 = net.addHost('h0')
    s0 = net.addSwitch('s0')
    h1 = net.addHost('h1')
    s1 = net.addSwitch('s1')

    # Creating links between nodes in network.
    h0int, s0int = createLink(h0, s0)
    h1int, s1int = createLink(h1, s1)
    s0pint, s1pint = createLink(s0, s1)

    # Configuration of IP addresses in interfaces
    s0.setIP(s0int, '192.168.1.1', 26)
    h0.setIP(h0int, '192.168.1.2', 26)
    s1.setIP(s1int, '192.168.1.65', 26)
    h1.setIP(h1int, '192.168.1.66', 26)
    s0.setIP(s0pint, '192.168.1.129', 26)
    s1.setIP(s1pint, '192.168.1.130', 26)

    info( '*** Network state:\n' )
    for node in s0, s1, h0, h1:
        info( str( node ) + '\n' )

    # Start command line 
    net.start()
    CLI(net)
    net.stop()
Example #13
0
def customNet():
        net = Mininet()        
        #Adding hosts
        pc0 = net.addHost( 'h1' )
        pc1 = net.addHost( 'h2' )
        pc2 = net.addHost( 'h3' )
        pc3 = net.addHost( 'h4' )
        #Adding switches
        switch0 = net.addSwitch( 's1' )
        switch1 = net.addSwitch( 's2' )
        router2 = net.addSwitch( 'r2' )
        router3 = net.addSwitch( 'r3' )
        # Add links
        net.addLink( pc0, switch0 )
        net.addLink( pc1, switch0 )
        net.addLink( pc2, switch1 )
        net.addLink( pc3, switch1 )
        net.addLink( switch0, router3 )
        net.addLink( switch1, router2 )
        net.addLink( router2, router3 )

        net.build()
        net.start()

        CLI( net )
        net.stop()
Example #14
0
def net():
    '''Create a simulated network'''

    net = Mininet(controller=lambda a: RemoteController(a,ip='127.0.0.1'))

    info('*** Adding controller\n')
    # currently, we do not add a controller to this network.
    net.addController('c0')

    info('*** Adding hosts\n')
    # this is a host that is in the external network
    h1 = net.addHost('h1', ip='10.0.0.1')
    h2 = net.addHost('h2', ip='10.0.0.1')

    info('*** Adding switches\n')
    inst1 = net.addSwitch('inst1', dpid=int2dpid(11))
    inst2 = net.addSwitch('inst2', dpid=int2dpid(12))
    lb = net.addSwitch('lb', dpid=int2dpid(1))

    info('*** Creating links\n')
    net.addLink(h1, inst1)
    net.addLink(h2, inst2)
    net.addLink(inst1, lb)
    net.addLink(inst2, lb)

    info('*** Starting network\n')
    net.start()

    info('*** Running CLI\n')
    CLI(net)

    info('*** Stopping network\n')
    net.stop()
Example #15
0
    def build( self ):
        "Build network based on our topology."

        net = Mininet(controller=RemoteController, topo=None )

        # Make controller
        net.addController( 'c0' )
        # Make nodes
        for widget in self.widgetToItem:
            name = widget[ 'text' ]
            tags = self.canvas.gettags( self.widgetToItem[ widget ] )
            nodeNum = int( name[ 1: ] )
            if 'Switch' in tags:
                net.addSwitch( name )
            elif 'Host' in tags:
                net.addHost( name, ip=ipStr( nodeNum ) )
            else:
                raise Exception( "Cannot create mystery node: " + name )
        # Make links
        for link in self.links.values():
            ( src, dst ) = link
            srcName, dstName = src[ 'text' ], dst[ 'text' ]
            src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
            src.linkTo( dst )

        # Build network (we have to do this separately at the moment )
        net.build()

        return net
Example #16
0
def createTopo(  ):
    "Simple topology example."


    net = Mininet( controller=RemoteController)

    info( '*** Adding controller\n' )
    net.addController( 'c0', controller=RemoteController,ip="127.0.0.1",port=6633 )

    # Add hosts and switches
    leftHost = net.addHost( 'h1' )
    rightHost = net.addHost( 'h2' )
    leftSwitch = net.addSwitch( 's3' )
    rightSwitch = net.addSwitch( 's4' )
    centerSwitchl = net.addSwitch( 's5' )
    centerSwitchr = net.addSwitch( 's6' )

    # Add links
    net.addLink( leftHost, leftSwitch )
    net.addLink( leftSwitch, centerSwitchl )
    net.addLink( centerSwitchl, centerSwitchr )
    net.addLink( centerSwitchr, rightSwitch)

    linkOpts = {'bw':10};
    net.addLink( rightSwitch, rightHost, cls=TCLink, **linkOpts)


    info( '*** Starting network\n')
    net.start()

    info( '*** Running CLI\n' )
    CLI( net )

    info( '*** Stopping network' )
    net.stop()
Example #17
0
def emptyNet():

    "Create an empty network and add nodes to it."

    #net = Mininet( controller=Controller )
    net = Mininet( controller=RemoteController )

    info( '*** Adding controller\n' )
    net.addController( 'c0' )

    info( '*** Adding hosts\n' )
    h1 = net.addHost( 'h1', ip='10.0.0.1' )
    h2 = net.addHost( 'h2', ip='10.0.0.2' )

    info( '*** Adding switch\n' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )
    s5 = net.addSwitch( 's5' )
    s6 = net.addSwitch( 's6' )

    info( '*** Creating links\n' )
    net.addLink( h1, s3 )
    net.addLink( s3, s4 )
    net.addLink( s3, s5 )
    net.addLink( s4, s6 )
    net.addLink( s5, s6 )
    net.addLink( h2, s6 )

    print "Stopping of " + 's5'
    net.configLinkStatus('s5', 's3', 'down')
    #net.configLinkStatus('s5', 's6', 'down')
    #net.hosts[0].cmd("ping -w 15 10.0.0.2")
    #net.pingAll()

    return net
    def config_net(self):
        net = Mininet(switch=OVSKernelSwitch,controller=RemoteController)

        print '*** Adding controller'
        net.addController('c0',ip=self.controller_ip)

        print '*** Adding hosts'
        h1 = net.addHost( 'h1', mac='00:00:00:00:00:01')
        h2 = net.addHost( 'h2', mac='00:00:00:00:00:02')
        h3 = net.addHost( 'h3', mac='00:00:00:00:00:03')
        h4 = net.addHost( 'h4', mac='00:00:00:00:00:04')

        print '*** Adding switch'
        s1 = net.addSwitch( 's1' )
        s2 = net.addSwitch( 's2' )
        s3 = net.addSwitch( 's3' )

        print '*** Creating links'
        net.addLink(h1,s2)
        net.addLink(h2,s2)
        net.addLink(h3,s3)
        net.addLink(h4,s3)
        net.addLink(s1,s2)
        net.addLink(s1,s3)

        self.net = net
def main():
    net = Mininet(controller = None, autoSetMacs=True, autoStaticArp=True)

    h1 = net.addHost('h1', cls=P4Host)
    h2 = net.addHost('h2', cls=P4Host)
    h3 = net.addHost('h3', cls=P4Host)
    h4 = net.addHost('h4', cls=P4Host)

    s1 = net.addSwitch('s1', cls = P4Switch, sw_path=SW_PATH, json_path=JSON_PATH, thrift_port=9091)
    s2 = net.addSwitch('s2', cls = P4Switch, sw_path=SW_PATH, json_path=JSON_PATH, thrift_port=9092)
    s3 = net.addSwitch('s3', cls = P4Switch, sw_path=SW_PATH, json_path=JSON_PATH, thrift_port=9093)
    s4 = net.addSwitch('s4', cls = P4Switch, sw_path=SW_PATH, json_path=JSON_PATH, thrift_port=9094)

    net.addLink(s1, h1, port1=0, port2=0)
    net.addLink(s1, s3, port1=1, port2=1)
    net.addLink(s1, s2, port1=2, port2=0)

    net.addLink(s2, s4, port1=1, port2=1)
    net.addLink(s2, h2, port1=2, port2=0)

    net.addLink(s3, h3, port1=0, port2=0)
    net.addLink(s3, s4, port1=2, port2=0)

    net.addLink(s4, h4, port1=2, port2=0)


    net.start()
    CLI(net)
    net.stop()
def QoSFlowNet():
    "Create network by using QoSFlow user switch."
    
    net = Mininet(controller=RemoteController, switch=QoSFlowUserSwitch, link=TCLink) 
    
    info('*** Adding controller\n')
    net.addController('c0')
    
    info('*** Adding hosts\n')
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')

    info('*** Adding switch\n')
    I1 = net.addSwitch('I1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')
    s5 = net.addSwitch('s5')
    s6 = net.addSwitch('s6')
    s7 = net.addSwitch('s7')
    s8 = net.addSwitch('s8')
    s9 = net.addSwitch('s9')
    E2 = net.addSwitch('E2')

    info('*** Creating host links\n')
    #h2.linkTo(s2)
    net.addLink(I1, h1)#, 2, 1, intfName1 = 'eth0-h1')
    net.addLink(E2, h2)#, 2, 1, intfName1 = 'eth0-h2')

    info('*** Creating swicth links\n')
    #s1.linkTo(s2)
    net.addLink(I1, s2)
    net.addLink(s2, s3)
    net.addLink(s3, s4)
    net.addLink(s4, s5)
    net.addLink(s5, s6)
    net.addLink(s6, s7)
    net.addLink(s7, s8)
    net.addLink(s8, s9)
    net.addLink(s9, E2)
    
    print I1.intfNames()
    print s2.intfNames()
    print s3.intfNames()
    print s4.intfNames()
    print s5.intfNames()
    print s6.intfNames()
    print s7.intfNames()
    print s8.intfNames()
    print s9.intfNames()
    print E2.intfNames()

    info('*** Starting network\n')
    net.start()
    
    info('*** Running CLI\n')
    CLI(net)

    info('*** Stopping network')
    net.stop()
Example #21
0
def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    info( '*** Add switches\n')
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch)

    info( '*** Add hosts\n')
    h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h10 = net.addHost('h10', cls=Host, ip='10.0.0.10', defaultRoute=None)
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
    h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
    h8 = net.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None)
    h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None)
    h9 = net.addHost('h9', cls=Host, ip='10.0.0.9', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)

    info( '*** Add links\n')
    net.addLink(h1, s1)
    net.addLink(h2, s1)
    net.addLink(h3, s4)
    net.addLink(h4, s4)
    net.addLink(h5, s2)
    net.addLink(h10, s2)
    net.addLink(h6, s3)
    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(s1, s4)
    net.addLink(s5, s3)
    net.addLink(s5, h8)
    net.addLink(s5, h7)
    net.addLink(s5, h9)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s4').start([])
    net.get('s1').start([])
    net.get('s3').start([])
    net.get('s2').start([])
    net.get('s5').start([])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
def sbyodTestingNetwork():


    "Create an empty network with remote controller"
    info('*** Creating Mininet object\n')
    net = Mininet( controller=RemoteController, autoSetMacs=True )

    info( '*** Adding controller\n' )
    net.addController( 'c0', controller=RemoteController, ip="0.0.0.0", port=6633 )

    info( '*** Adding hosts\n' )
    h1 = net.addHost( 'h1', ip='0.0.0.0' )
    h2 = net.addHost( 'h2', ip='0.0.0.0' )
    portalHost = net.addHost( 'h3', ip='10.1.0.2' )
    gatewayHost = net.addHost( 'h4', ip='10.1.0.1')
    HostList = (h1,h2,portalHost,gatewayHost)

    info( '*** Adding switches\n' )
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )
    SwitchList = (s1,s2,s3)

    info( '*** Creating switch to switch links\n' )
    net.addLink('s1', 's2')
    net.addLink('s1', 's3')
    net.addLink('s2', 's3')

    info( '*** Creating host to switch links\n' )
    net.addLink('h1', 's2')
    net.addLink('h2', 's3')
    #portalHost to switch s2
    net.addLink('h3', 's2')
    #gatewayHost to switch s1
    net.addLink('h4', 's1')


    # info( '*** Adding hardware interface to switch s1 (gateway)\n' )
    # physicalIntf = Intf( 'eth1', node=s1 )

    info( '*** Starting network\n')
    net.start()

    info( '*** Running DHClient\n' )
    #h1.cmd('dhclient ' + h1.defaultIntf().name)
    h1.cmd('dhclient')
    h2.cmd('dhclient')
    portalHost.cmd('ping -c 1 10.1.0.1 &')
    gatewayHost.cmd('ping -c 1 10.1.0.2 &')

    info( '*** Starting Simple HTTP Server on Portal\n')
    portalHost.cmd('python -m SimpleHTTPServer 443 &')

    info( '*** Running CLI\n' )
    CLI( net )

    info( '*** Stopping network' )
    portalHost.cmd('kill %python')
    net.stop()
Example #23
0
def myNetwork():

    net = Mininet(topo=None,
                  build=False,
                  ipBase='10.0.0.0/8')

    info('*** Adding controller\n')
    c0 = net.addController(name='c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           protocol='tcp',
                           port=6633)

    info('*** Add switches\n')
    info('*** switches protocols')
    openFlowVersions = []
    openFlowVersions.append('OpenFlow13')
    protoList = ",".join(openFlowVersions)
    switchParms = {}
    switchParms['protocols'] = protoList

    s1 = net.addSwitch('s1', cls=OVSKernelSwitch, **switchParms)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch, **switchParms)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch, **switchParms)
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch, **switchParms)

    info('*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', mac='B6:29:CE:E1:DB:51')
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', mac='B6:29:CE:E1:DB:52')
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', mac='B6:29:CE:E1:DB:53')
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', mac='B6:29:CE:E1:DB:54')

    info('*** Add links\n')
    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(s3, s4)
    net.addLink(s4, s1)

    net.addLink(h1, s1)
    net.addLink(h2, s2)
    net.addLink(h3, s3)
    net.addLink(h4, s4)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('s1').start([c0])
    net.get('s2').start([c0])
    net.get('s3').start([c0])
    net.get('s4').start([c0])

    info('*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
Example #24
0
def simpleNet():                                                                                                                             
    """
    A custom mininet topology for testing ofx.

               h1   -----|
                             |
               h2 --  switch -- OFX process
                             |          |
                             |          |
                             |          |
                        controller  -----
    """
    # spawn some switches. 
    switchIds = [1, 2]
    switchObjs = []
    switchNames = ['s%s'%sid for sid in switchIds]

    net = Mininet( autoStaticArp=True )

    s1 = net.addSwitch(switchNames[0]) 
    switchObjs.append(s1)
    s2 = net.addSwitch(switchNames[1])
    switchObjs.append(s2)
    h1 = net.addHost( 'h1', ip='1.1.1.1', mac='00:00:00:00:00:01')
    h2 = net.addHost( 'h2', ip='1.1.1.5', mac='00:00:00:00:00:02') 
    
    net.addLink( h1, s1 )                                                                                                                   
    net.addLink(s1, s2)
    net.addLink( s2, h2 )

    net.start()

    print ("compiling OFX..")
    compileOFX()
    print ("attempting to start OFX..")

    tapInterfaces = ['tap%s'%sid for sid in switchIds]
    listenPorts = [10000+sid for sid in switchIds]
    internalPorts = [22000 + sid for sid in switchIds]

    ofxObjs = []
    for i in range(len(switchObjs)):
        print ("spawning agent for switch %s"%i)
        testOFXInstance = OfxInstance(switchNames[i], tapInterfaces[i], listenPorts[i], internalPorts[i])
        testOFXInstance.spawnTap()
        testOFXInstance.startAgent('127.0.0.1', 6633)
        ofxObjs.append(testOFXInstance)
        time.sleep(.1)

    print ("waiting 10 seconds for OFX to start..")
    time.sleep(10)
    print ("done waiting for OFX.")
    CLI( net )

    # shutdown the OFX instances.
    for ofxObj in ofxObjs:
        ofxObj.shutDown()

    net.stop()
Example #25
0
def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   link=TCLink,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    c0=net.addController(name='c0',
                      controller=RemoteController,
                      ip='10.0.0.3',
                      protocol='tcp',
                      port=6653)
    info( '*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch, inband=True)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch, inband=True)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch, inband=True)
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch, inband=True)
    
    

    info( '*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
    h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
    h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
    h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None)
    h8 = net.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None)

    info( '*** Add links\n')
    net.addLink(h1, s1)
    net.addLink(h2, s1)
    net.addLink(s1, s2,delay='100ms')
    net.addLink(h3, s2)
    net.addLink(h4, s2)
    net.addLink(s2, s3, delay='1000ms')
    net.addLink(h5, s3)
    net.addLink(h6, s3)
    net.addLink(s3, s4, delay='1000ms')
    net.addLink(h7, s4)
    net.addLink(h8, s4)
    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s1').start(net.controllers)
    net.get('s2').start(net.controllers)
    net.get('s3').start(net.controllers)
    net.get('s4').start(net.controllers)
    
    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
Example #26
0
def createDoubleControllerNetwork():
    info( '*** Creating network for Double Controller Example\n' )

    # Create an empty network.
    net = Mininet(switch=OVSKernelSwitch)
    c0 = net.addController('c0', controller=RemoteController, 
      defaultIP="127.0.0.1", port=6633)
    c1 = net.addController('c1', controller=RemoteController, 
      defaultIP="127.0.0.1", port=6644)

    # Creating nodes in the network.
    h0 = net.addHost('h0')
    h1 = net.addHost('h1')
    s0 = net.addSwitch('s0')
    h2 = net.addHost('h2')
    h3 = net.addHost('h3')
    s1 = net.addSwitch('s1')

    # Creating links between nodes in network.
    h0int, s0int = createLink(h0, s0)
    h1int, s0int = createLink(h1, s0)
    h2int, s1int = createLink(h2, s1)
    h3int, s1int = createLink(h3, s1)
    s0int, s1int = createLink(s0, s1)

    # Configuration of IP addresses in interfaces
    h0.setIP(h0int, '192.168.1.2', 26)
    h1.setIP(h1int, '192.168.1.3', 26)
    h2.setIP(h2int, '192.168.1.66', 26)
    h3.setIP(h3int, '192.168.1.67', 26)

    # Start network
    net.build()

    # Attaching Controllers to Switches
    s0.start([c0])
    s1.start([c1])

    # Setting interface only routes and not default routes
    h0.cmd("route del -net 0.0.0.0")
    h1.cmd("route del -net 0.0.0.0")
    h2.cmd("route del -net 0.0.0.0")
    h3.cmd("route del -net 0.0.0.0")
    h0.cmd("route add -net 192.168.1.0 netmask 255.255.255.192 " + h0int)
    h1.cmd("route add -net 192.168.1.0 netmask 255.255.255.192 " + h1int)
    h2.cmd("route add -net 192.168.1.64 netmask 255.255.255.192 " + h2int)
    h3.cmd("route add -net 192.168.1.64 netmask 255.255.255.192 " + h3int)

    # dump stuff on the screen
    info( '*** Network state:\n' )
    for node in c0, c1, s0, s1, h0, h1, h2, h3:
        info( str( node ) + '\n' )

    # Start command line 
    CLI(net)

    # Stop network
    net.stop()
Example #27
0
def createTopo(  ):
    "Simple topology example."


    net = Mininet( controller=RemoteController)
    params = {'ip':'127.0.0.1','port':6633}
    info( '*** Adding controller\n' )
    net.addController( 'c0', controller=RemoteController, **params)

    # Add hosts and switches
    host1 = net.addHost( 'h1' )
    host2 = net.addHost( 'h2' )
    host3 = net.addHost( 'h3' )
    host4 = net.addHost( 'h4' )
    leftSwitch = net.addSwitch( 's5' )
    rightSwitch = net.addSwitch( 's6' )
    centerSwitchl = net.addSwitch( 's7' )
    centerSwitchr = net.addSwitch( 's8' )

    # Add links
    linkOpts = {'bw':100};
    net.addLink( host1, leftSwitch ) #, cls=TCLink, **linkOpts)
    net.addLink( host2, leftSwitch ) #, cls=TCLink, **linkOpts)
    linkOpts = {'bw':100};
    net.addLink( leftSwitch, centerSwitchl ) #, cls=TCLink, **linkOpts)
    net.addLink( centerSwitchl, centerSwitchr) # , cls=TCLink, **linkOpts)
    net.addLink( centerSwitchr, rightSwitch) # , cls=TCLink, **linkOpts)

    linkOpts = {'bw':100};
    net.addLink( rightSwitch, host3) #, cls=TCLink, **linkOpts)
    net.addLink( rightSwitch, host4) #, cls=TCLink, **linkOpts)
    

    info( '*** Starting network\n')
    net.start()
    net.pingAll();
    time.sleep(5);

    info( '*** adding q h1-h2\n' )
    cmd1 = 'curl -i http://221.199.216.240:8080/wm/haqos/createEfQ/00:00:00:00:00:00:00:05/00:00:00:00:00:00:00:06/60000000/5001/-1/json -X PUT';
    result1 = os.popen(cmd1);
    time.sleep(3);
    info( '*** adding q h2-h1\n' )
    cmd2 = 'curl -i http://221.199.216.240:8080/wm/haqos/createEfQ/00:00:00:00:00:00:00:06/00:00:00:00:00:00:00:05/60000000/-1/5001/json -X PUT';

    result2 = os.popen(cmd2);


    time.sleep(5);


    info( '*** Running CLI\n' )
    CLI( net )



    info( '*** Stopping network' )
    net.stop()
Example #28
0
def start(ip="127.0.0.1",port=6633):
#def start(ip="127.0.0.1",port=6653):

    ctrlr = lambda n: RemoteController(n, ip=ip, port=port, inNamespace=False)
    net = Mininet(switch=OVSSwitch, controller=ctrlr, autoStaticArp=False)
    c1 = net.addController('c1')

    gates_agraph = pgv.AGraph("simplified_gates_topology.dot")
    for sw in gates_agraph.nodes():
        net.addSwitch(sw, dpid = hex( int(sw.attr['dpid']) )[2:])

    for link in gates_agraph.edges():
        (src_switch, dst_switch) = link
        net.addLink(src_switch, dst_switch, int(link.attr['src_port']), int(link.attr['dport']) )

    # Only one host and an Internet Router disguised as a host for now (because it's not part of the OF network)
    h0 = net.addHost('h0', cls=VLANHost, mac='d4:c9:ef:b2:1b:80', ip='128.253.154.1', vlan=1356)
    net.addLink("s_bdf", h0, 1, 0)

    # To test DHCP functionality, ucnomment this line and comment out the fixed IP line.  Then when mininet
    # starts you issue:
    #   mininet> h1 dhclient -v -d -1 h1-eth0.1356
    # and make sure it gets its IP by going through all protocol steps.
    #h1 = net.addHost('h1', cls=VLANHost, mac='00:00:01:00:00:11', ip='0.0.0.0', vlan=1356)
    h1 = net.addHost('h1', cls=VLANHost, mac='00:00:01:00:00:11', ip='128.253.154.100', vlan=1356)
    net.addLink("s_f3a", h1, 32, 0)

    # h4{a,b,c} are wireless nodes supposedly hooked up to a dumb AP.  You can't just hook them up
    # to the same mininet port.  Y  
    h4a = net.addHost('h4a', cls=VLANHost, mac='00:00:01:00:00:14', ip='128.253.154.104', vlan=1356)
    net.addLink("s_f3a", h4a, 33, 0)
    #net.addHost('h4b', cls=VLANHost, mac='00:00:01:00:00:14', ip='128.253.154.104', vlan=1356)
    #net.addHost('h4c', cls=VLANHost, mac='00:00:01:00:00:14', ip='128.253.154.104', vlan=1356)

    # h2 is a syslab PC
    h2 = net.addHost('h2', cls=VLANHost, mac='00:00:01:00:00:13', ip='128.253.154.102', vlan=1356)
    net.addLink("s_lab_r6", h2, 1, 0)

    # MAC spoofing attempt of h2
    h3 = net.addHost('h3', cls=VLANHost, mac='00:00:01:00:00:13', ip='128.253.154.102', vlan=1356)
    net.addLink("s_lab_r6", h3, 2, 0)

    ###### Start of static Mininet epilogue ######
    # Set up logging etc.
    lg.setLogLevel('info')
    lg.setLogLevel('output')

    # Start the network
    net.start()
    # Start the DHCP server on Internet Router.  This will actually be a DHCP proxy in the real setup.  
    #startDHCPserver( h0, gw='128.253.154.1', dns='8.8.8.8')


    # Enter CLI mode
    output("Network ready\n")
    output("Press Ctrl-d or type exit to quit\n")
    CLI(net)
Example #29
0
def myNetwork():

    net = Mininet( topo=None,
                   listenPort=6633,
                   build=False,
                   ipBase='10.0.0.0/8',
		   link=TCLink,
		   )

    info( '*** Adding controller\n' )
    c0=net.addController(name='c0',
                      controller=RemoteController,
		      protocols='OpenFlow13',
		      ip='127.0.0.1'
                     )

    info( '*** Add switches\n')
    s1 = net.addSwitch('s3', cls=OVSSwitch, mac='00:00:00:00:00:06', protocols='OpenFlow13')
    s2 = net.addSwitch('s2', cls=OVSSwitch, mac='00:00:00:00:00:05', protocols='OpenFlow13')
    s3 = net.addSwitch('s1', cls=OVSSwitch, mac='00:00:00:00:00:04', protocols='OpenFlow13')

    info( '*** Add hosts\n')
    h1 = net.addHost('h3', cls=Host, ip='10.0.0.3', mac='00:00:00:00:00:03', defaultRoute='via 10.0.0.4')
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', mac='00:00:00:00:00:02', defaultRoute='via 10.0.0.4')
    h3 = net.addHost('h1', cls=Host, ip='10.0.0.1', mac='00:00:00:00:00:01', defaultRoute='via 10.0.0.4')
    # La ruta por defecto de los host es la de NAT (10.0.0.4 en este caso)

    info('*** Add NAT\n')
    net.addNAT().configDefault()


    info( '*** Add links\n')
    net.addLink(s1, s2, bw=10, delay='0.2ms')
    net.addLink(s1, s3, bw=10, delay='0.2ms')
    #net.addLink(s2, s1, bw=10, delay='0.2ms') #Esta linea con este controlador provoca errores.
    net.addLink(s1, h1, bw=10, delay='0.2ms')
    net.addLink(s2, h2, bw=10, delay='0.2ms')
    net.addLink(s3, h3, bw=10, delay='0.2ms')


    info( '*** Starting network\n')
    net.build()
    net.start()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()


    info( '*** Starting switches\n')
    net.get('s3').start([c0])
    net.get('s2').start([c0])
    net.get('s1').start([c0])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
Example #30
0
    mycontroller = RemoteController("RemoteController")
    net.controllers = [mycontroller]
    net.nameToNode["RemoteController"] = mycontroller

    # host
    # tenant 1
    host1 = net.addHost('h1', ip="191.168.2.1", mac='00:00:00:00:01:01')
    host2 = net.addHost('h2', ip="192.168.2.2", mac='00:00:00:00:01:02')

    # tenant 2
    host3 = net.addHost('h3', ip="191.168.2.1", mac='00:00:00:00:01:03')
    host4 = net.addHost('h4', ip="192.168.2.2", mac='00:00:00:00:01:04')

    # switch
    switch1 = net.addSwitch('s1', ip="191.168.3.1", datapath='user')
    switch2 = net.addSwitch('s2', ip="191.168.3.2", datapath='user')

    # gateway
    gateway1 = net.addSwitch('g1', ip="191.1.1.1", dpid='A')
    gateway2 = net.addSwitch('g2', ip="191.1.1.1", dpid='B')

    # host - switch
    # tenant 1
    net.addLink(host1, switch1, 1, 1, cls=TCLink, bw=default_hs_bw)
    net.addLink(host2, switch2, 1, 1, cls=TCLink, bw=default_hs_bw)

    # tenant 2
    net.addLink(host3, switch1, 1, 2, cls=TCLink, bw=default_hs_bw)
    net.addLink(host4, switch2, 1, 2, cls=TCLink, bw=default_hs_bw)
Example #31
0
def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   ipBase='172.16.0.0/16')

    info( '*** Adding controller\n' )
    gateways=net.addController(name='gateways',
                      controller=RemoteController,
                      ip='127.0.0.1',
                      protocol='tcp',
                      port=6633)

    routers=net.addController(name='routers',
                      controller=RemoteController,
                      ip='127.0.0.1',
                      protocol='tcp',
                      port=6653)



    info( '*** Add switches\n')
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch)
    s6 = net.addSwitch('s6', cls=OVSKernelSwitch)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)

    info( '*** Add hosts\n')
    h11 = net.addHost('h11', cls=Host, ip='172.16.1.2/24', defaultRoute='via 172.16.1.1')
    h12 = net.addHost('h12', cls=Host, ip='172.16.1.3/24', defaultRoute='via 172.16.1.1')
    h13 = net.addHost('h13', cls=Host, ip='172.16.1.4/24', defaultRoute='via 172.16.1.1')

    h21 = net.addHost('h21', cls=Host, ip='172.16.2.2/24', defaultRoute='via 172.16.2.1')
    h22 = net.addHost('h22', cls=Host, ip='172.16.2.3/24', defaultRoute='via 172.16.2.1')
    h23 = net.addHost('h23', cls=Host, ip='172.16.2.4/24', defaultRoute='via 172.16.2.1')

    h31 = net.addHost('h31', cls=Host, ip='172.16.3.2/24', defaultRoute='via 172.16.3.1')
    h32 = net.addHost('h32', cls=Host, ip='172.16.3.3/24', defaultRoute='via 172.16.3.1')
    h33 = net.addHost('h33', cls=Host, ip='172.16.3.4/24', defaultRoute='via 172.16.3.1')

    info( '*** Add links\n')
    
    # build the ring for core network
    net.addLink(s4, s5)
    net.addLink(s5, s6)
    net.addLink(s6, s4)

    # build links to edge routers
    net.addLink(s1, s4)
    net.addLink(s2, s5)
    net.addLink(s3, s6)

    # s1 hosts
    net.addLink(s1, h11)
    net.addLink(s1, h12)
    net.addLink(s1, h13)

    # s2 hosts
    net.addLink(s2, h21)
    net.addLink(s2, h22)
    net.addLink(s2, h23)

    # s3 hosts
    net.addLink(s3, h31)
    net.addLink(s3, h32)
    net.addLink(s3, h33)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s4').start([routers])
    net.get('s2').start([gateways])
    net.get('s5').start([routers])
    net.get('s6').start([routers])
    net.get('s3').start([gateways])
    net.get('s1').start([gateways])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
Example #32
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)
    c1 = net.addController('c1',
                           controller=RemoteController,
                           ip='192.168.56.1',
                           port=6633)
    c1.start()
    info('*** Adding switches\n')
    n = 10  #number of hosts per edge node
    lamda = 0.1  #flow arrival rate
    sw = 18  #total number of switches
    experimentDuration = 500
    for s in range(sw):
        switch = net.addSwitch('s%s' % (s + 1))
        switch.start([c1])
    switches = net.switches

    info('*** Creating links and adding hosts to edge switches\n')
    j = 0
    noCore = 12  #number of core switches
    CORE_SWITCHES = []  #the set of core switche
    for s in switches:
        j = j + 1
        i = 0
        for ss in switches:
            i = i + 1
            if i > j and i <= noCore and j <= noCore:  #12 core switches
                if random.random() > 0.5:
                    net.addLink(s, ss, bw=10)
                    CORE_SWITCHES.append(s)
                    CORE_SWITCHES.append(ss)
            if j > noCore:  # 6 edge switches
                net.addLink(s, CORE_SWITCHES[j - 11], bw=10)
                net.addLink(s, CORE_SWITCHES[j - 12], bw=10)
                info('*** Adding hosts to switch\n')
                for h in range(n):
                    host = net.addHost('h%s' % (h + j * sw))
                    net.addLink(host, s)
                break

    net.start()
    flowCounter = 0
    mu = 0.05  # average flow duration 1/mu 20 s
    flowStartAfter = random.expovariate(lamda)
    flowStartTime = flowStartAfter
    print(flowStartAfter)
    while (experimentDuration > flowStartTime):
        time.sleep(flowStartAfter)
        hostPair = random.sample(net.hosts, 2)
        src, dst = hostPair  # a tuple of Mininet host objects
        flowDuration = random.expovariate(mu)
        print(flowDuration)
        x = 'c' + str(flowDuration)
        #src.cmd( 'ping -%s'%x, dst.IP(), '1> /tmp/h1.out 2>/tmp/h1.err &' )
        src.cmd('iperf -s &')
        dst.cmd('iperf -c', src.IP(), '-t %s &' % flowDuration)
        flowStartAfter = random.expovariate(lamda)
        flowStartTime = flowStartTime + flowStartAfter
        print(flowStartAfter)
        print(flowStartTime)
        flowCounter = flowCounter + 1
    print(flowCounter)
    CLI(net)
Example #33
0
def topology():
    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    os.system('clear')
    parser = argparse.ArgumentParser(
        description='Compute Access Points over-reservation.')
    parser.add_argument("-aps",
                        metavar='APs',
                        type=int,
                        default=6,
                        help='amount of aps (default: 6)')
    parser.add_argument("-cosA",
                        metavar='MOs',
                        type=int,
                        default=0,
                        help='amount of MOs in CoS A (default: 0)')  # TBD
    parser.add_argument("-cosB",
                        metavar='MOs',
                        type=int,
                        default=0,
                        help='amount of MOs in CoS B (default: 0)')  # TBD
    parser.add_argument("-cosC",
                        metavar='MOs',
                        type=int,
                        default=0,
                        help='amount of MOs in CoS C (default: 0)')  # TBD
    args = parser.parse_args()

    print "*** Starting Simulation..."
    time.sleep(1)

    print "*** Starting Controller"
    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           port=6633)  # Add Controller
    s0 = net.addSwitch('s0')
    s11 = net.addSwitch('s11')
    s12 = net.addSwitch('s12')
    sc1 = net.addSwitch('sc1')
    sc2 = net.addSwitch('sc2')
    sc3 = net.addSwitch('sc3')
    sc4 = net.addSwitch('sc4')
    sc5 = net.addSwitch('sc5')
    sc6 = net.addSwitch('sc6')
    ap0 = net.addBaseStation('ap0', ssid='ssid_0', mode='g', channel='1')

    sta0 = net.addStation('sta0', ip="10.0.100.1")
    sta00 = net.addStation('sta00', ip="10.0.100.2")
    sta000 = net.addStation('sta000', ip="10.0.100.3")

    print "*** Creating PoAs"  # Cria e faz bootstrapping dos PoAs
    for i in range(1, args.aps + 1):
        print("\nCreating AP" + str(i) + "...")

        globals()['ap%s' % i] = net.addBaseStation(
            'ap' + str(i), ssid="ssid_" + str(i), mode="g",
            channel="1")  # Add AP/PoA   -> ap1 = net.addBaseStation
        globals()['ap%s' % i].start([c0])  # Start AP/PoA -> ap1.start( [c0] )
        print("Bootstrapping PoA" + str(i) + "...")
        print("Displaying PoA Pool" + "...")

    # Definicao da quantidade de MOs em cada CoS
    print "***Initializing scenario"
    cosA_MO = 1  # amount of MO in the CoSA
    cosB_MO = 1
    cosC_MO = 1
    cosX_MO = [cosC_MO, cosB_MO, cosA_MO]
    mn = 1
    sta_list = []

    # Scenario initialization - Criacao de todos os Stations (Necessario antes de addLink)
    print "*** Creating nodes"
    for mo in cosX_MO:
        for m in range(1, mo + 1):
            mo_name = 'sta' + str(mn)
            if (mn == 1):
                globals()['sta%s' % mn] = net.addStation(mo_name,
                                                         ip="10.0.0." +
                                                         str(mn),
                                                         wlans=2)
            else:
                globals()['sta%s' % mn] = net.addStation(mo_name,
                                                         ip="10.0.0." +
                                                         str(mn))
            sta_list.append("sta" + str(mn))
            mn += 1
    print sta_list

    # Initializes scenario in AP0
    mn = 1
    for mo in cosX_MO:
        for m in range(1, mo + 1):
            mo_name = 'sta' + str(mn)
            net.addLink(sta_list[mn - 1], ap0)
            sta = globals()['sta%s' % mn]
            sta.cmdPrint("sudo python ./scripts/server.py -ip 10.0.0." +
                         str(mn) + " -p 8088 &")
            sta.cmdPrint("sudo ./scripts/iperf_client.sh &")
            mn += 1

    print "*** Creating link between devices"
    #	for poa in range(1, args.aps+1):
    #		net.addLink(globals()['ap%s' % poa], s0)

    print "*** Adding link between devices"
    net.addLink(sc6, ap6)
    net.addLink(sc6, ap5)
    net.addLink(sc6, ap4)
    net.addLink(sc5, ap3)
    net.addLink(sc5, ap2)
    net.addLink(sc5, ap1)
    net.addLink(sc3, sc4)
    net.addLink(sc1, sc3)
    net.addLink(s12, sc3)
    net.addLink(s12, sc1)
    net.addLink(sc4, sc6)
    net.addLink(sc2, sc4)
    net.addLink(sc2, sc1)
    net.addLink(s11, sc1)
    net.addLink(sc5, ap0)
    net.addLink(sc2, sc5)
    net.addLink(s11, sc2)
    net.addLink(s0, sc2)
    net.addLink(s11, s0)

    #	net.addLink(sta0, s0)
    #	net.addLink(sta00, s11)
    #	net.addLink(sta000, s11)

    print "*** Starting network"
    net.build()
    c0.start()
    s0.start([c0])
    s11.start([c0])
    sc2.start([c0])
    sc5.start([c0])
    sc1.start([c0])
    sc4.start([c0])
    sc6.start([c0])
    s12.start([c0])
    sc3.start([c0])
    ap0.start([c0])
    ap1.start([c0])
    ap2.start([c0])
    ap3.start([c0])
    ap4.start([c0])
    ap5.start([c0])
    ap6.start([c0])

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #34
0
def myNetwork():

    net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8')

    info('*** Adding controller\n')
    c0 = net.addController(name='c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           protocol='tcp',
                           port=6653)

    info('*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch)
    s6 = net.addSwitch('s6', cls=OVSKernelSwitch)
    s7 = net.addSwitch('s7', cls=OVSKernelSwitch)

    info('*** Add hosts\n')
    h1 = net.addHost('h1',
                     cls=Host,
                     ip='10.0.0.1',
                     mac='00:00:00:00:00:01',
                     defaultRoute=None)
    h2 = net.addHost('h2',
                     cls=Host,
                     ip='10.0.0.2',
                     mac='00:00:00:00:00:02',
                     defaultRoute=None)
    h3 = net.addHost('h3',
                     cls=Host,
                     ip='10.0.0.3',
                     mac='00:00:00:00:00:03',
                     defaultRoute=None)
    h4 = net.addHost('h4',
                     cls=Host,
                     ip='10.0.0.4',
                     mac='00:00:00:00:00:04',
                     defaultRoute=None)
    h5 = net.addHost('h5',
                     cls=Host,
                     ip='10.0.0.5',
                     mac='00:00:00:00:00:05',
                     defaultRoute=None)
    h6 = net.addHost('h6',
                     cls=Host,
                     ip='10.0.0.6',
                     mac='00:00:00:00:00:06',
                     defaultRoute=None)
    h7 = net.addHost('h7',
                     cls=Host,
                     ip='10.0.0.7',
                     mac='00:00:00:00:00:07',
                     defaultRoute=None)

    info('*** Add links\n')
    h1s5 = {'bw': 1000}
    net.addLink(h1, s5, cls=TCLink, **h1s5)
    s5h2 = {'bw': 1000}
    net.addLink(s5, h2, cls=TCLink, **s5h2)
    s5h3 = {'bw': 1000}
    net.addLink(s5, h3, cls=TCLink, **s5h3)
    s5h4 = {'bw': 1000}
    net.addLink(s5, h4, cls=TCLink, **s5h4)
    s5s2 = {'bw': 1000}
    net.addLink(s5, s2, cls=TCLink, **s5s2)
    s5s3 = {'bw': 1000}
    net.addLink(s5, s3, cls=TCLink, **s5s3)
    s2s1 = {'bw': 1000}
    net.addLink(s2, s1, cls=TCLink, **s2s1)
    s3s4 = {'bw': 1000}
    net.addLink(s3, s4, cls=TCLink, **s3s4)
    s4s1 = {'bw': 1000}
    net.addLink(s4, s1, cls=TCLink, **s4s1)
    s1s6 = {'bw': 1000}
    net.addLink(s1, s6, cls=TCLink, **s1s6)
    s1s7 = {'bw': 1000}
    net.addLink(s1, s7, cls=TCLink, **s1s7)
    s6h5 = {'bw': 1000}
    net.addLink(s6, h5, cls=TCLink, **s6h5)
    s7h6 = {'bw': 1000}
    net.addLink(s7, h6, cls=TCLink, **s7h6)
    s7h7 = {'bw': 1000}
    net.addLink(s7, h7, cls=TCLink, **s7h7)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('s1').start([c0])
    net.get('s2').start([c0])
    net.get('s3').start([c0])
    net.get('s4').start([c0])
    net.get('s5').start([c0])
    net.get('s6').start([c0])
    net.get('s7').start([c0])

    info('*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
def topology():
    "Create a network."
    net = Mininet(controller=Controller,
                  link=TCLink,
                  switch=OVSKernelSwitch,
                  accessPoint=OVSKernelAP)
    global gnet
    gnet = net

    print "*** Creating nodes "
    car = []
    stas = []
    for x in range(0, 4):
        car.append(x)
        stas.append(x)
    for x in range(0, 4):
        car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \
        mac='00:00:00:00:00:0%s' % x, mode='b')

    eNodeB1 = net.addAccessPoint('eNodeB1',
                                 ssid='eNodeB1',
                                 dpid='1000000000000000',
                                 mode='ac',
                                 channel='1',
                                 position='80,75,0',
                                 range=60)
    eNodeB2 = net.addAccessPoint('eNodeB2',
                                 ssid='eNodeB2',
                                 dpid='2000000000000000',
                                 mode='ac',
                                 channel='6',
                                 position='180,75,0',
                                 range=70)
    rsu1 = net.addAccessPoint('rsu1',
                              ssid='rsu1',
                              dpid='3000000000000000',
                              mode='g',
                              channel='11',
                              position='140,120,0',
                              range=40)
    c1 = net.addController('c1', controller=Controller)
    client = net.addHost('client')
    switch = net.addSwitch('switch', dpid='4000000000000000')

    net.plotNode(client, position='125,230,0')
    net.plotNode(switch, position='125,200,0')

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Creating links "
    net.addLink(eNodeB1, switch)
    net.addLink(eNodeB2, switch)
    net.addLink(rsu1, switch)
    net.addLink(switch, client)

    print "*** Starting network"
    net.build()
    c1.start()
    eNodeB1.start([c1])
    eNodeB2.start([c1])
    rsu1.start([c1])
    switch.start([c1])

    for sw in net.vehicles:
        sw.start([c1])

    print "*** Configuring interfaces "

    i = 1
    j = 2
    for c in car:
        c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i))
        c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i))
        c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2

    i = 1
    j = 2
    for v in net.vehiclesSTA:
        v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j))
        v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i))
        v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for v1 in net.vehiclesSTA:
        i = 1
        j = 1
        for v2 in net.vehiclesSTA:
            if v1 != v2:
                v1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i))
            i += 1
            j += 2

    client.cmd('ifconfig client-eth0 200.0.10.2')
    net.vehiclesSTA[0].cmd('ifconfig car0STA-eth0 200.0.10.50')

    # Bonding interfaces for car0

    car[0].cmd('modprobe bonding mode=3')
    car[0].cmd('ip link add bond0 type bond')
    car[0].cmd('ip link set bond0 address 02:01:02:03:04:08')
    car[0].cmd('ip link set car0-eth0 down')
    car[0].cmd('ip link set car0-eth0 address 00:00:00:00:00:11')
    car[0].cmd('ip link set car0-eth0 master bond0')
    car[0].cmd('ip link set car0-wlan0 down')
    car[0].cmd('ip link set car0-wlan0 address 00:00:00:00:00:15')
    car[0].cmd('ip link set car0-wlan0 master bond0')
    car[0].cmd('ip link set car0-wlan1 down')
    car[0].cmd('ip link set car0-wlan1 address 00:00:00:00:00:13')
    car[0].cmd('ip link set car0-wlan1 master bond0')
    car[0].cmd('ip addr add 200.0.10.100/24 dev bond0')
    car[0].cmd('ip link set bond0 up')

    # more configuring and routing commands

    car[3].cmd('ifconfig car3-wlan0 200.0.10.150')

    client.cmd('ip route add 192.168.1.8 via 200.0.10.150')
    client.cmd('ip route add 10.0.0.1 via 200.0.10.150')

    net.vehiclesSTA[3].cmd('ip route add 200.0.10.2 via 192.168.1.7')
    net.vehiclesSTA[3].cmd('ip route add 200.0.10.100 via 10.0.0.1')
    net.vehiclesSTA[0].cmd('ip route add 200.0.10.2 via 10.0.0.4')

    car[0].cmd('ip route add 10.0.0.4 via 200.0.10.50')
    car[0].cmd('ip route add 192.168.1.7 via 200.0.10.50')
    car[0].cmd('ip route add 200.0.10.2 via 200.0.10.50')
    car[3].cmd('ip route add 200.0.10.100 via 192.168.1.8')

    car[0].cmdPrint(
        "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'car0' &")
    #car[3].cmdPrint("xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'car3' &")
    client.cmdPrint(
        "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'client' &")
    """plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()

    # remove previous data
    os.system('rm *.vanetdata')

    # stream video using VLC

    car[0].cmdPrint(
        "vlc -vvv /home/mininet/Desktop/bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,mux=ts},dst=display}' :sout-keep &"
    )
    client.cmdPrint("vlc rtp://@200.0.10.2:5004 &")

    # starting positions for cars

    car[0].moveNodeTo('110,100,0')
    car[1].moveNodeTo('80,100,0')
    car[2].moveNodeTo('65,100,0')
    car[3].moveNodeTo('50,100,0')

    # delete all previous flow rules

    os.system('ovs-ofctl del-flows switch')

    # sleep...

    time.sleep(3)

    # start experiment, 20 secs for each phase

    apply_experiment(car, client, switch)

    # Uncomment the line below to generate the graph that you implemented
    graphic()

    # kills all the xterms that have been opened
    #os.system('pkill xterm')

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def myNetwork():

    net = Mininet(topo=None,
                  build=False,
                  ipBase='10.0.0.0/8',
                  host=CPULimitedHost,
                  link=TCLink)

    info('*** Adding controller\n')
    c0 = net.addController(name='c0',
                           controller=Controller,
                           protocol='tcp',
                           port=6633)

    #print("Going to sleep for 10 seconds")
    #time.sleep(10)
    #c0 = RemoteController( 'c0', protocol='tcp', port= 6653) # this is for external Floodlight controller
    #net.addController(c0)

    info('*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch)
    s6 = net.addSwitch('s6', cls=OVSKernelSwitch)
    s7 = net.addSwitch('s7', cls=OVSKernelSwitch)
    s8 = net.addSwitch('s8', cls=OVSKernelSwitch)
    s9 = net.addSwitch('s9', cls=OVSKernelSwitch)
    s10 = net.addSwitch('s10', cls=OVSKernelSwitch)
    s11 = net.addSwitch('s11', cls=OVSKernelSwitch)
    s12 = net.addSwitch('s12', cls=OVSKernelSwitch)
    s13 = net.addSwitch('s13', cls=OVSKernelSwitch)
    s14 = net.addSwitch('s14', cls=OVSKernelSwitch)

    info('*** Add hosts\n')
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
    h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
    h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
    h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None)
    h8 = net.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None)

    info('*** Add links\n')
    #adds a bidirectional link with bandwidth, delay and loss characteristics,
    #with a maximum queue size of 1000 packets using the Hierarchical Token Bucket rate limiter
    linkopts = dict(bw=15,
                    delay='1ms',
                    loss=1,
                    max_queue_size=1000,
                    use_htb=True)

    net.addLink(s1, h1, **linkopts)
    net.addLink(s1, s2, **linkopts)
    net.addLink(s2, s3, **linkopts)
    net.addLink(s3, s5, **linkopts)
    net.addLink(s5, s6, **linkopts)
    net.addLink(s6, h2, **linkopts)
    net.addLink(s1, s4, **linkopts)
    net.addLink(s2, s7, **linkopts)
    net.addLink(s7, s8, **linkopts)
    net.addLink(s8, h3, **linkopts)
    net.addLink(s7, s9, **linkopts)
    net.addLink(s9, s10, **linkopts)
    net.addLink(s10, s11, **linkopts)
    net.addLink(s11, s12, **linkopts)
    net.addLink(s12, h4, **linkopts)
    net.addLink(s10, h5, **linkopts)
    net.addLink(s9, s13, **linkopts)
    net.addLink(s13, s14, **linkopts)
    net.addLink(s14, h7, **linkopts)
    net.addLink(s14, h8, **linkopts)
    net.addLink(s13, h6, **linkopts)
    # Adding 3 links to improve network survivability
    net.addLink(h7, s2, **linkopts)
    net.addLink(h7, s10, **linkopts)
    net.addLink(h7, s13, **linkopts)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('s1').start([c0])
    net.get('s2').start([c0])
    net.get('s3').start([c0])
    net.get('s4').start([c0])
    net.get('s5').start([c0])
    net.get('s6').start([c0])
    net.get('s7').start([c0])
    net.get('s8').start([c0])
    net.get('s9').start([c0])
    net.get('s10').start([c0])
    net.get('s11').start([c0])
    net.get('s12').start([c0])
    net.get('s13').start([c0])
    net.get('s14').start([c0])

    #CLI(net) # Opens up mininet terminal, use to run 'pingall'

    info('*** Post configure switches and hosts\n')
    hosts = net.hosts
    server = hosts[6]  # host[0] is h2
    outfiles, capfiles, errfiles = {}, {}, {}

    for h in hosts:
        #h.cmdPrint('IP address of', h) #, h.name.IP())
        outfiles[
            h] = './simpleNet/out/%s.out' % h.name  # to store the output of ping command for client to server
        capfiles[
            h] = './simpleNet/cap/%s.txt' % h.name  #cap file to store the output of tcpdump command
        errfiles[h] = './simpleNet/err/%s.err' % h.name

    newHosts = {hosts[1]}
    h7 = {hosts[6]}  # set h1 as a ping sender, i.e., client
    h1 = {hosts[1]}

    serverHost = {hosts[6]}

    for h in serverHost:
        h.cmdPrint('tcpdump -n -i h7-eth0', '>', capfiles[h], '2>',
                   errfiles[h], '&')

    print('IP address of the server is %s', server.IP())

    for h in newHosts:
        #ping -w option
        #This option sets the required running Time window value in second

        # Commented out call to 'ping' utility
        h.cmdPrint(
            'ping -w 80',
            server.IP(),  # CHANGED: -w 20 => -w 40
            '>',
            outfiles[h],
            '2>',
            errfiles[h])

        #server.cmdPrint('iperf -s -u -p 5566 -i 10',
        #               '>', outfiles[ h ],
        #               '2>', errfiles[ h ],
        #              '&' )
        #bandwidth=6
        #running_time=100
        #h.cmd('iperf -c %s -u -b %sM -p 5566 -t %s' % (server.IP(),bandwidth, running_time))

    #CLI(net)
    net.stop()
Example #37
0
def myNetwork():

    net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8')

    info('*** Adding controller\n')
    c0 = net.addController(name='c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           protocol='tcp',
                           port=6653)

    info('*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch)

    info('*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='192.168.1.1', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='192.168.1.2', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='192.168.1.3', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='192.168.1.4', defaultRoute=None)
    h5 = net.addHost('h5', cls=Host, ip='192.168.2.1', defaultRoute=None)
    h6 = net.addHost('h6', cls=Host, ip='192.168.2.2', defaultRoute=None)
    h7 = net.addHost('h7', cls=Host, ip='192.168.2.3', defaultRoute=None)
    h8 = net.addHost('h8', cls=Host, ip='192.168.2.4', defaultRoute=None)
    h9 = net.addHost('h9', cls=Host, ip='192.168.3.1', defaultRoute=None)
    h10 = net.addHost('h10', cls=Host, ip='192.168.3.2', defaultRoute=None)
    h11 = net.addHost('h11', cls=Host, ip='192.168.3.3', defaultRoute=None)
    h12 = net.addHost('h12', cls=Host, ip='192.168.3.4', defaultRoute=None)
    h13 = net.addHost('h13', cls=Host, ip='192.168.4.1', defaultRoute=None)
    h14 = net.addHost('h14', cls=Host, ip='192.168.4.2', defaultRoute=None)
    h15 = net.addHost('h15', cls=Host, ip='192.168.4.3', defaultRoute=None)
    h16 = net.addHost('h16', cls=Host, ip='192.168.4.4', defaultRoute=None)

    info('*** Add links\n')
    net.addLink(s1, h1)
    net.addLink(s1, h2)
    net.addLink(s1, h3)
    net.addLink(s2, h5)
    net.addLink(s2, h6)
    net.addLink(s3, h9)
    s5s1 = {'bw': 100}
    net.addLink(s5, s1, cls=TCLink, **s5s1)
    s5s2 = {'bw': 100}
    net.addLink(s5, s2, cls=TCLink, **s5s2)
    s5s3 = {'bw': 100}
    net.addLink(s5, s3, cls=TCLink, **s5s3)
    s5s4 = {'bw': 100}
    net.addLink(s5, s4, cls=TCLink, **s5s4)
    net.addLink(s1, h4)
    net.addLink(s2, h7)
    net.addLink(s2, h8)
    net.addLink(s3, h10)
    net.addLink(s3, h11)
    net.addLink(s3, h12)
    net.addLink(s4, h13)
    net.addLink(s4, h14)
    net.addLink(s4, h15)
    net.addLink(s4, h16)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('s1').start([c0])
    net.get('s2').start([c0])
    net.get('s3').start([c0])
    net.get('s4').start([c0])
    net.get('s5').start([c0])

    info('*** Post configure switches and hosts\n')
    s1.cmd('ifconfig s1 192.168.1.250')
    s2.cmd('ifconfig s2 192.168.2.250')
    s3.cmd('ifconfig s3 192.168.3.250')
    s4.cmd('ifconfig s4 192.168.4.250')
    s5.cmd('ifconfig s5 192.168.5.250')

    h1.cmd('ip route add 0.0.0.0/0 dev h1-eth0 scope link')
    h2.cmd('ip route add 0.0.0.0/0 dev h2-eth0 scope link')
    h3.cmd('ip route add 0.0.0.0/0 dev h3-eth0 scope link')
    h4.cmd('ip route add 0.0.0.0/0 dev h4-eth0 scope link')
    h5.cmd('ip route add 0.0.0.0/0 dev h5-eth0 scope link')
    h6.cmd('ip route add 0.0.0.0/0 dev h6-eth0 scope link')
    h7.cmd('ip route add 0.0.0.0/0 dev h7-eth0 scope link')
    h8.cmd('ip route add 0.0.0.0/0 dev h8-eth0 scope link')
    h9.cmd('ip route add 0.0.0.0/0 dev h9-eth0 scope link')
    h10.cmd('ip route add 0.0.0.0/0 dev h10-eth0 scope link')
    h11.cmd('ip route add 0.0.0.0/0 dev h11-eth0 scope link')
    h12.cmd('ip route add 0.0.0.0/0 dev h12-eth0 scope link')
    h13.cmd('ip route add 0.0.0.0/0 dev h13-eth0 scope link')
    h14.cmd('ip route add 0.0.0.0/0 dev h14-eth0 scope link')
    h15.cmd('ip route add 0.0.0.0/0 dev h15-eth0 scope link')
    h16.cmd('ip route add 0.0.0.0/0 dev h16-eth0 scope link')

    CLI(net)
    net.stop()
Example #38
0
def setupTopology(controller_addr):
    global net, c1, s1, s2, s3
    global h1, h2, h3, h4, h5, h6, h7, h8, h9, h10
    "Create and run multiple link network"

    net = Mininet(controller=RemoteController)

    print "mininet created"

    c1 = net.addController('c1', ip=controller_addr, port=6653)

    # h1: IOT Device.
    # h2 : StatciDHCPD
    # h3 : router / NAT
    # h4 : Non IOT device.

    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 = net.addHost('h3')
    h4 = net.addHost('h4')
    h5 = net.addHost('h5')
    h6 = net.addHost('h6')
    h7 = net.addHost('h7')
    h8 = net.addHost('h8')
    h9 = net.addHost('h9')
    h10 = net.addHost('h10')

    hosts.append(h1)
    hosts.append(h2)
    hosts.append(h3)
    hosts.append(h4)
    hosts.append(h5)
    hosts.append(h6)
    hosts.append(h7)
    hosts.append(h8)
    hosts.append(h9)
    hosts.append(h10)

    s2 = net.addSwitch('s2', dpid="2")
    s3 = net.addSwitch('s3', dpid="3")
    s1 = net.addSwitch('s1', dpid="1")

    s1.linkTo(h1)
    s1.linkTo(h2)
    s1.linkTo(h3)
    s1.linkTo(h4)
    s1.linkTo(h5)
    s1.linkTo(h6)
    s1.linkTo(h7)

    s2.linkTo(h8)
    s3.linkTo(h8)

    s3.linkTo(h9)
    s3.linkTo(h10)

    # S2 is the NPE switch.
    # Direct link between S1 and S2
    s1.linkTo(s2)

    h8.cmdPrint('echo 0 > /proc/sys/net/ipv4/ip_forward')
    # Flush old rules.
    h8.cmdPrint('iptables -F')
    h8.cmdPrint('iptables -t nat -F')
    h8.cmdPrint('iptables -t mangle -F')
    h8.cmdPrint('iptables -X')
    h8.cmdPrint('echo 1 > /proc/sys/net/ipv4/ip_forward')

    # Set up h3 to be our router (it has two interfaces).
    # Set up iptables to forward as NAT
    h8.cmdPrint(
        'iptables -t nat -A POSTROUTING -o h8-eth1 -s 10.0.0.0/24 -j MASQUERADE'
    )

    net.build()
    net.build()
    c1.start()
    s1.start([c1])
    s2.start([c1])
    s3.start([c1])

    net.start()

    # Clean up any traces of the previous invocation (for safety)

    h1.setMAC("00:00:00:00:00:01", "h1-eth0")
    h2.setMAC("00:00:00:00:00:02", "h2-eth0")
    h3.setMAC("00:00:00:00:00:03", "h3-eth0")
    h4.setMAC("00:00:00:00:00:04", "h4-eth0")
    h5.setMAC("00:00:00:00:00:05", "h5-eth0")
    h6.setMAC("00:00:00:00:00:06", "h6-eth0")
    h7.setMAC("00:00:00:00:00:07", "h7-eth0")
    h8.setMAC("00:00:00:00:00:08", "h8-eth0")
    h9.setMAC("00:00:00:00:00:09", "h9-eth0")
    h10.setMAC("00:00:00:00:00:10", "h10-eth0")

    # Set up a routing rule on h2 to route packets via h3
    h1.cmdPrint('ip route del default')
    h1.cmdPrint('ip route add default via 10.0.0.8 dev h1-eth0')

    # Set up a routing rule on h2 to route packets via h3
    h2.cmdPrint('ip route del default')
    h2.cmdPrint('ip route add default via 10.0.0.8 dev h2-eth0')

    # Set up a routing rule on h2 to route packets via h7
    h3.cmdPrint('ip route del default')
    h3.cmdPrint('ip route add default via 10.0.0.8 dev h3-eth0')

    # Set up a routing rule on h2 to route packets via h3
    h4.cmdPrint('ip route del default')
    h4.cmdPrint('ip route add default via 10.0.0.8 dev h4-eth0')

    # Set up a routing rule on h5 to route packets via h3
    h5.cmdPrint('ip route del default')
    h5.cmdPrint('ip route add default via 10.0.0.8 dev h5-eth0')

    # h6 is a localhost.
    h6.cmdPrint('ip route del default')
    h6.cmdPrint('ip route add default via 10.0.0.8 dev h6-eth0')

    # The IDS runs on h8
    h7.cmdPrint('ip route del default')
    h7.cmdPrint('ip route add default via 10.0.0.8 dev h7-eth0')

    # h9 is our fake host. It runs our "internet" web server.
    h9.cmdPrint('ifconfig h9-eth0 203.0.113.13 netmask 255.255.255.0')
    # Start a web server there.

    # h10 is our second fake host. It runs another internet web server that we cannot reach
    h10.cmdPrint('ifconfig h10-eth0 203.0.113.14 netmask 255.255.255.0')

    # Start dnsmasq (our dns server).
    h5.cmdPrint(
        '/usr/sbin/dnsmasq --server  10.0.4.3 --pid-file=/tmp/dnsmasq.pid')

    # Set up our router routes.
    h8.cmdPrint('ip route add 203.0.113.13/32 dev h8-eth1')
    h8.cmdPrint('ip route add 203.0.113.14/32 dev h8-eth1')
    h8.cmdPrint('ifconfig h8-eth1 203.0.113.1 netmask 255.255.255.0')

    #subprocess.Popen(cmd,shell=True,  stdin= subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False)
    if os.environ.get("UNITTEST") is None or os.environ.get("UNITTEST") == '0':
        h9.cmdPrint("python -m SimpleHTTPServer 80&")
        h4.cmdPrint("python -m SimpleHTTPServer 80&")
        #h3.cmdPrint("python ../util/udpping.py --port 8008 --server &")
        #h2.cmdPrint("python ../util/udpping.py --port 8008 --server &")
        #h3.cmdPrint("python ../util/tcp-server.py -P 8010 -H 10.0.0.3 -T 10000 -C&")

    # Start the IDS on node 8

    print "*********** System ready *********"
"""Custom topology example

Two directly connected switches plus a host for each switch:

   host --- switch --- switch --- host

Adding the 'topos' dict with a key/value pair to generate our newly defined
topology enables one to pass in '--topo=mytopo' from the command line.
"""
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.node import OVSSwitch, Controller, RemoteController

net = Mininet(controller=RemoteController)
c0 = net.addController('c0',
                       controller=RemoteController,
                       ip="192.168.1.74",
                       port=6633)
# Adding
h0 = net.addHost('h0')
s0 = net.addSwitch('s0')
h1 = net.addHost('h1')
net.addLink(h0, s0)
net.addLink(h1, s0)

net.start()
net.pingAll()
CLI(net)
Example #40
0
def createNetwork():
	#send rate at each link in Mbps
	bwg = 1 #in Mbps
	bwbn = 1 #in Mbps
	loss = 8 #in %
	mqs = 100 #max queue size of interfaces
	dly = '2.5ms'

	#create empty network
	net = Mininet(intf=TCIntf)

	info( '\n*** Adding controller\n' )
	net.addController( 'c0' ) #is it ok ?

	#add host to topology
	ht = net.addHost( 'ht', ip='10.10.0.1/24' )
	hu = net.addHost( 'hu', ip='10.10.0.2/24' )
	it = net.addHost( 'it', ip='10.20.0.1/24' )
	iu = net.addHost( 'iu', ip='10.20.0.2/24' )

	rh = net.addHost('rh', ip='10.10.0.10/24')
	ri = net.addHost('ri', ip='10.20.0.20/24')

	info('\n** Adding Switches\n')
	# Adding 2 switches to the network
	sw1 = net.addSwitch('sw1')
	sw2 = net.addSwitch('sw2')

	info('\n** Creating Links \n')
	#create link beetween the network
	link_ht_sw1 = net.addLink( ht, sw1)
	link_hu_sw1 = net.addLink( hu, sw1)
	link_rh_sw1 = net.addLink( rh, sw1, intfName1='rh-eth0')

	link_it_sw2 = net.addLink( it, sw2)
	link_iu_sw2 = net.addLink( iu, sw2)
	link_ri_sw2 = net.addLink( ri, sw2, intfName1='ri-eth0')

	link_rh_ri  = net.addLink( rh, ri, intfName1='rh-eth1', intfName2='ri-eth1')


	#set bandwith
	link_ht_sw1.intf1.config( bw = bwbn, max_queue_size = mqs)
	link_hu_sw1.intf1.config( bw = bwbn, max_queue_size = mqs)
	link_rh_sw1.intf1.config( bw = bwbn, max_queue_size = mqs) #max_queue_size is hardcoded low to prevent bufferbloat, too high queuing delays

	link_it_sw2.intf1.config( bw = bwg, max_queue_size = mqs)
	link_iu_sw2.intf1.config( bw = bwg, max_queue_size = mqs)
	link_ri_sw2.intf1.config( bw = bwg, max_queue_size = mqs, delay=dly) #delay is set at ri on both interfaces

	link_rh_ri.intf1.config(  bw = bwg, max_queue_size = mqs, loss=loss) #loss is set at rh on its interface to ri only

	link_ht_sw1.intf2.config( bw = bwbn, max_queue_size = mqs)
	link_hu_sw1.intf2.config( bw = bwbn, max_queue_size = mqs)
	link_rh_sw1.intf2.config( bw = bwbn, max_queue_size = mqs)

	link_it_sw2.intf2.config( bw = bwg, max_queue_size = mqs)
	link_iu_sw2.intf2.config( bw = bwg, max_queue_size = mqs)
	link_ri_sw2.intf2.config( bw = bwg, max_queue_size = mqs)

	link_rh_ri.intf2.config(  bw = bwg, max_queue_size = mqs,  delay=dly) #delay is set at ri on both interfaces

	net.start()

	info( '\n*** Configuring hosts\n' )

	rh.cmd('ifconfig rh-eth1 10.12.0.10 netmask 255.255.255.0') #reconfiguring mutiples intefaces host to prevent mininet strange initialisation behaviors
	rh.cmd('ifconfig rh-eth0 10.10.0.10 netmask 255.255.255.0')
	rh.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward') #enable forwarding at routers

	ri.cmd('ifconfig ri-eth1 10.12.0.20 netmask 255.255.255.0') #reconfiguring mutiples intefaces host to prvent mininet strange initialisation behaviors
	ri.cmd('ifconfig ri-eth0 10.20.0.20 netmask 255.255.255.0')
	ri.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward') #enable forwarding at routers

	#configure host default gateways
	ht.cmd('ip route add default via 10.10.0.10')
	hu.cmd('ip route add default via 10.10.0.10')
	it.cmd('ip route add default via 10.20.0.20')
	iu.cmd('ip route add default via 10.20.0.20')

	#configure router routing tables
	rh.cmd('ip route add default via 10.12.0.20')
	ri.cmd('ip route add default via 10.12.0.10')

        # weiyu:
        iu.cmd('touch server.pcap')
        hu.cmd('touch client.pcap')


        rh.cmd('tc qdisc del dev rh-eth1 root')

	start_nodes(rh, ri, iu, hu, mqs) #experiment actions

	it.cmd('ethtool -K it-eth0 tx off sg off tso off') #disable TSO on TCP on defaul TCP sender need to be done on other host if sending large TCP file from other nodes

	time.sleep(1)

	# Enable the mininet> prompt if uncommented
 	info('\n*** Running CLI\n')
	CLI(net)

	# stops the simulation
	net.stop()
Example #41
0
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.term import makeTerm

if '__main__' == __name__:

    net = Mininet(controller=RemoteController)
    c0 = net.addController('c0', ip='192.168.99.123', port=6633)

    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')

    h1 = net.addHost('h1', mac='00:00:00:00:00:01')
    h2 = net.addHost('h2', mac='00:00:00:00:00:02')
    h3 = net.addHost('h3', mac='00:00:00:00:00:03')
    net.addLink(s1, h1)
    net.addLink(s2, h2)
    net.addLink(s3, h3)
    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(s3, s1)

    net.build()
    c0.start()
    s1.start([c0])
    s2.start([c0])
    s3.start([c0])
    CLI(net)
    net.stop()
Example #42
0
             ⁴                ³
    H2 ²---² S2 ³----------⁴ S3 ²---² H3

    The little numbers are the switch ports.
    """

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

#hosts
h1 = net.addHost('h1')
h2 = net.addHost('h2')
h3 = net.addHost('h3')
h4 = net.addHost('h4')

#Switches
s1 = net.addSwitch('s1', protocols="OpenFlow13")
s2 = net.addSwitch('s2', protocols="OpenFlow13")
s3 = net.addSwitch('s3', protocols="OpenFlow13")
s4 = net.addSwitch('s4', protocols="OpenFlow13")

c0 = net.addController('c0', ip='127.0.0.1', port=6633)

#adding links
net.addLink(h1, s1, port1=2, port2=2)
net.addLink(h2, s2, port1=2, port2=2)
net.addLink(h3, s3, port1=2, port2=2)
net.addLink(h4, s4, port1=2, port2=2)
net.addLink(s1, s2, port1=3, port2=4)
net.addLink(s2, s3, port1=3, port2=4)
net.addLink(s3, s4, port1=3, port2=4)
net.addLink(s4, s1, port1=3, port2=4)
Example #43
0
from mininet.topolib import TreeTopo
from mininet.topo import Topo
from mininet.node import Controller, RemoteController, OVSController
from mininet.log import setLogLevel, info, error
from mininet.link import Intf
from mininet.util import quietRun

net = Mininet()

#Define controller
c0 = net.addController('c0', controller=RemoteController, ip='10.100.0.3', port=6633)
host1 = net.addHost('host1')
host2 = net.addHost('host2')

#Give switch real interface
s3 = net.addSwitch('s3')
s2 = net.addSwitch('s2')
_intf = Intf( 'ens192', node=s3 )

#Create links between nodes
net.addLink(host1, s3)
net.addLink(host2, s3)
net.addLink(s3, s2)

#Configure IP addresses
host1.setIP(self,'10.100.0.100',8,None)
host2.setIP(self,'10.100.0.101',8,None)

#h0.cmd("route del -net 0.0.0.0")
#h0.cmd("route add -net 10.100.0.0 netmask 255.255.255.0 " + h0int)
Example #44
0
def myNetwork():

    net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8')

    info('*** Adding controller\n')
    c0 = net.addController(name='c0',
                           controller=RemoteController,
                           ip='192.168.1.3',
                           protocol='tcp',
                           port=6633)

    info('*** Add switches\n')
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
    s11 = net.addSwitch('s11', cls=OVSKernelSwitch)
    s8 = net.addSwitch('s8', cls=OVSKernelSwitch)
    s12 = net.addSwitch('s12', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch)
    s9 = net.addSwitch('s9', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s10 = net.addSwitch('s10', cls=OVSKernelSwitch)
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s7 = net.addSwitch('s7', cls=OVSKernelSwitch)
    s6 = net.addSwitch('s6', cls=OVSKernelSwitch)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)

    info('*** Add hosts\n')
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
    h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)

    info('*** Add links\n')
    net.addLink(h1, s1)
    s1s3 = {'bw': 1000}
    net.addLink(s1, s3, cls=TCLink, **s1s3)
    s3s6 = {'bw': 1000}
    net.addLink(s3, s6, cls=TCLink, **s3s6)
    s6s10 = {'bw': 1000}
    net.addLink(s6, s10, cls=TCLink, **s6s10)
    net.addLink(s10, h6)
    net.addLink(h2, s2)
    s2s4 = {'bw': 1000}
    net.addLink(s2, s4, cls=TCLink, **s2s4)
    s4s5 = {'bw': 1000}
    net.addLink(s4, s5, cls=TCLink, **s4s5)
    s5s11 = {'bw': 1000}
    net.addLink(s5, s11, cls=TCLink, **s5s11)
    net.addLink(s11, h5)
    net.addLink(h3, s7)
    s7s8 = {'bw': 1000}
    net.addLink(s7, s8, cls=TCLink, **s7s8)
    s8s9 = {'bw': 1000}
    net.addLink(s8, s9, cls=TCLink, **s8s9)
    s9s12 = {'bw': 1000}
    net.addLink(s9, s12, cls=TCLink, **s9s12)
    net.addLink(s12, h4)
    s8s4 = {'bw': 1000}
    net.addLink(s8, s4, cls=TCLink, **s8s4)
    s9s5 = {'bw': 1000}
    net.addLink(s9, s5, cls=TCLink, **s9s5)
    s5s6 = {'bw': 1000}
    net.addLink(s5, s6, cls=TCLink, **s5s6)
    s4s3 = {'bw': 1000}
    net.addLink(s4, s3, cls=TCLink, **s4s3)
    s1s2 = {'bw': 1000}
    net.addLink(s1, s2, cls=TCLink, **s1s2)
    s2s7 = {'bw': 1000}
    net.addLink(s2, s7, cls=TCLink, **s2s7)
    s10s11 = {'bw': 1000}
    net.addLink(s10, s11, cls=TCLink, **s10s11)
    s11s12 = {'bw': 1000}
    net.addLink(s11, s12, cls=TCLink, **s11s12)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('s4').start([c0])
    net.get('s11').start([c0])
    net.get('s8').start([c0])
    net.get('s12').start([c0])
    net.get('s5').start([c0])
    net.get('s9').start([c0])
    net.get('s2').start([c0])
    net.get('s10').start([c0])
    net.get('s1').start([c0])
    net.get('s7').start([c0])
    net.get('s6').start([c0])
    net.get('s3').start([c0])

    info('*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
Example #45
0
def emptyNet():
    #ns.core.LogComponentEnable("UanChannel", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("UanHelper",  ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("UanNetDevice", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("UanPhyGen", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("TagBuffer", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("TapBridge", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("TapBridgeHelper", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("TapFdNetDeviceHelper", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("UanPhy", ns.core.LOG_ALL)
    #ns.core.LogComponentEnableAll(ns.core.LOG_PREFIX_NODE)
    #ns.core.LogComponentEnableAll(ns.core.LOG_PREFIX_TIME)
    #"Create an empty network and add nodes to it."

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

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

    h1 = net.addHost('h1', ip='10.0.0.1')
    h2 = net.addHost('h2', ip='10.0.0.2')
    #h3 = net.addHost( 'h3', ip='10.0.0.3' )
    h4 = net.addHost('h4', ip='10.0.0.4')

    s1 = net.addSwitch('s1', cls=OVSSwitch, inband=True)
    s2 = net.addSwitch('s2', cls=OVSSwitch, inband=True)
    #s3 = net.addSwitch( 's3', cls=OVSSwitch, inband=True )
    net.addLink(h1, s1)
    net.addLink(h2, s2)
    #net.addLink( h3, s3 )

    uanLL = UanSegment(ns.uan.UanTxMode.FSK, 10000, 10000, 24000, 6000, 2,
                       "Default mode", 0, 0, 1)
    #uanLL.add(s0)
    uanLL.add(h4)
    uanLL.add(s1)
    uanLL.add(s2)
    #uanLL.add(s3)

    #Csma.add(s3)
    #net.addLink( h4, s1 )
    #net.addLink( h4, s2 )
    #net.addLink( h4, s3 )
    #net.addLink( s1, s2 )
    #net.addLink( s2, s3 )
    mobility_helpers = {
        'h1':
        opennet.createMobilityHelper("ns3::ConstantPositionMobilityModel"),
        'h2':
        opennet.createMobilityHelper("ns3::ConstantPositionMobilityModel"),
        'h3':
        opennet.createMobilityHelper("ns3::ConstantPositionMobilityModel"),
        'h4':
        opennet.createMobilityHelper("ns3::ConstantPositionMobilityModel"),
        's1':
        opennet.createMobilityHelper("ns3::ConstantPositionMobilityModel"),
        's2':
        opennet.createMobilityHelper("ns3::ConstantPositionMobilityModel"),
        's3':
        opennet.createMobilityHelper("ns3::ConstantPositionMobilityModel")
    }

    list_position = {
        'h1': opennet.createListPositionAllocate(x1=0, y1=1, z1=-10),
        'h2': opennet.createListPositionAllocate(x1=0, y1=-1, z1=-10),
        'h3': opennet.createListPositionAllocate(x1=10, y1=10, z1=-10),
        'h4': opennet.createListPositionAllocate(x1=0, y1=0, z1=-10),
        's1': opennet.createListPositionAllocate(x1=0, y1=2, z1=-10),
        's2': opennet.createListPositionAllocate(x1=0, y1=-2, z1=-10),
        's3': opennet.createListPositionAllocate(x1=10, y1=10, z1=-10)
    }

    mobility_models = {
        'h1':
        opennet.setListPositionAllocate(mobility_helpers['h1'],
                                        list_position['h1']),
        'h2':
        opennet.setListPositionAllocate(mobility_helpers['h2'],
                                        list_position['h2']),
        'h3':
        opennet.setListPositionAllocate(mobility_helpers['h3'],
                                        list_position['h3']),
        'h4':
        opennet.setListPositionAllocate(mobility_helpers['h4'],
                                        list_position['h4']),
        's1':
        opennet.setListPositionAllocate(mobility_helpers['s1'],
                                        list_position['s1']),
        's2':
        opennet.setListPositionAllocate(mobility_helpers['s2'],
                                        list_position['s2']),
        's3':
        opennet.setListPositionAllocate(mobility_helpers['s3'],
                                        list_position['s3'])
    }
    opennet.setMobilityModel(h1, mobility_models.get('h1'))
    opennet.setMobilityModel(h2, mobility_models.get('h2'))
    #opennet.setMobilityModel(h3, mobility_models.get('h3'))
    opennet.setMobilityModel(h4, mobility_models.get('h4'))
    opennet.setMobilityModel(s1, mobility_models.get('s1'))
    opennet.setMobilityModel(s2, mobility_models.get('s2'))
    #opennet.setMobilityModel(s3, mobility_models.get('s3'))

    net.start()
    opennet.start()
    #s1.cmd('ifconfig s1 10.0.0.10')
    #s2.cmd('ifconfig s2 10.0.0.11')
    #s3.cmd('ifconfig s3 10.0.0.12')
    CLI(net)
    net.stop()
Example #46
0
def myNetwork():

	net = Mininet( topo=None,
		build=False,
		ipBase='10.0.0.0/8')
	core=1
	aggregation=2
	edge=2
	h=1
	Core=[core]
	Aggr= [aggregation]
	Edge=[edge]
	Host= [edge*h]



	info( '*** Adding controller\n' )
	c0=net.addController(name='c0',
		controller=Controller,
                protocol='tcp',
                port=6633)

	info( '*** Add switches\n')
        "s14 = net.addSwitch('s14', cls=OVSKernelSwitch)"
        for i in range(core):
    		Core.append(net.addSwitch('s%s' % i))

        for i in range(aggregation):
    		Aggr.append(net.addSwitch('s%s' % (i+core)))

        for i in range(edge):
    		Edge.append(net.addSwitch('s%s' % (i+core+aggregation), cls=OVSKernelSwitch))

    

        info( '*** Add hosts\n')
        "h9 = net.addHost('h9', cls=Host, ip='10.0.0.9', defaultRoute=None)"
    
        for i in range (h*edge):
    		Host.append(net.addHost('h%s' % i))


        info( '*** Add links\n')
        for i in range (core):
    		for j in range (aggregation):
    			net.addLink( Core[i+1], Aggr[j+1])
    			for k in range (edge):
    				net.addLink(Aggr[j+1], Edge[k+1])
                                for n in range (h*edge):
                                	net.addLink(Edge[k+1], Host[n+1])
   


	info( '*** Starting network\n')
        net.build()
        info( '*** Starting controllers\n')
        for controller in net.controllers:
        	controller.start()

        info( '*** Starting switches\n')
        net.get('s4').start([])
        net.get('s3').start([])
        net.get('s2').start([])
        net.get('s1').start([])
        net.get('s0').start([c0])

        info( '*** Post configure switches and hosts\n')

        CLI(net)
        net.stop()
Example #47
0
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          wlans=2,
                          ip='10.0.0.2/8',
                          max_x=120,
                          max_y=50,
                          min_v=1.4,
                          max_v=1.6)
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
    h2 = net.addHost('h2', mac='00:00:00:00:00:11', ip='10.0.0.11/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='ssid_ap1',
                             mode='g',
                             channel=6,
                             position='70,25,0')
    ap2 = net.addBaseStation('ap2',
                             ssid='ssid_ap2',
                             mode='g',
                             channel=1,
                             position='30,25,0')
    ap3 = net.addBaseStation('ap3',
                             ssid='ssid_ap3',
                             mode='g',
                             channel=11,
                             position='110,25,0')
    s4 = net.addSwitch('s4', mac='00:00:00:00:00:10')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, s4)
    net.addLink(ap2, s4)
    net.addLink(ap3, s4)
    net.addLink(s4, h1)
    net.addLink(s4, h2)

    sta1.cmd('modprobe bonding mode=3')
    sta1.cmd('ip link add bond0 type bond')
    sta1.cmd('ip link set bond0 address 02:01:02:03:04:08')
    sta1.cmd('ip link set sta1-wlan0 down')
    sta1.cmd('ip link set sta1-wlan0 address 00:00:00:00:00:11')
    sta1.cmd('ip link set sta1-wlan0 master bond0')
    sta1.cmd('ip link set sta1-wlan1 down')
    sta1.cmd('ip link set sta1-wlan1 address 00:00:00:00:00:12')
    sta1.cmd('ip link set sta1-wlan1 master bond0')
    sta1.cmd('ip addr add 10.0.0.10/8 dev bond0')
    sta1.cmd('ip link set bond0 up')

    print "*** Starting network"
    net.build()
    c1.start()
    s4.start([c1])
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])

    sta1.cmd('ip addr del 10.0.0.2/8 dev sta1-wlan0')
    os.system('ovs-ofctl add-flow s4 actions=normal')
    """seed"""
    net.seed(12)
    """uncomment to plot graph"""
    net.plotGraph(max_x=140, max_y=140)

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***"
    net.startMobility(startTime=0, model='RandomDirection')

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #48
0
class Solar(object):
    """ Create a tiered topology from semi-scratch in Mininet """

    def __init__(self, cname='onos', cips=['192.168.56.1'], islands=3, edges=2, hosts=2):
        """Create tower topology for mininet"""

        # We are creating the controller with local-loopback on purpose to avoid
        # having the switches connect immediately. Instead, we'll set controller
        # explicitly for each switch after configuring it as we want.
        self.ctrls = [ RemoteController(cname, cip, 6653) for cip in cips ]
        self.net = Mininet(controller=RemoteController, switch = OVSKernelSwitch,
                           build=False)

        self.cips = cips
        self.spines = []
        self.leaves = []
        self.hosts = []
        for ctrl in self.ctrls:
            self.net.addController(ctrl)

        # Create the two core switches and links between them
        c1 = self.net.addSwitch('c1',dpid='1111000000000000')
        c2 = self.net.addSwitch('c2',dpid='2222000000000000')
        self.spines.append(c1)
        self.spines.append(c2)

        self.net.addLink(c1, c2)
        self.net.addLink(c2, c1)

        for i in range(1, islands + 1):
            sc = self.createSpineClump(i, edges, hosts)
            self.net.addLink(c1, sc[0])
            self.net.addLink(c2, sc[0])
            self.net.addLink(c1, sc[1])
            self.net.addLink(c2, sc[1])

    def createSpineClump(self, island, edges, hosts):
        """ Creates a clump of spine and edge switches with hosts"""
        s1 = self.net.addSwitch('s%1d1' % island,dpid='00000%1d0100000000' % island)
        s2 = self.net.addSwitch('s%1d2' % island,dpid='00000%1d0200000000' % island)
        self.net.addLink(s1, s2)
        self.net.addLink(s2, s1)

        for i in range(1, edges + 1):
            es = self.createEdgeSwitch(island, i, hosts)
            self.net.addLink(es, s1)
            self.net.addLink(es, s2)

        self.spines.append(s1)
        self.spines.append(s2)

        clump = []
        clump.append(s1)
        clump.append(s2)
        return clump

    def createEdgeSwitch(self, island, index, hosts):
        """ Creates an edge switch in an island and ads hosts to it"""
        sw = self.net.addSwitch('e%1d%1d' % (island, index),dpid='0000000%1d0000000%1d' % (island, index))
        self.leaves.append(sw)

        for j in range(1, hosts + 1):
            host = self.net.addHost('h%d%d%d' % (island, index, j),ip='10.%d.%d.%d' % (island, index, j))
            self.net.addLink(host, sw)
            self.hosts.append(host)
        return sw

    def run(self):
        """ Runs the created network topology and launches mininet cli"""
        self.net.build()
        self.net.start()
        CustomCLI(self.net)
        self.net.stop()

    def pingAll(self):
        """ PingAll to create flows - for unit testing """
        self.net.pingAll()

    def stop(self):
        "Stops the topology. You should call this after run_silent"
        self.net.stop()
Example #49
0
def myNetwork():

    net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8')

    info('*** Adding controller\n')
    c0 = net.addController(name='c0',
                           controller=RemoteController,
                           ip='192.168.31.5',
                           protocol='tcp',
                           port=6633)

    info('*** Add switches\n')
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch, protocols='OpenFlow13')
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch, protocols='OpenFlow13')
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch, protocols='OpenFlow13')
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch, protocols='OpenFlow13')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch, protocols='OpenFlow13')

    info('*** Add hosts\n')
    h2 = net.addHost('h2',
                     cls=Host,
                     ip='10.0.0.2',
                     mac='00:00:00:00:00:02',
                     defaultRoute=None)
    h3 = net.addHost('h3',
                     cls=Host,
                     ip='10.0.0.3',
                     mac='00:00:00:00:00:03',
                     defaultRoute=None)
    h1 = net.addHost('h1',
                     cls=Host,
                     ip='10.0.0.1',
                     mac='00:00:00:00:00:01',
                     defaultRoute=None)

    info('*** Add links\n')
    net.addLink(s1, s4)
    net.addLink(s1, s5)
    net.addLink(s4, s2)
    net.addLink(s5, s2)
    net.addLink(s4, s3)
    net.addLink(s5, s3)
    net.addLink(h1, s1)
    net.addLink(s2, h2)
    net.addLink(s3, h3)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('s3').start([c0])
    net.get('s4').start([c0])
    net.get('s5').start([c0])
    net.get('s2').start([c0])
    net.get('s1').start([c0])

    info('*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
def createNetwork():
	#send rate at each link in Mbps
	bwg = 0.1#000 #1000 #in Mbps
	bwbn = 0.1#000 #1000 #25 #in Mbps
	loss = 80 #1 #2.5 #10 #1 #in %
	mqs = 100 #0 #1000 #max queue size of interfaces
	dly = '2.5ms' #'2.5ms 0.5ms'#'1ms 0.5ms' #can take all tc qdisc delay distribution formulations

	#create empty network
	net = Mininet(intf=TCIntf)

	info( '\n*** Adding controller\n' )
	net.addController( 'c0' ) #is it ok ?

	#add host to topology
	ht = net.addHost( 'ht', ip='10.10.0.1/24' )
	hu = net.addHost( 'hu', ip='10.10.0.2/24' )
	it = net.addHost( 'it', ip='10.20.0.1/24' )
	iu = net.addHost( 'iu', ip='10.20.0.2/24' )

	rh = net.addHost('rh', ip='10.10.0.10/24')
	ri = net.addHost('ri', ip='10.20.0.20/24')

	info('\n** Adding Switches\n')
	# Adding 2 switches to the network
	sw1 = net.addSwitch('sw1')
	sw2 = net.addSwitch('sw2')

	info('\n** Creating Links \n')
	#create link beetween the network
	link_ht_sw1 = net.addLink( ht, sw1)
	link_hu_sw1 = net.addLink( hu, sw1)
	link_rh_sw1 = net.addLink( rh, sw1, intfName1='rh-eth0')

	link_it_sw2 = net.addLink( it, sw2)
	link_iu_sw2 = net.addLink( iu, sw2)
	link_ri_sw2 = net.addLink( ri, sw2, intfName1='ri-eth0')

	link_rh_ri  = net.addLink( rh, ri, intfName1='rh-eth1', intfName2='ri-eth1')


	#set bandwith
	link_ht_sw1.intf1.config( bw = bwbn, max_queue_size = mqs)
	link_hu_sw1.intf1.config( bw = bwbn, max_queue_size = mqs)
	link_rh_sw1.intf1.config( bw = bwbn, max_queue_size = mqs) #max_queue_size is hardcoded low to prevent bufferbloat, too high queuing delays

	link_it_sw2.intf1.config( bw = bwg, max_queue_size = mqs)
	link_iu_sw2.intf1.config( bw = bwg, max_queue_size = mqs)
	link_ri_sw2.intf1.config( bw = bwg, max_queue_size = mqs, delay=dly) #delay is set at ri on both interfaces

	# link_rh_ri.intf1.config(  bw = bwg, max_queue_size = 10, loss=loss) #loss is set at rh on its interface to ri only
	link_rh_ri.intf1.config(  bw = bwg, max_queue_size = mqs, loss=loss) #loss is set at rh on its interface to ri only

	link_ht_sw1.intf2.config( bw = bwbn, max_queue_size = mqs)
	link_hu_sw1.intf2.config( bw = bwbn, max_queue_size = mqs)
	link_rh_sw1.intf2.config( bw = bwbn, max_queue_size = mqs)

	link_it_sw2.intf2.config( bw = bwg, max_queue_size = mqs)
	link_iu_sw2.intf2.config( bw = bwg, max_queue_size = mqs)
	link_ri_sw2.intf2.config( bw = bwg, max_queue_size = mqs)

	link_rh_ri.intf2.config(  bw = bwg, max_queue_size = mqs,  delay=dly) #delay is set at ri on both interfaces

	net.start()

	info( '\n*** Configuring hosts\n' )

	rh.cmd('ifconfig rh-eth1 10.12.0.10 netmask 255.255.255.0') #reconfiguring mutiples intefaces host to prevent mininet strange initialisation behaviors
	rh.cmd('ifconfig rh-eth0 10.10.0.10 netmask 255.255.255.0')
	rh.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward') #enable forwarding at routers

	ri.cmd('ifconfig ri-eth1 10.12.0.20 netmask 255.255.255.0') #reconfiguring mutiples intefaces host to prvent mininet strange initialisation behaviors
	ri.cmd('ifconfig ri-eth0 10.20.0.20 netmask 255.255.255.0')
	ri.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward') #enable forwarding at routers

	#configure host default gateways
	ht.cmd('ip route add default via 10.10.0.10')
	hu.cmd('ip route add default via 10.10.0.10')
	it.cmd('ip route add default via 10.20.0.20')
	iu.cmd('ip route add default via 10.20.0.20')

	#configure router routing tables
	rh.cmd('ip route add default via 10.12.0.20')
	ri.cmd('ip route add default via 10.12.0.10')

        # weiyu:
        iu.cmd('touch server.pcap')
        hu.cmd('touch client.pcap')


        rh.cmd('tc qdisc del dev rh-eth1 root')
        rh.cmd('tc qdisc add dev rh-eth1 root netem loss gemodel 0.2% 2% 90% 2% limit ' + str(mqs))
        #rh.cmd('tc qdisc add dev rh-eth1 root netem loss gemodel 0.2% 2% 90% 2% limit 10')
        #rh.cmd('tc qdisc add dev rh-eth1 root netem loss gemodel 0.1% 1% 90% 2% limit 1000')
        #rh.cmd('tc qdisc add dev rh-eth1 root netem loss gemodel 0.5% 2% 90% 2% limit 1000')

       # rh.cmd('python ./monitor_qlen_rh.py &')
        rh.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T rh -e \'sudo python ./monitor_queue.py\' &')
       # ri.cmd('python ./monitor_qlen_ri.py &')
        ri.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T ri -e \'sudo python ./monitor_qlen_ri.py\' &')
        #it.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T it -e \'sudo ./tcpserver 6666 > tcp-output-server.txt\' &')

        #ht.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T ht -e \'sleep 10; sudo ./tcpclient 10.20.0.1 6666 > tcp-output-client.txt\' &')

       # iu.cmd('tshark -i iu-eth0 -w server.pcap &')
        iu.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T iu -e \'sudo tshark -i iu-eth0 -w server.pcap\' &')
       # iu.cmd('./server.sh &')
        iu.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T iu -e \'sudo ./server.sh > output-server.txt\' &')
       # iu.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T iu -e \'python3 udp_server.py | tee udp-output-server.txt\' &')
       # hu.cmd('tshark -i hu-eth0 -w client.pcap &')
        hu.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T hu -e \'sudo tshark -i hu-eth0 -w client.pcap\' &')
       # hu.cmd('./client.sh &')
        hu.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T hu -e \'sleep 5; sudo ./client.sh > output-client.txt\' &')
       # hu.cmd('xterm -xrm \'XTerm.vt100.allowTitleOps: false\' -T hu -e \'python3 udp_client.py | tee udp-output-client.txt \' &')


	it.cmd('ethtool -K it-eth0 tx off sg off tso off') #disable TSO on TCP on defaul TCP sender need to be done on other host if sending large TCP file from other nodes

	method = 'tcp' #case selector varible for the flow used by smart-grid 'udp' = FRED

	logFolder = "../Estimations/wifiTer/"+ method + "/" #folder where log files and metrics will be saved
	# timeout = 10 #durantion of test

	#if not os.path.exists(logFolder):
	try:
		os.makedirs(logFolder) #error if folder already exist in order to prevent exidental overwirie
	except:
		print("File already exists.")

        # makeTerms([iu, hu, rh, ri], "host")

	#hu.cmd("bash /home/lca2/Desktop/server.sh")
	time.sleep(1)

	#iu.cmd("bash /home/lca2/Desktop/client-network.sh")
	time.sleep(1)

	"""it.cmd("python3 tcpserver.py &> "+logFolder+"it.txt &")
	time.sleep(1)
	ht.cmd("python3 tcpclient.py --ip 10.20.0.1 --port 4242 -s "+logFolder+"ht- -t "+str(timeout)+" &> "+logFolder+"ht.txt &")

	#potential second flow in the reverse direction of the first

	#ht.cmd("python3 tcpserver.py --ip 10.10.0.1 --port 4243 &> "+logFolder+"ht2.txt &")
	#time.sleep(1)
	#it.cmd("python3 tcpclient.py --ip 10.10.0.1 --port 4243 -s "+logFolder+"it2- -t "+str(timeout)+" &> "+logFolder+"it2.txt &")

	#smart grid data will be transported by TCP, delay will be recorded
	if method == 'tcp':
		info(method)
		iu.cmd("python3 delayReceiver.py --tcp --ip 10.20.0.2 -p 4242 -s "+logFolder+"iu- -t "+str(timeout)+" &> "+logFolder+"iu.txt &")
		time.sleep(1)
		hu.cmd("python3 tcpsender.py -t "+str(timeout)+" &> "+logFolder+"hu.txt &")

	#smart grid data will be transported by FRED, delay will be recorded
	elif method == 'udp':
		info(method)
		iu.cmd("python3 delayReceiver.py --ip 10.20.0.2 -p 4242 -s "+logFolder+"iu- -t "+str(timeout)+" &> "+logFolder+"iu.txt &")
		time.sleep(1)
		hu.cmd("python3 udpsender.py -s "+logFolder+"hu- -t "+str(timeout)+" &> "+logFolder+"hu.txt &")

	else:
		info("method unknown")
		net.stop()
		return

	#wainting until test end
	info('\n*** Sleeping\n')
	for i in range(int(timeout)):
		time.sleep(60)
		info("**slept "+str(i+1))"""

	# Enable the mininet> prompt if uncommented
	info('\n*** Running CLI\n')
	CLI(net)

	#kill xterms in case some where opened
	#ht.cmd("killall xterm")
	#it.cmd("killall xterm")
	# hu.cmd("killall xterm")
	iu.cmd("killall xterm")
Example #51
0
def topology():
    "Create a network."
    net = Mininet( link=TCLink, switch=OVSSwitch )
    #create local controller for APs
    c0 = Controller( 'c0', port=6634 )
    #create controller for s0 (Ryuretic)
    c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
    net.addController(c0)
    net.addController(c1)
    
    print "*** Creating nodes"
    s0 = net.addSwitch('s0')
        ##################    Create Rogue APs    ############################### 
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", channel="1", mode="g",
                              range='20' )
    ap3 = net.addBaseStation( 'ap3', ssid="ssid_ap3", mode="g", channel="6",
                              range='20')
    
    ################   Create Rogue Stations   #############################
    sta1 = net.addStation( 'sta1', ip='192.168.0.11/24', mac='AA:BB:BB:BB:BB:01',
                           defaultRoute='via 192.168.0.224' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.12/24', mac='AA:BB:BB:BB:BB:02',
                           defaultRoute='via 192.168.0.224' )
    sta3 = net.addStation( 'sta3', ip='192.168.0.13/24', mac='AA:BB:BB:BB:BB:03',
                           defaultRoute='via 192.168.0.224' )
    sta4 = net.addStation( 'sta4', ip='10.0.0.1/24', mac='AA:BB:BB:BB:BB:11',
                           defaultRoute='via 10.0.0.22' )
    sta5 = net.addStation( 'sta5', ip='10.0.0.2/24', mac='AA:BB:BB:BB:BB:12',
                           defaultRoute='via 10.0.0.22' )
    sta6 = net.addStation( 'sta6', ip='10.0.0.3/24', mac='AA:BB:BB:BB:BB:13',
                           defaultRoute='via 10.0.0.22' )
    
    ##################    Create Hosts    ####################################
    h1 = net.addHost('h1', ip='192.168.0.1', mac='AA:AA:AA:AA:AA:01',
                     defaultRoute='via 192.168.0.224')
    h2 = net.addHost('h2', ip='192.168.0.2', mac='AA:AA:AA:AA:AA:02',
                     defaultRoute='via 192.168.0.224')
    h3 = net.addHost('h3', ip='192.168.0.3', mac='AA:AA:AA:AA:AA:03',
                     defaultRoute='via 192.168.0.224')
    h4 = net.addHost('h4', ip='192.168.0.4', mac='AA:AA:AA:AA:AA:04',
                     defaultRoute='via 192.168.0.224')
    h5 = net.addHost('h5', ip='192.168.0.5', mac='AA:AA:AA:AA:AA:05',
                     defaultRoute='via 192.168.0.224')
    h6 = net.addHost('h6', ip='192.168.0.6', mac='AA:AA:AA:AA:AA:06',
                     defaultRoute='via 192.168.0.224')
    ##################   Wireless AP Interface   #############################

    print "*** Adding Link"
    wl_bw = 15
    wl_delay =  '2ms'
    wl_loss = 10
    
    w_bw = 15
    w_delay= '1ms'
    
    net.addLink(ap1, sta1, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    net.addLink(ap1, sta2, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    net.addLink(ap1, sta3, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    #####################    NAT1 Interface    ###############################   
    net.addLink(ap3, sta4, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    net.addLink(ap3, sta5, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    net.addLink(ap3, sta6, bw=wl_bw, loss=wl_loss, delay=wl_delay )
    #####################   Link devices to Switch    ######################## 
    
    
    net.addLink(ap1, s0, bw=w_bw, delay=w_delay)
    net.addLink(h1, s0, bw=w_bw, delay=w_delay)
    net.addLink(h2, s0, bw=w_bw, delay=w_delay)
    net.addLink(h3, s0, bw=w_bw, delay=w_delay)
    net.addLink(h4, s0, bw=w_bw, delay=w_delay)
    net.addLink(h5, s0, bw=w_bw, delay=w_delay)
    net.addLink(h6, s0, bw=w_bw, delay=w_delay)
    ######################   Create NAT for Internet   #######################
    nat = net.addHost( 'nat', cls=NAT, ip='192.168.0.224', mac='AA:AA:AA:AA:02:24',
                       subnet='192.168.0.0/24', inNamespace=False)
    net.addLink(nat, s0, bw=50)
    ###########################     Create RAP        ########################
    nat1=net.addHost('nat1', cls=NAT, ip='192.168.0.22', mac='AA:AA:AA:AA:00:22',
                                  subnet='10.0.0.0/24', inNameSpace=False,
                                  inetIntf='nat1-eth0', localIntf='nat1-eth1',
                                  defaultRoute='via 192.168.0.224')
    net.addLink(nat1,s0, bw=w_bw, delay=w_delay)
    net.addLink(ap3, nat1,bw=wl_bw, delay=w_delay)
    #########################   Build Topology      ##########################
    net.build()
    #########################   Start Topology      ##########################     
    c0.start()
    c1.start()                                               
    ap1.start( [c0] )
    ap3.start( [c0] )
    s0.start( [c1] )
    ########################   Add RAP Interface    ########################## 
    nat1.setIP('10.0.0.22/8', intf='nat1-eth1')

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #52
0
from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.util import quietRun

net = Mininet(link=TCLink)

# Add links
# set link capacity to 100Mbit/s
linkopts = dict(bw=100)

# initialize switches
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
s3 = net.addSwitch('s3')
s4 = net.addSwitch('s4')
s5 = net.addSwitch('s5')
s6 = net.addSwitch('s6')
s7 = net.addSwitch('s7')
s8 = net.addSwitch('s8')
s9 = net.addSwitch('s9')
s10 = net.addSwitch('s10')
s11 = net.addSwitch('s11')
s12 = net.addSwitch('s12')

# initialize hosts
h1 = net.addHost('h1')
h3 = net.addHost('h3')
h2 = net.addHost('h2')
h4 = net.addHost('h4')
Example #53
0
    def __init__(self):
	
    	"""Create a fat-tree network"""

    	net = Mininet( controller=RemoteController )
    	c0 = RemoteController( 'c0', ip='127.0.0.1', port=6633 )

    	info( '*** Adding controller ***\n' )
   	net.addController(c0 )

    	## Core switches
   	info(' *** Core switches ***\n')
    	cs_0 = net.addSwitch( 'cs0' )    
    	cs_1 = net.addSwitch( 'cs1' )
    	cs_2 = net.addSwitch( 'cs2' )
    	cs_3 = net.addSwitch( 'cs3' )

    	################################################## 
    	## Pod 0
    	info( '*** Pod - 0 ***\n' )
    	info( '*** Adding switches ***\n' )
   	edge_sw_0 = net.addSwitch( 'edge_sw_0' )
    	edge_sw_1 = net.addSwitch( 'edge_sw_1' ) 
    	aggr_sw_2 = net.addSwitch( 'aggr_sw_2' )
    	aggr_sw_3 = net.addSwitch( 'aggr_sw_3' )

    	info( '*** Adding hosts ***\n' )
    	# Lower left
    	h0 = net.addHost( 'h0', ip='10.0.0.2' )
    	h1 = net.addHost( 'h1', ip='10.0.0.3' )
    	# Lower right
    	h2 = net.addHost( 'h2', ip='10.0.1.2' )
    	h3 = net.addHost( 'h3', ip='10.0.1.3' )

    	info( '*** Creating links ***\n' )
    	net.addLink( h0, edge_sw_0 )
    	net.addLink( h1, edge_sw_0 )
    	net.addLink( h2, edge_sw_1 )
    	net.addLink( h3, edge_sw_1 )
    
    	net.addLink( edge_sw_0, aggr_sw_2)
    	net.addLink( edge_sw_0, aggr_sw_3)
    	net.addLink( edge_sw_1, aggr_sw_2)
    	net.addLink( edge_sw_1, aggr_sw_3)    
    
	net.addLink( cs_0, aggr_sw_2)
	net.addLink( cs_1, aggr_sw_2)

	net.addLink( cs_2, aggr_sw_3)
	net.addLink( cs_3, aggr_sw_3)

    	#################################################
    	## Pod 1
    	info( '*** Pod - 1 ***\n' )
    	info( '*** Adding switches ***\n' )
    	edge_sw_4 = net.addSwitch( 'edge_sw_4' )
    	edge_sw_5 = net.addSwitch( 'edge_sw_5' )
    	aggr_sw_6 = net.addSwitch( 'aggr_sw_6' )
    	aggr_sw_7 = net.addSwitch( 'aggr_sw_7' )

    	info( '*** Adding hosts ***\n' )
    	# Lower left
    	h4 = net.addHost( 'h4', ip='10.1.0.2' )
    	h5 = net.addHost( 'h5', ip='10.1.0.3' )
    	# Lower right   
    	h6 = net.addHost( 'h6', ip='10.1.1.2' )
    	h7 = net.addHost( 'h7', ip='10.1.1.3' )

    	info( '*** Creating links ***\n' )
    	net.addLink( h4, edge_sw_4 )
   	net.addLink( h5, edge_sw_4 )
    	net.addLink( h6, edge_sw_5 )
    	net.addLink( h7, edge_sw_5 )

    	net.addLink( edge_sw_4, aggr_sw_6)
    	net.addLink( edge_sw_4, aggr_sw_7)
    	net.addLink( edge_sw_5, aggr_sw_6)
    	net.addLink( edge_sw_5, aggr_sw_7)

	net.addLink( cs_0, aggr_sw_6)
        net.addLink( cs_1, aggr_sw_6)

        net.addLink( cs_2, aggr_sw_7)
        net.addLink( cs_3, aggr_sw_7) 

    	################################################
    	## Pod 2
    	info( '*** Pod - 2 ***\n' )
    	info( '*** Adding switches ***\n' )
    	edge_sw_8 = net.addSwitch( 'edge_sw_8' )
    	edge_sw_9 = net.addSwitch( 'edge_sw_9' )
    	aggr_sw_10 = net.addSwitch( 'aggr_sw_10' )
    	aggr_sw_11 = net.addSwitch( 'aggr_sw_11' )

    	info( '*** Adding hosts ***\n' )
    	# Lower left
    	h8 = net.addHost( 'h8', ip='10.2.0.2' )
   	h9 = net.addHost( 'h9', ip='10.2.0.3' )
    	# Lower right   
    	h10 = net.addHost( 'h10', ip='10.2.1.2' )
    	h11 = net.addHost( 'h11', ip='10.2.1.3' )

    	info( '*** Creating links ***\n' )
    	net.addLink( h8, edge_sw_8 )
    	net.addLink( h9, edge_sw_8 )
    	net.addLink( h10, edge_sw_9 )
    	net.addLink( h11, edge_sw_9 )

    	net.addLink( edge_sw_8, aggr_sw_10)
    	net.addLink( edge_sw_8, aggr_sw_11)
    	net.addLink( edge_sw_9, aggr_sw_10)
    	net.addLink( edge_sw_9, aggr_sw_11)

	net.addLink( cs_0, aggr_sw_10)
        net.addLink( cs_1, aggr_sw_10)

        net.addLink( cs_2, aggr_sw_11)
        net.addLink( cs_3, aggr_sw_11)

    	##############################################
    	## Pod 3
    	info( '*** Pod - 3 ***\n' )
    	info( '*** Adding switches ***\n' )
    	edge_sw_12 = net.addSwitch( 'edge_sw_12' )
    	edge_sw_13 = net.addSwitch( 'edge_sw_13' )
    	aggr_sw_14 = net.addSwitch( 'aggr_sw_14' )
    	aggr_sw_15 = net.addSwitch( 'aggr_sw_15' )
  
    	info( '*** Adding hosts ***\n' )
    	# Lower left
    	h12 = net.addHost( 'h12', ip='10.3.0.2' )
    	h13 = net.addHost( 'h13', ip='10.3.0.3' )
    	# Lower right   
    	h14 = net.addHost( 'h14', ip='10.3.1.2' )
    	h15 = net.addHost( 'h15', ip='10.3.1.3' )
  
    	info( '*** Creating links ***\n' )
    	net.addLink( h12, edge_sw_12 )
    	net.addLink( h13, edge_sw_12 )
    	net.addLink( h14, edge_sw_13 )
    	net.addLink( h15, edge_sw_13 )
  
    	net.addLink( edge_sw_12, aggr_sw_14)
    	net.addLink( edge_sw_12, aggr_sw_15)
    	net.addLink( edge_sw_13, aggr_sw_14)
    	net.addLink( edge_sw_13, aggr_sw_15) 

	net.addLink( cs_0, aggr_sw_14)
        net.addLink( cs_1, aggr_sw_14)

        net.addLink( cs_2, aggr_sw_15)
        net.addLink( cs_3, aggr_sw_15)

	net.build()
	net.start()
	CLI(net)
	net.stop()	
   host --- switch --- switch --- host

Adding the 'topos' dict with a key/value pair to generate our newly defined
topology enables one to pass in '--topo=mytopo' from the command line.
"""
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.node import OVSSwitch, Controller, RemoteController

net = Mininet( controller=RemoteController)
c0 = net.addController('c0',controller=RemoteController,ip="192.168.1.75",port=6633)
# Adding Hosts/Switches
h0 = net.addHost('h0')
s0 = net.addSwitch('s0')
h1 = net.addHost('h1')
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
# Adding Links
net.addLink(h0,s0)
net.addLink(h1,s1)
net.addLink(s0,s1)
net.addLink(s0,s2)
net.addLink(s2,s1)

#net.build()
net.start()
#net.pingAll()
CLI(net)
Example #55
0
def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    info( '*** Add switches\n')
    r4 = net.addHost('r4', cls=Node, ip='0.0.0.0')
    r4.cmd('sysctl -w net.ipv4.ip_forward=1')
    s15 = net.addSwitch('s15', cls=OVSKernelSwitch, failMode='standalone')
    r6 = net.addHost('r6', cls=Node, ip='0.0.0.0')
    r6.cmd('sysctl -w net.ipv4.ip_forward=1')
    r8 = net.addHost('r8', cls=Node, ip='0.0.0.0')
    r8.cmd('sysctl -w net.ipv4.ip_forward=1')
    s14 = net.addSwitch('s14', cls=OVSKernelSwitch, failMode='standalone')
    r1 = net.addHost('r1', cls=Node, ip='0.0.0.0')
    r1.cmd('sysctl -w net.ipv4.ip_forward=1')
    r10 = net.addHost('r10', cls=Node, ip='0.0.0.0')
    r10.cmd('sysctl -w net.ipv4.ip_forward=1')
    r3 = net.addHost('r3', cls=Node, ip='0.0.0.0')
    r3.cmd('sysctl -w net.ipv4.ip_forward=1')
    r2 = net.addHost('r2', cls=Node, ip='0.0.0.0')
    r2.cmd('sysctl -w net.ipv4.ip_forward=1')
    r5 = net.addHost('r5', cls=Node, ip='0.0.0.0')
    r5.cmd('sysctl -w net.ipv4.ip_forward=1')
    r7 = net.addHost('r7', cls=Node, ip='0.0.0.0')
    r7.cmd('sysctl -w net.ipv4.ip_forward=1')
    r11 = net.addHost('r11', cls=Node, ip='0.0.0.0')
    r11.cmd('sysctl -w net.ipv4.ip_forward=1')
    r9 = net.addHost('r9', cls=Node, ip='0.0.0.0')
    r9.cmd('sysctl -w net.ipv4.ip_forward=1')

    info( '*** Add hosts\n')

    info( '*** Add links\n')
    net.addLink(r1, r2)
    net.addLink(r2, r3)
    net.addLink(r3, r4)
    net.addLink(r4, r5)
    net.addLink(r5, r6)
    net.addLink(r6, r7)
    net.addLink(r7, r8)
    net.addLink(r8, r9)
    net.addLink(r9, r10)
    net.addLink(r10, r11)
    net.addLink(r11, r1)
    net.addLink(r4, s14)
    net.addLink(r5, s14)
    net.addLink(r6, s14)
    net.addLink(r7, s14)
    net.addLink(r8, s14)
    net.addLink(r4, s15)
    net.addLink(r5, s15)
    net.addLink(r6, s15)
    net.addLink(r7, s15)
    net.addLink(r8, s15)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s15').start([])
    net.get('s14').start([])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
Example #56
0
def myNetwork():

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

    info('*** Adding controller\n')
    # Change port and IP accordingly (c0 is Local controller, rest are Global controllers)
    c0 = net.addController(name='c0',
                           controller=RemoteController,
                           ip='0.0.0.0',
                           protocol='tcp',
                           port=6653)
    c1 = net.addController(name='c1',
                           controller=InbandController,
                           ip='10.0.0.1',
                           protocol='tcp',
                           port=6653)

    c2 = net.addController(name='c2',
                           controller=InbandController,
                           ip='10.0.0.2',
                           protocol='tcp',
                           port=6653)

    c3 = net.addController(name='c3',
                           controller=InbandController,
                           ip='10.0.0.3',
                           protocol='tcp',
                           port=6653)

    info('*** Add switches\n')
    s98 = net.addSwitch('s98',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s37 = net.addSwitch('s37',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s143 = net.addSwitch('s143',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s15 = net.addSwitch('s15',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s119 = net.addSwitch('s119',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s52 = net.addSwitch('s52',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s6 = net.addSwitch('s6',
                       cls=OVSSwitch,
                       inband=True,
                       protocols='OpenFlow13')
    s51 = net.addSwitch('s51',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s120 = net.addSwitch('s120',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s63 = net.addSwitch('s63',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s162 = net.addSwitch('s162',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s118 = net.addSwitch('s118',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s49 = net.addSwitch('s49',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s188 = net.addSwitch('s188',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s121 = net.addSwitch('s121',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s175 = net.addSwitch('s175',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s149 = net.addSwitch('s149',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s138 = net.addSwitch('s138',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s189 = net.addSwitch('s189',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s185 = net.addSwitch('s185',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s50 = net.addSwitch('s50',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s110 = net.addSwitch('s110',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s16 = net.addSwitch('s16',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s4 = net.addSwitch('s4',
                       cls=OVSSwitch,
                       inband=True,
                       protocols='OpenFlow13')
    s55 = net.addSwitch('s55',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s36 = net.addSwitch('s36',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s113 = net.addSwitch('s113',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s190 = net.addSwitch('s190',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s179 = net.addSwitch('s179',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s123 = net.addSwitch('s123',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s165 = net.addSwitch('s165',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s1 = net.addSwitch('s1',
                       cls=OVSSwitch,
                       inband=True,
                       protocols='OpenFlow13')
    s93 = net.addSwitch('s93',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s107 = net.addSwitch('s107',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s127 = net.addSwitch('s127',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s54 = net.addSwitch('s54',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s173 = net.addSwitch('s173',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s191 = net.addSwitch('s191',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s41 = net.addSwitch('s41',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s69 = net.addSwitch('s69',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s124 = net.addSwitch('s124',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s61 = net.addSwitch('s61',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s29 = net.addSwitch('s29',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s95 = net.addSwitch('s95',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s164 = net.addSwitch('s164',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s100 = net.addSwitch('s100',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s125 = net.addSwitch('s125',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s17 = net.addSwitch('s17',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s170 = net.addSwitch('s170',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s31 = net.addSwitch('s31',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s2 = net.addSwitch('s2',
                       cls=OVSSwitch,
                       inband=True,
                       protocols='OpenFlow13')
    s187 = net.addSwitch('s187',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s160 = net.addSwitch('s160',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s38 = net.addSwitch('s38',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s131 = net.addSwitch('s131',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s106 = net.addSwitch('s106',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s161 = net.addSwitch('s161',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s30 = net.addSwitch('s30',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s56 = net.addSwitch('s56',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s103 = net.addSwitch('s103',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s163 = net.addSwitch('s163',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s108 = net.addSwitch('s108',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s97 = net.addSwitch('s97',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s176 = net.addSwitch('s176',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s58 = net.addSwitch('s58',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s166 = net.addSwitch('s166',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s11 = net.addSwitch('s11',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s32 = net.addSwitch('s32',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s139 = net.addSwitch('s139',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s94 = net.addSwitch('s94',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s109 = net.addSwitch('s109',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s75 = net.addSwitch('s75',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s71 = net.addSwitch('s71',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s24 = net.addSwitch('s24',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s65 = net.addSwitch('s65',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s39 = net.addSwitch('s39',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s99 = net.addSwitch('s99',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s35 = net.addSwitch('s35',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s192 = net.addSwitch('s192',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s96 = net.addSwitch('s96',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s169 = net.addSwitch('s169',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s60 = net.addSwitch('s60',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s128 = net.addSwitch('s128',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s68 = net.addSwitch('s68',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s13 = net.addSwitch('s13',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s20 = net.addSwitch('s20',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s7 = net.addSwitch('s7',
                       cls=OVSSwitch,
                       inband=True,
                       protocols='OpenFlow13')
    s114 = net.addSwitch('s114',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s153 = net.addSwitch('s153',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s10 = net.addSwitch('s10',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s142 = net.addSwitch('s142',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s117 = net.addSwitch('s117',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s12 = net.addSwitch('s12',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s57 = net.addSwitch('s57',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s151 = net.addSwitch('s151',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s78 = net.addSwitch('s78',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s174 = net.addSwitch('s174',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s42 = net.addSwitch('s42',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s147 = net.addSwitch('s147',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s45 = net.addSwitch('s45',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s5 = net.addSwitch('s5',
                       cls=OVSSwitch,
                       inband=True,
                       protocols='OpenFlow13')
    s132 = net.addSwitch('s132',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s34 = net.addSwitch('s34',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s157 = net.addSwitch('s157',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s155 = net.addSwitch('s155',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s144 = net.addSwitch('s144',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s177 = net.addSwitch('s177',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s148 = net.addSwitch('s148',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s81 = net.addSwitch('s81',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s133 = net.addSwitch('s133',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s136 = net.addSwitch('s136',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s145 = net.addSwitch('s145',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s178 = net.addSwitch('s178',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s79 = net.addSwitch('s79',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s186 = net.addSwitch('s186',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s28 = net.addSwitch('s28',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s22 = net.addSwitch('s22',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s122 = net.addSwitch('s122',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s181 = net.addSwitch('s181',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s111 = net.addSwitch('s111',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s18 = net.addSwitch('s18',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s140 = net.addSwitch('s140',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s168 = net.addSwitch('s168',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s76 = net.addSwitch('s76',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s14 = net.addSwitch('s14',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s135 = net.addSwitch('s135',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s183 = net.addSwitch('s183',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s47 = net.addSwitch('s47',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s129 = net.addSwitch('s129',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s40 = net.addSwitch('s40',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s70 = net.addSwitch('s70',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s104 = net.addSwitch('s104',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s23 = net.addSwitch('s23',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s101 = net.addSwitch('s101',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s25 = net.addSwitch('s25',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s43 = net.addSwitch('s43',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s171 = net.addSwitch('s171',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s8 = net.addSwitch('s8',
                       cls=OVSSwitch,
                       inband=True,
                       protocols='OpenFlow13')
    s180 = net.addSwitch('s180',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s112 = net.addSwitch('s112',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s137 = net.addSwitch('s137',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s141 = net.addSwitch('s141',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s182 = net.addSwitch('s182',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s27 = net.addSwitch('s27',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s74 = net.addSwitch('s74',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s156 = net.addSwitch('s156',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s48 = net.addSwitch('s48',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s53 = net.addSwitch('s53',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s21 = net.addSwitch('s21',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s154 = net.addSwitch('s154',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s172 = net.addSwitch('s172',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s102 = net.addSwitch('s102',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s150 = net.addSwitch('s150',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s159 = net.addSwitch('s159',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s73 = net.addSwitch('s73',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s105 = net.addSwitch('s105',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s184 = net.addSwitch('s184',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s46 = net.addSwitch('s46',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s44 = net.addSwitch('s44',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s19 = net.addSwitch('s19',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s130 = net.addSwitch('s130',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s134 = net.addSwitch('s134',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s167 = net.addSwitch('s167',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s59 = net.addSwitch('s59',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s115 = net.addSwitch('s115',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s126 = net.addSwitch('s126',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s62 = net.addSwitch('s62',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s152 = net.addSwitch('s152',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s158 = net.addSwitch('s158',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s33 = net.addSwitch('s33',
                        cls=OVSSwitch,
                        inband=True,
                        protocols='OpenFlow13')
    s116 = net.addSwitch('s116',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')
    s146 = net.addSwitch('s146',
                         cls=OVSSwitch,
                         inband=True,
                         protocols='OpenFlow13')

    info('*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)

    linkopts = dict(bw=1000)

    info('*** Add links\n')
    net.addLink(s51, h1, cls=TCLink, **linkopts)
    net.addLink(s71, h2, cls=TCLink, **linkopts)
    net.addLink(s139, h3, cls=TCLink, **linkopts)
    net.addLink(s2, s4, cls=TCLink, **linkopts)
    net.addLink(s1, s2, cls=TCLink, **linkopts)
    net.addLink(s4, s6, cls=TCLink, **linkopts)
    net.addLink(s4, s5, cls=TCLink, **linkopts)
    net.addLink(s5, s6, cls=TCLink, **linkopts)
    net.addLink(s7, s6, cls=TCLink, **linkopts)
    net.addLink(s4, s7, cls=TCLink, **linkopts)
    net.addLink(s7, s8, cls=TCLink, **linkopts)
    net.addLink(s6, s10, cls=TCLink, **linkopts)
    net.addLink(s5, s10, cls=TCLink, **linkopts)
    net.addLink(s10, s11, cls=TCLink, **linkopts)
    net.addLink(s11, s12, cls=TCLink, **linkopts)
    net.addLink(s12, s13, cls=TCLink, **linkopts)
    net.addLink(s14, s12, cls=TCLink, **linkopts)
    net.addLink(s14, s13, cls=TCLink, **linkopts)
    net.addLink(s14, s15, cls=TCLink, **linkopts)
    net.addLink(s13, s16, cls=TCLink, **linkopts)
    net.addLink(s11, s16, cls=TCLink, **linkopts)
    net.addLink(s17, s13, cls=TCLink, **linkopts)
    net.addLink(s17, s15, cls=TCLink, **linkopts)
    net.addLink(s14, s18, cls=TCLink, **linkopts)
    net.addLink(s19, s17, cls=TCLink, **linkopts)
    net.addLink(s19, s18, cls=TCLink, **linkopts)
    net.addLink(s19, s20, cls=TCLink, **linkopts)
    net.addLink(s20, s21, cls=TCLink, **linkopts)
    net.addLink(s20, s22, cls=TCLink, **linkopts)
    net.addLink(s20, s23, cls=TCLink, **linkopts)
    net.addLink(s24, s21, cls=TCLink, **linkopts)
    net.addLink(s24, s25, cls=TCLink, **linkopts)
    net.addLink(s25, s16, cls=TCLink, **linkopts)
    net.addLink(s24, s10, cls=TCLink, **linkopts)
    net.addLink(s25, s21, cls=TCLink, **linkopts)
    net.addLink(s27, s10, cls=TCLink, **linkopts)
    net.addLink(s27, s15, cls=TCLink, **linkopts)
    net.addLink(s28, s27, cls=TCLink, **linkopts)
    net.addLink(s28, s6, cls=TCLink, **linkopts)
    net.addLink(s28, s7, cls=TCLink, **linkopts)
    net.addLink(s28, s25, cls=TCLink, **linkopts)
    net.addLink(s32, s29, cls=TCLink, **linkopts)
    net.addLink(s32, s30, cls=TCLink, **linkopts)
    net.addLink(s32, s31, cls=TCLink, **linkopts)
    net.addLink(s29, s31, cls=TCLink, **linkopts)
    net.addLink(s31, s30, cls=TCLink, **linkopts)
    net.addLink(s29, s7, cls=TCLink, **linkopts)
    net.addLink(s30, s7, cls=TCLink, **linkopts)
    net.addLink(s33, s34, cls=TCLink, **linkopts)
    net.addLink(s34, s28, cls=TCLink, **linkopts)
    net.addLink(s33, s32, cls=TCLink, **linkopts)
    net.addLink(s33, s31, cls=TCLink, **linkopts)
    net.addLink(s33, s30, cls=TCLink, **linkopts)
    net.addLink(s33, s29, cls=TCLink, **linkopts)
    net.addLink(s31, s28, cls=TCLink, **linkopts)
    net.addLink(s34, s7, cls=TCLink, **linkopts)
    net.addLink(s34, s6, cls=TCLink, **linkopts)
    net.addLink(s34, s35, cls=TCLink, **linkopts)
    net.addLink(s33, s36, cls=TCLink, **linkopts)
    net.addLink(s35, s37, cls=TCLink, **linkopts)
    net.addLink(s35, s38, cls=TCLink, **linkopts)
    net.addLink(s37, s38, cls=TCLink, **linkopts)
    net.addLink(s38, s39, cls=TCLink, **linkopts)
    net.addLink(s38, s40, cls=TCLink, **linkopts)
    net.addLink(s40, s41, cls=TCLink, **linkopts)
    net.addLink(s41, s39, cls=TCLink, **linkopts)
    net.addLink(s39, s35, cls=TCLink, **linkopts)
    net.addLink(s21, s42, cls=TCLink, **linkopts)
    net.addLink(s42, s43, cls=TCLink, **linkopts)
    net.addLink(s43, s44, cls=TCLink, **linkopts)
    net.addLink(s42, s44, cls=TCLink, **linkopts)
    net.addLink(s44, s45, cls=TCLink, **linkopts)
    net.addLink(s43, s45, cls=TCLink, **linkopts)
    net.addLink(s45, s46, cls=TCLink, **linkopts)
    net.addLink(s43, s38, cls=TCLink, **linkopts)
    net.addLink(s44, s39, cls=TCLink, **linkopts)
    net.addLink(s39, s46, cls=TCLink, **linkopts)
    net.addLink(s35, s48, cls=TCLink, **linkopts)
    net.addLink(s35, s47, cls=TCLink, **linkopts)
    net.addLink(s51, s50, cls=TCLink, **linkopts)
    net.addLink(s51, s49, cls=TCLink, **linkopts)
    net.addLink(s49, s50, cls=TCLink, **linkopts)
    net.addLink(s52, s51, cls=TCLink, **linkopts)
    net.addLink(s52, s36, cls=TCLink, **linkopts)
    net.addLink(s55, s54, cls=TCLink, **linkopts)
    net.addLink(s53, s50, cls=TCLink, **linkopts)
    net.addLink(s53, s51, cls=TCLink, **linkopts)
    net.addLink(s54, s51, cls=TCLink, **linkopts)
    net.addLink(s54, s50, cls=TCLink, **linkopts)
    net.addLink(s51, s33, cls=TCLink, **linkopts)
    net.addLink(s36, s49, cls=TCLink, **linkopts)
    net.addLink(s56, s57, cls=TCLink, **linkopts)
    net.addLink(s56, s31, cls=TCLink, **linkopts)
    net.addLink(s57, s33, cls=TCLink, **linkopts)
    net.addLink(s56, s34, cls=TCLink, **linkopts)
    net.addLink(s59, s60, cls=TCLink, **linkopts)
    net.addLink(s60, s49, cls=TCLink, **linkopts)
    net.addLink(s58, s49, cls=TCLink, **linkopts)
    net.addLink(s56, s59, cls=TCLink, **linkopts)
    net.addLink(s63, s61, cls=TCLink, **linkopts)
    net.addLink(s63, s62, cls=TCLink, **linkopts)
    net.addLink(s61, s62, cls=TCLink, **linkopts)
    net.addLink(s50, s61, cls=TCLink, **linkopts)
    net.addLink(s50, s62, cls=TCLink, **linkopts)
    net.addLink(s50, s63, cls=TCLink, **linkopts)
    net.addLink(s49, s63, cls=TCLink, **linkopts)
    net.addLink(s49, s61, cls=TCLink, **linkopts)
    net.addLink(s60, s50, cls=TCLink, **linkopts)
    net.addLink(s65, s50, cls=TCLink, **linkopts)
    net.addLink(s68, s56, cls=TCLink, **linkopts)
    net.addLink(s68, s69, cls=TCLink, **linkopts)
    net.addLink(s69, s70, cls=TCLink, **linkopts)
    net.addLink(s70, s71, cls=TCLink, **linkopts)
    net.addLink(s71, s69, cls=TCLink, **linkopts)
    net.addLink(s69, s73, cls=TCLink, **linkopts)
    net.addLink(s73, s74, cls=TCLink, **linkopts)
    net.addLink(s75, s76, cls=TCLink, **linkopts)
    net.addLink(s75, s57, cls=TCLink, **linkopts)
    net.addLink(s76, s56, cls=TCLink, **linkopts)
    net.addLink(s74, s79, cls=TCLink, **linkopts)
    net.addLink(s74, s78, cls=TCLink, **linkopts)
    net.addLink(s79, s81, cls=TCLink, **linkopts)
    net.addLink(s78, s76, cls=TCLink, **linkopts)
    net.addLink(s79, s76, cls=TCLink, **linkopts)
    net.addLink(s81, s78, cls=TCLink, **linkopts)
    net.addLink(s17, s12, cls=TCLink, **linkopts)
    net.addLink(s33, s27, cls=TCLink, **linkopts)
    net.addLink(s62, s93, cls=TCLink, **linkopts)
    net.addLink(s65, s93, cls=TCLink, **linkopts)
    net.addLink(s63, s94, cls=TCLink, **linkopts)
    net.addLink(s62, s94, cls=TCLink, **linkopts)
    net.addLink(s94, s95, cls=TCLink, **linkopts)
    net.addLink(s95, s96, cls=TCLink, **linkopts)
    net.addLink(s98, s97, cls=TCLink, **linkopts)
    net.addLink(s97, s93, cls=TCLink, **linkopts)
    net.addLink(s99, s98, cls=TCLink, **linkopts)
    net.addLink(s98, s65, cls=TCLink, **linkopts)
    net.addLink(s97, s65, cls=TCLink, **linkopts)
    net.addLink(s81, s101, cls=TCLink, **linkopts)
    net.addLink(s99, s102, cls=TCLink, **linkopts)
    net.addLink(s102, s97, cls=TCLink, **linkopts)
    net.addLink(s102, s101, cls=TCLink, **linkopts)
    net.addLink(s101, s100, cls=TCLink, **linkopts)
    net.addLink(s102, s59, cls=TCLink, **linkopts)
    net.addLink(s101, s59, cls=TCLink, **linkopts)
    net.addLink(s100, s62, cls=TCLink, **linkopts)
    net.addLink(s100, s57, cls=TCLink, **linkopts)
    net.addLink(s56, s101, cls=TCLink, **linkopts)
    net.addLink(s57, s102, cls=TCLink, **linkopts)
    net.addLink(s56, s103, cls=TCLink, **linkopts)
    net.addLink(s97, s59, cls=TCLink, **linkopts)
    net.addLink(s98, s59, cls=TCLink, **linkopts)
    net.addLink(s59, s93, cls=TCLink, **linkopts)
    net.addLink(s59, s62, cls=TCLink, **linkopts)
    net.addLink(s101, s61, cls=TCLink, **linkopts)
    net.addLink(s105, s101, cls=TCLink, **linkopts)
    net.addLink(s104, s98, cls=TCLink, **linkopts)
    net.addLink(s104, s100, cls=TCLink, **linkopts)
    net.addLink(s104, s103, cls=TCLink, **linkopts)
    net.addLink(s103, s101, cls=TCLink, **linkopts)
    net.addLink(s103, s102, cls=TCLink, **linkopts)
    net.addLink(s103, s106, cls=TCLink, **linkopts)
    net.addLink(s106, s107, cls=TCLink, **linkopts)
    net.addLink(s107, s100, cls=TCLink, **linkopts)
    net.addLink(s81, s76, cls=TCLink, **linkopts)
    net.addLink(s106, s100, cls=TCLink, **linkopts)
    net.addLink(s106, s101, cls=TCLink, **linkopts)
    net.addLink(s101, s58, cls=TCLink, **linkopts)
    net.addLink(s101, s60, cls=TCLink, **linkopts)
    net.addLink(s104, s102, cls=TCLink, **linkopts)
    net.addLink(s104, s59, cls=TCLink, **linkopts)
    net.addLink(s65, s102, cls=TCLink, **linkopts)
    net.addLink(s108, s69, cls=TCLink, **linkopts)
    net.addLink(s109, s69, cls=TCLink, **linkopts)
    net.addLink(s110, s69, cls=TCLink, **linkopts)
    net.addLink(s111, s69, cls=TCLink, **linkopts)
    net.addLink(s112, s69, cls=TCLink, **linkopts)
    net.addLink(s113, s69, cls=TCLink, **linkopts)
    net.addLink(s114, s69, cls=TCLink, **linkopts)
    net.addLink(s115, s69, cls=TCLink, **linkopts)
    net.addLink(s116, s69, cls=TCLink, **linkopts)
    net.addLink(s117, s69, cls=TCLink, **linkopts)
    net.addLink(s118, s2, cls=TCLink, **linkopts)
    net.addLink(s119, s2, cls=TCLink, **linkopts)
    net.addLink(s120, s2, cls=TCLink, **linkopts)
    net.addLink(s121, s2, cls=TCLink, **linkopts)
    net.addLink(s122, s2, cls=TCLink, **linkopts)
    net.addLink(s123, s2, cls=TCLink, **linkopts)
    net.addLink(s124, s2, cls=TCLink, **linkopts)
    net.addLink(s125, s2, cls=TCLink, **linkopts)
    net.addLink(s126, s2, cls=TCLink, **linkopts)
    net.addLink(s127, s2, cls=TCLink, **linkopts)
    net.addLink(s128, s2, cls=TCLink, **linkopts)
    net.addLink(s129, s2, cls=TCLink, **linkopts)
    net.addLink(s130, s2, cls=TCLink, **linkopts)
    net.addLink(s134, s2, cls=TCLink, **linkopts)
    net.addLink(s131, s2, cls=TCLink, **linkopts)
    net.addLink(s132, s2, cls=TCLink, **linkopts)
    net.addLink(s133, s2, cls=TCLink, **linkopts)
    net.addLink(s135, s2, cls=TCLink, **linkopts)
    net.addLink(s136, s2, cls=TCLink, **linkopts)
    net.addLink(s137, s2, cls=TCLink, **linkopts)
    net.addLink(s138, s2, cls=TCLink, **linkopts)
    net.addLink(s155, s20, cls=TCLink, **linkopts)
    net.addLink(s154, s20, cls=TCLink, **linkopts)
    net.addLink(s153, s20, cls=TCLink, **linkopts)
    net.addLink(s152, s20, cls=TCLink, **linkopts)
    net.addLink(s151, s20, cls=TCLink, **linkopts)
    net.addLink(s150, s20, cls=TCLink, **linkopts)
    net.addLink(s149, s20, cls=TCLink, **linkopts)
    net.addLink(s148, s20, cls=TCLink, **linkopts)
    net.addLink(s147, s20, cls=TCLink, **linkopts)
    net.addLink(s146, s20, cls=TCLink, **linkopts)
    net.addLink(s145, s20, cls=TCLink, **linkopts)
    net.addLink(s144, s20, cls=TCLink, **linkopts)
    net.addLink(s143, s20, cls=TCLink, **linkopts)
    net.addLink(s142, s20, cls=TCLink, **linkopts)
    net.addLink(s141, s20, cls=TCLink, **linkopts)
    net.addLink(s140, s20, cls=TCLink, **linkopts)
    net.addLink(s139, s20, cls=TCLink, **linkopts)
    net.addLink(s156, s94, cls=TCLink, **linkopts)
    net.addLink(s157, s94, cls=TCLink, **linkopts)
    net.addLink(s158, s94, cls=TCLink, **linkopts)
    net.addLink(s159, s94, cls=TCLink, **linkopts)
    net.addLink(s185, s94, cls=TCLink, **linkopts)
    net.addLink(s184, s94, cls=TCLink, **linkopts)
    net.addLink(s183, s94, cls=TCLink, **linkopts)
    net.addLink(s182, s94, cls=TCLink, **linkopts)
    net.addLink(s181, s94, cls=TCLink, **linkopts)
    net.addLink(s165, s94, cls=TCLink, **linkopts)
    net.addLink(s164, s94, cls=TCLink, **linkopts)
    net.addLink(s163, s94, cls=TCLink, **linkopts)
    net.addLink(s162, s94, cls=TCLink, **linkopts)
    net.addLink(s161, s94, cls=TCLink, **linkopts)
    net.addLink(s160, s94, cls=TCLink, **linkopts)
    net.addLink(s192, s101, cls=TCLink, **linkopts)
    net.addLink(s191, s101, cls=TCLink, **linkopts)
    net.addLink(s190, s101, cls=TCLink, **linkopts)
    net.addLink(s189, s101, cls=TCLink, **linkopts)
    net.addLink(s188, s101, cls=TCLink, **linkopts)
    net.addLink(s187, s101, cls=TCLink, **linkopts)
    net.addLink(s186, s101, cls=TCLink, **linkopts)
    net.addLink(s54, s166, cls=TCLink, **linkopts)
    net.addLink(s54, s167, cls=TCLink, **linkopts)
    net.addLink(s54, s168, cls=TCLink, **linkopts)
    net.addLink(s54, s169, cls=TCLink, **linkopts)
    net.addLink(s54, s170, cls=TCLink, **linkopts)
    net.addLink(s54, s171, cls=TCLink, **linkopts)
    net.addLink(s54, s172, cls=TCLink, **linkopts)
    net.addLink(s54, s173, cls=TCLink, **linkopts)
    net.addLink(s54, s174, cls=TCLink, **linkopts)
    net.addLink(s54, s175, cls=TCLink, **linkopts)
    net.addLink(s54, s176, cls=TCLink, **linkopts)
    net.addLink(s54, s180, cls=TCLink, **linkopts)
    net.addLink(s54, s179, cls=TCLink, **linkopts)
    net.addLink(s54, s177, cls=TCLink, **linkopts)
    net.addLink(s54, s178, cls=TCLink, **linkopts)

    info('*** Starting network\n')
    net.build()
    info('*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info('*** Starting switches\n')
    net.get('s98').start([c0])
    net.get('s37').start([c0])
    net.get('s143').start([c0])
    net.get('s15').start([c0])
    net.get('s119').start([c0])
    net.get('s52').start([c0])
    net.get('s6').start([c0])
    net.get('s51').start([c0, c1])
    net.get('s120').start([c0])
    net.get('s63').start([c0])
    net.get('s162').start([c0])
    net.get('s118').start([c0])
    net.get('s49').start([c0])
    net.get('s188').start([c0])
    net.get('s121').start([c0])
    net.get('s175').start([c0])
    net.get('s149').start([c0])
    net.get('s138').start([c0])
    net.get('s189').start([c0])
    net.get('s185').start([c0])
    net.get('s50').start([c0])
    net.get('s110').start([c0])
    net.get('s16').start([c0])
    net.get('s4').start([c0])
    net.get('s55').start([c0])
    net.get('s36').start([c0])
    net.get('s113').start([c0])
    net.get('s190').start([c0])
    net.get('s179').start([c0])
    net.get('s123').start([c0])
    net.get('s165').start([c0])
    net.get('s1').start([c0])
    net.get('s93').start([c0])
    net.get('s107').start([c0])
    net.get('s127').start([c0])
    net.get('s54').start([c0])
    net.get('s173').start([c0])
    net.get('s191').start([c0])
    net.get('s41').start([c0])
    net.get('s69').start([c0])
    net.get('s124').start([c0])
    net.get('s61').start([c0])
    net.get('s29').start([c0])
    net.get('s95').start([c0])
    net.get('s164').start([c0])
    net.get('s100').start([c0])
    net.get('s125').start([c0])
    net.get('s17').start([c0])
    net.get('s170').start([c0])
    net.get('s31').start([c0])
    net.get('s2').start([c0])
    net.get('s187').start([c0])
    net.get('s160').start([c0])
    net.get('s38').start([c0])
    net.get('s131').start([c0])
    net.get('s106').start([c0])
    net.get('s161').start([c0])
    net.get('s30').start([c0])
    net.get('s56').start([c0])
    net.get('s103').start([c0])
    net.get('s163').start([c0])
    net.get('s108').start([c0])
    net.get('s97').start([c0])
    net.get('s176').start([c0])
    net.get('s58').start([c0])
    net.get('s166').start([c0])
    net.get('s11').start([c0])
    net.get('s32').start([c0])
    net.get('s139').start([c0, c3])
    net.get('s94').start([c0])
    net.get('s109').start([c0])
    net.get('s75').start([c0])
    net.get('s71').start([c0, c2])
    net.get('s24').start([c0])
    net.get('s65').start([c0])
    net.get('s39').start([c0])
    net.get('s99').start([c0])
    net.get('s35').start([c0])
    net.get('s192').start([c0])
    net.get('s96').start([c0])
    net.get('s169').start([c0])
    net.get('s60').start([c0])
    net.get('s128').start([c0])
    net.get('s68').start([c0])
    net.get('s13').start([c0])
    net.get('s20').start([c0])
    net.get('s7').start([c0])
    net.get('s114').start([c0])
    net.get('s153').start([c0])
    net.get('s10').start([c0])
    net.get('s142').start([c0])
    net.get('s117').start([c0])
    net.get('s12').start([c0])
    net.get('s57').start([c0])
    net.get('s151').start([c0])
    net.get('s78').start([c0])
    net.get('s174').start([c0])
    net.get('s42').start([c0])
    net.get('s147').start([c0])
    net.get('s45').start([c0])
    net.get('s5').start([c0])
    net.get('s132').start([c0])
    net.get('s34').start([c0])
    net.get('s157').start([c0])
    net.get('s155').start([c0])
    net.get('s144').start([c0])
    net.get('s177').start([c0])
    net.get('s148').start([c0])
    net.get('s81').start([c0])
    net.get('s133').start([c0])
    net.get('s136').start([c0])
    net.get('s145').start([c0])
    net.get('s178').start([c0])
    net.get('s79').start([c0])
    net.get('s186').start([c0])
    net.get('s28').start([c0])
    net.get('s22').start([c0])
    net.get('s122').start([c0])
    net.get('s181').start([c0])
    net.get('s111').start([c0])
    net.get('s18').start([c0])
    net.get('s140').start([c0])
    net.get('s168').start([c0])
    net.get('s76').start([c0])
    net.get('s14').start([c0])
    net.get('s135').start([c0])
    net.get('s183').start([c0])
    net.get('s47').start([c0])
    net.get('s129').start([c0])
    net.get('s40').start([c0])
    net.get('s70').start([c0])
    net.get('s104').start([c0])
    net.get('s23').start([c0])
    net.get('s101').start([c0])
    net.get('s25').start([c0])
    net.get('s43').start([c0])
    net.get('s171').start([c0])
    net.get('s8').start([c0])
    net.get('s180').start([c0])
    net.get('s112').start([c0])
    net.get('s137').start([c0])
    net.get('s141').start([c0])
    net.get('s182').start([c0])
    net.get('s27').start([c0])
    net.get('s74').start([c0])
    net.get('s156').start([c0])
    net.get('s48').start([c0])
    net.get('s53').start([c0])
    net.get('s21').start([c0])
    net.get('s154').start([c0])
    net.get('s172').start([c0])
    net.get('s102').start([c0])
    net.get('s150').start([c0])
    net.get('s159').start([c0])
    net.get('s73').start([c0])
    net.get('s105').start([c0])
    net.get('s184').start([c0])
    net.get('s46').start([c0])
    net.get('s44').start([c0])
    net.get('s19').start([c0])
    net.get('s130').start([c0])
    net.get('s134').start([c0])
    net.get('s167').start([c0])
    net.get('s59').start([c0])
    net.get('s115').start([c0])
    net.get('s126').start([c0])
    net.get('s62').start([c0])
    net.get('s152').start([c0])
    net.get('s158').start([c0])
    net.get('s33').start([c0])
    net.get('s116').start([c0])
    net.get('s146').start([c0])

    info('*** Post configure switches and hosts\n')
    s51.cmd('ifconfig s51 10.0.0.21 up')
    s71.cmd('ifconfig s71 10.0.0.81 up')
    s139.cmd('ifconfig s139 10.0.0.149 up')

    s51.cmd('route add 10.0.0.1 dev s51')
    s71.cmd('route add 10.0.0.2 dev s71')
    s139.cmd('route add 10.0.0.3 dev s139')

    rootdir = '/sys/class/net'
    h1.cmd('ifconfig h1-eth0 mtu 10000')
    h2.cmd('ifconfig h2-eth0 mtu 10000')
    h3.cmd('ifconfig h3-eth0 mtu 10000')
    for switch in net.switches:
        for subdir, dirs, files in os.walk(rootdir):
            for dir in dirs:
                if (str(switch) == dir.split("-")[0]):
                    switch.cmd('ifconfig ' + dir + ' mtu 10000')

    net.staticArp()
    CLI(net)
    net.stop()
Example #57
0
import datetime
import subprocess
import os, signal
import sys
#           1.0
#    h1----s1----h2

nonbottlebw1 = 20
bottleneckbw = 6
nonbottlebw2 = 100
buffer_size = bottleneckbw * 1000 * 30 / (1500 * 8)
net = Mininet(cleanup=True)
h1 = net.addHost('h1', ip='10.0.1.1')
h2 = net.addHost('h2', ip='10.0.1.2')

s1 = net.addSwitch('s1')
c0 = net.addController('c0')
net.addLink(h1,
            s1,
            intfName1='h1-eth0',
            intfName2='s1-eth0',
            cls=TCLink,
            bw=nonbottlebw1,
            delay='10ms',
            max_queue_size=10 * buffer_size)
net.addLink(s1,
            h2,
            intfName1='s1-eth1',
            intfName2='h2-eth0',
            cls=TCLink,
            bw=nonbottlebw1,
def createNetwork():
    #send rate at each link in Mbps
    bwg = 1  #in Mbps
    bwbn = 1  #in Mbps
    mqs = 100  #max queue size of interfaces
    dly = '2.5ms'
    apps = 4  #number of other UDP applications = number of DRR classes - 1  [MAXIMUM = 9(!)]
    qlim = int(
        mqs /
        (apps +
         1))  #limit of queue in DRR is mqs divided by the number of apps + 1
    qlim = 5  #TODO delete (just a tryout)
    appquantum = 1500  #quantum for UDP traffic
    quicquantum = 55  # quantum for QUIC traffic

    #create empty network
    net = Mininet(intf=TCIntf)

    info('\n*** Adding controller\n')
    net.addController('c0')  #is it ok ?

    #add host to topology
    ht = net.addHost('ht', ip='10.10.0.1/24')
    hu = net.addHost('hu', ip='10.10.0.2/24')
    it = net.addHost('it', ip='10.20.0.1/24')
    iu = net.addHost('iu', ip='10.20.0.2/24')

    rh = net.addHost('rh', ip='10.10.0.10/24')
    ri = net.addHost('ri', ip='10.20.0.20/24')

    info('\n** Adding Switches\n')
    # Adding 2 switches to the network
    sw1 = net.addSwitch('sw1')
    sw2 = net.addSwitch('sw2')

    info('\n** Creating Links \n')
    #create link beetween the network
    link_ht_sw1 = net.addLink(ht, sw1)
    link_hu_sw1 = net.addLink(hu, sw1, intfName1='hu-eth0')
    link_rh_sw1 = net.addLink(rh, sw1, intfName1='rh-eth0')

    link_it_sw2 = net.addLink(it, sw2)
    link_iu_sw2 = net.addLink(iu, sw2)
    link_ri_sw2 = net.addLink(ri, sw2, intfName1='ri-eth0')

    link_rh_ri = net.addLink(rh, ri, intfName1='rh-eth1', intfName2='ri-eth1')

    #set bandwith
    link_ht_sw1.intf1.config(bw=bwbn, max_queue_size=mqs)
    link_hu_sw1.intf1.config(bw=bwbn, max_queue_size=mqs)
    link_rh_sw1.intf1.config(
        bw=bwbn, max_queue_size=mqs
    )  #max_queue_size is hardcoded low to prevent bufferbloat, too high queuing delays

    link_it_sw2.intf1.config(bw=bwg, max_queue_size=mqs)
    link_iu_sw2.intf1.config(bw=bwg, max_queue_size=mqs)
    link_ri_sw2.intf1.config(bw=bwg, max_queue_size=mqs,
                             delay=dly)  #delay is set at ri on both interfaces

    link_rh_ri.intf1.config(
        bw=bwg,
        max_queue_size=mqs)  #loss is set at rh on its interface to ri only

    link_ht_sw1.intf2.config(bw=bwbn, max_queue_size=mqs)
    link_hu_sw1.intf2.config(bw=bwbn, max_queue_size=mqs)
    link_rh_sw1.intf2.config(bw=bwbn, max_queue_size=mqs)

    link_it_sw2.intf2.config(bw=bwg, max_queue_size=mqs)
    link_iu_sw2.intf2.config(bw=bwg, max_queue_size=mqs)
    link_ri_sw2.intf2.config(bw=bwg, max_queue_size=mqs)

    link_rh_ri.intf2.config(bw=bwg, max_queue_size=mqs,
                            delay=dly)  #delay is set at ri on both interfaces

    net.start()

    info('\n*** Configuring hosts\n')

    rh.cmd(
        'ifconfig rh-eth1 10.12.0.10 netmask 255.255.255.0'
    )  #reconfiguring mutiples intefaces host to prevent mininet strange initialisation behaviors
    rh.cmd('ifconfig rh-eth0 10.10.0.10 netmask 255.255.255.0')
    rh.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward'
           )  #enable forwarding at routers

    ri.cmd(
        'ifconfig ri-eth1 10.12.0.20 netmask 255.255.255.0'
    )  #reconfiguring mutiples intefaces host to prvent mininet strange initialisation behaviors
    ri.cmd('ifconfig ri-eth0 10.20.0.20 netmask 255.255.255.0')
    ri.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward'
           )  #enable forwarding at routers

    #configure host default gateways
    ht.cmd('ip route add default via 10.10.0.10')
    hu.cmd('ip route add default via 10.10.0.10')
    it.cmd('ip route add default via 10.20.0.20')
    iu.cmd('ip route add default via 10.20.0.20')

    #configure router routing tables
    rh.cmd('ip route add default via 10.12.0.20')
    ri.cmd('ip route add default via 10.12.0.10')

    # weiyu:
    iu.cmd('touch server.pcap')
    hu.cmd('touch client.pcap')

    rh.cmd('tc qdisc del dev rh-eth1 root')

    start_nodes(rh, ri, iu, hu, mqs, it, ht, apps, appquantum, quicquantum,
                qlim)  #experiment actions

    it.cmd(
        'ethtool -K it-eth0 tx off sg off tso off'
    )  #disable TSO on TCP on defaul TCP sender need to be done on other host if sending large TCP file from other nodes

    time.sleep(5)

    hu.cmd('sudo tc -s -g qdisc show dev hu-eth0 >> tc.log')
    hu.cmd('sudo tc -s -g class show dev hu-eth0 >> tc.log')
    hu.cmd('echo "class show done (running).\n" >> tc.log')

    # Enable the mininet> prompt if uncommented
    info('\n*** Running CLI\n')
    CLI(net)

    hu.cmd('sudo tc -s -g class show dev hu-eth0 >> tc.log')
    hu.cmd('echo "class show done (end).\n" >> tc.log')
    # stops the simulation
    net.stop()
Example #59
0
def main():
    # --+--------+------------------+-- 10.0.0.0/24, fc00::/64
    #   |        |         |        |
    #   |.1/24   |.2/24    |.3/24   |.254/24
    # +----+   +----+   +----+   +------+
    # | r1 |   | r2 |   | r3 |   | r254 |
    # +----+   +----+   +----+   +------+
    net = Mininet(controller=RemoteController, switch=mnextlib.Bird)

    s1 = net.addSwitch('s1', cls=OVSBridge)

    r1 = net.addSwitch(
        'r1',
        intfIPs=[
            ('lo', '1.1.1.1/32'),
            ('r1-eth1', '10.0.0.1/8'),
            ('r2-eth1', 'fc00::1/64'),
        ],
        confFile='~/mnextlib/example/bird/bgp_star/r1/bird.conf',
    )
    r2 = net.addSwitch(
        'r2',
        intfIPs=[
            ('lo', '2.2.2.2/32'),
            ('r2-eth1', '10.0.0.2/8'),
            ('r2-eth1', 'fc00::2/64'),
        ],
        confFile='~/mnextlib/example/bird/bgp_star/r2/bird.conf',
    )
    # r2 = net.addSwitch(
    #     'r2',
    #     intfIPs=[
    #         ('r2-eth1', '10.0.0.2/24'),
    #         ('r2-eth1', 'fc00::2/64'),
    #     ],
    #     cls=mnextlib.Router,
    # )
    r3 = net.addSwitch(
        'r3',
        intfIPs=[
            ('r3-eth1', '10.0.0.3/24'),
            ('r3-eth1', 'fc00::3/64'),
        ],
        cls=mnextlib.Router,
    )
    r254 = net.addSwitch(
        'r254',
        intfIPs=[
            ('r254-eth1', '10.0.0.254/24'),
            ('r254-eth1', 'fc00::254/64'),
        ],
        cls=mnextlib.Router,
    )

    net.addLink(s1, r1)
    net.addLink(s1, r2)
    net.addLink(s1, r3)
    net.addLink(s1, r254)

    net.start()
    CLI(net)
    net.stop()
Example #60
-1
def main():
    net = Mininet(controller=None)

    # add hosts
    h1 = net.addHost("h1", ip="172.16.10.1/24")
    h2 = net.addHost("h2", ip="172.16.10.2/24")

    # add switch 1
    sw1 = net.addSwitch("sw1", target_name="p4dockerswitch", cls=P4DockerSwitch, sai_port=25000, pcap_dump=True)

    # add switch 2
    sw2 = net.addSwitch("sw2", target_name="p4dockerswitch", cls=P4DockerSwitch, sai_port=25001, pcap_dump=True)

    # add links
    if StrictVersion(VERSION) <= StrictVersion("2.2.0"):
        net.addLink(sw1, h1, port1=1)
        net.addLink(sw1, sw2, port1=2, port2=2)
        net.addLink(sw2, h2, port1=1)
    else:
        net.addLink(sw1, h1, port1=1, fast=False)
        net.addLink(sw1, sw2, port1=2, port2=2, fast=False)
        net.addLink(sw2, h2, port1=1, fast=False)

    net.start()

    print "Waiting 10 seconds for switches to intialize..."
    time.sleep(10)

    cfg_switch1()
    cfg_switch2()

    CLI(net)

    net.stop()