Esempio n. 1
0
    def runDemo(self, host_cmd='/usr/sbin/sshd', host_cmd_opts='-D'):
        routers = self.readProtobuf()
        self.setSubnetRootSwitchBaseDpid(routers)

        controller = customConstructor(CONTROLLERS, self.options.controller)
        switch = customConstructor(SWITCHES, self.options.switch)

        network = Mininet(controller=controller, # link=TCLink,
                          # host=CPULimitedHost, # seems better without this
                          switch=switch,
                          autoSetMacs=True)

        network.addController('flowlog')
        self.buildNetwork(network, routers, CREATE_EDGE[self.options.create_edge],
                                            CREATE_SRS[self.options.create_srs])

        self.connectRouters(network, routers)
        self.launchNetwork(network, host_cmd, host_cmd_opts)

        '''
        for key in self.networksToLaunch:
          self.launchHttpdOnInternets(network, key, self.networksToLaunch[key])
        '''

        self.demo(network)
        self.teardownNetwork(network, host_cmd)
Esempio n. 2
0
    def runDemo(self, host_cmd='/usr/sbin/sshd', host_cmd_opts='-D'):
        routers = self.readProtobuf()
        self.setSubnetRootSwitchBaseDpid(routers)

        controller = customConstructor(CONTROLLERS, self.options.controller)
        switch = customConstructor(SWITCHES, self.options.switch)

        network = Mininet(
            controller=controller,  # link=TCLink,
            # host=CPULimitedHost, # seems better without this
            switch=switch,
            autoSetMacs=True)

        network.addController('flowlog')
        self.buildNetwork(network, routers,
                          CREATE_EDGE[self.options.create_edge],
                          CREATE_SRS[self.options.create_srs])

        self.connectRouters(network, routers)
        self.launchNetwork(network, host_cmd, host_cmd_opts)
        '''
        for key in self.networksToLaunch:
          self.launchHttpdOnInternets(network, key, self.networksToLaunch[key])
        '''

        self.demo(network)
        self.teardownNetwork(network, host_cmd)
Esempio n. 3
0
    def runDemo(self, host_cmd='/usr/sbin/sshd', host_cmd_opts='-D'):
        topo = self.buildTopo()
        controller = customConstructor(CONTROLLERS, self.options.controller)
        switch = customConstructor(SWITCHES, self.options.switch)

        network = Mininet(topo, controller=controller, link=TCLink, 
                          # host=CPULimitedHost, # seems better without this
                          switch=switch, ipBase='10.0.0.0/24')

        self.launchNetwork(network, host_cmd, host_cmd_opts)
        self.demo(network)
        self.teardownNetwork(network, host_cmd)
Esempio n. 4
0
def myNet():
    #call(['sudo', 'mn', '-c'])
    britefile = sys.argv[1] if len(sys.argv) >= 2 else None
    print "britefile:", britefile
    generateOps()

    topo = MyBriteTopo(britefile)
    remotecontroller = customConstructor(CONTROLLERS, "remote,ip=192.168.56.1")
    net = Mininet(topo=topo, controller=remotecontroller)
    net.start()  #启动您的拓扑网络
    for host in net.hosts:
        host.cmdPrint('route add default dev %s-eth0' % host.name)
    time.sleep(SLEEP_TIME)

    for i in range(len(operations)):
        if (operations[i] == 1):
            addhost = operationNodes[i]
            host = net.get(addhost)
            print "%s is ready to join" % addhost
            host.cmdPrint('iperf -s -u -B 224.0.55.55 &')
            time.sleep(ADD_SLEEP_T)
        else:
            removehost = operationNodes[i]
            host = net.get(removehost)
            print "%s is ready to leave and its last pid  is %s" % (
                removehost, host.lastPid)
            cmd = "kill %s" % host.lastPid
            host.cmd(cmd)
            time.sleep(REMOVE_SLEEP_T)

    net.stop()
Esempio n. 5
0
def myNet():
    #call(['sudo', 'mn', '-c'])
    britefile =  sys.argv[1] if len(sys.argv) >=2 else None
    print "britefile:",  britefile
    generateOps()


    topo = MyBriteTopo(britefile)
    remotecontroller = customConstructor(CONTROLLERS, "remote,ip=192.168.56.1")
    net = Mininet(topo = topo, controller=remotecontroller)
    net.start()    #启动您的拓扑网络
    for host in net.hosts:
        host.cmdPrint('route add default dev %s-eth0' %host.name)
    time.sleep(SLEEP_TIME)

    for i in range(len(operations)):
        if(operations[i] == 1):
            addhost = operationNodes[i]
            host = net.get(addhost)
            print "%s is ready to join" % addhost
            host.cmdPrint('iperf -s -u -B 224.0.55.55 &')
            time.sleep(ADD_SLEEP_T)
        else:
            removehost = operationNodes[i]
            host = net.get(removehost)
            print "%s is ready to leave and its last pid  is %s" % (removehost, host.lastPid)
            cmd = "kill %s" % host.lastPid
            host.cmd(cmd)
            time.sleep(REMOVE_SLEEP_T)

    net.stop()
Esempio n. 6
0
    def runDemo(self, host_cmd='/usr/sbin/sshd', host_cmd_opts='-D'):
        topo = self.buildTopo()
        controller = customConstructor(CONTROLLERS, self.options.controller)
        switch = customConstructor(SWITCHES, self.options.switch)

        network = Mininet(
            topo,
            controller=controller,
            link=TCLink,
            # host=CPULimitedHost, # seems better without this
            switch=switch,
            ipBase='10.0.0.0/24',
            autoSetMacs=True)

        self.launchNetwork(network, host_cmd, host_cmd_opts)
        self.demo(network)
        self.teardownNetwork(network, host_cmd)
Esempio n. 7
0
    def begin( self ):
        "Create and run mininet."

#        if self.options.clean:
#            cleanup()
#            exit()

        start = time.time()

 #       topo = buildTopo( TOPOS, self.options.topo )
        #3 wifi handling switches with 2 clients each
        topo = WiFiTopo( N = self.N, S = self.S )
        switch = customConstructor( SWITCHES, SWITCHDEF )
        host = customConstructor( HOSTS, HOSTDEF )
        controller = customConstructor( CONTROLLERS, CONTROLLERDEF )
        link = customConstructor( LINKS, LINKDEF )

        inNamespace = False
        #Net = MininetWithControlNet if inNamespace else Mininet
        Net = wrpMininet
        ipBase = '10.0.0.0/8'
	listenPort = 6634 

        mn = Net( topo=topo,
                  switch=switch, host=host, controller=controller,
                  link=link,
                  ipBase=ipBase,
                  inNamespace=inNamespace,
                  listenPort=listenPort )

#Add services here
        mn.add_preconf_service(1, 'hs0', 'dhcpd')
        
        for swi in irange( 1, self.S):
            hl = [ ('h%s' % h ) for h in irange((swi - 1) * self.N + 1, swi * self.N) ]
            for hn in hl:
                mn.add_preconf_service(2, hn, 'dhclient')

        mn.start()
	CLI(mn)
        mn.stop()

        elapsed = float( time.time() - start )
        info( 'completed in %0.3f seconds\n' % elapsed )
Esempio n. 8
0
    def begin( self ):
        "Create and run mininet."

        start = time.time()

        topo = LinearConnectTopo( N = self.N, S = self.S )
        switch = customConstructor( SWITCHES, SWITCHDEF )
        host = customConstructor( HOSTS, HOSTDEF )
        controller = customConstructor( CONTROLLERS, CONTROLLERDEF )
        link = customConstructor( LINKS, LINKDEF )

        inNamespace = False
        Net = wrpMininet
        ipBase = '10.0.0.0/8'
    	listenPort = 6634 

        mn = Net( topo=topo,
                  switch=switch, host=host, controller=controller,
                  link=link,
                  ipBase=ipBase,
                  inNamespace=inNamespace,
                  listenPort=listenPort,
                  services = True)

#Add services here
#        mn.add_preconf_service( 'hs0', 1 , 'dhcpd' )
#ADD cmdStrSubst modification to preconf_service
        #mn.add_preconf_service( 'hs0', 3 , 'ntpd-srv' )
        
#        for swi in irange( 1, self.S):
#            hl = [ ('h%s' % h ) for h in irange((swi - 1) * self.N + 1, swi * self.N) ]
#            for hn in hl:
#                mn.add_preconf_service( hn, 2, 'dhclient' )
                #mn.add_preconf_service( hn, 4, 'ntpd-cli' )

        mn.start()
    	CLI(mn)
        mn.stop()

        elapsed = float( time.time() - start )
        info( 'completed in %0.3f seconds\n' % elapsed )
Esempio n. 9
0
def myNetSimulation():
    #call(['sudo', 'mn', '-c'])
    global terminals
    global nonterminals

    nonterminals = map(lambda x: 's'+str(int(x+1)), range(HIGH))
    terminals = []
    britefile =  sys.argv[1] if len(sys.argv) >=2 else None
    topo = MyBriteTopo(britefile)
    remotecontroller = customConstructor(CONTROLLERS, "remote,ip=192.168.56.1")
    net = Mininet(topo = topo, controller=remotecontroller)
    net.start()    #启动您的拓扑网络
    for host in net.hosts:
        host.cmdPrint('route add default dev %s-eth0' %host.name)
    time.sleep(SLEEP_TIME)
    doSimulation()
Esempio n. 10
0
def myNetSimulation():
    #call(['sudo', 'mn', '-c'])
    global terminals
    global nonterminals

    nonterminals = map(lambda x: 's' + str(int(x + 1)), range(HIGH))
    terminals = []
    britefile = sys.argv[1] if len(sys.argv) >= 2 else None
    topo = MyBriteTopo(britefile)
    remotecontroller = customConstructor(CONTROLLERS, "remote,ip=192.168.56.1")
    net = Mininet(topo=topo, controller=remotecontroller)
    net.start()  #启动您的拓扑网络
    for host in net.hosts:
        host.cmdPrint('route add default dev %s-eth0' % host.name)
    time.sleep(SLEEP_TIME)
    doSimulation()
def main():
    lg.setLogLevel('info')

    context = Context()
    if not get_cmd_line_args(context):
        return

    print 'Starting with [%s] switches' % context.switch_number

    # Create the topology with the context args taken from the cmd-line
    myTopo = create_topology(context)

    # The network
    myNet = Mininet(myTopo)

    # The SDN-remote_controller connection
    mySDNController = myNet.addController(
        context.remote_controller_name,
        customConstructor({'remote': RemoteController},
                          context.remote_controller_args))
    myLocalController = myNet.addController('c1', controller=OVSController)
    myLocalController.start()

    dump_hosts(myNet)

    # This will output the nodes port connections to MININET_NET_FILE
    dumpNodeConnections(myNet.values())
    # This will output the nodes port connections to MININET_DUMP_FILE
    dumpNodes(myNet.values())

    # start_gateways(myNet)
    start_switches(context, myNet, mySDNController, myLocalController)

    # Insert ovs-ofctl rules
    print 'Inserting flows into the switches...'
    init_flows(context)

    # Start the command line
    CLI(myNet)

    cleanup()
def main():
    lg.setLogLevel('info')

    context = Context()
    if not get_cmd_line_args(context):
        return

    print 'Starting with [%s] switches' % context.switch_number

    # Create the topology with the context args taken from the cmd-line
    myTopo = create_topology(context)

    # The network
    myNet = Mininet(myTopo)

    # The SDN-remote_controller connection
    mySDNController = myNet.addController(
        context.remote_controller_name,
        customConstructor({'remote': RemoteController},
                          context.remote_controller_args))
    myLocalController = myNet.addController('c1', controller=OVSController)
    myLocalController.start()

    dump_hosts(myNet)

    # This will output the nodes port connections to MININET_NET_FILE
    dumpNodeConnections(myNet.values())
    # This will output the nodes port connections to MININET_DUMP_FILE
    dumpNodes(myNet.values())

    # start_gateways(myNet)
    start_switches(context, myNet, mySDNController, myLocalController)

    # Insert ovs-ofctl rules
    print 'Inserting flows into the switches...'
    init_flows(context)

    # Start the command line
    CLI(myNet)

    cleanup()
# Verifing topology type
if options.topology == 'tree':
  topo = TreeTopo( depth=options.depth, fanout=options.fanout )
elif options.topology == 'single':
  topo = SingleSwitchTopo( k=options.hosts )
elif options.topology == 'ufrgs':
  topo = UFRGSTopo()
elif options.topology == 'fattree':
  topo = FatTree( num_pods=options.pods )

# Setting mininet configuration
setLogLevel( 'info' )

# Setting links configuration
LINKS = {'default':Link, 'tc':TCLink}
link = customConstructor( LINKS, 'tc,bw=100' )

# Adding root host
root = Host( 'root', inNamespace=False )

# Adding the remote controller
net = Mininet( topo=topo, link=link, autoSetMacs=True, controller=lambda name: RemoteController( name, ip=options.ip ) )

for host in net.hosts:
   host.linkTo ( root )

# Start the network
net.start()

# Waiting for apache starts
file_server = 0
Esempio n. 14
0
    def begin( self ):
        "Create and run mininet."

        if self.options.clean:
            cleanup()
            exit()

        start = time.time()

#navy
        #topo = buildTopo( TOPOS, self.options.topo )
        topo = MyTopo()
        switch = customConstructor( SWITCHES, self.options.switch )
        host = customConstructor( HOSTS, self.options.host )
        controller = lambda name: RemoteController( name,ip='10.211.55.2',port=int('6633') )
        link = customConstructor( LINKS, self.options.link )

        if self.validate:
            self.validate( self.options )

        inNamespace = self.options.innamespace
        #navy
        #Net = MininetWithControlNet if inNamespace else Mininet
        Net = mininet.services.wrpMininet

        ipBase = self.options.ipbase
        xterms = self.options.xterms
        mac = self.options.mac
        arp = self.options.arp
        pin = self.options.pin
        listenPort = None
        if not self.options.nolistenport:
            listenPort = self.options.listenport


        intfName = 'eth1'
        info( '*** Checking', intfName, '\n' )
        checkIntf( intfName )

        mn = Net( topo=topo,
            switch=switch, host=host, controller=controller,
            link=link,
            ipBase=ipBase,
            inNamespace=inNamespace,
            xterms=xterms, autoSetMacs=mac,
            autoStaticArp=arp, autoPinCpus=pin,
#navy
#           listenPort=listenPort )
            listenPort=listenPort, services = True )


        for sw in mn.switches:
            if sw.name in sw_ext_intf:
                info( '*** Adding hardware interface', intfName, 'to switch',
                    sw.name, '\n' )
                _intf = Intf( intfName, node=sw )

        info( '*** Note: you may need to reconfigure the interfaces for '
            'the Mininet hosts:\n', mn.hosts, '\n' )

#navy
#Add services here
#-----------------


        if self.options.pre:
            CLI( mn, script=self.options.pre )

        test = self.options.test
        test = ALTSPELLING.get( test, test )

        mn.start()

        if test == 'none':
            pass
        elif test == 'all':
            mn.start()
            mn.ping()
            mn.iperf()
        elif test == 'cli':
            CLI( mn )
        elif test != 'build':
            getattr( mn, test )()

        if self.options.post:
            CLI( mn, script=self.options.post )

        mn.stop()

        elapsed = float( time.time() - start )
        info( 'completed in %0.3f seconds\n' % elapsed )
Esempio n. 15
0
        if (len(topoParts) != 2 or not topoParts[1].isdigit()):
            sys.exit(1)
        topo = LinearTopo(k=int(topoParts[1]))
    elif (topoParts[0] == "assign1"):
        topo = AssignOneTopo()
    elif (topoParts[0] == "triangle"):
        topo = TriangleTopo()
    elif (topoParts[0] == "mesh"):
        if (len(topoParts) != 2 or not topoParts[1].isdigit()):
            sys.exit(1)
        topo = MeshTopo(n=int(topoParts[1]))
    elif (topoParts[0] == "someloops"):
        topo = SomeLoopsTopo()
    else:
        print 'Unknown topology'
        sys.exit(1) 

    net = Mininet(topo=topo, autoSetMacs=True, controller=RemoteController,
            switch=customConstructor({'ovsk' : OVSSwitch}, "ovsk,protocols=OpenFlow13"))

    # Run network
    net.start()
    for h in net.hosts: 
        info('*** ARPing from host %s\n' % (h.name))
        h.cmd('arping -c 2 -A -I '+h.name+'-eth0 '+h.IP())
        starthttp(h)
    CLI( net )
    stophttp()
    net.stop()

Esempio n. 16
0
    def begin( self ):
        "Create and run mininet."

        if self.options.clean:
            cleanup()
            exit()

        start = time.time()

#navy
        #topo = buildTopo( TOPOS, self.options.topo )
        topo = MyTopo()
        switch = customConstructor( SWITCHES, self.options.switch )
        host = customConstructor( HOSTS, self.options.host )
        controller = lambda name: RemoteController( name,ip='10.211.55.2',port=int('6633') )
        link = customConstructor( LINKS, self.options.link )

        if self.validate:
            self.validate( self.options )

        inNamespace = self.options.innamespace
        #navy
        #Net = MininetWithControlNet if inNamespace else Mininet
        Net = mininet.services.wrpMininet

        ipBase = self.options.ipbase
        xterms = self.options.xterms
        mac = self.options.mac
        arp = self.options.arp
        pin = self.options.pin
        listenPort = None
        if not self.options.nolistenport:
            listenPort = self.options.listenport


        intfName = 'eth1'
        info( '*** Checking', intfName, '\n' )
        checkIntf( intfName )

        mn = Net( topo=topo,
            switch=switch, host=host, controller=controller,
            link=link,
            ipBase=ipBase,
            inNamespace=inNamespace,
            xterms=xterms, autoSetMacs=mac,
            autoStaticArp=arp, autoPinCpus=pin,
#navy
#           listenPort=listenPort )
            listenPort=listenPort, services = True )


        for sw in mn.switches:
            if sw.name in sw_ext_intf:
                info( '*** Adding hardware interface', intfName, 'to switch',
                    sw.name, '\n' )
                _intf = Intf( intfName, node=sw )

        info( '*** Note: you may need to reconfigure the interfaces for '
            'the Mininet hosts:\n', mn.hosts, '\n' )

#navy
#Add services here
        mn.add_preconf_service( 'h100', 2 , 'dhcp' )
        mn.add_preconf_service( 'h101', 2 , 'dhcp' )
        mn.add_preconf_service( 'h102', 2 , 'dhcp' )
        mn.add_preconf_service( 'h103', 2 , 'dhcp' )
        mn.add_preconf_service( 'h104', 2 , 'dhcp' )
        mn.add_preconf_service( 'h105', 2 , 'dhcp' )
        mn.add_preconf_service( 'h107', 2 , 'dhcp' )
        mn.add_preconf_service( 'h108', 2 , 'dhcp' )
        mn.add_preconf_service( 'h11', 2 , 'dhcp' )
        mn.add_preconf_service( 'h110', 2 , 'dhcp' )
        mn.add_preconf_service( 'h111', 2 , 'dhcp' )
        mn.add_preconf_service( 'h113', 2 , 'dhcp' )
        mn.add_preconf_service( 'h114', 2 , 'dhcp' )
        mn.add_preconf_service( 'h115', 2 , 'dhcp' )
        mn.add_preconf_service( 'h116', 2 , 'dhcp' )
        mn.add_preconf_service( 'h117', 2 , 'dhcp' )
        mn.add_preconf_service( 'h119', 2 , 'dhcp' )
        mn.add_preconf_service( 'h120', 2 , 'dhcp' )
        mn.add_preconf_service( 'h121', 2 , 'dhcp' )
        mn.add_preconf_service( 'h127', 2 , 'dhcp' )
        mn.add_preconf_service( 'h128', 2 , 'dhcp' )
        mn.add_preconf_service( 'h130', 2 , 'dhcp' )
        mn.add_preconf_service( 'h131', 2 , 'dhcp' )
        mn.add_preconf_service( 'h134', 2 , 'dhcp' )
        mn.add_preconf_service( 'h135', 2 , 'dhcp' )
        mn.add_preconf_service( 'h137', 2 , 'dhcp' )
        mn.add_preconf_service( 'h138', 2 , 'dhcp' )
        mn.add_preconf_service( 'h139', 2 , 'dhcp' )
        mn.add_preconf_service( 'h140', 2 , 'dhcp' )
        mn.add_preconf_service( 'h142', 2 , 'dhcp' )
        mn.add_preconf_service( 'h144', 2 , 'dhcp' )
        mn.add_preconf_service( 'h145', 2 , 'dhcp' )
        mn.add_preconf_service( 'h147', 2 , 'dhcp' )
        mn.add_preconf_service( 'h148', 2 , 'dhcp' )
        mn.add_preconf_service( 'h149', 2 , 'dhcp' )
        mn.add_preconf_service( 'h150', 2 , 'dhcp' )
        mn.add_preconf_service( 'h151', 2 , 'dhcp' )
        mn.add_preconf_service( 'h154', 2 , 'dhcp' )
        mn.add_preconf_service( 'h156', 2 , 'dhcp' )
        mn.add_preconf_service( 'h157', 2 , 'dhcp' )
        mn.add_preconf_service( 'h158', 2 , 'dhcp' )
        mn.add_preconf_service( 'h159', 2 , 'dhcp' )
        mn.add_preconf_service( 'h160', 2 , 'dhcp' )
        mn.add_preconf_service( 'h162', 2 , 'dhcp' )
        mn.add_preconf_service( 'h163', 2 , 'dhcp' )
        mn.add_preconf_service( 'h164', 2 , 'dhcp' )
        mn.add_preconf_service( 'h166', 2 , 'dhcp' )
        mn.add_preconf_service( 'h167', 2 , 'dhcp' )
        mn.add_preconf_service( 'h168', 2 , 'dhcp' )
        mn.add_preconf_service( 'h169', 2 , 'dhcp' )
        mn.add_preconf_service( 'h170', 2 , 'dhcp' )
        mn.add_preconf_service( 'h172', 2 , 'dhcp' )
        mn.add_preconf_service( 'h173', 2 , 'dhcp' )
        mn.add_preconf_service( 'h174', 2 , 'dhcp' )
        mn.add_preconf_service( 'h175', 2 , 'dhcp' )
        mn.add_preconf_service( 'h176', 2 , 'dhcp' )
        mn.add_preconf_service( 'h20', 2 , 'dhcp' )
        mn.add_preconf_service( 'h23', 2 , 'dhcp' )
        mn.add_preconf_service( 'h29', 2 , 'dhcp' )
        mn.add_preconf_service( 'h30', 2 , 'dhcp' )
        mn.add_preconf_service( 'h31', 2 , 'dhcp' )
        mn.add_preconf_service( 'h42', 2 , 'dhcp' )
        mn.add_preconf_service( 'h44', 2 , 'dhcp' )
        mn.add_preconf_service( 'h49', 2 , 'dhcp' )
        mn.add_preconf_service( 'h53', 2 , 'dhcp' )
        mn.add_preconf_service( 'h54', 2 , 'dhcp' )
        mn.add_preconf_service( 'h57', 2 , 'dhcp' )
        mn.add_preconf_service( 'h60', 2 , 'dhcp' )
        mn.add_preconf_service( 'h61', 2 , 'dhcp' )
        mn.add_preconf_service( 'h62', 2 , 'dhcp' )
        mn.add_preconf_service( 'h64', 2 , 'dhcp' )
        mn.add_preconf_service( 'h65', 2 , 'dhcp' )
        mn.add_preconf_service( 'h68', 2 , 'dhcp' )
        mn.add_preconf_service( 'h69', 2 , 'dhcp' )
        mn.add_preconf_service( 'h70', 2 , 'dhcp' )
        mn.add_preconf_service( 'h72', 2 , 'dhcp' )
        mn.add_preconf_service( 'h76', 2 , 'dhcp' )
        mn.add_preconf_service( 'h77', 2 , 'dhcp' )
        mn.add_preconf_service( 'h79', 2 , 'dhcp' )
        mn.add_preconf_service( 'h80', 2 , 'dhcp' )
        mn.add_preconf_service( 'h82', 2 , 'dhcp' )
        mn.add_preconf_service( 'h83', 2 , 'dhcp' )
        mn.add_preconf_service( 'h86', 2 , 'dhcp' )
        mn.add_preconf_service( 'h89', 2 , 'dhcp' )
        mn.add_preconf_service( 'h92', 2 , 'dhcp' )
        mn.add_preconf_service( 'h95', 2 , 'dhcp' )
        mn.add_preconf_service( 'h99', 2 , 'dhcp' )
#-----------------


        if self.options.pre:
            CLI( mn, script=self.options.pre )

        test = self.options.test
        test = ALTSPELLING.get( test, test )

        mn.start()

        if test == 'none':
            pass
        elif test == 'all':
            mn.start()
            mn.ping()
            mn.iperf()
        elif test == 'cli':
            CLI( mn )
        elif test != 'build':
            getattr( mn, test )()

        if self.options.post:
            CLI( mn, script=self.options.post )

        mn.stop()

        elapsed = float( time.time() - start )
        info( 'completed in %0.3f seconds\n' % elapsed )
Esempio n. 17
0
    def begin(self):
        "Create and run mininet."

        if self.options.clean:
            cleanup()
            exit()

        start = time.time()

        topo = buildTopo(TOPOS, self.options.topo)
        switch = customConstructor(SWITCHES, self.options.switch)
        host = customConstructor(HOSTS, self.options.host)
        controller = customConstructor(CONTROLLERS, self.options.controller)
        link = customConstructor(LINKS, self.options.link)

        if self.validate:
            self.validate(self.options)

        inNamespace = self.options.innamespace
        Net = MininetWithControlNet if inNamespace else Mininet
        ipBase = self.options.ipbase
        xterms = self.options.xterms
        mac = self.options.mac
        arp = self.options.arp
        pin = self.options.pin
        listenPort = None
        if not self.options.nolistenport:
            listenPort = self.options.listenport
        mn = Net(topo=topo,
                  switch=switch, host=host, controller=controller,
                  link=link,
                  ipBase=ipBase,
                  inNamespace=inNamespace,
                  xterms=xterms, autoSetMacs=mac,
                  autoStaticArp=arp, autoPinCpus=pin,
                  listenPort=listenPort)

        # ## PYRETIC CHANGE - SETUP HOSTS BASED ON TOPOLOGY NODE_INFO
        for host in mn.hosts:
            try:
                gw = topo.node_info[host.name]['gw']
                intf = host.defaultIntf()
                host.cmd('route add default gw %s dev %s' % (gw, intf))        
            except KeyError:
                pass
        # ## END PYRETIC CHANGE - SETUP HOSTS BASED ON TOPOLOGY NODE_INFO

        if self.options.pre:
            CLI(mn, script=self.options.pre)

        test = self.options.test
        test = ALTSPELLING.get(test, test)

        mn.start()
        print "*** network built:"
        dumpNodeConnections(mn.values())

        if test == 'pingall':
            mn.ping()
        elif test == 'iperfudp':
            iperf(mn)
        elif test == 'iperftcp':
            iperf(mn, 'TCP')
        elif test == 'ifconfig':
            ifconfigTest(mn)
        else:
            pass
        
        if self.options.post:
            CLI(mn, script=self.options.post)

        mn.stop()

        elapsed = float(time.time() - start)
        info('completed in %0.3f seconds\n' % elapsed)
Esempio n. 18
0
def start_mininet():

    stophttp()
    ret = load_ip_setting()
    if (ret == -1):
        sys.exit(
            "Couldn't load config file for ip addresses, check wether %s exists"
            % IPCONFIG_FILE)
    else:
        info('*** Successfully loaded ip settings for hosts\n %s\n' %
             IP_SETTING)

    topo = NatTopo()
    link = customConstructor(LINKS, LINKDEF)
    switch = customConstructor(SWITCHES, SWITCHDEF)
    host = customConstructor(HOSTS, HOSTDEF)
    controller = customConstructor(CONTROLLERS, 'remote,ip=%s' % controller_ip)

    mn = Mininet(topo=topo,
                 switch=switch,
                 host=host,
                 controller=controller,
                 link=link,
                 autoSetMacs=auto_mac,
                 listenPort=6634)
    mn.start()

    # set hosts ip address
    server1, server2, client1, client2, client3, nat = mn.get(
        'server1', 'server2', 'client1', 'client2', 'client3', 'sw0')

    s1intf = server1.defaultIntf()
    s1intf.setIP('%s/8' % IP_SETTING['server1'])
    s2intf = server2.defaultIntf()
    s2intf.setIP('%s/8' % IP_SETTING['server2'])

    c1intf = client1.defaultIntf()
    c1intf.setIP('%s/8' % IP_SETTING['client1'])
    c2intf = client2.defaultIntf()
    c2intf.setIP('%s/8' % IP_SETTING['client2'])
    c3intf = client3.defaultIntf()
    c3intf.setIP('%s/8' % IP_SETTING['client3'])

    # add default route
    for host in client1, client2, client3, server1, server2:
        set_default_route(host)

    # initialize static arp
    if static_arp:
        gw_int_ip = IP_SETTING['sw0-eth1']
        gw_ext_ip = IP_SETTING['sw0-eth2']

        client1.setARP(ip=client2.IP(), mac=client2.MAC())
        client1.setARP(ip=client3.IP(), mac=client3.MAC())
        client1.setARP(ip=gw_int_ip, mac=nat.intf(intf='sw0-eth1').MAC())

        client2.setARP(ip=client1.IP(), mac=client1.MAC())
        client2.setARP(ip=client3.IP(), mac=client3.MAC())
        client2.setARP(ip=gw_int_ip, mac=nat.intf(intf='sw0-eth2').MAC())

        client3.setARP(ip=client1.IP(), mac=client1.MAC())
        client3.setARP(ip=client2.IP(), mac=client2.MAC())
        client3.setARP(ip=gw_int_ip, mac=nat.intf(intf='sw0-eth3').MAC())

        server1.setARP(ip=server2.IP(), mac=server2.MAC())
        server1.setARP(ip=gw_ext_ip, mac=nat.intf(intf='sw0-eth4').MAC())

        server2.setARP(ip=server1.IP(), mac=server1.MAC())
        server2.setARP(ip=gw_ext_ip, mac=nat.intf(intf='sw0-eth4').MAC())

    starthttp(server1)
    starthttp(server2)
    setclient(client1)
    setclient(client2)
    setclient(client3)

    CLI(mn)

    stophttp()
    mn.stop()
Esempio n. 19
0
        if (len(topoParts) != 2 or not topoParts[1].isdigit()):
            sys.exit(1)
        topo = TreeTopo(depth=int(topoParts[1]))
    elif (topoParts[0] == "linear"):
        if (len(topoParts) != 2 or not topoParts[1].isdigit()):
            sys.exit(1)
        topo = LinearTopo(k=int(topoParts[1]))
    elif (topoParts[0] == "assign1"):
        topo = AssignOneTopo()
    elif (topoParts[0] == "triangle"):
        topo = TriangleTopo()
    else:
        print 'Unknown topology'
        sys.exit(1)

    net = Mininet(topo=topo,
                  autoSetMacs=True,
                  controller=RemoteController,
                  switch=customConstructor({'ovsk': OVSSwitch},
                                           "ovsk,protocols=OpenFlow13"))

    # Run network
    net.start()
    for h in net.hosts:
        info('*** ARPing from host %s\n' % (h.name))
        h.cmd('arping -c 2 -A -I ' + h.name + '-eth0 ' + h.IP())
        starthttp(h)
    CLI(net)
    stophttp()
    net.stop()
os.chown(experiment_path, 1000, 1000)

# Verifing topology type
if options.topology == "tree":
    topo = TreeTopo(depth=options.depth, fanout=options.fanout)
elif options.topology == "single":
    topo = SingleSwitchTopo(k=options.hosts)
elif options.topology == "ufrgs":
    topo = UFRGSTopo()

# Setting mininet configuration
setLogLevel("info")

# Setting links configuration
LINKS = {"default": Link, "tc": TCLink}
link = customConstructor(LINKS, "tc,bw=100")

# Adding root host
root = Host("root", inNamespace=False)

# Adding the remote controller
net = Mininet(topo=topo, link=link, autoSetMacs=True, controller=lambda name: RemoteController(name, ip=options.ip))

for host in net.hosts:
    host.linkTo(root)

# Start the network
net.start()

# Waiting for apache starts
file_server = 0
Esempio n. 21
0
ADD_SLEEP_T = 2
REMOVE_SLEEP_T = 2
#multicastGroup = ['h1','h2','h3','h4', 'h5','h6','h7','h8','h9','h10','h11','h12']
##for i in range(1,13):
    ##multicastGroup.append('h'+ str(i))
#multicastLeave = ['h2','h3','h4', 'h5','h6','h7','h8','h9','h10','h11','h12']

#print "multicastGroup", multicastGroup
#print "multicastLeave", multicastLeave

operations=[1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
operationNodes=['h1','h2','h3','h4', 'h5','h6','h7','h8','h9','h10','h11','h12','h2','h3','h4', 'h5','h6','h7','h8','h9','h10','h11','h12']

setLogLevel( 'info' )
topo = MyTopo()
remotecontroller = customConstructor(CONTROLLERS, "remote,ip=192.168.56.1")
net = Mininet(topo = topo, controller=remotecontroller)
net.start()
for host in net.hosts:
    host.cmdPrint('route add default dev %s-eth0' %host.name)
time.sleep(5)

for i in range(len(operations)):
    if operations[i] == 1:
        hostname = operationNodes[i]
        print "%s is ready to join" % hostname
        host = net.get(hostname)
        host.cmdPrint('iperf -s -u -B 224.0.55.55 &')
        time.sleep(ADD_SLEEP_T)
    else:
        hostname = operationNodes[i]
Esempio n. 22
0
#print "multicastGroup", multicastGroup
#print "multicastLeave", multicastLeave

operations = [
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1
]
operationNodes = [
    'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8', 'h9', 'h10', 'h11', 'h12',
    'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8', 'h9', 'h10', 'h11', 'h12'
]

setLogLevel('info')
topo = MyTopo()
remotecontroller = customConstructor(CONTROLLERS, "remote,ip=192.168.56.1")
net = Mininet(topo=topo, controller=remotecontroller)
net.start()
for host in net.hosts:
    host.cmdPrint('route add default dev %s-eth0' % host.name)
time.sleep(5)

for i in range(len(operations)):
    if operations[i] == 1:
        hostname = operationNodes[i]
        print "%s is ready to join" % hostname
        host = net.get(hostname)
        host.cmdPrint('iperf -s -u -B 224.0.55.55 &')
        time.sleep(ADD_SLEEP_T)
    else:
        hostname = operationNodes[i]