Example #1
0
def create(delay, bw, max_queue_size):
    net = Mininet(link=TCLink)

    router = net.addSwitch('s1', cls=LinuxBridge)

    # create virtual hosts
    client = net.addHost('h1')
    server = net.addHost('h2')

    info("Create link client <-> router")
    net.addLink(client,
                router,
                loss=0,
                bw=1000,
                delay="0.5ms",
                use_hfsc=True)
    info("\n")

    info("Create link server <-> router")
    net.addLink(server,
                router,
                loss=0,
                bw=bw,
                delay=delay,
                use_hfsc=True,
                max_queue_size=max_queue_size)
    info("\n")

    return net, client, server
Example #2
0
def intfOptions():
    "run various traffic control commands on a single interface"
    net = Mininet( autoStaticArp=True )
    net.addController( 'c0' )
    h1 = net.addHost( 'h1' )
    h2 = net.addHost( 'h2' )
    s1 = net.addSwitch( 's1' )
    link1 = net.addLink( h1, s1, cls=TCLink )
    net.addLink( h2, s1 )
    net.start()
    
    # flush out latency from reactive forwarding delay
    net.pingAll()

    info( '\n*** Configuring one intf with bandwidth of 5 Mb\n' )
    link1.intf1.config( bw=5 )
    info( '\n*** Running iperf to test\n' )
    net.iperf()

    info( '\n*** Configuring one intf with loss of 50%\n' )
    link1.intf1.config( loss=50 )
    info( '\n' )
    net.iperf( ( h1, h2 ), l4Type='UDP' )
    
    info( '\n*** Configuring one intf with delay of 15ms\n' )
    link1.intf1.config( delay='15ms' )
    info( '\n*** Run a ping to confirm delay\n' )
    net.pingPairFull()
    
    info( '\n*** Done testing\n' )
    net.stop()
Example #3
0
def sdnTopo(interface_name):

    CONTROLLER_IP='10.0.0.200'

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

    # Create nodes
    h1 = net.addHost( 'h1', ip='10.0.0.1/8' )
    h2 = net.addHost( 'h2', ip='10.0.0.2/8' )

    # Create switches
    s1 = net.addSwitch( 's1')

    net.addLink(h1, s1, )
    net.addLink(h2, s1, )

    # Add Controllers
    odl_ctrl = net.addController( 'c0', controller=RemoteController, ip=CONTROLLER_IP)


    info( "*** Creation de l'architecture réseau\n" )
    net.build()

    # Connect each switch to a different controller
    s1.start( [odl_ctrl] )


    info( "*** Ajout de l'interface",interface_name,"au switch" )
    _intf = Intf( interface_name, node=s1)
    net.start()
    CLI( net )
    net.stop()
Example #4
0
def myNetwork():

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

    info( '*** Adding controller\n' )
    info( '*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone')

    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)

    info( '*** Add links\n')
    net.addLink(s1, h1)
    net.addLink(s1, h2)

    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([])

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

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

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** adding Link"
    net.addLink(sta1, ap1)

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

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    getTrace(sta1, 'examples/replaying/replayingBandwidth/throughputData.dat')

    replayingBandwidth()

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

    print "*** Stopping network"
    net.stop()
Example #6
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 #7
0
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,20,0' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,30,0' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='15,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

    """uncomment to plot graph"""
    #net.plotGraph(max_x=60, max_y=60)

    print "*** Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

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

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

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
    #wirelessRadios = Number of STAs + APs
    
    print "*** Creating nodes"
    ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5" )
    sta1 = net.addStation( 'sta1', ip='192.168.0.1/24' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.2/24' )
    h3 = net.addHost( 'h3', ip='192.168.0.3/24' )
    h4 = net.addHost( 'h4', ip='192.168.0.4/24' )

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

    print "*** Adding Link"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(h3, ap1)
    net.addLink(h4, ap1)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )

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

    print "*** Stopping network"
    net.stop()
Example #9
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
Example #10
0
def myNet():
    #OpenDayLight controller
    CONTROLLER1_IP='127.0.0.1'

    #Floodlight controller

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

    # Create nodes
    h1 = net.addHost( 'h1', mac='01:00:00:00:01:00', ip='192.168.0.1/24' )

    # Create switches
    s1 = net.addSwitch( 's1', listenPort=6634, mac='00:00:00:00:00:01' )
    
    print "*** Creating links"
    net.addLink(h1, s1 )
  

    # Add Controllers
    c0 = net.addController( 'c0', controller=RemoteController, ip=CONTROLLER1_IP, port=6633)

    net.build()

    # Connect each switch to a different controller
    s1.start([c0])

    s1.cmdPrint('ovs-vsctl show')
    
    CLI( net )
    net.stop()
def emptyNet():

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

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

    net.addController( 'c0',
                       controller=RemoteController,
                       ip='0.0.0.0'  )

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

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

    net.addLink( h1, s1 )
    net.addLink( h2, s1 )
    net.addLink( h3, s1 )

    net.start()
    s1.cmd('ifconfig s1 inet 10.0.0.10')

    CLI( net )
    net.stop()
Example #12
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()
def createEmptyNet():
    final_hosts=[]
    final_switches=[]
    net = Mininet(controller=OVSController,link=TCLink)
    net.addController('c0')
    evenflag=1
    oddflag=1
    evenflagip='11.0.0.'
    oddflagip='11.0.1.'
    for x in range(0,B*A):
        if x%2==0:
            final_hosts.append(net.addHost('h'+str(x+1), ip=evenflagip+str(evenflag)+'/24'))
            evenflag+=1
        else:
            final_hosts.append(net.addHost('h'+str(x+1), ip=oddflagip+str(oddflag)+'/24'))
            oddflag+=1
    for x in range(0,A):
        final_switches.append(net.addSwitch('s'+str(x+1)))
    
    bwidth=0
    for x in range(0,A):
        for y in range(0,B):
            net.addLink( final_hosts[B*x+y], final_switches[x] , bw=bwidth+1)
            bwidth=(bwidth+1)%2
    for x in range(0,A-1):
        net.addLink(final_switches[x],final_switches[x+1],bw=2)

    net.start()
    CLI( net )
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    """Seed"""
    net.seed(20) 

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0, model='RandomDirection', max_x=60, max_y=60, min_v=0.5, max_v=0.5)
   
    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #15
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()
class MyTopo(object):
    def __init__(self, cname='onos', cips=['10.0.3.1']):
        # Create network with multiple controllers
        self.net = Mininet(controller=RemoteController, switch=OVSKernelSwitch,
                           build=False, autoSetMacs=True)
 
        # Add controllers with input IPs to the network
        ctrls = [RemoteController(cname, cip, 6633) for cip in cips]
        for ctrl in ctrls:
            print ctrl.ip
            self.net.addController(ctrl)
 
        # Add components
        self.s1 = self.net.addSwitch('s1', dpid='00000000000000a1')
        h1 = self.net.addHost('h1', ip='10.0.0.11/24', mac='00:00:00:00:00:01')

        # Add links
        self.net.addLink(h1, self.s1)
 
    def run(self):
        self.net.build()
        self.net.start()
	self.s1.cmd('ovs-vsctl set bridge s1 protocols=OpenFlow13')
        self.s1.cmd('ovs-vsctl add-port s1 vxlan1')
        self.s1.cmd('ovs-vsctl set interface vxlan1 type=vxlan option:remote_ip=45.55.19.146 option:key=flow')
        CLI(self.net)
        self.net.stop()
Example #17
0
def main():
    net = Mininet()
    # create hosts
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')

    # create switch
    s1 = net.addSwitch('S1')

    # create controller
    c1 = net.addController('c1')

    # create links
    net.addLink(h1, s1)
    net.addLink(h2, s1)

    net.start()

    # start web server on h2
    print('starting web server...')
    h2.cmd('python -m SimpleHTTPServer 80 &')
    sleep(2)

    # use h1 as a web client
    print('accessing web server..')
    h1.cmd('curl', h2.IP())

    # CLI(net)
    print('kill web server..')
    h2.cmd('kill %python')

    print('finish.')
    net.stop()
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()
Example #19
0
def Topology():
	net = Mininet(controller= Cotroller, switch = OVSSwitch)
	
	print "******** Creating controller"
	c1= net.addController ('c1', ip='127.0.0.1', port = 6633)
	
	print "******** Creating switches"
	s1 = net.addSwitch( 's1' )
	s2 = net.addSwitch( 's2' )

	print "******** Creating host"
	h1 = net.addHost( 'h1' )
	h2 = net.addHost( 'h2' )
	
	print "******** Creating links"
	net.addLink (h1,s1)
	net.addLink (h2,s2)
	net.addLink (s1,s2)

	print "******* Starting network"
	net.build()
	c1.start
	s1.start([c1])
	s2.start([c2])
	
	net.start()

	print "******* Testing network"
	net.pingAll()

	print "****** Running CLI"
	CLI(net)
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='10,10,0' )
    c1 = net.addController( 'c1', controller=Controller )

    """uncomment to plot graph"""
    #net.plotGraph(max_x=60, max_y=60)

    print "*** Associating and Creating links"
    net.addLink(ap1, h1, 1, 0)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    
    
    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***"
    net.startMobility(0, model='GaussMarkov', max_x=20, max_y=20, min_v=0.1, max_v=0.3)
   
    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #21
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 allfour():

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

    net = Mininet(controller = OVSController, 
                    switch=OVSSwitch, autoSetMacs=True)

    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' )
    h3 = net.addHost( 'h3', ip='10.0.0.3' )
    h4 = net.addHost( 'h4', ip='10.0.0.4' )

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

    info( '*** Creating links\n' )
    net.addLink( h1, s1)
    net.addLink( h2, s1)
    net.addLink( h3, s1)
    net.addLink( h4, s1)

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

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

    info( '*** Stopping network' )
    net.stop()
Example #23
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 #24
0
def server2():

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

    net = Mininet( controller=None )

    info( '*** Adding hosts\n' )
    h3 = net.addHost( 'h3', ip='10.0.0.3', mac='00:00:00:00:00:03')
    h4 = net.addHost( 'h4', ip='10.0.0.4', mac='00:00:00:00:00:04')

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

    info( '*** Creating links\n' )
    net.addLink( h3, s2 )
    net.addLink( h4, s2 )

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

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

    info( '*** Stopping network' )
    net.stop()
Example #25
0
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', wlans=3 ) # 3 wlan added
    sta2 = net.addStation( 'sta2' ) # 1 wlan added
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_1", mode="g", channel=5 ) # 1 wlan added
    c0 = net.addController('c0', controller=Controller)

    print "*** Associating..."
    net.addLink(ap1, sta1)

    net.addHoc(sta1, ssid='adhoc1', mode='g')
    net.addHoc(sta2, ssid='adhoc1', mode='g')

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )

    print "***Addressing..."
    sta1.setIP('192.168.10.1/24', intf="sta1-wlan1")
    sta2.setIP('192.168.10.2/24', intf="sta2-wlan0")

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

    print "*** Stopping network"
    net.stop()
Example #26
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 #27
0
def emptyNet():

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

    net = Mininet( controller=RemoteController )

    info( '*** Adding controller\n' )
    net.addController( 'c1',controller=RemoteController,ip="192.168.1.38",port=6653 )

    info( '*** Adding hosts\n' )
    h3 = net.addHost( 'h3', ip = "10.0.0.3" )
    h4 = net.addHost( 'h4', ip = "10.0.0.4" )
    info( '*** Adding switch\n' )
    s2 = net.addSwitch( 's2' ,mac="00:00:00:00:00:02" )

    info( '*** Creating links\n' )
    net.addLink( h3, s2 )
    net.addLink( h4, s2 )

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

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

    info( '*** Stopping network' )
    net.stop()
Example #28
0
def myNetwork():
    net = Mininet()
    
    host_1 = net.addHost('host_1', ip='192.168.0.10/24')
    router_1 = net.addHost('router_1')
    
    net.addLink(host_1, router_1)

    # Interface binding with the SDN_hub's eth1 
    Intf( 'eth0', node=router_1)

    # Print information
    info( '*** Starting network\n')

    net.start()

    router_1.cmd('ifconfig router-eth0 0')
    router_1.cmd('ifconfig router-eth1 0')
    
    # Get ip from NAT's DHCP
    router_1.cmd("dhclient eth0")
    
    router_1.cmd("ip addr add 192.168.0.1/24 brd + dev router_1-eth0")
    router_1.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")
    
    # Change the Intranet IP to NAT IP
    router_1.cmd("iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE")

    host_1.cmd("ip route add default via 192.168.0.1")

    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')
    s1 = net.addSwitch('s1')

    info('*** Creating host links\n')
    #h2.linkTo(s2)
    net.addLink(s1, h1, 1, 1)
    net.addLink(s1, h2, 2, 1)

    #info('*** Creating swicth links\n')
    #s1.linkTo(s2)
    #net.addLink(s1, s2, 2, 2) #, bw=10, delay='5ms', jitter='2ms', loss=10, max_queue_size=1000, use_htb=True)

    print s1.intfNames()
    #print s2.intfNames()

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

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

    info('*** Stopping network')
    net.stop()
def emptyNet():

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

    net = Mininet( controller=RemoteController )

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

    info( '*** Adding hosts\n' )
    h3 = net.addHost( 'host3', cls=Host, ip='10.0.0.1', mac="00:00:00:00:00:00:00:01" )
    h4 = net.addHost( 'host4', cls=Host, ip='10.0.0.2', mac="00:00:00:00:00:00:00:02" )
    h1 = net.addHost( 'host1', cls=Host, ip='10.0.0.3', mac="00:00:00:00:00:00:00:03" )
    h2 = net.addHost( 'host2', cls=Host, ip='10.0.0.4', mac="00:00:00:00:00:00:00:04" )

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


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


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

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

    info( '*** Stopping network' )
    net.stop()
Example #31
0
print "# 3) Bronze                   #"
print "#                             #"
print "###############################"
#
servicelevel = input("Number selection: ")
print 'Selection: %s ' % servicelevel
print " "
a = raw_input("Hit Enter to confirm!")
os.system('clear')
#
#
net = Mininet()
h1 = net.addHost('h1')

s1 = net.addSwitch('s1')
net.addLink(h1, s1)
print "###############################"
print "# Creating Virtual Machine... #"
print "# Creating Virtual Switch.... #"
print "# Assign IP addressing....... #"
print "# Testing IP connectivity.... #"
print "###############################"
net.start()
print h1.cmd('ping -c3', h1.IP())

a = raw_input("Hit Enter to continue")
os.system('clear')
#
#net.stop()

#
Example #32
0
def emptyNet():

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

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

    info('*** Adding hosts\n')
    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')

    info('*** Adding switch\n')
    s1 = net.addSwitch('s1', cls=OVSSwitch)
    s2 = net.addSwitch('s2', cls=OVSSwitch)
    s3 = net.addSwitch('s3', cls=OVSSwitch)
    s4 = net.addSwitch('s4', cls=OVSSwitch)
    s5 = net.addSwitch('s5', cls=OVSSwitch)
    s6 = net.addSwitch('s6', cls=OVSSwitch)
    s7 = net.addSwitch('s7', cls=OVSSwitch)

    info('*** Creating links\n')

    ## host - switch
    net.addLink(h1, s3)
    net.addLink(h2, s3)
    net.addLink(h3, s4)
    net.addLink(h4, s4)
    net.addLink(h5, s6)
    net.addLink(h6, s6)
    net.addLink(h7, s7)
    net.addLink(h8, s7)

    ## switches
    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(s2, s4)
    net.addLink(s3, s4)
    net.addLink(s1, s5)
    net.addLink(s5, s7)
    net.addLink(s5, s6)
    net.addLink(s6, s7)

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

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

    info('*** Stopping network')
    net.stop()
Example #33
0
                  link=TCLink)

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

    s1 = net.addSwitch('s1', protocols='OpenFlow13')
    s2 = net.addSwitch('s2', protocols='OpenFlow13')

    hs1 = net.addHost('hs1')
    hs2 = net.addHost('hs2')
    hs3 = net.addHost('hs3')

    hc1 = net.addHost('hc1')
    hc2 = net.addHost('hc2')
    hc3 = net.addHost('hc3')

    net.addLink(hs1, s1)
    net.addLink(hs2, s1)
    net.addLink(hs3, s1)

    net.addLink(s1, s2, bw=8)

    net.addLink(hc1, s2)
    net.addLink(hc2, s2)
    net.addLink(hc3, s2)

    net.build()
    c0.start()
    s1.start([c0])
    s2.start([c0])

    #net.startTerms()
def startTopo():
    operation = 0
    if (len(sys.argv) < 2):
        sys.exit(
            "Oops you didn't specify the operation mode. Specify --all for all the mappings or --file for the mappings that are\
 specified in the topo config file")
    else:
        operation = sys.argv[1]
        if (str(operation) != "--all" and str(operation) != "--file"):
            sys.exit(
                "Unsupported Operation. Supported arguments are --all and --file"
            )

    n = 3
    host = partial(VLANHost, vlan=100)

    net = Mininet(switch=OVSHtbQosSwitch,
                  host=host,
                  link=TCLink,
                  autoStaticArp=True,
                  autoSetMacs=True,
                  controller=None,
                  build=False)
    c0 = net.addController('c0', controller=RemoteController, ip='127.0.0.1')
    c1 = net.addController('c1',
                           controller=RemoteController,
                           ip='192.168.56.107')

    # Open Topology Configuration File#
    config = open('topo_config', 'r')
    #Create 3 lists. One should store the switches names and the other the number of Hosts per Switch#
    switches = []
    hostsPerSwitch = []
    bandwidths = []
    # Parse the file and fill the 3 lists with the information #
    for line in config:
        if not "*" in line:
            temp = line.split(" ")
            switchName = temp.pop(0)
            if (switchName == 's1'):
                raise Exception(
                    "The name s1 represents the core of the network. Please make sure that you don't use it in your config file"
                )
            switches.append(switchName)
            hostsPerSwitch.append(temp.pop(0))
            bandwidths.append(temp.pop(0))

    hostCount = 1
    i = 0
    # Create the switch that represents the core of the network #
    coreSwitch = net.addSwitch('s1')
    # Iterate through switches #
    for i in range(len(switches)):
        # Create the switch according to the name that is specified in the list and connect it to the core network #
        switch = net.addSwitch(switches[i])
        if (int(bandwidths[i]) == 0):
            net.addLink(coreSwitch, switch)
        else:
            net.addLink(coreSwitch, switch, bw=int(bandwidths[i]))
        # Create the number of hosts that are specified to the list and connect them to the switch that we created above #
        for j in range(int(hostsPerSwitch[i])):
            host = net.addHost('h%s' % hostCount)
            net.addLink(host, switch)
            hostCount += 1

    #start the controllers
    net.build()
    c0.start()
    c1.start()

    # Assign all the edge switches to the controller zero
    for switch in switches:
        Switch = net.getNodeByName(str(switch))
        Switch.start([c1])
    #Assign the core network switch to the controller 1
    coreSwitch.start([c0])
    print "\nApplying VTN Settings..."
    os.system("python createVTNAutomatedOdl.py " + str(operation))
    print "Executing Pingall to identify hosts... Don't worry about the loss."
    net.pingAll()
    print "Applying Queues Configuration..."
    os.system("python vlan_queues.py " + str(len(switches)))
    CLI(net)
Example #35
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='172.20.5.137',
                           protocol='tcp',
                           port=6633)

    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, dpid='000000000000010')
    s11 = net.addSwitch('s11', cls=OVSKernelSwitch, dpid='000000000000011')
    s12 = net.addSwitch('s12', cls=OVSKernelSwitch, dpid='000000000000012')
    s13 = net.addSwitch('s13', cls=OVSKernelSwitch, dpid='000000000000013')
    s14 = net.addSwitch('s14', cls=OVSKernelSwitch, dpid='000000000000014')
    s15 = net.addSwitch('s15', cls=OVSKernelSwitch, dpid='000000000000015')
    s16 = net.addSwitch('s16', cls=OVSKernelSwitch, dpid='000000000000016')

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

    # root
    root_eth0 = {'ipAddrs': ['10.0.0.1'],
                 'mask': '255.0.0.0', 'gateway': '10.0.0.1'}
    myDict_root = {'root-eth0': root_eth0}
    root = net.addHost("root", cls=MyHost,
                       inNamespace=False, intfDict=myDict_root)

    # Region 01
    # sr_01
    sr_01_eth0 = {'ipAddrs': ['10.0.1.2'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:10'}
    myDict_sr_01 = {'sr_01-eth0': sr_01_eth0}
    privateDirs_sr_01 = [
        ('/opt/ts2/etc/trafficserver', '/home/notroot/mininet-lab/topos/components/ats/configuration_02')]
    sr_01 = net.addHost("sr_01", cls=MyHost,
                        intfDict=myDict_sr_01, privateDirs=privateDirs_sr_01)

    # sr_02
    sr_02_eth0 = {'ipAddrs': ['10.0.1.3'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:11'}
    myDict_sr_02 = {'sr_02-eth0': sr_02_eth0}
    sr_02 = net.addHost("sr_02", cls=MyHost, intfDict=myDict_sr_02)

    # Region 02
    # sr_03
    sr_03_eth0 = {'ipAddrs': ['10.0.2.2'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:12'}
    privateDirs_sr_03 = [
        ('/opt/ts3/etc/trafficserver', '/home/notroot/mininet-lab/topos/components/ats/configuration_03')]
    myDict_sr_03 = {'sr_03-eth0': sr_03_eth0}
    sr_03 = net.addHost("sr_03", cls=MyHost,
                        intfDict=myDict_sr_03, privateDirs=privateDirs_sr_03)

    # sr_04
    sr_04_eth0 = {'ipAddrs': ['10.0.2.3'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:13'}
    privateDirs_sr_04 = [
        ('/opt/ts/etc/trafficserver', '/home/notroot/mininet-lab/topos/components/ats/configuration_01')]
    myDict_sr_04 = {'sr_04-eth0': sr_04_eth0}
    sr_04 = net.addHost("sr_04", cls=MyHost,
                        intfDict=myDict_sr_04, privateDirs=privateDirs_sr_04)

    # Region 03
    # sr_05
    sr_05_eth0 = {'ipAddrs': ['10.0.3.2'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:14'}
    privateDirs_sr_05 = [
        ('/opt/ts4/etc/trafficserver', '/home/notroot/mininet-lab/topos/components/ats/configuration_04')]
    myDict_sr_05 = {'sr_05-eth0': sr_05_eth0}
    sr_05 = net.addHost("sr_05", cls=MyHost,
                        intfDict=myDict_sr_05, privateDirs=privateDirs_sr_05)

    # sr_06
    sr_06_eth0 = {'ipAddrs': ['10.0.3.3'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:15'}
    myDict_sr_06 = {'sr_06-eth0': sr_06_eth0}
    sr_06 = net.addHost("sr_06", cls=MyHost, intfDict=myDict_sr_06)

    # Region 04
    # sr_07
    sr_07_eth0 = {'ipAddrs': ['10.0.4.2'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:16'}
    myDict_sr_07 = {'sr_07-eth0': sr_07_eth0}
    sr_07 = net.addHost("sr_07", cls=MyHost, intfDict=myDict_sr_07)

    # sr_08
    sr_08_eth0 = {'ipAddrs': ['10.0.4.3'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:17'}
    myDict_sr_08 = {'sr_08-eth0': sr_08_eth0}
    sr_08 = net.addHost("sr_08", cls=MyHost, intfDict=myDict_sr_08)

    # Region 05
    # sr_09
    sr_09_eth0 = {'ipAddrs': ['10.0.5.2'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:18'}
    myDict_sr_09 = {'sr_09-eth0': sr_09_eth0}
    sr_09 = net.addHost("sr_09", cls=MyHost, intfDict=myDict_sr_09)

    # sr_10
    sr_10_eth0 = {'ipAddrs': ['10.0.5.3'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:19'}
    myDict_sr_10 = {'sr_10-eth0': sr_10_eth0}
    sr_10 = net.addHost("sr_10", cls=MyHost, intfDict=myDict_sr_10)

    # sr_11
    sr_11_eth0 = {'ipAddrs': ['10.0.6.7'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:20'}
    myDict_sr_11 = {'sr_11-eth0': sr_11_eth0}
    sr_11 = net.addHost("sr_11", cls=MyHost, intfDict=myDict_sr_11)

    # sr_11
    sr_12_eth0 = {'ipAddrs': ['10.0.7.7'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:21'}
    myDict_sr_12 = {'sr_12-eth0': sr_12_eth0}
    sr_12 = net.addHost("sr_12", cls=MyHost, intfDict=myDict_sr_12)

    # sr_13
    sr_13_eth0 = {'ipAddrs': ['10.0.8.70'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:22'}
    myDict_sr_13 = {'sr_13-eth0': sr_13_eth0}
    sr_13 = net.addHost("sr_13", cls=MyHost, intfDict=myDict_sr_13)

    # sr_14
    sr_14_eth0 = {'ipAddrs': ['10.0.9.23'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:23'}
    myDict_sr_14 = {'sr_14-eth0': sr_14_eth0}
    sr_14 = net.addHost("sr_14", cls=MyHost, intfDict=myDict_sr_14)

    # sr_15
    sr_15_eth0 = {'ipAddrs': ['10.0.10.35'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:24'}
    myDict_sr_15 = {'sr_15-eth0': sr_15_eth0}
    sr_15 = net.addHost("sr_15", cls=MyHost, intfDict=myDict_sr_15)

    # sr_16
    sr_16_eth0 = {'ipAddrs': ['10.0.11.40'],
                  'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:25'}
    myDict_sr_16 = {'sr_16-eth0': sr_16_eth0}
    sr_16 = net.addHost("sr_16", cls=MyHost, intfDict=myDict_sr_16)

    # Client01
    client_01_eth0 = {'ipAddrs': ['10.0.1.5'],
                      'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:26'}
    myDict_client_01 = {'client_01-eth0': client_01_eth0}
    client_01 = net.addHost("client_01", cls=MyHost, intfDict=myDict_client_01)

    # Client02
    client_02_eth0 = {'ipAddrs': ['10.0.1.6'],
                      'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:27'}
    myDict_client_02 = {'client_02-eth0': client_02_eth0}
    client_02 = net.addHost("client_02", cls=MyHost, intfDict=myDict_client_02)

    # MAR
    mar_eth0 = {'ipAddrs': ['10.0.1.7'],
                'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:28'}
    myDict_mar = {'mar-eth0': mar_eth0}
    mar = net.addHost("mar", cls=MyHost, intfDict=myDict_mar,
                      defaultRoute='10.0.0.1')

    # Topology
    topology_eth0 = {'ipAddrs': ['10.0.1.8'],
                     'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:29'}
    myDict_topology = {'topology-eth0': topology_eth0}
    topology = net.addHost("topology", cls=MyHost, intfDict=myDict_topology)

    # Consul
    consul_eth0 = {'ipAddrs': ['10.0.1.9'],
                   'mask': '255.0.0.0', 'gateway': '10.0.0.1', 'mac': 'B6:29:CE:E1:DB:30'}
    myDict_consul = {'consul-eth0': consul_eth0}
    consul = net.addHost("consul", cls=MyHost, intfDict=myDict_consul)

    info('*** Add links\n')
    # Between switches
    # Region 1
    net.addLink(s1, s2, bw=100, delay='25us')
    net.addLink(s2, s3, bw=100, delay='25us')
    net.addLink(s3, s4, bw=100, delay='25us')
    net.addLink(s4, s1, bw=100, delay='25us')
    # Region 2
    net.addLink(s5, s6, bw=100, delay='25us')
    net.addLink(s6, s7, bw=100, delay='25us')
    net.addLink(s7, s8, bw=100, delay='25us')
    net.addLink(s8, s5, bw=100, delay='25us')
    # Region 3
    net.addLink(s9, s10, bw=100, delay='25us')
    net.addLink(s10, s11, bw=100, delay='25us')
    net.addLink(s11, s12, bw=100, delay='25us')
    net.addLink(s12, s9, bw=100, delay='25us')
    # Region 4
    net.addLink(s13, s14, bw=100, delay='25us')
    net.addLink(s14, s15, bw=100, delay='25us')
    net.addLink(s15, s16, bw=100, delay='25us')
    net.addLink(s16, s13, bw=100, delay='25us')
    # Links between regions
    net.addLink(s3, s13, bw=1000, delay='250us')
    net.addLink(s14, s12, bw=1000, delay='250us')
    net.addLink(s7, s9, bw=1000, delay='250us')
    net.addLink(s8, s2, bw=1000, delay='250us')

    # s1
    net.addLink(s1, root, bw=100, delay='25us')
    net.addLink(s1, mar, bw=100, delay='25us')
    net.addLink(s1, topology, bw=100, delay='25us')
    net.addLink(s1, consul, bw=100, delay='25us')

    # Replication servers
    net.addLink(s4, sr_01, bw=100, delay='25us')
    net.addLink(s5, sr_02, bw=100, delay='25us')
    net.addLink(s8, sr_16, bw=100, delay='25us')
    net.addLink(s9, sr_10, bw=100, delay='25us')
    net.addLink(s10, sr_03, bw=100, delay='25us')
    net.addLink(s15, sr_04, bw=100, delay='25us')
    net.addLink(s16, sr_05, bw=100, delay='25us')
    net.addLink(s11, sr_06, bw=100, delay='25us')
    net.addLink(s12, sr_07, bw=100, delay='25us')
    net.addLink(s13, sr_08, bw=100, delay='25us')
    net.addLink(s14, sr_09, bw=100, delay='25us')
    net.addLink(s3, sr_11, bw=100, delay='25us')
    net.addLink(s2, sr_12, bw=100, delay='25us')
    net.addLink(s1, sr_13, bw=100, delay='25us')
    net.addLink(s6, sr_14, bw=100, delay='25us')
    net.addLink(s7, sr_15, bw=100, delay='25us')

    # Clients
    net.addLink(s16, client_01, bw=100, delay='25us')
    net.addLink(s15, client_02, bw=100, delay='25us')

    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])
    net.get('s15').start([c0])
    net.get('s16').start([c0])

    info('*** Post configure switches and hosts\n')
    # mar.cmd('ifconfig')

    CLI(net)
    net.stop()
def Mptcp():
    net = Mininet(cleanup=True)

    #add 5 hosts with mininet default IP 10.0.0.1 to 10.0.0.5 to the network topology
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 = net.addHost('h3')
    h4 = net.addHost('h4')
    h5 = net.addHost('h5')

    #add 1 switch to the topology
    s3 = net.addSwitch('s3')

    c0 = net.addController('c0')

    #connect 5 hosts through a switch
    net.addLink(h1, s3, cls=TCLink, bw=1000)
    net.addLink(h2, s3, cls=TCLink, bw=1000)
    net.addLink(h3, s3, cls=TCLink, bw=1000)
    net.addLink(h4, s3, cls=TCLink, bw=1000)
    net.addLink(h5, s3, cls=TCLink, bw=1000)

    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)

    print "Testing network connectivity"
    net.pingAll()
    print "Testing bandwidth between h1 and h4"
    #CLI(net)
    time.sleep(1)  # wait for net to startup
    print "\n", " " * 5, "#" * 40, "\n", " " * 10, "STARTING\n"

    #enable mptcp on hosts
    if tcp_on:

        set_mptcp_enabled(False)

        #test connectivity of h1,h3,h4,h5(client) to the h2(server) from both the interfaces.
        h2_out = h1.cmdPrint('ping -c 1 ' + h2.IP('h2-eth0') + ' ')
        print "ping test output: %s\n" % h2_out

        h2_out = h3.cmdPrint('ping -c 1 ' + h2.IP('h2-eth0') + ' ')
        print "ping test output: %s\n" % h2_out

        h2_out = h4.cmdPrint('ping -c 1 ' + h2.IP('h2-eth0') + ' ')
        print "ping test output: %s\n" % h2_out

        h2_out = h5.cmdPrint('ping -c 1 ' + h2.IP('h2-eth0') + ' ')
        print "ping test output: %s\n" % h2_out

        #give time to print ping output
        time.sleep(3)

        print 'starting iperf server at: ', h2.IP()
        h2.cmd('iperf -s  > iperf_mptcp_server_log.txt & ')

        #create pool of 5 processes to send data from 4-clients to server simultaniously
        p = Pool(5)
        i = 0
        lst = [[
            h,
            h2,
        ] for h in [h1, h3, h4, h5]]
        main_list = []
        for l in lst:
            i += 1
            l.append(i)
            t = tuple(l)
            main_list.append(t)
        print main_list

        print p.map(wrap_fn, main_list)

        h2.cmd('kill -9 %while')
        time.sleep(test_duration / 3.0)

        CLI(net)

    net.stop()
    os.system("sudo mn -c")
def createNetwork():
    #send rate at each link in Mbps
    bwg = 1  #000 #1000 #in Mbps
    bwbn = 1  #000 #1000 #25 #in Mbps
    loss = 80  #1 #2.5 #10 #1 #in %
    mqs = 100  #0 #1000 #max queue size of interfaces
    dly = '10ms'  #'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 #38
0
                  mac='00:00:10:00:01:13',
                  ip='10.0.1.13/24',
                  defaultRoute='via 10.0.1.1')
h14 = net.addHost('h14',
                  mac='00:00:10:00:01:14',
                  ip='10.0.1.14/24',
                  defaultRoute='via 10.0.1.1')
d11 = net.addHost('d11',
                  mac='00:00:10:00:01:a1',
                  ip='10.0.1.111/24',
                  defaultRoute='via 10.0.1.1')
d12 = net.addHost('d12',
                  mac='00:00:10:00:01:a2',
                  ip='10.0.1.112/24',
                  defaultRoute='via 10.0.1.1')
net.addLink(s10, h11)
net.addLink(s10, h12)
net.addLink(s10, h13)
net.addLink(s10, h14)
net.addLink(s10, d11)
net.addLink(s10, d12)

# Add leaf switch and hosts in rack 2
# subnet: 10.0.2.0/24
s20 = net.addSwitch('s20', dpid='0000000000000012')
h21 = net.addHost('h21',
                  mac='00:00:10:00:02:21',
                  ip='10.0.2.21/24',
                  defaultRoute='via 10.0.2.1')
h22 = net.addHost('h22',
                  mac='00:00:10:00:02:22',
Example #39
0
def WifiNet(inputFile):
    input = open(inputFile, "r")
    """ Node names """
    max_outgoing = []
    hosts = []
    switches = []  # satellite and dummy satellite
    links = []

    queueConfig = open("FDMQueueConfig.sh", "w")
    flowTableConfig = open("FDMFlowTableConfig.sh", "w")
    queueConfig.write("#!/bin/bash\n\n")
    flowTableConfig.write("#!/bin/bash\n\n")
    queue_num = 1
    num_host = 0
    num_ship = 0
    num_sat = 0

    # Read src-des pair for testing
    src_hosts = []
    des_hosts = []
    des_ip = []
    line = input.readline()
    while line.strip() != "End":
        src, des, ip = line.strip().split()
        src_hosts.append(src)
        des_hosts.append(des)
        des_ip.append(ip)
        line = input.readline()

    # Add nodes
    # Mirror ships are switches
    line = input.readline()
    while line.strip() != "End":
        action, type_node, target = line.strip().split()
        if type_node == "host:":
            hosts.append(target)
            num_host += 1
        else:
            if type_node == "ship:":
                num_ship += 1
                max_outgoing.append(0)
            elif type_node == "sat:":
                num_sat += 1
            switches.append(target)
        line = input.readline()
    num_sat = num_sat / 2

    # Add links
    line = input.readline()
    while line.strip() != "End":
        action, type_node, end1, end2 = line.strip().split()
        if end1[0] == "s" and int(end1[1:]) <= num_ship and end2[0] == "s":
            max_outgoing[int(end1[1:]) - 1] += 1
        links.append([end1, end2])
        line = input.readline()

    print(max_outgoing)
    # Routing table of hosts
    line = input.readline()
    while line.strip() != "End":
        host, st, num_ip = line.strip().split()
        file = open(host + ".sh", "w")
        file.write("#!/bin/bash\n\n")
        for i in range(0, int(num_ip)):
            ipaddr = input.readline().strip()
            intf = host + "-eth" + str(i)
            file.write("ifconfig " + intf + " " + ipaddr +
                       " netmask 255.255.255.255\n")
            file.write("ip rule add from " + ipaddr + " table " + str(i + 1) +
                       "\n")
            file.write("ip route add " + ipaddr + "/32 dev " + intf +
                       " scope link table " + str(i + 1) + "\n")
            file.write("ip route add default via " + ipaddr + " dev " + intf +
                       " table " + str(i + 1) + "\n")
            if i == 0:
                file.write("ip route add default scope global nexthop via " +
                           ipaddr + " dev " + intf + "\n")
        file.close()
        call(["sudo", "chmod", "777", host + ".sh"])
        line = input.readline()

    # Flow table and queue
    queue_num = 1
    line = input.readline()
    while line:
        # print(line)
        end1, end2, num_flow = line.strip().split()
        num_flow = num_flow.strip().split(":")[1]

        # Routing tables have been configured
        if "host" in end1:
            for i in range(0, int(num_flow)):
                line = input.readline()
        else:
            switch, intf = end1.split("-")
            index_switch = int(switch[1:])
            index_intf = intf[3:]

            if index_switch <= num_ship and "host" != end2[0:4]:
                # uplink to ship, need to configure both flowtable and queue
                # put the queues for one port on one line in definition
                commandQueue = "sudo ovs-vsctl -- set Port " + end1 + " qos=@newqos -- --id=@newqos create QoS type=linux-htb other-config:max-rate=100000000 "
                queue_nums = []
                rates = []
                ipaddrs = []
                for i in range(0, int(num_flow) - 1):
                    ipaddr, rate = input.readline().strip().split()
                    rates.append(rate)
                    ipaddrs.append(ipaddr)
                    queue_nums.append(queue_num)
                    commandQueue += "queues:" + str(queue_num) + "=@q" + str(
                        queue_num) + " "
                    queue_num += 1
                ipaddr, rate = input.readline().strip().split()
                rates.append(rate)
                ipaddrs.append(ipaddr)
                queue_nums.append(queue_num)
                commandQueue += "queues:" + str(queue_num) + "=@q" + str(
                    queue_num) + " -- "
                queue_num += 1

                for i in range(0, int(num_flow) - 1):
                    commandQueue += " --id=@q" + str(
                        queue_nums[i]
                    ) + " create Queue other-config:min-rate=" + str(
                        int(float(rates[i]) *
                            1000000)) + " other-config:max-rate=" + str(
                                int(float(rates[i]) * 1000000)) + " -- "
                commandQueue += " --id=@q" + str(
                    queue_nums[len(queue_nums) - 1]
                ) + " create Queue other-config:min-rate=" + str(
                    int(float(rates[len(queue_nums) - 1]) *
                        1000000)) + " other-config:max-rate=" + str(
                            int(float(rates[len(queue_nums) - 1]) * 1000000))
                queueConfig.write(commandQueue + "\n")

                for i in range(0, int(num_flow)):
                    commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " ip,nw_src=" + ipaddrs[
                        i] + "/32,actions=set_queue:" + str(
                            queue_nums[i]) + ",output:" + index_intf
                    flowTableConfig.write(commandFlowTable + "\n")

                commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " in_port=" + index_intf + ",actions=normal"
                flowTableConfig.write(commandFlowTable + "\n")
            # elif index_switch <= num_ship:
            #     # ship to host downlink
            #     # port forwarding
            #     for i in range(0, int(num_flow)):
            #         input.readline()
            #     for i in range(0, int(max_outgoing[index_switch - 1])):
            #         # ipaddr, rate = input.readline().strip().split()
            #         commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " in_port=" + str(int(index_intf) - i - 1) + ",actions=output:" + index_intf
            #         flowTableConfig.write(commandFlowTable + "\n")
            #     commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " in_port=" + index_intf + ",actions=normal"
            #     flowTableConfig.write(commandFlowTable + "\n")

            else:
                # sat-dummy_sat
                # port forwarding
                for i in range(0, int(num_flow)):
                    input.readline()
                for i in range(1, int(index_intf)):
                    commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " in_port=" + str(
                        i) + ",actions=output:" + index_intf
                    flowTableConfig.write(commandFlowTable + "\n")
                commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " in_port=" + index_intf + ",actions=normal"
                flowTableConfig.write(commandFlowTable + "\n")
            # elif index_switch <= num_ship + num_sat * 3:
            #     # dummy to mirror ship, ip forwarding
            #     for i in range(0, int(num_flow)):
            #         ipaddr, rate = input.readline().strip().split()
            #         commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " ip,nw_src=" + ipaddr + "/32,actions=output:" + index_intf
            #         flowTableConfig.write(commandFlowTable + "\n")
            #     commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " in_port=" + index_intf + ",actions=normal"
            #     flowTableConfig.write(commandFlowTable + "\n")
            # else:
            #     # mirror ship to host, port forwarding
            #     for i in range(0, int(num_flow)):
            #         input.readline()
            #     for i in range(1, int(index_intf)):
            #         commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " in_port=" + str(i) + ",actions=output:" + index_intf
            #         flowTableConfig.write(commandFlowTable + "\n")
            #     commandFlowTable = "sudo ovs-ofctl add-flow " + switch + " in_port=" + index_intf + ",actions=normal"
            #     flowTableConfig.write(commandFlowTable + "\n")
        line = input.readline()
    for i in range(0, num_ship):
        queueConfig.write("sudo ovs-ofctl -O Openflow13 queue-stats s" +
                          str(i + 1) + "\n")

    for i in range(0, num_ship + 3 * num_sat):
        flowTableConfig.write("sudo ovs-ofctl add-flow s" + str(i + 1) +
                              " priority=100,actions=normal\n")

    flowTableConfig.close()
    queueConfig.close()
    # call(["sudo", "chmod", "777", "FDMQueueConfig.sh"])
    call(["sudo", "chmod", "777", "MPTCPFlowTable.sh"])

    net = Mininet(link=TCLink, controller=None, autoSetMacs=True)

    nodes = {}
    """ Initialize Ships """
    for host in hosts:
        node = net.addHost(host)
        nodes[host] = node
    """ Initialize SATCOMs """
    for switch in switches:
        node = net.addSwitch(switch)
        nodes[switch] = node
    """ Add links """
    for link in links:
        name1, name2 = link[0], link[1]
        node1, node2 = nodes[name1], nodes[name2]
        if (name1 == 's6' and name2 == 's9'):
            net.addLink(node1, node2, bw=30)
            info('set *************************')
        elif (name1 == 's7' and name2 == 's10'):
            net.addLink(node1, node2, bw=20)
        elif (name1 == 's8' and name2 == 's11'):
            net.addLink(node1, node2, bw=15)
        else:
            net.addLink(node1, node2)
    """ Start the simulation """
    info('*** Starting network ***\n')
    net.start()

    #  set all ships
    for i in range(0, num_host):
        src = nodes[hosts[i]]
        info("--configing routing table of " + hosts[i])
        if os.path.isfile(hosts[i] + '.sh'):
            src.cmdPrint('./' + hosts[i] + '.sh')

    # time.sleep(3)
    # info('*** set queues ***\n')
    # call(["sudo", "bash","FDMQueueConfig.sh"])

    time.sleep(3)
    info('*** set flow tables ***\n')
    call(["sudo", "bash", "MPTCPFlowTable.sh"])

    # start D-ITG Servers
    for i in [num_host - 1]:  # last host is receiver
        srv = nodes[hosts[i]]
        info("starting D-ITG servers...\n")
        srv.cmdPrint("cd ~/D-ITG-2.8.1-r1023/bin")
        srv.cmdPrint("./ITGRecv &")

    time.sleep(1)

    # start D-ITG application
    # set simulation time
    sTime = 60000  # default 120,000ms
    # bwReq = [10,10,8,6,6]
    bwReq = [12, 12, 12, 12, 12]
    for i in range(0, num_host - 1):
        sender = i
        receiver = num_host - 1
        ITGTest(sender, receiver, hosts, nodes, bwReq[i] * 125, sTime)
        time.sleep(0.2)
    info("running simulaiton...\n")
    info("please wait...\n")

    time.sleep(sTime / 1000)

    # You need to change the path here
    call(["sudo", "python", "../analysis/analysis.py"])

    CLI(net)

    net.stop()
    info('*** net.stop()\n')
Example #40
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=Controller,
                           protocol='tcp',
                           port=6633)

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

    info('*** Add hosts\n')
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', 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)
    h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
    h10 = net.addHost('h10', cls=Host, ip='10.0.0.10', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
    h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
    h11 = net.addHost('h11', cls=Host, ip='10.0.0.11', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
    h12 = net.addHost('h12', cls=Host, ip='10.0.0.12', defaultRoute=None)
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h9 = net.addHost('h9', cls=Host, ip='10.0.0.9', defaultRoute=None)

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

    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([])
    net.get('s5').start([c0])
    net.get('s2').start([])
    net.get('s1').start([])
    net.get('s6').start([c0])
    net.get('s4').start([])

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

    CLI(net)
    net.stop()
def myNetwork():
    net = Mininet(topo=None,
                  link=TCLink,
                  build=False,
                  ipBase='10.0.0.0/8',
                  autoStaticArp=True)

    #Adding Controllers
    info('*** Adding controller\n')
    c0 = net.addController('c0', controller=OVSController, port=6633)

    #Adding Switches
    info('*** Adding Switches\n ')
    s1 = net.addSwitch('s1', stp=True)
    s2 = net.addSwitch('s2', stp=True)
    s3 = net.addSwitch('s3', stp=True)
    s4 = net.addSwitch('s4', stp=True)
    s5 = net.addSwitch('s5', stp=True)
    s6 = net.addSwitch('s6', stp=True)

    info('*** Adding hosts\n')
    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')
    h5 = net.addHost('h5', ip='10.0.0.5')
    h6 = net.addHost('h6', ip='10.0.0.6')
    h7 = net.addHost('h7', ip='10.0.0.7')

    #Adding Links
    info(' *** Adding Links\n ')
    net.addLink(h1, s1)
    net.addLink(h2, s2)
    net.addLink(h3, s5)
    net.addLink(h4, s5)
    net.addLink(h5, s6)
    net.addLink(h6, s4)
    net.addLink(h7, s4)
    #------------------------------------------------------------------------------
    net.addLink(s1, s2, bw=10)
    net.addLink(s1, s3, bw=10)
    net.addLink(s2, s4, bw=15)
    net.addLink(s3, s4, bw=5)
    net.addLink(s4, s6, bw=10)
    net.addLink(s5, s6, bw=5)
    net.addLink(s1, s5, bw=5)
    #------------------------------------------------------------------------------

    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])

    #Enable STP
    s1.cmd('ovs-vsctl set bridge s1 stp_enable = true')
    s2.cmd('ovs-vsctl set bridge s2 stp_enable = true')
    s3.cmd('ovs-vsctl set bridge s3 stp_enable = true')
    s4.cmd('ovs-vsctl set bridge s4 stp_enable = true')
    s5.cmd('ovs-vsctl set bridge s5 stp_enable = true')
    s6.cmd('ovs-vsctl set bridge s6 stp_enable = true')

    info('**** Post Configure switches and hosts\n ')
    CLI(net)
    net.stop()
def myNet():

    ctl1 = '192.168.1.101'
    ctl2 = '192.168.1.102'

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

    # Create nodes
    h1 = net.addHost('h1', mac='01:00:00:00:01:00', ip='192.168.0.1/24')
    h2 = net.addHost('h2', mac='01:00:00:00:02:00', ip='192.168.0.2/24')
    h3 = net.addHost('h3', mac='01:00:00:00:03:00', ip='192.168.0.3/24')

    # Create switches
    s1 = net.addSwitch('s1', listenPort=6634, mac='00:00:00:00:00:01')
    s2 = net.addSwitch('s2', listenPort=6634, mac='00:00:00:00:00:02')

    print "*** Creating links"
    net.addLink(
        h1,
        s1,
    )
    net.addLink(
        h2,
        s2,
    )
    net.addLink(
        h3,
        s2,
    )
    net.addLink(
        s1,
        s2,
    )

    # Add Controllers
    ctrl_1 = net.addController('c0',
                               controller=RemoteController,
                               ip=ctl1,
                               port=6633)

    ctrl_2 = net.addController('c1',
                               controller=RemoteController,
                               ip=ctl2,
                               port=6633)

    net.build()

    # Connect each switch to a different controller
    s1.start([ctrl_1])
    s2.start([ctrl_1])

    s1.cmdPrint('ovs-vsctl show')

    print "Testing network connectivity\n"
    net.pingAll()
    print "Dumping host connections\n"
    dumpNodeConnections(net.hosts)

    h1, h2, h3, s1, s2 = net.getNodeByName('h1', 'h2', 'h3', 's1', 's2')

    h1_intf = str(h1.intf())
    h2_intf = str(h2.intf())
    h3_intf = str(h3.intf())

    info("h1 interface: " + h1_intf + "\n")
    info("h2 interface: " + h2_intf + "\n")
    info("h3 interface: " + h3_intf + "\n")

    sleep(5)
    #h1.cmd('nohup sudo sh ~/wifi/mininet-wifi/sdn-tactical-network/shaping.sh > h1_shaping.log &')
    h1.cmd('/sbin/tc qdisc del dev h1-eth0 root')
    sleep(5)
    h1.cmd(
        '/sbin/tc qdisc add dev h1-eth0 root handle 1:0 htb default 20 && '
        '/sbin/tc class add dev h1-eth0 parent 1:0 classid 1:1 htb rate 250kbps ceil 250kbps && '
        '/sbin/tc class add dev h1-eth0 parent 1:1 classid 1:10 htb rate 240kbps ceil 240kbps && '
        '/sbin/tc class add dev h1-eth0 parent 1:1 classid 1:20 htb rate 10kbps ceil 10kbps && '
        '/sbin/tc filter add dev h1-eth0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.3 flowid 1:10 && '
        '/sbin/tc filter add dev h1-eth0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.2 flowid 1:20'
    )
    sleep(5)
    h1.cmdPrint('/sbin/tc -s -d qdisc show dev h1-eth0')
    sleep(5)
    h1.cmdPrint('/sbin/tc -s -d class show dev h1-eth0')
    sleep(5)
    h2.cmd('/usr/bin/iperf3 -s -J > VHF_dst.json &')
    sleep(1)
    h3.cmd('/usr/bin/iperf3 -s -J > UHF_dst.json &')
    sleep(1)
    h1.cmd(
        '/usr/bin/iperf3 -c 192.168.0.2 -u -t 100 -i 1 -J > VHF_qdisc.json &')
    h1.cmd(
        '/usr/bin/iperf3 -c 192.168.0.3 -u -t 100 -i 1 -J > UHF_qdisc.json &')
    sleep(105)
    sleep(5)
    h1.cmdPrint('/sbin/tc -s -d qdisc show dev h1-eth0')
    sleep(5)
    h1.cmdPrint('/sbin/tc -s -d class show dev h1-eth0')
    sleep(5)

    net.stop()
    sleep(5)
    os.system('sudo mn -c')
Example #43
0
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])

    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

    print "\n"

    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

    print "\n"

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

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

    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')
    """plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()

    # Uncomment and modify the two commands below to stream video using VLC
    car[0].cmdPrint(
        "vlc -vvv ./bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,mux=ts},dst=display}' :sout-keep --meta-title 'car0' &"
    )
    client.cmdPrint("vlc rtp://@200.0.10.2:5004 --meta-title 'client' &")

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

    #time.sleep(3)

    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()
Example #44
0
def C2Net():

    "C2 dual site test"

    net = Mininet( controller=Controller )

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

    info( '*** Adding hosts\n' )
    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' )

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

    info( '*** Creating links\n' )
    net.addLink( h1, s1 )
    net.addLink( h2, s1 )
    net.addLink( h3, s2 )
    net.addLink( h4, s2 )
    net.addLink( h5, s5 )
    net.addLink( h6, s5 )
    net.addLink( h7, s6 )
    net.addLink( h8, s6 )
    net.addLink( s1, s3 )
    net.addLink( s2, s3 )
    net.addLink( s3, s4 )
    net.addLink( s4, s5 )
    net.addLink( s4, s6 )
Example #45
0
def mutiControllerNet(con_num=3,sw_num=4,host_num=8):
    "Create a network from semi-scratch with mutiple controller"
    controller_list=[]
    switch_list=[]
    host_list=[]
    
    #创建SDN网络
    net = Mininet(controller=None,switch=OVSSwitch,link=TCLink)

    # 这里原来是自动控制器的源代码,现在改成自定义控制器Ip
    # c1=RemoteController('c1',ip='127.0.0.1',port=1234)
    c2=RemoteController('c2',ip='192.168.43.144',port=6633)
    # c3=RemoteController('c3',ip='127.0.0.1',port=1236)
    #  c1=Controller('c1',port=1234)
    # c2=Controller('c2',port=1235)
    #  c3=Controller('c3',port=1236)
    
    # 加入网络
    net.addController(c1)
    #  net.addController(c2)
    #  net.addController(c3)

    #加入控制器数组
    controller_list.append(c1)
    controller_list.append(c2)
    controller_list.append(c3)

    #创建交换机
    print "*** 创建交换机"
    switch_list = [net.addSwitch('s%d'% n) for n in xrange(sw_num)]

    #创建主机
    print "*** Create hosts"
    host_list = [net.addHost('h%d' % n) for n in xrange(host_num)]

    #创建主机到交换机之间的连接
    net.addLink(switch_list[0],host_list[0])
    net.addLink(switch_list[0],host_list[1])
    net.addLink(switch_list[1],host_list[2])
    net.addLink(switch_list[1],host_list[3])
    net.addLink(switch_list[2],host_list[4])
    net.addLink(switch_list[2],host_list[5])
    net.addLink(switch_list[3],host_list[6])
    net.addLink(switch_list[3],host_list[7])

    #创建交换机和交换机之间的连接
    print "*** 创建交换机之间的连接"
    net.addLink(switch_list[0],switch_list[1])
    net.addLink(switch_list[1],switch_list[2])
    net.addLink(switch_list[2],switch_list[3])

    #创建交换机和控制器之间的连接
    # print "***创建交换机和控制器之间的连接"
    print "*** Staring network"
    net.build()
    for c in controller_list:
        c.start()

    _No = 0
    for i in xrange(0,sw_num,sw_num/con_num):
        for j in xrange(sw_num/con_num):
            switch_list[i+j].start([controller_list[_No]])

    print "*** Runing CLI"
    CLI(net)

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

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

    core_sw = []
    dist_sw = []
    aces_sw = []
    h = []
    core_num = 1
    dist_num = 2
    aces_num = 20
    fanout_num = 10

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

    info('*** Adding switches ***\n')
    #Adding core switches
    for i in range(core_num):
        switch_name = 's10' + str(i + 1)
        sw = net.addSwitch(switch_name, cls=OVSKernelSwitch)
        core_sw.append(sw)
    #Adding distribution switches
    for i in range(dist_num):
        switch_name = 's20' + str(i + 1)
        sw = net.addSwitch(switch_name, cls=OVSKernelSwitch)
        dist_sw.append(sw)
    #Adding access switches
    for i in range(aces_num):
        if i <= 8:
            switch_name = 's30' + str(i + 1)
        else:
            switch_name = 's3' + str(i + 1)
        sw = net.addSwitch(switch_name, cls=OVSKernelSwitch)
        aces_sw.append(sw)

    info('*** Adding hosts ***\n')
    #Adding normal hosts
    for i in xrange(1, 291):
        host_name = 'h' + str(i)
        ip_addr = '10.0.' + str((i / 100)) + '.' + str((i % 100))
        hs = net.addHost(host_name, cls=Host, ip=ip_addr, defaultRoute=None)
        h.append(hs)
    #Adding the special host "h291"
    hs = net.addHost('h291', cls=Host, ip='10.0.2.91', defaultRoute=None)
    h.append(hs)

    info('*** Adding links ***\n')
    #Adding the special link between h291 and s101
    net.addLink(core_sw[0], h[290])
    #Adding links between core switches and distribution switches
    for i in range(core_num):
        for j in range(dist_num):
            net.addLink(core_sw[i], dist_sw[j])
    #Adding links between distribution switches and access switches
    for i in range(dist_num):
        for j in range(10):
            net.addLink(dist_sw[i], aces_sw[i * 10 + j])
    #Adding links between access switche s301 and 100 normal hosts
    for i in range(100):
        net.addLink(aces_sw[0], h[i])
    #Adding links between other access switches and ohter normal hosts
    for i in xrange(1, aces_num):
        for j in range(fanout_num):
            net.addLink(aces_sw[i], h[(i - 1) * fanout_num + j + 100])

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

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

    info('*** Starting switches ***\n')
    for i in range(core_num):
        net.get(core_sw[i].name).start([RYU])
    for i in range(dist_num):
        net.get(dist_sw[i].name).start([RYU])
    for i in range(aces_num):
        net.get(aces_sw[i].name).start([RYU])

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

    CLI(net)
    net.stop()
Example #47
0
def MininetTopo():
    '''
    Prepare Your Topology
    '''
    net = Mininet (topo=None, link=TCLink, build=False)
 
    c0 = net.addController(name='c0',
                           controller=RemoteController,
                           ip=REMOTE_CONTROLLER_IP,
                           port=6633)
 
    info("Create Host node\n")
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1')
    h2 = net.addHost('h2', mac='00:00:00:00:00:02', ip='10.0.0.2')
    h3 = net.addHost('h3', mac='00:00:00:00:00:03', ip='10.0.0.3')
    h4 = net.addHost('h4', mac='00:00:00:00:00:04', ip='10.0.0.4')
    h5 = net.addHost('h5', mac='00:00:00:00:00:05', ip='10.0.0.5')
    h6 = net.addHost('h6', mac='00:00:00:00:00:06', ip='10.0.0.6')
 
    info("Create Switch node\n")
    s1 = net.addSwitch('s1', protocols='OpenFlow13')
    s2 = net.addSwitch('s2', protocols='OpenFlow13')
    s3 = net.addSwitch('s3', protocols='OpenFlow13')
    s4 = net.addSwitch('s4', protocols='OpenFlow13')
 
    info("Link switch to host\n")
    # net.addLink(s1, h1, 4, bw=BW)
    # net.addLink(s1, h2, 5, bw=BW)
    # net.addLink(s1, h3, 6, bw=BW)
    # net.addLink(s3, h4, 4, bw=BW)
    # net.addLink(s3, h5, 5, bw=BW)
    # net.addLink(s3, h6, 6, bw=BW)
    # net.addLink(s1, s2, 1, 1, bw=BW)
    # net.addLink(s2, s3, 2, 1, bw=BW)
    # net.addLink(s3, s4, 2, 2, bw=BW)
    # net.addLink(s4, s1, 1, 2, bw=BW)
    # net.addLink(s1, s3, 3, 3, bw=BW)
    # net.addLink(s2, s4, 3, 3, bw=BW)
    net.addLink(s1, h1, 4)
    net.addLink(s1, h2, 5)
    net.addLink(s1, h3, 6)
    net.addLink(s3, h4, 4)
    net.addLink(s3, h5, 5)
    net.addLink(s3, h6, 6)
    net.addLink(s1, s2, 1, 1)
    net.addLink(s2, s3, 2, 1)
    net.addLink(s3, s4, 2, 2)
    net.addLink(s4, s1, 1, 2)
    net.addLink(s1, s3, 3, 3)
    net.addLink(s2, s4, 3, 3)
 
 
    '''
    Working your topology
    '''
    info("Start network\n")
    net.build()
    c0.start()
    s1.start( [c0] )
    s2.start( [c0] )
    s3.start( [c0] )
    s4.start( [c0] )

    # info("Start xterm\n")
    # net.terms.append(makeTerm(c0))
 
    info("Dumping host connections\n")
    dumpNodeConnections(net.hosts)
    sleep(2)
    
    h1.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn")
    h2.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn")
    h3.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn")
    h4.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn")
    h5.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn")
    h6.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn")
 
    CLI(net)
    '''
    Clean mininet
    '''
    net.stop()
Example #48
0
def createNetwork():
    #send rate at each link in Mbps
    bwg = 1  #in Mbps
    bwbn = 1  #in Mbps
    loss = 6  #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 #49
0
#SET SWITCHES
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
s3 = net.addSwitch('s3')
s4 = net.addSwitch('s4')
s5 = net.addSwitch('s5')

#SET HOSTS
h1 = net.addHost('h1')
h2 = net.addHost('h2')
h3 = net.addHost('h3')
h4 = net.addHost('h4')
h5 = net.addHost('h5')

#SET SWITCH-HOST LINKS
net.addLink(h1, s1)
net.addLink(h2, s2)
net.addLink(h3, s3)
net.addLink(h4, s4)
net.addLink(h5, s5)

#SET SWITCH-SWITCH LINKS
i = 0
while (i < len(hosts)):
    net.addLink('s%s' % hosts[i][0], 's%s' % hosts[i][1])
    i += 1

#MININET START
net.start()

#RESULT: PLOSS PACKET LOSS PERCENTAGE
Example #50
0
def topologie():
    call(["mn", "-c"])

    net = Mininet(controller=RemoteController, link=TCLink)
    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip="127.0.0.1",
                           port=6633)

    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")
    h3 = net.addHost('h3', ip='10.0.0.3', mac="00:00:00:00:00:03")
    h4 = net.addHost('h4', ip='10.0.0.4', mac="00:00:00:00:00:04")
    h5 = net.addHost('h5', ip='10.0.0.5', mac="00:00:00:00:00:05")
    h6 = net.addHost('h6', ip='10.0.0.6', mac="00:00:00:00:00:06")

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

    net.addLink(h1, s1)
    net.addLink(h2, s2)
    net.addLink(h3, s3)
    net.addLink(h4, s10)
    net.addLink(h5, s11)
    net.addLink(h6, s12)

    net.addLink(s1, s4, bw=10)
    net.addLink(s2, s4, bw=10)
    net.addLink(s3, s4, bw=10)

    net.addLink(s4, s5, bw=3)
    net.addLink(s4, s6, bw=4)
    net.addLink(s4, s7)

    net.addLink(s5, s6, bw=3)

    net.addLink(s6, s9)
    net.addLink(s6, s10, bw=10)
    net.addLink(s6, s11, bw=10)
    net.addLink(s6, s12, bw=10)

    net.addLink(s7, s8, bw=2)
    net.addLink(s8, s9, bw=2)

    net.start()

    net.pingAllFull()

    CLI(net)
    net.stop()
Example #51
0
from mininet.net import Mininet\
from mininet.node import Controller, RemoteController, OVSKernelSwitch, UserSwitch\
from mininet.cli import CLI\
from mininet.log import setLogLevel\
from mininet.link import Link, TCLink\
\
def topology():\
    "Create a network."\
    net = Mininet( controller=None, link=TCLink, switch=OVSKernelSwitch )\
    print "*** Creating nodes"\
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/24' )\
    h2 = net.addHost( 'h2', mac='00:00:00:00:00:02', ip='10.0.0.2/24' )\
\
    print "*** Creating links"\
\
    net.addLink(h1, h2, intfName1='h1-eth0', intfName2='h2-eth0',bw=100)\
    net.addLink(h1, h2, intfName1='h1-eth1', intfName2='h2-eth1', bw=100)\
    h1.cmd('ifconfig h1-eth1 10.0.10.1 netmask 255.255.255.0')\
    h2.cmd('ifconfig h2-eth1 10.0.10.2 netmask 255.255.255.0')\
    print "*** Starting network"\
    net.build()\
    print "*** Running CLI"\
    CLI( net )\
    print "*** Stopping network"\
    net.stop()\
\
if __name__ == '__main__':\
\
    setLogLevel( 'info' )\
\
    topology()}
Example #52
0
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    ## The mobile node
    sta1 = net.addStation( 'sta1', wlans=2, mac='00:00:00:00:00:02', ip='10.0.0.2/24' )
    ## The long range, poor quality access point
    ap1 = net.addAccessPoint( 'ap1', ssid= 'ap1-ssid', mode= 'g', channel= '1', position='50,50,0', range=51 )
    ## The sort range, good quality access points
    ap2 = net.addAccessPoint( 'ap2', ssid= 'ap2-ssid', mode= 'g', channel= '4', position='10,10,0', range=30 )
    ap3 = net.addAccessPoint( 'ap3', ssid= 'ap3-ssid', mode= 'g', channel= '4', position='90,10,0', range=30 )
    ap4 = net.addAccessPoint( 'ap4', ssid= 'fast-ssid', mode= 'g', channel= '4', position='50,80,0', range=10 )
    ## Controller for the APs (don't need to change this)
    c1 = net.addController( 'c1', controller=Controller )
    ## The host, will run the HTTP server in this example
    h1 = net.addHost ( 'h1', ip='10.0.0.3/24' )

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

    ## (ap2--ap3--ap4)
    print "*** Creating links"
    net.addLink(ap2, ap3)
    net.addLink(ap3, ap4)

    ## Poor quality link ap1---h1
    net.addLink(ap1, h1, bw=2, delay='10ms', max_queue_size=1000)
    ## Good quality link ap2---h1 (note that ap2--ap3--ap4)
    net.addLink(ap2, h1)

    ## Just to make sure the interfaces are correctly set
    net.addLink(ap1, sta1) 
    net.addLink(ap2, sta1)

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

    ## Manually set a second IP for h1 and sta1
    sta1.setIP('10.1.0.2/24', intf='sta1-wlan1')
    h1.setIP('10.1.0.3/24', intf='h1-eth1')

    ## Run a simple HTTP server on h1
    #print "*** Starting HTTP server on H1"
    #h1.cmdPrint('python -m SimpleHTTPServer 80 &')
        
    ## TODO Implement own h1 server (Send or receive?)
    #print "*** Starting our own server on H1"
    #h1.cmdPrint('python h1.py')

    """association control"""
    net.associationControl('ssf')

    """Plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    """Seed"""
    net.seed(20) 

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0, model='RandomWayPoint', max_x=100, max_y=100, min_v=0.5, max_v=0.8)

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

    print "*** Stopping network"
    net.stop()
Example #53
0
    def __init__(net):
        "Create custom topo."

        # Initialize topology
        Topo.__init__(net)
        net = Mininet(controller=RemoteController)
        info('*** Adding controllers\n')
        cA = net.addController('cA',
                               controller=RemoteController,
                               ip="127.0.0.1",
                               port=6653)
        cB = net.addController('cB',
                               controller=RemoteController,
                               ip="127.0.0.1",
                               port=6634)
        info('*** Adding hosts\n')
        AAh1 = net.addHost('AAh1', ip='10.1.1.1 ', mac='0A:0A:00:00:00:01')
        AAh2 = net.addHost('AAh2', ip='10.1.1.2 ', mac='0A:0A:00:00:00:02')
        ABh1 = net.addHost('ABh1', ip='10.1.2.1 ', mac='0A:0B:00:00:00:01')
        ABh2 = net.addHost('ABh2', ip='10.1.2.2 ', mac='0A:0B:00:00:00:02')
        BAh1 = net.addHost('BAh1', ip='10.10.10.1 ', mac='0A:0B:0A:00:00:01')
        BAh2 = net.addHost('BAh2', ip='10.10.10.2 ', mac='0A:0B:0A:00:00:02')
        BBh1 = net.addHost('BBh1', ip='10.10.20.1 ', mac='0A:0B:0B:00:00:01')
        BBh2 = net.addHost('BBh2', ip='10.10.20.2 ', mac='0A:0B:0B:00:00:02')

        info('*** Adding switches\n')
        sA = net.addSwitch('s1', dpid='0000000000000001')
        sAA = net.addSwitch('s11', dpid='000000000000000b')
        sAB = net.addSwitch('s12', dpid='000000000000000c')
        sB = net.addSwitch('s2', dpid='0000000000000002')
        sBA = net.addSwitch('s21', dpid='0000000000000015')
        sBB = net.addSwitch('s22', dpid='0000000000000016')

        info('*** Adding links\n')
        net.addLink(AAh1, sAA)
        net.addLink(AAh2, sAA)

        net.addLink(ABh1, sAB)
        net.addLink(ABh2, sAB)
        net.addLink(BAh1, sBA)
        net.addLink(BAh2, sBA)
        info('*** Adding links\n')
        net.addLink(AAh1, sAA)
        net.addLink(AAh2, sAA)

        net.addLink(ABh1, sAB)
        net.addLink(ABh2, sAB)
        net.addLink(BAh1, sBA)
        net.addLink(BAh2, sBA)

        net.addLink(BBh1, sBB)
        net.addLink(BBh2, sBB)
        net.addLink(sAA, sA)
        net.addLink(sAB, sA)

        net.addLink(sBA, sB)
        net.addLink(sBB, sB)
        net.addLink(sA, sB)

        info('*** Starting network\n')
        net.build()
        sA.start([cA])
        sAA.start([cA])
        sAB.start([cA])
        sB.start([cB])
        sBA.start([cB])
        sBB.start([cB])

        info('\n*** Running pingall\n')
        net.pingAll()

        info('*** Running CLI\n')
        CLI(net)
        info('*** Stopping network')
        net.stop()
Example #54
0
    time_labels = {}

    host1 = net.addHost('h1')
    update_topo(graph_tree, time_labels,
                host1.name)  #Mutate addHost function for this
    host2 = net.addHost('h2')
    update_topo(graph_tree, time_labels, host2.name)
    host3 = net.addHost('h3')
    update_topo(graph_tree, time_labels, host3.name)
    host4 = net.addHost('h4')
    update_topo(graph_tree, time_labels, host4.name)
    switch1 = net.addSwitch('s0')
    update_topo(graph_tree, time_labels, switch1.name)
    switch2 = net.addSwitch('s1')
    update_topo(graph_tree, time_labels, switch2.name)
    net.addLink(host1, switch1, 1, 1)
    graphnet(host1.name, switch1.name, graph_tree)
    net.addLink(host3, switch2, 3, 3)
    graphnet(host3.name, switch2.name, graph_tree)
    net.addLink(host2, switch1, 2, 2)
    graphnet(host2.name, switch1.name, graph_tree)
    net.addLink(host4, switch2, 2, 2)
    graphnet(host4.name, switch2.name, graph_tree)
    net.addLink(switch1, switch2, 4, 4)
    graphnet(switch1.name, switch2.name, graph_tree)
    net.build()  #Build network

    Way1 = set(dijkstra_path('h2', 'h3',
                             graph_tree))  #Used vertexes were found
    Way2 = {'s1'}  #Used vertexes were found
def my_network():
    net = Mininet(topo=None,
                  build=False,
                  controller=RemoteController,
                  link=TCLink)

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

    # Create switch nodes
    for i in range(4):
        sconfig = {'dpid': "%016x" % (i + 1)}
        net.addSwitch('s%d' % (i + 1), **sconfig)
        for j in range(3):
            sconfig = {'dpid': "%016x" % ((i + 1) * 10 + (j + 1))}
            net.addSwitch('s%d%d' % (i + 1, j + 1), **sconfig)
    net.addSwitch('scc1', dpid="%016x" % 17)
    net.addSwitch('scc2', dpid="%016x" % 18)
    net.addSwitch('sdc1', dpid="%016x" % 19)

    # Create host nodes
    hconfig = {'inNamespace': True}
    for i in range(24):
        net.addHost('h%d' % (i + 1), **hconfig)
    net.addHost('cc51', **hconfig)
    net.addHost('cc52', **hconfig)
    net.addHost('dc50', **hconfig)

    # Add switch links
    net.addLink('s1', 's11', cls=TCLink, use_htb=True)
    net.addLink('s1', 's12', cls=TCLink, use_htb=True)
    net.addLink('s1', 's13', cls=TCLink, use_htb=True)
    net.addLink('s11', 's12', cls=TCLink, use_htb=True)
    net.addLink('s12', 's13', cls=TCLink, use_htb=True)

    net.addLink('s2', 's21', cls=TCLink, use_htb=True)
    net.addLink('s2', 's22', cls=TCLink, use_htb=True)
    net.addLink('s2', 's23', cls=TCLink, use_htb=True)
    net.addLink('s21', 's22', cls=TCLink, use_htb=True)
    net.addLink('s22', 's23', cls=TCLink, use_htb=True)

    net.addLink('s3', 's31', cls=TCLink, use_htb=True)
    net.addLink('s3', 's32', cls=TCLink, use_htb=True)
    net.addLink('s3', 's33', cls=TCLink, use_htb=True)
    net.addLink('s31', 's32', cls=TCLink, use_htb=True)
    net.addLink('s32', 's33', cls=TCLink, use_htb=True)

    net.addLink('s4', 's41', cls=TCLink, use_htb=True)
    net.addLink('s4', 's42', cls=TCLink, use_htb=True)
    net.addLink('s4', 's43', cls=TCLink, use_htb=True)
    net.addLink('s41', 's42', cls=TCLink, use_htb=True)
    net.addLink('s42', 's43', cls=TCLink, use_htb=True)

    net.addLink('s1', 'sdc1', cls=TCLink, use_htb=True)
    net.addLink('s1', 'scc1', cls=TCLink, use_htb=True)
    net.addLink('s2', 'sdc1', cls=TCLink, use_htb=True)
    net.addLink('s2', 'scc1', cls=TCLink, use_htb=True)
    net.addLink('s3', 'sdc1', cls=TCLink, use_htb=True)
    net.addLink('s3', 'scc2', cls=TCLink, use_htb=True)
    net.addLink('s4', 'sdc1', cls=TCLink, use_htb=True)
    net.addLink('s4', 'scc2', cls=TCLink, use_htb=True)

    net.addLink('scc1', 'sdc1', cls=TCLink, use_htb=True)
    net.addLink('scc2', 'sdc1', cls=TCLink, use_htb=True)

    # Add host links
    net.addLink('h1', 's11', cls=TCLink, use_htb=True)
    net.addLink('h2', 's11', cls=TCLink, use_htb=True)
    net.addLink('h3', 's12', cls=TCLink, use_htb=True)
    net.addLink('h4', 's12', cls=TCLink, use_htb=True)
    net.addLink('h5', 's13', cls=TCLink, use_htb=True)
    net.addLink('h6', 's13', cls=TCLink, use_htb=True)

    net.addLink('h7', 's21', cls=TCLink, use_htb=True)
    net.addLink('h8', 's21', cls=TCLink, use_htb=True)
    net.addLink('h9', 's22', cls=TCLink, use_htb=True)
    net.addLink('h10', 's22', cls=TCLink, use_htb=True)
    net.addLink('h11', 's23', cls=TCLink, use_htb=True)
    net.addLink('h12', 's23', cls=TCLink, use_htb=True)

    net.addLink('h13', 's31', cls=TCLink, use_htb=True)
    net.addLink('h14', 's31', cls=TCLink, use_htb=True)
    net.addLink('h15', 's32', cls=TCLink, use_htb=True)
    net.addLink('h16', 's32', cls=TCLink, use_htb=True)
    net.addLink('h17', 's33', cls=TCLink, use_htb=True)
    net.addLink('h18', 's33', cls=TCLink, use_htb=True)

    net.addLink('h19', 's41', cls=TCLink, use_htb=True)
    net.addLink('h20', 's41', cls=TCLink, use_htb=True)
    net.addLink('h21', 's42', cls=TCLink, use_htb=True)
    net.addLink('h22', 's42', cls=TCLink, use_htb=True)
    net.addLink('h23', 's43', cls=TCLink, use_htb=True)
    net.addLink('h24', 's43', cls=TCLink, use_htb=True)

    net.addLink('cc51', 'scc1', cls=TCLink, use_htb=True)
    net.addLink('dc50', 'sdc1', cls=TCLink, use_htb=True)
    net.addLink('cc52', 'scc2', cls=TCLink, use_htb=True)

    net.build()

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

    info('***Configuring the links\n')
    cli_obj = CLI(net, script='/home/mininet/new_folder/mproject/mod_qos.py')

    info('***Entering command prompt\n')
    CLI(net)

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

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

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

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

    info('*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='10.10.1.1', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='10.10.1.2', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.10.1.3', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.10.2.1', defaultRoute=None)
    h5 = net.addHost('h5', cls=Host, ip='10.10.2.2', defaultRoute=None)
    h6 = net.addHost('h6', cls=Host, ip='10.10.2.3', defaultRoute=None)
    h7 = net.addHost('h7', cls=Host, ip='10.10.3.1', defaultRoute=None)
    h8 = net.addHost('h8', cls=Host, ip='10.10.3.2', defaultRoute=None)
    h9 = net.addHost('h9', cls=Host, ip='10.10.3.3', defaultRoute=None)

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

    net.addLink(h4, s2)
    net.addLink(h5, s2)
    net.addLink(h6, s2)

    net.addLink(h7, s3)
    net.addLink(h8, s3)
    net.addLink(h9, s3)

    net.addLink(s1, s2)
    net.addLink(s1, s3)
    net.addLink(s2, s3)

    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])

    info('*** Post configure switches and hosts\n')
    #s1.cmd('ovs-ofctl add-flow s1 arp,nw_dst=10.10.1.1,action=output:1')
    #s1.cmd('ovs-ofctl add-flow s1 arp,nw_dst=10.10.1.2,action=output:2')
    #s1.cmd('ovs-ofctl add-flow s1 arp,nw_dst=10.10.1.3,action=output:3')
    #s1.cmd('ovs-ofctl add-flow s1 ip,nw_dst=10.10.1.0/255.255.255.0,action=normal')
    #s1.cmd('ovs-ofctl add-flow s1 arp,nw_dst=10.10.2.0/255.255.255.0,action=output:4')
    #s1.cmd('ovs-ofctl add-flow s1 arp,nw_dst=10.10.3.0/255.255.255.0,action=output:5')

    #s2.cmd('ovs-ofctl add-flow s2 arp,nw_dst=10.10.2.1,action=output:1')
    #s2.cmd('ovs-ofctl add-flow s2 arp,nw_dst=10.10.2.2,action=output:2')
    #s2.cmd('ovs-ofctl add-flow s2 arp,nw_dst=10.10.2.3,action=output:3')
    #s2.cmd('ovs-ofctl add-flow s2 ip,nw_dst=10.10.2.0/255.255.255.0,action=normal')
    #s2.cmd('ovs-ofctl add-flow s2 arp,nw_dst=10.10.1.0/255.255.255.0,action=output:4')
    #s2.cmd('ovs-ofctl add-flow s2 arp,nw_dst=10.10.3.0/255.255.255.0,action=output:5')

    #s3.cmd('ovs-ofctl add-flow s3 arp,nw_dst=10.10.3.1,action=output:1')
    #s3.cmd('ovs-ofctl add-flow s3 arp,nw_dst=10.10.3.2,action=output:2')
    #s3.cmd('ovs-ofctl add-flow s3 arp,nw_dst=10.10.3.3,action=output:3')
    #s3.cmd('ovs-ofctl add-flow s3 ip,nw_dst=10.10.3.0/255.255.255.0,action=normal')
    #s3.cmd('ovs-ofctl add-flow s3 arp,nw_dst=10.10.1.0/255.255.255.0,action=output:4')
    #s3.cmd('ovs-ofctl add-flow s3 arp,nw_dst=10.10.2.0/255.255.255.0,action=output:5')
    for i in xrange(9):
        h = net.get('h%d' % (i + 1))
        h.cmd("ip route add default dev %s-eth0" % ('h%d' % (i + 1)))
        for j in xrange(9):
            h_dst = net.get('h%d' % (j + 1))
            h.setARP(h_dst.IP(), h_dst.MAC())

    CLI(net)
    net.stop()
Example #57
0
def multiControllerNet():
    "Create a network from semi-scratch with multiple controllers."
    controller_conf = [{
        "name": "ryu1",
        "ip": "127.0.0.1",
        "port": 6653
    }, {
        "name": "ryu2",
        "ip": "127.0.0.1",
        "port": 6654
    }]
    controller_list = []
    switch_list = []
    host_list = []

    inter_bw = 500

    logger = logging.getLogger('ryu.openexchange.test.multi_network')

    net = Mininet(controller=None,
                  switch=OVSSwitch,
                  link=TCLink,
                  autoSetMacs=True)

    for controller in controller_conf:
        name = controller["name"]
        ip = controller["ip"]
        port = controller["port"]
        c = net.addController(name,
                              controller=RemoteController,
                              port=port,
                              ip=ip)
        controller_list.append(c)
        logger.debug("*** Creating %s" % name)

    logger.debug("*** Creating switches")

    switch_list = [net.addSwitch('s%d' % n) for n in xrange(1, 3)]

    logger.debug("*** Creating hosts")
    host_list = [net.addHost('h%d' % n) for n in xrange(1, 3)]

    logger.debug("*** Creating links of host2switch.")
    net.addLink(switch_list[0], host_list[0])
    net.addLink(switch_list[1], host_list[1])

    logger.debug("*** Creating intra links of switch2switch.")
    net.addLink(switch_list[0], switch_list[1])
    net.addLink(switch_list[1], switch_list[0])

    net.build()
    for c in controller_list:
        c.start()

    _No = 0
    switch_list[0].start([controller_list[0]])
    switch_list[1].start([controller_list[1]])
    logger.info("*** Setting OpenFlow version")

    logger.info("*** Running CLI")
    CLI(net)

    logger.info("*** Stopping network")
    net.stop()
Example #58
0
def run():
    " Creates the virtual environment, by starting the network and configuring debug information "
    info('** Creating an instance of Lab5 network topology\n')
    global net
    global hosts

    net = Mininet(intf=TCIntf)

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

    info('\n** Adding Hosts\n')
    h1 = net.addHost('h1',
                     ip='10.10.0.1/24',
                     hostname='h1',
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)
    h2 = net.addHost('h2',
                     ip='10.10.0.2/24',
                     hostname='h2',
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)
    h3 = net.addHost('h3',
                     ip='10.10.1.3/24',
                     hostname='h3',
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)
    r1 = net.addHost('r1',
                     ip='10.10.0.10/24',
                     hostname='r1',
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)

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

    info('\n** Creating Links \n')
    link_h1sw1 = net.addLink(h1, sw1)
    link_h2sw1 = net.addLink(h2, sw1)
    link_h3sw2 = net.addLink(h3, sw2)
    link_r1sw1 = net.addLink(r1, sw1, intfName1='r1-eth0')
    link_r1sw2 = net.addLink(r1, sw2, intfName1='r1-eth1')

    info('\n** Modifying Link Parameters \n')
    """
        Default parameters for links:
        bw = None,
 		delay = None,
 		jitter = None,
 		loss = None,
 		disable_gro = True,
 		speedup = 0,
 		use_hfsc = False,
 		use_tbf = False,
 		latency_ms = None,
 		enable_ecn = False,
 		enable_red = False,
 		max_queue_size = None 
    """
    link_r1sw2.intf1.config(bw=3, enable_ecn=True)

    net.start()

    info('*** Configuring hosts\n')
    r1.cmd('ifconfig r1-eth1 10.10.1.10 netmask 255.255.255.0')
    # Space to add commands for configuring routing tables and default gateways
    r1.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
    h1.cmd('ip route add default via 10.10.0.10')
    h2.cmd('ip route add default via 10.10.0.10')
    h3.cmd('ip route add default via 10.10.1.10')

    info('** Executing custom commands\n')
    output = net.nameToNode.keys
    #Enable Xterm window for every host
    info('** Enabling xterm for hosts only\n')
    # We check if the display is available
    hosts = [h1, h2, h3, r1]
    if 'DISPLAY' not in os.environ:
        error("Error starting terms: Cannot connect to display\n")
        return
    # Remove previous (and possible non-used) socat X11 tunnels
    cleanUpScreens()
    # Mininet's function to create Xterms in hosts
    makeTerms(hosts, 'host')

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

    info('*** Closing the terminals on the hosts\n')
    h1.cmd("killall xterm")
    h2.cmd("killall xterm")
    h3.cmd("killall xterm")
    r1.cmd("killall xterm")

    # This command stops the simulation
    net.stop()
    cleanUpScreens()
def myNetwork(containers, host_count, split):
    hosts = []
    container_number = int(containers)
    host_num = int(host_count)
    container_split = 100 / int(split)
    max_id = host_num / container_split
    net = Mininet(topo=None, build=False, controller=OVSController)

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

    info('*** Add switches\n')
    s1 = net.addSwitch('s1')
    Intf('eno2', node=s1)

    for x in range(0, host_num):
        host_name = 'h' + str(x)
        h = net.addHost(host_name, ip='0.0.0.0')
        hosts.append(h)
        net.addLink(h, s1)

    info('*** Starting network\n')
    net.start()
    for h in hosts:
        h.cmdPrint('dhclient ' + h.defaultIntf().name)

    # register
    CLI(net)
    confirm = str(raw_input("run test? y or n "))
    request_num = int(raw_input("numbers of request? "))
    max_count = int(raw_input("perform on how many container pairs? "))
    host_num = int(raw_input("Use how many hosts? "))
    request_freq = 0.5
    try:
        request_freq = float(raw_input("request_freq? "))
    except:
        pass
    max_id = host_num / max_count
    current_request = 0
    while confirm != "n":
        container_counter = 0
        for x in range(0, host_num):

            # move on to the next container pair
            if x / max_id > container_counter:
                container_counter += 1
            # limit the container pairs involved
            if container_counter >= max_count:
                break

            # spin up the IoT device scripts
            if x % 2 == 0:
                cmdstring = "python3 actuator.py " + str(
                    request_num) + " " + str(request_freq) + " " + str(
                        x % max_id) + " 52.74.73." + str(
                            (container_counter * 2) +
                            2) + " " + str(current_request)
                current_request = current_request + request_num + 1
            else:
                cmdstring = "python receiver.py " + str(
                    (x % max_id)) + " 13.55.147." + str(
                        (container_counter * 2) + 1)
            hosts[x].cmdPrint(cmdstring + " &")

        raw_input("parse results? ")

        # kill all python processes
        kill_all_py(hosts)

        # save results
        curr_time = str(datetime.datetime.now().strftime("%H:%M:%S"))
        cmd_list = "./results_mover.sh " + str(
            max_id) + " " + curr_time + " " + str(container_number)
        subprocess.call(cmd_list, shell=True)

        # reset variables
        confirm = str(raw_input("run test again ? "))
        if confirm != "n":
            if str(raw_input("same values ? ")) == "n":
                container_number = int(raw_input("container number ? "))
                hosts[0].cmdPrint("sudo python3 ./ghost_reg.py " +
                                  str(container_number))
                max_count = int(
                    raw_input("perform on how many container pairs? "))
                host_num = int(raw_input("Use how many hosts? "))
                max_id = host_num / max_count
                request_num = int(raw_input("numbers of request? "))
                try:
                    request_freq = float(raw_input("request_freq? "))
                except:
                    pass
                print(str(request_num))
                raw_input("configs done ? ")

    CLI(net)

    net.stop()
def my_network():
    net = Mininet(topo=None, build=False, controller=RemoteController)

    #Add Controller
    info('***Adding Controller\n')
    poxController1 = net.addController('c0',
                                       controller=RemoteController,
                                       ip="172.16.61.129",
                                       port=6633)
    #poxController2 = net.addController(name='c2',controller=POX)

    #Add Switches

    switch1 = net.addSwitch('s1')
    switch2 = net.addSwitch('s2')

    #Add Hosts
    info('***Adding Hosts\n')
    host1 = net.addHost('h1', ip='10.0.0.2/24')
    host2 = net.addHost('h2', ip='10.0.0.3/24')
    host3 = net.addHost('h3', ip='10.0.0.4/24')
    host4 = net.addHost('h4', ip='10.0.0.5/24')
    host5 = net.addHost('h5', ip='10.0.0.6/24')
    server = net.addHost('h6', mac='00:00:10:00:00:01', ip='10.0.0.7/24')
    client = net.addHost('h7', ip='10.0.0.8/24')
    ill_client = net.addHost('h8', ip='10.0.0.9/24')

    #Add Links
    info('***Creating Links\n')
    net.addLink(host1, switch1)
    net.addLink(host2, switch1)
    net.addLink(host3, switch1)
    net.addLink(host4, switch1)
    net.addLink(host5, switch1)
    net.addLink(client, switch1)
    net.addLink(ill_client, switch1)
    net.addLink(switch1, switch2)
    net.addLink(server, switch2)

    net.build()

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

    #s1.start([poxController1])
    #s2.start([poxController2])
    #net.get('switch12').start([poxController])

    info('***Entering command prompt\n')
    CLI(net)

    info('***Stopping network\n')
    net.stop()