Exemple #1
0
def bwtest(cpuLimits, period_us=100000, seconds=5):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo(depth=1, fanout=2)

    results = {}

    for sched in "rt", "cfs":
        print "*** Testing with", sched, "bandwidth limiting"
        for cpu in cpuLimits:
            host = custom(CPULimitedHost, sched=sched, period_us=period_us, cpu=cpu)
            try:
                net = Mininet(topo=topo, host=host)
            except:
                info("*** Skipping host %s\n" % sched)
                break
            net.start()
            net.pingAll()
            hosts = [net.getNodeByName(h) for h in topo.hosts()]
            client, server = hosts[0], hosts[-1]
            server.cmd("iperf -s -p 5001 &")
            waitListening(client, server, 5001)
            result = client.cmd("iperf -yc -t %s -c %s" % (seconds, server.IP())).split(",")
            bps = float(result[-1])
            server.cmdPrint("kill %iperf")
            net.stop()
            updated = results.get(sched, [])
            updated += [(cpu, bps)]
            results[sched] = updated

    return results
Exemple #2
0
def sshd(network,
         cmd='/usr/sbin/sshd',
         opts='-D',
         ip='191.168.111.1/8',
         routes=None,
         switch=None):
    if not switch:
        switch = network['s1']  # switch to use
    if not routes:
        routes = ['191.0.0.0/8']
    connectToRootNS(network, switch, ip, routes)
    for host in network.hosts:
        print(host, "host==============")
        host.cmd(cmd + ' ' + opts + '&')  # host.cmd('/usr/sbin/sshd -D &')
    info("*** Waiting for ssh daemons to start\n")
    for server in network.hosts:
        print(server)
        waitListening(server=server, port=22, timeout=5)
    info("\n*** Hosts are running sshd at the following addresses:\n")
    for host in network.hosts:
        info(host.name, host.IP(), '\n')
    info("\n*** Type 'exit' or control-D to shut down network\n")
    CLI(network)
    for host in network.hosts:
        host.cmd('kill %' + cmd)
    network.stop()
def sshd(network,
         cmd='/usr/sbin/sshd',
         opts='-D',
         ip='10.123.123.1/32',
         routes=None,
         switch=None):
    """Start a network, connect it to root ns, and run sshd on all hosts.
       ip: root-eth0 IP address in root namespace (10.123.123.1/32)
       routes: Mininet host networks to route to (10.0/24)
       switch: Mininet switch to connect to root namespace (s1)"""
    if not switch:
        switch = network['s1']  # switch to use
    if not routes:
        routes = ['10.0.0.0/24']
    connectToRootNS(network, switch, ip, routes)
    for host in network.hosts:
        host.cmd(cmd + ' ' + opts + '&')
    print "*** Waiting for ssh daemons to start"
    for server in network.hosts:
        waitListening(server=server, port=22, timeout=5)

    print
    print "*** Hosts are running sshd at the following addresses:"
    print
    for host in network.hosts:
        print host.name, host.IP()
    print
Exemple #4
0
def sshd(network,
         cmd='/usr/sbin/sshd',
         opts='-D',
         ip='10.123.123.1/32',
         routes=None,
         switch=None):
    """Start a network, connect it to root ns, and run sshd on all hosts.
       ip: root-eth0 IP address in root namespace (10.123.123.1/32)
       routes: Mininet host networks to route to (10.0/24)
       switch: Mininet switch to connect to root namespace (s1)"""
    if not switch:
        switch = network['s1']  # switch to use
    if not routes:
        routes = ['10.0.0.0/24']
    connectToRootNS(network, switch, ip, routes)
    for host in network.hosts:
        host.cmd(cmd + ' ' + opts + '&')
    info("*** Waiting for ssh daemons to start\n")
    for server in network.hosts:
        waitListening(server=server, port=22, timeout=5)

    info("\n*** Hosts are running sshd at the following addresses:\n")
    for host in network.hosts:
        info(host.name, host.IP(), '\n')
    info("\n*** Type 'exit' or control-D to shut down network\n")
    CLI(network)
    for host in network.hosts:
        host.cmd('kill %' + cmd)
    network.stop()
Exemple #5
0
def bwtest( cpuLimits, period_us=100000, seconds=5 ):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo( depth=1, fanout=2 )

    results = {}

    for sched in 'rt', 'cfs':
        print '*** Testing with', sched, 'bandwidth limiting'
        for cpu in cpuLimits:
            host = custom( CPULimitedHost, sched=sched,
                           period_us=period_us,
                           cpu=cpu )
            try:
                net = Mininet( topo=topo, host=host )
            except:
                info( '*** Skipping host %s\n' % sched )
                break
            net.start()
            net.pingAll()
            hosts = [ net.getNodeByName( h ) for h in topo.hosts() ]
            client, server = hosts[ 0 ], hosts[ -1 ]
            server.cmd( 'iperf -s -p 5001 &' )
            waitListening( client, server, 5001 )
            result = client.cmd( 'iperf -yc -t %s -c %s' % (
                seconds, server.IP() ) ).split( ',' )
            bps = float( result[ -1 ] )
            server.cmdPrint( 'kill %iperf' )
            net.stop()
            updated = results.get( sched, [] )
            updated += [ ( cpu, bps ) ]
            results[ sched ] = updated

    return results
def open_ssh_channel(net, opts='', containers=[]):
    cmd_base = '/usr/sbin/sshd %s'
    for c in containers:
        c.sendCmd(cmd_base % opts)

    for server in net.hosts:
        waitListening(server=server, port=22, timeout=30)
def sshd( network, cmd='/sbin/sshd', opts='-D',
          ip='172.16.0.253/32', routes=None, switch=None ):
    """Start a network, connect it to root ns, and run sshd on all hosts.
       ip: root-eth0 IP address in root namespace (10.123.123.1/32)
       routes: Mininet host networks to route to (10.0/24)
       switch: Mininet switch to connect to root namespace (s1)"""
    if not switch:
        switch = network[ 's1' ]  # switch to use
    if not routes:
        routes = [ '172.16.0.0/24' ]
    connectToRootNS( network, switch, ip, routes )
    for host in network.hosts:
        host.cmd( cmd + ' ' + opts + '&' )
    print "*** Waiting for ssh daemons to start"
    for server in network.hosts:
        waitListening( server=server, port=22, timeout=5 )

    print
    print "*** Hosts are running sshd at the following addresses:"
    print
    for host in network.hosts:
        print host.name, host.IP()
    print
    print "*** Type 'exit' or control-D to shut down network"
    CLI( network )
    for host in network.hosts:
        host.cmd( 'kill %' + cmd )
    network.stop()
Exemple #8
0
def iperf_experiment(net):
    print "*** Running iperf experiment"
    
    # Get receiver and clients
    sender = net.getNodeByName('sender')
    receiver = net.getNodeByName('receiver')
    
    s1 = net.getNodeByName('s1')
    s2 = net.getNodeByName('s2')
    
    port = 5001
    
    # Start the bandwidth and cwnd monitors in the background
    monitor = Process(target=monitor_devs_ng, args=('%s/bwm-iperf-udp.txt' % args.dir, 1.0))
    monitor.start()
    start_tcpprobe("udp")
    
    # Start the receiver
    receiver.cmd('iperf -s -w 256K -l 16K -u -p', port, '> %s/iperf_server-udp.txt' % args.dir, '&')
    
    print "*** Starting iperf udp"
    sender.sendCmd('iperf -c %s -p %s -t %d -i 1 -r -w 256K -l 16K -u -b %dM -yc > %s/iperf_client-udp.txt' %
	           (receiver.IP(), port, args.time, args.bw, args.dir))
    sender.waitOutput(verbose=True)
    print "*** Killing iperf proc"

    receiver.cmd('kill %iperf')

    # Shut down monitors
    stop_tcpprobe()
    monitor.terminate()
    os.system("killall -9 bwm-ng")
    
    
    ### do tcp test
    monitor = Process(target=monitor_devs_ng, args=('%s/bwm-iperf-tcp.txt' % args.dir, 1.0))
    monitor.start()
    start_tcpprobe("tcp")
    
    # Start the receiver
    receiver.cmd('iperf -s -w 256K -l 16K -p', port, '> %s/iperf_server-tcp.txt' % args.dir, '&')
    waitListening(sender, receiver, port)

    print "*** Starting iperf tcp"
    sender.sendCmd('iperf -c %s -p %s -t %d -i 1 -r -w 256K -l 16K -yc > %s/iperf_client-tcp.txt' %
	           (receiver.IP(), port, args.time, args.dir))
    sender.waitOutput(verbose=True)
    print "*** Killing iperf proc"
    
    receiver.cmd('kill %iperf')
    
    # Shut down monitors
    stop_tcpprobe()
    monitor.terminate()
    os.system("killall -9 bwm-ng")
    
    print "*** End iperf experiment"
Exemple #9
0
def sshd( network, cmd='/usr/sbin/sshd', opts='-D',
          ip='10.123.123.1/32', routes=None, switch=None ):
    """Start a network, connect it to root ns, and run sshd on all hosts.
       ip: root-eth0 IP address in root namespace (10.123.123.1/32)
       routes: Mininet host networks to route to (10.0/24)
       switch: Mininet switch to connect to root namespace (s1)"""
    if not switch:
        switch = network[ '1001' ]  # switch to use
    if not routes:
        routes = [ '10.0.0.0/24' ]
    connectToRootNS( network, switch, ip, routes )
    for host in network.hosts:
        host.cmd( cmd + ' ' + opts + '&' )
    print "*** Waiting for ssh daemons to start"
    for server in network.hosts:
        waitListening( server=server, port=22, timeout=5 )

    print
    print "*** Hosts are running sshd at the following addresses:"
    print
    for host in network.hosts:
        print host.name, host.IP()
    print
    print "*** Running NameNode and DataNode:"
    print
    i = 0
    for host in network.hosts:
        if host is Pod_host[0]:
            host.cmd( './namenode.sh start' )
            print "NN start"
        else:
            i+=1
            host.cmd( './additional_datanode.sh start ' + str(i) + ' &' )
            print "DN"+str(i)+" start"
    print
    print "*** Type 'exit' or control-D to shut down network"
    CLI( network )
    i = 0
    for host in network.hosts:
        host.cmd( 'kill %' + cmd )
        if host is Pod_host[0]:
            host.cmd( './namenode.sh stop' )
            print "NN stop"
        else:
            i+=1
            host.cmd( './additional_datanode.sh stop ' + str(i) + ' &' )
            print "DN"+str(i)+" stop"
    network.stop()
Exemple #10
0
 def debiperf(self,
              hosts=None,
              l4Type='TCP',
              udpBw='10M',
              fmt=None,
              seconds=5,
              port=5001):
     print port
     print time.time()
     """Run iperf between two hosts.
        hosts: list of hosts; if None, uses first and last hosts
        l4Type: string, one of [ TCP, UDP ]
        udpBw: bandwidth target for UDP test
        fmt: iperf format argument if any
        seconds: iperf time to transmit
        port: iperf port
        returns: two-element array of [ server, client ] speeds
        note: send() is buffered, so client rate can be much higher than
        the actual transmission rate; on an unloaded system, server
        rate should be much closer to the actual receive rate"""
     hosts = hosts or [self.hosts[0], self.hosts[-1]]
     assert len(hosts) == 2
     client, server = hosts
     output('*** Iperf: testing', l4Type, 'bandwidth between', client,
            'and', server, '\n')
     server.cmd('killall -9 iperf')
     iperfArgs = 'iperf -p %d ' % port
     bwArgs = ''
     if l4Type == 'UDP':
         iperfArgs += '-u '
         bwArgs = '-b ' + udpBw + ' '
     elif l4Type != 'TCP':
         raise Exception('Unexpected l4 type: %s' % l4Type)
     if fmt:
         iperfArgs += '-f %s ' % fmt
     server.sendCmd(iperfArgs + '-s')
     if l4Type == 'TCP':
         if not waitListening(client, server.IP(), port):
             raise Exception('Could not connect to iperf on port %d' % port)
     cliout = client.cmd(iperfArgs + '-t %d -c ' % seconds + server.IP() +
                         ' ' + bwArgs)
     debug('Client output: %s\n' % cliout)
     servout = ''
     # We want the last *b/sec from the iperf server output
     # for TCP, there are two of them because of waitListening
     count = 2 if l4Type == 'TCP' else 1
     while len(re.findall('/sec', servout)) < count:
         servout += server.monitor(timeoutms=5000)
     server.sendInt()
     servout += server.waitOutput()
     debug('Server output: %s\n' % servout)
     result = [
         self._parseIperf(servout),
         self._parseIperf(cliout),
         time.time()
     ]
     if l4Type == 'UDP':
         result.insert(0, udpBw)
     output('*** Results: %s\n' % result)
     return result
Exemple #11
0
    def iperf_one_par(self,
                      hosts=None,
                      l4Type='TCP',
                      udpBw='10M',
                      fmt=None,
                      seconds=5,
                      port=5001,
                      num_conn='',
                      par=''):
        client, server = hosts
        fn = client.name[1:] + '_' + num_conn + '.txt'
        output('Testing %s and %s using port %s\n' %
               (client.name, server.name, port))
        iperfArgs = 'iperf -p %d ' % port
        iperfArgs += par
        bwArgs = ''
        #server.cmd( iperfArgs + '-s &' )
        server.popen(iperfArgs + '-s &')
        print "server started"
        if l4Type == 'TCP':
            if not waitListening(client, server.IP(), port):
                print "Could not connect to iperf on the port"
                raise Exception('Could not connect to iperf on port %d' % port)
        #client.cmd( iperfArgs + '-t %d -c ' % seconds +
        #                     server.IP() + '  > ~/results/clients/' + fn + ' &')
        full_fn = os.path.expanduser('~/results/clients/') + fn

        fh = open(full_fn, "w")
        client.popen(iperfArgs + '-t %d -c ' % seconds + server.IP() + ' &',
                     stdout=fh)
def iperf(hosts=None, l4Type='TCP', udpBw='10M', seconds=5, port=5001):
    hosts = hosts or [hosts[0], hosts[-1]]
    assert len(hosts) == 2
    client, server = hosts
    conn1 = 0
    conn2 = 0
    if client.type == 'station' or server.type == 'station':
        if client.type == 'station':
            while conn1 == 0:
                conn1 = int(
                    client.cmd(
                        'iwconfig %s-wlan0 | grep -ic \'Link Quality\'' %
                        client))
        if server.type == 'station':
            while conn2 == 0:
                conn2 = int(
                    server.cmd(
                        'iwconfig %s-wlan0 | grep -ic \'Link Quality\'' %
                        server))
    #output( '*** Iperf: testing', l4Type, 'bandwidth between',
    #        client, 'and', server, '\n' )


#        if not conn2:
#            print "#$%^%$#@#$%^%$#@"
#        else:
    server.cmd('killall -9 iperf')
    iperfArgs = 'iperf -p %d ' % port
    bwArgs = ''
    if l4Type == 'UDP':
        iperfArgs += '-u '
        bwArgs = '-b ' + udpBw + ' '
    #elif l4Type != 'TCP':
    #    raise Exception( 'Unexpected l4 type: %s' % l4Type )
    #if fmt:
    #   iperfArgs += '-f %s ' % fmt
    server.sendCmd(iperfArgs + '-s')
    if l4Type == 'TCP':
        if not waitListening(client, server.IP(), port):
            raise Exception('Could not connect to iperf on port %d' % port)
    cliout = client.cmd(iperfArgs + '-t %d -c ' % seconds + server.IP() + ' ' +
                        bwArgs)
    #print cliout
    debug('Client output: %s\n' % cliout)
    servout = ''
    count = 2 if l4Type == 'TCP' else 1

    while len(re.findall('/sec', servout)) < count:
        servout += server.monitor(timeoutms=5000)

    server.sendInt()
    servout += server.waitOutput()
    debug('Server output: %s\n' % servout)
    result = [_parseIperf(servout), _parseIperf(cliout)]
    #if l4Type == 'UDP':
    #    result.insert( 0, udpBw )
    #output( '%s\n' % result )
    #return result[-1]
    return result[0]
Exemple #13
0
def bwtest(cpuLimits, period_us=100000, seconds=10):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo(depth=1, fanout=2)

    results = {}

    for sched in 'rt', 'cfs':
        info('*** Testing with', sched, 'bandwidth limiting\n')
        for cpu in cpuLimits:
            # cpu is the cpu fraction for all hosts, so we divide
            # it across two hosts
            host = custom(CPULimitedHost,
                          sched=sched,
                          period_us=period_us,
                          cpu=.5 * cpu)
            try:
                net = Mininet(topo=topo, host=host, waitConnected=True)
            # pylint: disable=bare-except
            except:
                info('*** Skipping scheduler %s and cleaning up\n' % sched)
                cleanup()
                break
            net.start()
            net.pingAll()
            hosts = [net.getNodeByName(h) for h in topo.hosts()]
            client, server = hosts[0], hosts[-1]
            info('*** Starting iperf with %d%% of CPU allocated to hosts\n' %
                 (100.0 * cpu))
            # We measure at the server because it doesn't include
            # the client's buffer fill rate
            popen = server.popen('iperf -yc -s -p 5001')
            waitListening(client, server, 5001)
            # ignore empty result from waitListening/telnet
            popen.stdout.readline()
            client.cmd('iperf -yc -t %s -c %s' % (seconds, server.IP()))
            result = decode(popen.stdout.readline()).split(',')
            bps = float(result[-1])
            popen.terminate()
            net.stop()
            updated = results.get(sched, [])
            updated += [(cpu, bps)]
            results[sched] = updated

    return results
Exemple #14
0
def bwtest( cpuLimits, period_us=100000, seconds=10 ):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo( depth=1, fanout=2 )

    results = {}

    for sched in 'rt', 'cfs':
        info( '*** Testing with', sched, 'bandwidth limiting\n' )
        for cpu in cpuLimits:
            # cpu is the cpu fraction for all hosts, so we divide
            # it across two hosts
            host = custom( CPULimitedHost, sched=sched,
                           period_us=period_us,
                           cpu=.5*cpu )
            try:
                net = Mininet( topo=topo, host=host )
            # pylint: disable=bare-except
            except:
                info( '*** Skipping scheduler %s and cleaning up\n' % sched )
                cleanup()
                break
            net.start()
            net.pingAll()
            hosts = [ net.getNodeByName( h ) for h in topo.hosts() ]
            client, server = hosts[ 0 ], hosts[ -1 ]
            info( '*** Starting iperf with %d%% of CPU allocated to hosts\n' %
                  ( 100.0 * cpu ) )
            # We measure at the server because it doesn't include
            # the client's buffer fill rate
            popen = server.popen( 'iperf -yc -s -p 5001' )
            waitListening( client, server, 5001 )
            # ignore empty result from waitListening/telnet
            popen.stdout.readline()
            client.cmd( 'iperf -yc -t %s -c %s' % ( seconds, server.IP() ) )
            result = decode( popen.stdout.readline() ).split( ',' )
            bps = float( result[ -1 ] )
            popen.terminate()
            net.stop()
            updated = results.get( sched, [] )
            updated += [ ( cpu, bps ) ]
            results[ sched ] = updated

    return results
Exemple #15
0
    def iperf(self,
              hosts=None,
              l4Type='TCP',
              udpBw='10M',
              seconds=5,
              port=5001):
        #t_begin = time.time()
        hosts = hosts or [hosts[0], hosts[-1]]
        assert len(hosts) == 2
        client, server = hosts
        conn1 = 0
        conn2 = 0
        if client.type == 'station' or server.type == 'station':
            if client.type == 'station':
                while conn1 == 0:
                    conn1 = int(
                        client.cmd(
                            'iwconfig %s-wlan0 | grep -ic \'Link Quality\'' %
                            client))
            if server.type == 'station':
                while conn2 == 0:
                    conn2 = int(
                        server.cmd(
                            'iwconfig %s-wlan0 | grep -ic \'Link Quality\'' %
                            server))

        server.cmd('killall -9 iperf')
        iperfArgs = 'iperf -p %d ' % port
        bwArgs = ''
        if l4Type == 'UDP':
            iperfArgs += '-u '
            bwArgs = '-b ' + udpBw + ' '
        server.sendCmd(iperfArgs + '-s')
        if l4Type == 'TCP':
            if not waitListening(client, server.IP(), port):
                raise Exception('Could not connect to iperf on port %d' % port)
        cliout = client.cmd(iperfArgs + '-t %d -c ' % seconds + server.IP() +
                            ' ' + bwArgs)
        debug('Client output: %s\n' % cliout)
        servout = ''
        count = 2 if l4Type == 'TCP' else 1
        while len(re.findall('/sec', servout)) < count:
            servout += server.monitor(timeoutms=5000)
        server.sendInt()
        servout += server.waitOutput()
        debug('Server output: %s\n' % servout)
        result = [self._parseIperf(servout), self._parseIperf(cliout)]
        if 'Mbit' in result[0]:
            result_new = re.findall(r'([\d\.]+\w)', result[0])[0]
        else:
            result_new = float(re.findall(r'([\d\.]+\w)',
                                          result[0])[0]) / 1024.0

        return result_new
Exemple #16
0
def sshd(network,
         cmd="/usr/sbin/sshd",
         opts="-D",
         ip="10.99.99.1/32",
         routes=None,
         switch=None):
    """Start a network, connect it to root ns, and run sshd on all hosts.
       ip: root-eth0 IP address in root namespace (10.123.123.1/32)
       routes: Mininet host networks to route to (10.0/24)
       switch: Mininet switch to connect to root namespace (s1)"""
    connectToRootNS(network, switch, ip, routes)
    for host in network.hosts:
        host.cmd(cmd + " " + opts + "&")
    info("*** Waiting for ssh daemons to start\n")
    for server in network.hosts:
        if server.name is not "f1":
            waitListening(server=server, port=22, timeout=5)
    info("\n*** Hosts are running sshd at the following addresses:\n")
    for host in network.hosts:
        if host.name is not "f1":
            info(host.name, host.IP(), "\n")
Exemple #17
0
def myiperf(self, hosts=None, l4Type='TCP', udpBw='10M', fmt=None,
          seconds=2, port=5001):
    """Run iperf between two hosts.
       hosts: list of hosts; if None, uses first and last hosts
       l4Type: string, one of [ TCP, UDP ]
       udpBw: bandwidth target for UDP test
       fmt: iperf format argument if any
       seconds: iperf time to transmit
       port: iperf port
       returns: two-element array of [ server, client ] speeds
       note: send() is buffered, so client rate can be much higher than
       the actual transmission rate; on an unloaded system, server
       rate should be much closer to the actual receive rate"""


    hosts = hosts or [self.hosts[0], self.hosts[-1]]
    assert len(hosts) == 2
    client, server = hosts
    output('*** Iperf: testing', l4Type, 'bandwidth between',
           client, 'and', server, '\n')
    server.cmd('killall -9 iperf')
    iperfArgs = 'iperf3 -p %d ' % port
    bwArgs = ''
    if l4Type == 'UDP':
        iperfArgs += '-u '
        bwArgs = '-b ' + udpBw + ' '
    elif l4Type != 'TCP':
        raise Exception('Unexpected l4 type: %s' % l4Type)
    if fmt:
        iperfArgs += '-f %s ' % fmt
    server.sendCmd(iperfArgs + '-s')
    if l4Type == 'TCP':
        if not waitListening(client, server.IP(), port):
            raise Exception('Could not connect to iperf on port %d'
                            % port)
    time1 = time.time()
    ttt=2
    for coun in range(3):
        cliout = client.cmd(iperfArgs + '-P 20 -l 42 -n %d -c ' % ttt +
                        server.IP() + ' ' + bwArgs)
#        time.sleep(.01)
    time2 = time.time()
    output('this took %0.3f ms \n' % ( (time2 - time1) * 1000.0))

    debug('Client output: %s\n' % cliout)
    server.sendInt()
    servout = server.waitOutput()
    debug('Server output: %s\n' % servout)
    result = [self._parseIperf(servout), self._parseIperf(cliout)]
    if l4Type == 'UDP':
        result.insert(0, udpBw)
    output('*** Results: %s\n' % result)
    return result
Exemple #18
0
 def waitStarted( self ):
     "Wait until we've really started"
     info( '(checking: karaf' )
     while True:
         status = self.ucmd( 'karaf status' ).lower()
         if 'running' in status and 'not running' not in status:
             break
         info( '.' )
         time.sleep( 1 )
     info( ' ssh-port' )
     waitListening( server=self, port=KarafPort )
     info( ' openflow-port' )
     waitListening( server=self, port=OpenFlowPort )
     info( ' client' )
     while True:
         result = quietRun( 'echo apps -a | %s -h %s' %
                            ( self.client, self.IP() ), shell=True )
         if 'openflow' in result:
             break
         info( '.' )
         time.sleep( 1 )
     info( ')\n' )
Exemple #19
0
 def start_sshd(self, net, net_name, multi_count=1):
     # do not detach, but run in background (so it will get killed when
     # container stops)
     hosts = NETWORKS[net_name]
     for host_name in hosts:
         options = HOSTS[host_name]
         if options.get("type") is None:
             if options.get("multi", False):
                 for i in range(multi_count):
                     host_name_i = host_name + "-" + str(i + 1)
                     host = net[host_name_i]
                     host.cmd("/usr/sbin/sshd -D -o UseDNS=no -u0 &")
                     debug("Starting SSHD on host")
                     waitListening(client=host,
                                   server=host,
                                   port=22,
                                   timeout=5)
             else:
                 host = net[host_name]
                 host.cmd("/usr/sbin/sshd -D -o UseDNS=no -u0 &")
                 debug("Starting SSHD on host")
                 waitListening(client=host, server=host, port=22, timeout=5)
Exemple #20
0
 def waitStarted(self):
     "Wait until we've really started"
     info('(checking: karaf')
     while True:
         status = self.ucmd('karaf status').lower()
         if 'running' in status and 'not running' not in status:
             break
         info('.')
         time.sleep(1)
     info(' ssh-port')
     waitListening(server=self, port=KarafPort)
     info(' openflow-port')
     waitListening(server=self, port=OpenFlowPort)
     info(' client')
     while True:
         result = quietRun('echo apps -a | %s -h %s' %
                           (self.client, self.IP()),
                           shell=True)
         if 'openflow' in result:
             break
         info('.')
         time.sleep(1)
     info(')\n')
Exemple #21
0
 def iperf( self, hosts=None, l4Type='TCP', udpBw='10M', fmt=None,
            seconds=5, port=5001):
     """Run iperf between two hosts.
        hosts: list of hosts; if None, uses first and last hosts
        l4Type: string, one of [ TCP, UDP ]
        udpBw: bandwidth target for UDP test
        fmt: iperf format argument if any
        seconds: iperf time to transmit
        port: iperf port
        returns: two-element array of [ server, client ] speeds
        note: send() is buffered, so client rate can be much higher than
        the actual transmission rate; on an unloaded system, server
        rate should be much closer to the actual receive rate"""
     hosts = hosts or [ self.hosts[ 0 ], self.hosts[ -1 ] ]
     assert len( hosts ) == 2
     client, server = hosts
     output( '*** Iperf: testing', l4Type, 'bandwidth between',
             client, 'and', server, '\n' )
     server.cmd( 'killall -9 iperf' )
     iperfArgs = 'iperf -p %d ' % port
     bwArgs = ''
     if l4Type == 'UDP':
         iperfArgs += '-u '
         bwArgs = '-b ' + udpBw + ' '
     elif l4Type != 'TCP':
         raise Exception( 'Unexpected l4 type: %s' % l4Type )
     if fmt:
         iperfArgs += '-f %s ' % fmt
     server.sendCmd( iperfArgs + '-s' )
     if l4Type == 'TCP':
         if not waitListening( client, server.IP(), port ):
             raise Exception( 'Could not connect to iperf on port %d'
                              % port )
     cliout = client.cmd( iperfArgs + '-t %d -c ' % seconds +
                          server.IP() + ' ' + bwArgs )
     debug( 'Client output: %s\n' % cliout )
     servout = ''
     # We want the last *b/sec from the iperf server output
     # for TCP, there are two fo them because of waitListening
     count = 2 if l4Type == 'TCP' else 1
     while len( re.findall( '/sec', servout ) ) < count:
         servout += server.monitor( timeoutms=5000 )
     server.sendInt()
     servout += server.waitOutput()
     debug( 'Server output: %s\n' % servout )
     result = [ self._parseIperf( servout ), self._parseIperf( cliout ) ]
     if l4Type == 'UDP':
         result.insert( 0, udpBw )
     output( '*** Results: %s\n' % result )
     return result
Exemple #22
0
def sshd( network, cmd='/usr/sbin/sshd', opts='-D -o UseDNS=no -u0 -f /var/lib/qcrypt/sshd_config',
          ip='10.123.123.1/32', routes=None, switch=None ,host=''):
    """Start a network, connect it to root ns, and run sshd on all hosts.
       ip: root-eth0 IP address in root namespace (10.123.123.1/32)
       routes: Mininet host networks to route to (10.0/24)
       switch: Mininet switch to connect to root namespace (s1)"""
    if not switch:
        switch = network[ 's1' ]  # switch to use
    if not routes:
        routes = [ '10.0.0.0/24' ]
    connectToRootNS( network, switch, ip, routes ,host)
    for host in network.hosts:
        host.cmd( cmd + ' ' + opts + '&' )
    print( "*** Waiting for ssh daemons to start" )
    for server in network.hosts:
        waitListening( server=server, port=22, timeout=5 )

    print()
    print( "*** Hosts are running sshd at the following addresses:" )
    print()
    for host in network.hosts:
        print( host.name, host.IP() )
    print()
Exemple #23
0
def sshd( network, cmd='/usr/sbin/sshd', opts='-D',
          ip='10.123.123.1/32', routes=None, switch=None ):
    if not switch:
        switch = network[ 's1' ]  # switch to use
    if not routes:
        routes = [ '10.0.0.0/24' ]
    connectToRootNS( network, switch, ip, routes )
    for host in network.hosts:
        host.cmd( cmd + ' ' + opts + '&' )
    print "*** Waiting for ssh daemons to start"
    for server in network.hosts:
        waitListening( server=server, port=22, timeout=5 )

    print
    print "*** Hosts are running sshd at the following addresses:"
    print
    for host in network.hosts:
        print host.name, host.IP()
    print
    print "*** Type 'exit' or control-D to shut down network"
    CLI( network )
    for host in network.hosts:
        host.cmd( 'kill %' + cmd )
    network.stop()
Exemple #24
0
 def iperf(self, hosts=None, l4Type="TCP", udpBw="10M", fmt=None, seconds=5, port=5001):
     """Run iperf between two hosts.
        hosts: list of hosts; if None, uses first and last hosts
        l4Type: string, one of [ TCP, UDP ]
        udpBw: bandwidth target for UDP test
        fmt: iperf format argument if any
        seconds: iperf time to transmit
        port: iperf port
        returns: two-element array of [ server, client ] speeds
        note: send() is buffered, so client rate can be much higher than
        the actual transmission rate; on an unloaded system, server
        rate should be much closer to the actual receive rate"""
     hosts = hosts or [self.hosts[0], self.hosts[-1]]
     assert len(hosts) == 2
     client, server = hosts
     output("*** Iperf: testing", l4Type, "bandwidth between", client, "and", server, "\n")
     server.cmd("killall -9 iperf")
     iperfArgs = "iperf -p %d " % port
     bwArgs = ""
     if l4Type == "UDP":
         iperfArgs += "-u "
         bwArgs = "-b " + udpBw + " "
     elif l4Type != "TCP":
         raise Exception("Unexpected l4 type: %s" % l4Type)
     if fmt:
         iperfArgs += "-f %s " % fmt
     server.sendCmd(iperfArgs + "-s")
     if l4Type == "TCP":
         if not waitListening(client, server.IP(), port):
             raise Exception("Could not connect to iperf on port %d" % port)
     cliout = client.cmd(iperfArgs + "-t %d -c " % seconds + server.IP() + " " + bwArgs)
     debug("Client output: %s\n" % cliout)
     servout = ""
     # We want the last *b/sec from the iperf server output
     # for TCP, there are two fo them because of waitListening
     count = 2 if l4Type == "TCP" else 1
     while len(re.findall("/sec", servout)) < count:
         servout += server.monitor(timeoutms=5000)
     server.sendInt()
     servout += server.waitOutput()
     debug("Server output: %s\n" % servout)
     result = [self._parseIperf(servout), self._parseIperf(cliout)]
     if l4Type == "UDP":
         result.insert(0, udpBw)
     output("*** Results: %s\n" % result)
     return result
Exemple #25
0
    def iperf_set_servers(self,
                          hosts=None,
                          seconds=5,
                          port=5001,
                          num_conn='',
                          par=''):
        client, server = hosts
        client, server = hosts
        fn = client.name[1:] + '_' + num_conn + '.txt'
        output('Setting up server %s using port %s\n' % (server.name, port))
        iperfArgs = 'iperf -p %d ' % port
        iperfArgs += par
        bwArgs = ''
        #server.cmd( iperfArgs + '-s &' )
        server.popen(iperfArgs + '-s &')
        if not waitListening(client, server.IP(), port):
            print "Could not connect to iperf on the port"
            raise Exception('Could not connect to iperf on port %d' % port)

        print "server started"
Exemple #26
0
 def iperfWithoutInfo(self,
                      hosts=None,
                      l4Type='TCP',
                      udpBw='10M',
                      fmt=None,
                      seconds=5,
                      port=5001):
     hosts = hosts or [self.hosts[0], self.hosts[-1]]
     assert len(hosts) == 2
     client, server = hosts
     server.cmd('killall -9 iperf')
     iperfArgs = 'iperf -p %d ' % port
     bwArgs = ''
     if l4Type == 'UDP':
         iperfArgs += '-u '
         bwArgs = '-b ' + udpBw + ' '
     elif l4Type != 'TCP':
         raise Exception('Unexpected l4 type: %s' % l4Type)
     if fmt:
         iperfArgs += '-f %s ' % fmt
     server.sendCmd(iperfArgs + '-s')
     if l4Type == 'TCP':
         if not waitListening(client, server.IP(), port):
             raise Exception('Could not connect to iperf on port %d' % port)
     cliout = client.cmd(iperfArgs + '-t %d -c ' % seconds + server.IP() +
                         ' ' + bwArgs)
     debug('Client output: %s\n' % cliout)
     servout = ''
     # We want the last *b/sec from the iperf server output
     # for TCP, there are two of them because of waitListening
     count = 2 if l4Type == 'TCP' else 1
     while len(re.findall('/sec', servout)) < count:
         servout += server.monitor(timeoutms=5000)
     server.sendInt()
     servout += server.waitOutput()
     debug('Server output: %s\n' % servout)
     result = [self._parseIperf(servout), self._parseIperf(cliout)]
     if l4Type == 'UDP':
         result.insert(0, udpBw)
     return result
 def iperfTestConnection(self, server, client, l4Type='TCP', port=5001):
     if l4Type == 'TCP':
         return waitListening(client, server.IP(), port)
     return True
    def iperf(self, hosts=None, l4Type='TCP', udpBw='10M', fmt=None,
              seconds=5, port=5001, cong='cubic'):
        """Run iperf between two hosts.
           hosts: list of hosts; if None, uses first and last hosts
           l4Type: string, one of [ TCP, UDP ]
           udpBw: bandwidth target for UDP test
           fmt: iperf format argument if any
           seconds: iperf time to transmit
           port: iperf port
           returns: two-element array of [ server, client ] speeds
           note: send() is buffered, so client rate can be much higher than
           the actual transmission rate; on an unloaded system, server
           rate should be much closer to the actual receive rate"""
        hosts = hosts or [self.hosts[0], self.hosts[-1]]
        # CONFIG_TCP_CONG_BIC = m
        # CONFIG_TCP_CONG_CUBIC = y
        # CONFIG_TCP_CONG_WESTWOOD = m
        # CONFIG_TCP_CONG_HTCP = m
        # CONFIG_TCP_CONG_HSTCP = m
        # CONFIG_TCP_CONG_HYBLA = m
        # CONFIG_TCP_CONG_VEGAS = m
        # CONFIG_TCP_CONG_NV = m
        # CONFIG_TCP_CONG_SCALABLE = m
        # CONFIG_TCP_CONG_LP = m
        # CONFIG_TCP_CONG_VENO = m
        # CONFIG_TCP_CONG_YEAH = m
        # CONFIG_TCP_CONG_ILLINOIS = m
        # CONFIG_TCP_CONG_DCTCP = m
        # CONFIG_TCP_CONG_CDG = m
        # CONFIG_TCP_CONG_BBR = m
        # congModes = ['CUBIC', 'BIC', 'BBR', 'WESTWOOD', 'HTCP', 'HSTCP', 'HYBLA', 'VEGAS', 'NV', 'SCALABLE', 'LP', 'VENO', 'YEAH', 'ILLINOIS', 'DCTCP', 'CDR']
        assert len(hosts) == 2
        assert cong in self.congModes
        if cong == "hstcp":
            cong = "highspeed"

        client, server = hosts
        output('*** Iperf: testing', l4Type, 'bandwidth between',
               client, 'and', server, '\n')
        iperfArgs = 'iperf -m -p %d ' % port
        bwArgs = ''
        if l4Type == 'UDP':
            iperfArgs += '-u '
            bwArgs = '-b ' + udpBw + ' '
        elif l4Type != 'TCP':
            raise Exception('Unexpected l4 type: %s' % l4Type)
        if fmt:
            iperfArgs += '-f %s ' % fmt
        server.sendCmd(iperfArgs + '-s')
        if l4Type == 'TCP':
            if not waitListening(client, server.IP(), port):
                raise Exception('Could not connect to iperf on port %d'
                                % port)
        cliout = client.cmd(iperfArgs + '-t %d -c ' % seconds +
                            server.IP() + ' ' + bwArgs + ' -Z %s' % cong)
        debug('Client output: %s\n' % cliout)
        servout = ''
        # We want the last *b/sec from the iperf server output
        # for TCP, there are two of them because of waitListening
        count = 2 if l4Type == 'TCP' else 1
        while len(re.findall('/sec', servout)) < count:
            servout += server.monitor(timeoutms=5000)
        server.sendInt()
        servout += server.waitOutput()
        debug('Server output: %s\n' % servout)
        result = [self._parseIperf(servout), self._parseIperf(cliout)]
        if l4Type == 'UDP':
            result.insert(0, udpBw)
        output('*** Results: %s\n' % result)
        return result
Exemple #29
0
root = Host('root', inNamespace=False)

print("*** Creating links")
h1.linkTo(root)

print(h1)

print("*** Configuring nodes")
h1.setIP('10.0.0.1', 8)
root.setIP('10.0.0.2', 8)

print("*** Creating banner file")
f = open('/tmp/%s.banner' % h1.name, 'w')
f.write('Welcome to %s at %s\n' % (h1.name, h1.IP()))
f.close()

print("*** Running sshd")
cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
# add arguments from the command line
if len(sys.argv) > 1:
    cmd += ' ' + ' '.join(sys.argv[1:])
h1.cmd(cmd)
listening = waitListening(server=h1, port=22, timeout=timeout)

if listening:
    print("*** You may now ssh into", h1.name, "at", h1.IP())
else:
    print("*** Warning: after %s seconds, %s is not listening on port 22" %
          (timeout, h1.name))
root = Host( 'root', inNamespace=False )

print( "*** Creating links" )
h1.linkTo( root )

print( h1 )

print( "*** Configuring nodes" )
h1.setIP( '10.0.0.1', 8 )
root.setIP( '10.0.0.2', 8 )

print( "*** Creating banner file" )
f = open( '/tmp/%s.banner' % h1.name, 'w' )
f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
f.close()

print( "*** Running sshd" )
cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
# add arguments from the command line
if len( sys.argv ) > 1:
    cmd += ' ' + ' '.join( sys.argv[ 1: ] )
h1.cmd( cmd )
listening = waitListening( server=h1, port=22, timeout=timeout )

if listening:
    print( "*** You may now ssh into", h1.name, "at", h1.IP() )
else:
    print( "*** Warning: after %s seconds, %s is not listening on port 22"
            % ( timeout, h1.name ) )
Exemple #31
0
def Run(network,
        cmd='/usr/sbin/sshd',
        opts='-D',
        ip='10.123.123.1/32',
        routes=None,
        switch=None):
    """Start a network, connect it to root ns, and run sshd on all hosts.
       ip: root-eth0 IP address in root namespace (10.123.123.1/32)
       routes: Mininet host networks to route to (10.0/24)
       switch: Mininet switch to connect to root namespace (s1)"""
    if not switch:
        switch = network['s1']  # switch to use
    if not routes:
        routes = ['10.0.0.0/24']
    connectToRootNS(network, switch, ip, routes)
    for host in network.hosts:
        host.cmd(cmd + ' ' + opts + '&')
    info("*** Waiting for ssh daemons to start\n")
    for server in network.hosts:
        waitListening(server=server, port=22, timeout=5)

    info("\n*** Hosts are running sshd at the following addresses:\n")
    for host in network.hosts:
        info(host.name, host.IP(), '\n')

    ####################
    ####################
    ####################
    # Get nodes
    s1 = net.get('s1')
    h1 = net.get('h1')
    h2 = net.get('h2')

    # Iniciar controlador
    info('*** Iniciando ryu...')
    try:
        info('por ahora no ejecutamos ryu aca...')
        #os.system('ryu-manager  ryu.app.qos_simple_switch_13_CAC ryu.app.qos_simple_switch_rest_13_CAC ryu.app.rest_conf_switch ryu.app.rest_qos &')
    except ValueError:
        info('Error...')

    sleep(2)

    # Configurar protocolo y manager
    info('*** Configurando OpenFlow13 en s1')
    s1.cmd('ovs-vsctl set Bridge s1 protocols=OpenFlow13')
    info('*** Configurando OVSDB port')
    s1.cmd('ovs-vsctl set-manager ptcp:6632')

    # Configurar QoS
    info('*** Configurando QoS...')
    try:
        qosSetup(1)
        sleep(2)
    except ValueError:
        print('Error....')

    #wireshark
    h1.cmdPrint('wireshark &')
    sleep(5)

    # Ejecutamos pruebas
    iperfTest(h1, h2)
    qosSetup(2)
    iperfTest(h1, h2)
    qosSetup(1)
    iperfTest(h1, h2)
    #aca continuar con pruebas con mas escenarios
    ####################
    ####################
    ####################

    info("\n*** Type 'exit' or control-D to shut down network\n")
    CLI(network)
    for host in network.hosts:
        host.cmd('kill %' + cmd)
    network.stop()

    # Destruir qos y colas
    info('*** Delete qos and queues in s1...')
    s1.cmdPrint('ovs-vsctl --all destroy QoS')
    s1.cmdPrint('ovs-vsctl --all destroy queue')
    sleep(2)
Exemple #32
0
    def myiperf(self, hosts=None, iterations=10, seconds=1, port=5001):
        client = []
        server = []
        a = server
        port = []
        r = r'([\d\.]+ \w+/sec)'
        """Run iperf between two hosts.
           hosts: list of hosts; if None, uses first and last hosts
           l4Type: string, one of [ TCP, UDP ]
           udpBw: bandwidth target for UDP test
           fmt: iperf format argument if any
           seconds: iperf time to transmit
           port: iperf port
           returns: two-element array of [ server, client ] speeds
           note: send() is buffered, so client rate can be much higher than
           the actual transmission rate; on an unloaded system, server
           rate should be much closer to the actual receive rate"""
        print "hello"
        hosts = hosts or [self.hosts]

        for n in range(len(self.hosts) / 2):
            client.append(self.hosts[2 * (n)])
            server.append(self.hosts[2 * (n) + 1])
            port.append(5001)

        for i in range(len(server)):
            iperfArgs = 'iperf -p %d ' % port[i]
            server[i].sendCmd(iperfArgs + '-s -D')

        for l in range(iterations):

            a = server[:]
            b = port[:]
            for i in range(len(client)):
                print time.time()
                start_time = time.time()
                x = random.randint(0, len(a) - 1)
                print x
                bwArgs = ''
                output('*** Iperf: testing', 'bandwidth between', client[i],
                       'and', a[x], '\n')

                if not waitListening(client[i], a[x].IP(), b[x], 20):
                    raise Exception('Could not connect to iperf on port %d' %
                                    b[x])

                cliout = client[i].cmd('iperf -p %d ' % b[x] +
                                       ' -t %d -c ' % seconds + a[x].IP() +
                                       ' ' + bwArgs)

                debug('Client output: %s\n' % cliout)
                servout = ''
                # We want the last *b/sec from the iperf server output
                # for TCP, there are two of them because of waitListening
                count = 2

                while len(re.findall('/sec', servout)) < count:
                    servout += a[x].monitor(timeoutms=1000)
                print servout
                print cliout
                a[x].sendInt()
                servout = a[x].waitOutput()
                debug('Server output: %s\n' % servout)
                m1 = re.findall(r, servout)
                m2 = re.findall(r, cliout)
                if m1:
                    print "lololo"
                if m2:
                    print "lalala"
                "result = [ m1[-1], m2[-1], time.time() ]"
                print time.time()
                result = time.time() - start_time
                output('*** Results: %s\n' % result)
                print a
                print a[x]
                print b
                print b[x]
                del a[x]
                del b[x]
                print a
                print b
        return result
 def ownTestConnection(self, server, client):
     return waitListening(client, server.IP(), 5001)
Exemple #34
0
def closTest(duration, discovery_time):
    """Test the controller performance on a Clos-like topology.

    Args:
        discovery_time: how long to wait for controller topology discovery in
                        seconds
    """
    # If you modify the topology on next line, you will also likely want to
    # modify the tests done below
    topo = ClosTopo(nCore=2, nEdge=3, nHosts=4, bw=10)
    net = Mininet(topo=topo, switch=OVSKernelSwitch,
                  controller=RemoteController, autoSetMacs=True,
                  autoStaticArp=True, waitConnected=True,
                  link=TCLink)
    net.start()

    info("*** Waiting for controller topology discovery\n")
    for i in range(discovery_time, -1, -1):
        info("\r{:02d}".format(i))
        time.sleep(1)
    info('\n')

    h1, h2, h3, h4 = net.getNodeByName('h1', 'h2', 'h3', 'h4')
    clients = [h1, h2, h3, h4]
    h5, h7, h10, h12 = net.getNodeByName('h5', 'h7', 'h10', 'h12')
    servers = [h5, h10, h7, h12]
    clientServerPairs = zip(clients, servers)

    info("*** Testing basic connectivity\n")
    for (c, s) in clientServerPairs:
        net.ping([c, s])

    info("*** Starting servers\n")
    for s in servers:
        s.sendCmd('iperf -p 5001 -s')

    info("*** Waiting for servers to start\n")

    def abortOnFail(client, server):
        error("\nCannot join server {} from client {}!\nAborting..."
              .format(server, client))
        for s in servers:
            if s.waiting:
                s.sendInt()
                s.waitOutput()
        net.stop()
        exit(1)

    for (c, s) in clientServerPairs:
        if not waitListening(client=c, server=s, port=5001, timeout=5):
            abortOnFail(c, s)
        info('.')
    info('\n')

    info("*** Starting clients\n")
    big = "/home/mininet/clos-test/client.py {} 2 {} 4 3"
    small = "/home/mininet/clos-test/client.py {} 2 {} 1 0"
    h1.sendCmd(big.format("10.0.0.5", duration))
    h2.sendCmd(big.format("10.0.0.10", duration))
    h3.sendCmd(small.format("10.0.0.7", duration))
    h4.sendCmd(small.format("10.0.0.12", duration))

    info("*** Measuring\n")
    for i in range(duration + 5, -1, -1):
        info("\r{:03d}".format(i))
        time.sleep(1)
    info('\n')

    info("*** Waiting for clients to finish\n")
    results = {}
    for c in clients:
        results[c] = c.waitOutput()
        info('.')
    info('\n')

    info("*** Stopping servers\n")
    for s in servers:
        s.sendInt()
        s.waitOutput()

    info("*** Measured bandwidths\n")
    for (c, out) in results.items():
        info("{}: {}".format(c, out))

    net.stop()
Exemple #35
0
    def run_iperf(self,
                  hosts=None,
                  l4Type='TCP',
                  udpBw='10M',
                  fmt=None,
                  seconds=5,
                  port=5001,
                  args='',
                  net=None):
        """
        This is an copy of the Mininet.net.Mininet.iperf(...) function,
        with addition to add some custom args to the connection command

        This code belongs to Mininet, and has only been adapted to work for this
        use case

        Parameters
        ----------
        hosts : type
            Description of parameter `hosts`.
        l4Type : type
            Description of parameter `l4Type`.
        udpBw : type
            Description of parameter `udpBw`.
        fmt : type
            Description of parameter `fmt`.
        seconds : type
            Description of parameter `seconds`.
        port : type
            Description of parameter `port`.
        args : type
            Description of parameter `args`.
        net : type
            Description of parameter `net`.

        Returns
        -------
        type
            Description of returned object.

        """
        '''
        This is an copy of the Mininet.net.Mininet.iperf(...) function,
        with addition to add some custom args to the connection command
        '''
        hosts = hosts or [net.hosts[0], net.hosts[-1]]
        assert len(hosts) == 2
        client, server = hosts

        server.cmd('killall -9 iperf')
        iperfArgs = 'iperf -p %d ' % port
        bwArgs = ''
        if l4Type == 'UDP':
            iperfArgs += '-u '
            bwArgs = '-b ' + udpBw + ' '
        elif l4Type != 'TCP':
            print('Unexpected l4 type: %s' % l4Type)
        if fmt:
            iperfArgs += '-f %s ' % fmt
        server.sendCmd(iperfArgs + '-s')
        if l4Type == 'TCP':
            if not waitListening(client, server.IP(), port):
                print('Could not connect to iperf on port %d' % port)
        cliout = client.cmd(iperfArgs + '-t %d -c ' % seconds + server.IP() +
                            ' ' + bwArgs + ' ' + args)

        servout = ''
        # We want the last *b/sec from the iperf server output
        # for TCP, there are two of them because of waitListening
        count = 2 if l4Type == 'TCP' else 1
        while len(re.findall('/sec', servout)) < count:
            servout += server.monitor(timeoutms=5000)
        server.sendInt()
        servout += server.waitOutput()

        result = [net._parseIperf(servout), net._parseIperf(cliout)]
        if l4Type == 'UDP':
            result.insert(0, udpBw)

        return result
Exemple #36
0
        network.stop()
        print('Broker not found')
        sys.exit(0)

    info('*** Waiting for broker to start\n')

    if options.relay:
        broker.cmd(
            'python3 -u "{}/application.py" broker -r {} 5555 &> "{}/{}.log" &'
            .format(path, broker.IP(), path, broker.name))
    else:
        broker.cmd(
            'python3 -u "{}/application.py" broker {} 5555 &> "{}/{}.log" &'.
            format(path, broker.IP(), path, broker.name))

    waitListening(server=broker.IP(), port=5555, timeout=5)

    info('\n')

    for host in network.hosts:
        if host.name in options.publishers:
            if options.relay:
                host.cmd(
                    'python3 -u "{}/application.py" publisher -r -d {} -t {} {} 5555 &> "{}/{}.log" &'
                    .format(path, options.delay, options.topics, broker.IP(),
                            path, host.name))
            else:
                host.cmd(
                    'python3 -u "{}/application.py" publisher -d {} -t {} {} 5555 &> "{}/{}.log" &'
                    .format(path, options.delay, options.topics, broker.IP(),
                            path, host.name))
Exemple #37
0
def enableSSH(node, extraOpts='', wait_listen_ip=None):
    node.cmd('/usr/sbin/sshd -D -o UseDNS=no %s -u0 &' % extraOpts)
    if not wait_listen_ip:
        waitListening(server=node, port=22, timeout=5)
    else:
        waitListening(server=wait_listen_ip, port=22, timeout=5)
Exemple #38
0
    options = parse_args()

    network = start_network()

    zookeeper = get_zookeeper(network)

    if zookeeper is None:
        network.stop()
        print('Zookeeper not found')
        sys.exit(0)

    info('*** Waiting for zookeeper to start\n')

    zookeeper.cmd('/opt/zookeeper/bin/zkServer.sh start')

    waitListening(server=zookeeper.IP(), port=2181, timeout=5)

    info('\n')

    zookeeper.cmd('/opt/zookeeper/bin/zkCli.sh deleteall /brokers')
    zookeeper.cmd('/opt/zookeeper/bin/zkCli.sh create /brokers')

    info('*** Starting brokers\n')

    for host in network.hosts:
        if host.name in options.brokers:
            if options.relay:
                host.cmd('python3 -u "{}/application.py" broker -r {} 2181 &> "{}/{}.log" &'.format(path, zookeeper.IP(), path, host.name))
            else:
                host.cmd('python3 -u "{}/application.py" broker {} 2181 &> "{}/{}.log" &'.format(path, zookeeper.IP(), path, host.name))