Ejemplo n.º 1
0
def network_start_dataplane(ryu_app_path):
    """Manually start the OpenFlow control-plane session between the
    controller (c0) and the data-plane switch (dps1).

    :param ryu_app_path: Path to a Ryu application to be run.
    """
    # Get the configuration details of the nodes
    mgmts1_conf, dps1_conf, c0_conf, h1_conf, h2_conf = \
        get_node_configs()

    # Start a Ryu application on c0.
    cmd = "ryu-manager --verbose --ofp-tcp-listen-port %d %s &" % (
        c0_conf["of_port"], ryu_app_path)
    c0 = _NETWORK.getNodeByName(c0_conf["name"])
    lg.info("*** Starting Ryu application %s on %s\n" %
            (ryu_app_path, c0_conf["name"]))
    c0.cmd(cmd)

    # Manually configure dps1 to connect to c0.
    c0_ip = c0_conf["cp_ip"].split("/")[0]  # Need to strip the mask
    cmd = "ovs-vsctl set-controller %s tcp:%s:%d" % (dps1_conf["name"], c0_ip,
                                                     c0_conf["of_port"])
    dps1 = _NETWORK.getNodeByName(dps1_conf["name"])
    lg.info("*** Manually starting the OF control-plane session "
            "between %s and %s\n" % (c0_conf["name"], dps1_conf["name"]))
    dps1.cmd(cmd)
Ejemplo n.º 2
0
def setup(args):
    """Enable MPTCP if true, disable if false"""
    if (args.mptcp):
        lg.info("Enable MPTCP\n")
        sysctl_set('net.mptcp.mptcp_enabled', 1)
        lg.info("setting MPTCP path manager to full mesh %s\n")
        sysctl_set('net.mptcp.mptcp_path_manager', 'fullmesh')
Ejemplo n.º 3
0
def runIperf(net, args):
    recvr = net.getNodeByName('receiver')
    sender = net.getNodeByName('sender')
    recvr.cmd('iperf3 -s > %s/receiver.txt &' % args.dir)
    # Wait iperf3 server get start
    sleep(0.1)
    sender.sendCmd('iperf3 -c 10.0.0.4 -t %d -i 1' % (args.time))
    s1 = net.getNodeByName('s1')
    s2 = net.getNodeByName('s2')
    for i in xrange(0):
        # Turn off and turn on links
        sleep(5)
        #recvr.cmd('ifconfig receiver-eth0 down')
        #s1.cmd('tc qdisc change dev s1-eth1 parent 5:1 netem rate 10Mbit')
        s1.cmd('ifconfig s1-eth1 down')
        sleep(5)
        s1.cmd('ifconfig s1-eth1 up')
    #sleep(5)
    #s1.cmd('tc qdisc change dev s1-eth1 parent 5:1 netem rate 5Mbit')
    #sleep(5)
    #s1.cmd('tc qdisc change dev s1-eth1 parent 5:1 netem rate 150Mbit')
    # Wait for outputs and finish
    progress(args.time)

    snd_out = sender.waitOutput()
    lg.info("Sender output:\n%s\n" % snd_out)
    with open("%s/sender.txt" % args.dir, "w") as f:
        f.write(snd_out)
    sleep(0.1)  # hack to wait for iperf sender output.
    lg.info("Killing iperf\n")
    recvr.cmd('pkill iperf')
Ejemplo n.º 4
0
def set_optimizations_enabled(enabled):
    """Enable MPTCP optimizations if true, disable if false"""
    e = 1 if enabled else 0
    lg.info("setting MPTCP opts to %s\n" % e)
    sysctl_set('net.mptcp.mptcp_rbuf_opti', e)
    sysctl_set('net.mptcp.mptcp_rbuf_penal', e)
    sysctl_set('net.mptcp.mptcp_rbuf_retr', e)
Ejemplo n.º 5
0
def set_TC(args,net):
    ct_name=args.names.client[0]
    sv_name=args.names.server[0]
    client = net.getNodeByName(args.names.client[0])
    server = net.getNodeByName(args.names.server[0])

    eth_dev= "-eth1" 
    ct_dev=[]
    for i in range(args.n):
        eth_dev= '-eth%i' %(i)
        ct_dev.append(ct_name + eth_dev)
        print(ct_dev[i])

    lg.info("****************************  set tc ****************************\n")
    print "arg:"
    print args.arg1
    lg.info('%s\n' %ct_dev)
    for i in range(args.n):
        client.cmdPrint('tc qdisc del dev %s root' %ct_dev[i])

    client.cmdPrint('tc qdisc add dev %s root netem delay %s' %(ct_dev[0],args.arg1))
    client.cmdPrint('tc qdisc add dev %s root netem delay %s' %(ct_dev[1],args.arg2))
    client.cmdPrint('tc qdisc add dev %s root netem delay %s' %(ct_dev[2],args.arg3))
    client.cmdPrint('tc qdisc add dev %s root netem delay %s' %(ct_dev[3],args.arg4))
    client.cmdPrint('tc qdisc add dev %s root netem delay %s' %(ct_dev[4],args.arg5))

    for i in range(args.n):
        client.cmdPrint('tc -s qdisc ls dev %s' %ct_dev[i])
        
    print
Ejemplo n.º 6
0
def set_optimizations_enabled(enabled):
    """Enable MPTCP optimizations if true, disable if false"""
    e = 1 if enabled else 0
    lg.info("setting MPTCP opts to %s\n" % e)
    sysctl_set('net.mptcp.mptcp_rbuf_opti', e)
    sysctl_set('net.mptcp.mptcp_rbuf_penal', e)
    sysctl_set('net.mptcp.mptcp_rbuf_retr', e)
Ejemplo n.º 7
0
def routeConfig(h):
    for i in range(1,6):
        lg.info("configuring source-specific routing tables for MPTCP\n")
        # This creates two different routing tables, that we use based on the
        # source-address.
    
    # eth0 config
        j = i-1
        dev = 'h%i-eth0' % i
        h[j].cmdPrint('ip rule add from 10.0.0.%i table 1' % i)
        h[j].cmdPrint('ip route add 10.0.0.0/8 dev %s scope link table 1' % dev)
        h[j].cmdPrint('ip route add default via 10.0.0.1 dev %s table 1' % dev)
    
    # eth1 config
        dev = 'h%i-eth1' % i
        h[j].cmdPrint('ip rule add from 172.168.0.%i table 2' % i)
        h[j].cmdPrint('ip route add 172.168.0.0/18 dev %s scope link table 2' % dev)
        h[j].cmdPrint('ip route add default via 172.168.0.1 dev %s table 2' % dev)

    # extra links route config

    h[0].cmdPrint('ip rule add from 172.168.64.1 table 3')
    h[0].cmdPrint('ip route add 172.168.64.0/18 dev h1-eth2 scope link table 3')
    h[0].cmdPrint('ip route add default via 172.168.64.1 dev h1-eth2 table 3')

    h[0].cmdPrint('ip rule add from 172.168.128.1 table 4')
    h[0].cmdPrint('ip route add 172.168.128.0/18 dev h1-eth3 scope link table 4')
    h[0].cmdPrint('ip route add default via 172.168.128.1 dev h1-eth3 table 4')
Ejemplo n.º 8
0
def main():
    args = initParser()
    import json
    topo = json.load(args.topo)
    lg.setLogLevel(args.verbosity)
    net = interopNet(topo)
    net.start()
    for h in net.hosts:
        if not h.name.endswith('-c'):
            h.setDefaultRoute(h.params.get('defaultRoute'))
    if args.cli:
        CLI(net)
    if not args.notest:
        interopTest(net)
    for sw in net.switches:
        sw.printTableEntries()

    for sw in net.switches:
        # Assume everyone assigns the control-plane thread to a 'controller' attr
        sw_ctrl = getattr(sw, 'controller', None)
        if sw_ctrl is not None:
            sw_ctrl_join = getattr(sw_ctrl, 'join', None)
            if sw_ctrl_join is not None:
                lg.info('*** Stopping control-plane of %s\n' % sw.name)
                sw_ctrl_join()
                lg.info('*** Control-plane of %s stopped\n' % sw.name)
Ejemplo n.º 9
0
def set_TC(args,net):
    
    
    ct_name=args.names.client[0]
    sv_name=args.names.server[0]
    client = net.getNodeByName(args.names.client[0])
    server = net.getNodeByName(args.names.server[0])

    eth_dev = "-eth1" 
    ct_dev = ct_name + eth_dev
    sv_dev = sv_name + eth_dev 

    lg.info("****************************  set tc ****************************\n")
    print "arg:"
    print args.arg1
    lg.info('%s\n' %ct_dev)
    client.cmdPrint('tc qdisc del dev %s root' %ct_dev)
    client.cmdPrint('tc qdisc add dev %s root netem delay %s' %(ct_dev,args.arg1))
    client.cmdPrint('tc -s qdisc ls dev %s' %ct_dev)


    server.cmdPrint('tc qdisc del dev %s root' %sv_dev)
    server.cmdPrint('tc qdisc add dev %s root netem delay %s' %(sv_dev,args.arg1))
    server.cmdPrint('tc -s qdisc ls dev %s' %sv_dev)

    print
Ejemplo n.º 10
0
def killprocs(patterns, timeout=10):
    """Reliably terminate processes matching a pattern (including args)"""

    # Try clean kill
    for p in patterns:
        mnclean.sh('pkill -SIGINT -f %s' % p)

    # Make sure they are gone
    t = 0
    to_be_killed = {p: True for p in patterns}
    while any(to_be_killed.values()) or t >= timeout:
        for p in patterns:
            try:
                pids = check_output(['pgrep', '-f', p])
            except CalledProcessError:
                pids = ''
            if not pids:
                log.info(p)
                to_be_killed[p] = False

        time.sleep(.5)
        t += .5

    # Last resort
    for p in patterns:
        if to_be_killed[p]:
            log.info(p)
            mnclean.killprocs(p)
Ejemplo n.º 11
0
def configBuf(net, args):
    recvr = net.getNodeByName('receiver')
    sender = net.getNodeByName('sender')
    lg.info("Sender/Receiver buffer setting")
    print sender.cmd("sysctl net.ipv4.tcp_rmem")
    print sender.cmd("sysctl net.ipv4.tcp_wmem")
    print recvr.cmd("sysctl net.ipv4.tcp_rmem")
    print recvr.cmd("sysctl net.ipv4.tcp_wmem")
Ejemplo n.º 12
0
def set_mptcp_ndiffports(ports):
    """Set ndiffports, the number of subflows to instantiate"""
    lg.info("setting MPTCP ndiffports to %s\n" % ports)
    if(ports !=1):
    	sysctl_set("net.mptcp.mptcp_path_manager", "ndiffports")
    	print("*****ndiff ports")
    else:
    	sysctl_set('net.mptcp.mptcp_path_manager','fullmesh')
    	print("*****FULL MESH")
Ejemplo n.º 13
0
def run(mptcp, net, type):
    if type == 'wifi':
        log = 'logfile_wifi'
        ip = '10.0.0.4'
    elif type == '3g':
        log = 'logfile_3g'
        ip = '10.0.1.4'
    else:
        if type == 'mptcp_noopt':
            log = 'logfile_mptcp_noopt'
        else:
            log = 'logfile_mptcp'
        ip = '10.0.0.4'

    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')

    for i in range(2):
        # Setup IPs:
        h1.cmdPrint('ifconfig h1-eth%i 10.0.%i.3 netmask 255.255.255.0' %
                    (i, i))
        h2.cmdPrint('ifconfig h2-eth%i 10.0.%i.4 netmask 255.255.255.0' %
                    (i, i))

        h1.cmdPrint('ifconfig h1-eth%i txqueuelen 50' % (i, ))
        h2.cmdPrint('ifconfig h2-eth%i txqueuelen 50' % (i, ))

        if mptcp:
            lg.info("configuring source-specific routing tables for MPTCP\n")
            # This creates two different routing tables, that we use based on the
            # source-address.
            dev = 'h1-eth%i' % i
            table = '%s' % (i + 1)
            h1.cmdPrint('ip rule add from 10.0.%i.3 table %s' % (i, table))
            h1.cmdPrint(
                'ip route add 10.0.%i.0/24 dev %s scope link table %s' %
                (i, dev, table))
            h1.cmdPrint('ip route add default via 10.0.%i.1 dev %s table %s' %
                        (i, dev, table))

    # verify connectivity with a ping test.
    lg.info("pinging each destination interface\n")
    for i in range(2):
        h2_out = h2.cmd('ping -c 3 10.0.%i.3' % i)
        lg.info("ping test output: %s\n" % h2_out)

    lg.info("%s: starting server and client\n" % type)
    server = h2.popen('./server', log)
    client = h1.popen('./client', ip)
    retcode = client.wait()
    if retcode != 0:
        return False
    sleep(2)
    server.terminate()
    lg.info("%s run completed\n" % type)
    return True
Ejemplo n.º 14
0
 def do_ips(self, line):
     """ips n1 n2 ...: return the ips associated to the given node name"""
     for n in line.split(' '):
         try:
             l = [itf.ip for itf in self.mn[n].intfList()]
         except KeyError:
             l = 'unknown node'
         finally:
             lg.info(n, '|', l)
     lg.info('\n')
Ejemplo n.º 15
0
 def do_ip(self, line):
     """ip IP1 IP2 ...: return the node associated to the given IP"""
     for ip in line.split(' '):
         try:
             n = self.mn.node_for_ip(ip)
         except KeyError:
             n = 'unknown IP'
         finally:
             lg.info(ip, '|', n)
     lg.info('\n')
Ejemplo n.º 16
0
 def do_ip(self, line):
     """ip IP1 IP2 ...: return the node associated to the given IP"""
     for ip in line.split(' '):
         try:
             n = self.mn.node_for_ip(ip)
         except KeyError:
             n = 'unknown IP'
         finally:
             lg.info(ip, '|', n)
     lg.info('\n')
Ejemplo n.º 17
0
 def do_ips(self, line):
     """ips n1 n2 ...: return the ips associated to the given node name"""
     for n in line.split(' '):
         try:
             l = [itf.ip for itf in self.mn[n].intfList()]
         except KeyError:
             l = 'unknown node'
         finally:
             lg.info(n, '|', l)
     lg.info('\n')
Ejemplo n.º 18
0
def _kill_ryu():
    """Kill the ryu-manager process running on the controller (c0).
    """
    # Get the configuration details of the nodes
    mgmts1_conf, dps1_conf, c0_conf, h1_conf, h2_conf = \
        get_node_configs()

    cmd = "pkill \"ryu-manager\""
    c0 = _NETWORK.getNodeByName(c0_conf["name"])
    lg.info("*** Terminating the Ryu application on %s\n" % (c0_conf["name"]))
    c0.cmd(cmd)
Ejemplo n.º 19
0
def mdtcp():    
    if not os.path.exists(args.dir): 
      os.makedirs(args.dir)
    # os.system("sysctl -w net.ipv4.tcp_congestion_control=%s" % args.cong)
    topo =NetTopo(n=args.n)
    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink)

    h0 = net.get('h0')
    h1 = net.get('h1')

    for i in range(args.intf):
        ip='10.0.%s.2'%str(i+4)
        etf='h0-eth%s'%str(i)
        h0.setIP(ip, intf=etf)
       
        lg.info("configuring source-specific routing tables for MPTCP\n")
        h0.cmdPrint("ip rule add from 10.1.%s.2 table 1",i+4)
        h0.cmdPrint("ip route add 10.1.%s.0/24 dev h0-eth0 scope link table %s",(i+4,i+1))
        h0.cmdPrint("ip route add default via 10.1.1.1 dev h0-eth%s table %s",(i,i+1))

    net.start()
    sleep(1) # wait for net to startup (unless this, it might won't work...)
    # This dumps the topology and how nodes are interconnected through
    # links.
    dumpNodeConnections(net.hosts)
    # This performs a basic all pairs ping test.
    net.pingAll()


    if args.expt is 1:
      comparison(net)

    if args.expt is 2:
       convergence(net)

    # Start all the monitoring processes
    start_tcpprobe("cwnd.txt")

    # Start monitoring the queue sizes. 
    qmon = start_qmon(iface='s1-eth1',
                      outfile='%s/q.txt' % (args.dir))

    start_time = time()
    while True:
        now = time()
        delta = now - start_time
        if delta > args.time:
            break

    stop_tcpprobe()
    qmon.terminate()
    net.stop()
    Popen("killall -s 9 iperf",shell=True).wait()
Ejemplo n.º 20
0
def set_IP(args,net):

    print
    lg.info("**************************** set IP ****************************\n")
    ct_name=args.names.client[0]
    sv_name=args.names.server[0]
    client = net.getNodeByName(ct_name)
    server = net.getNodeByName(sv_name)
	
    i=1
    for host in net.hosts:
        if (host == server):
            continue
        if (host != client):
            host.setIP('172.16.0.%i' %i,prefixLen=24)#/24
            i+=1
        else:
            client.setIP('172.16.0.%i' %i,prefixLen=24)
            server.setIP('172.16.0.%i' %(i+1),prefixLen=24)
            for j in range(args.n):
                eth_dev= "-eth%i" %j
                ct_dev = ct_name + eth_dev
                sv_dev = sv_name + eth_dev
                
                client.cmdPrint('ifconfig ' + ct_dev + ' 172.16.%i.%i netmask 255.255.255.0' %  (j,i))
                server.cmdPrint('ifconfig ' + sv_dev + ' 172.16.%i.%i netmask 255.255.255.0' %  (j,i+1))
		
        
                if args.verbose:
                    print("-------debug-------")
                    print(ct_dev)
                    print(sv_dev)
                    
                    server.cmdPrint('ifconfig ' + sv_dev)
                    client.cmdPrint('ifconfig ' + ct_dev)
                    print("-------/debug-------")
        
                if args.mptcp:
                    lg.info("configuring source-specific routing tables for MPTCP\n")
            
                    table = '%s' % (j+1)
                    client.cmdPrint('ip rule add from 172.16.%i.%i table %s' % (j,i, table))
                    client.cmdPrint('ip route add 172.16.%i.0/24 dev %s scope link table %s' % (j, ct_dev, table))
                    client.cmdPrint('ip route add default dev %s table %s' % ( ct_dev, table))

#                    client.cmdPrint('ip route add default via 172.16.0.%i dev %s table %s' % (j, ct_dev, table))
            i+=2#client + server
            
    for host in net.hosts:
        print host,host.IP()        
    
    print
Ejemplo n.º 21
0
def debug(onoff):
    onoff = 1 if onoff else 0
    lg.info("setting MPTCP debug to %s\n" % onoff)
    p = Popen("sysctl -w net.mptcp.mptcp_debug=%s" % onoff, shell=True, stdout=PIPE,
              stderr=PIPE)
        # Output should be empty; otherwise, we have an issue.  
    stdout, stderr = p.communicate()
    stdout_expected = "net.mptcp.mptcp_debug = %s\n" % onoff
    if stdout != stdout_expected:
        raise Exception("Popen returned unexpected stdout: %s != %s" %
                        (stdout, stdout_expected))
    if stderr:
        raise Exception("Popen returned unexpected stderr: %s" % stderr)
Ejemplo n.º 22
0
def routeConfig(h):
    for i in range(1, 6):
        lg.info("configuring source-specific routing tables for MPTCP\n")
        # This creates two different routing tables, that we use based on the
        # source-address.

        # eth0 config
        j = i - 1
        dev = 'h%i-eth0' % i
        h[j].cmdPrint('ip rule add from 10.0.0.%i table 1' % i)
        h[j].cmdPrint('ip route add 10.0.0.0/8 dev %s scope link table 1' %
                      dev)
        h[j].cmdPrint('ip route add default via 10.0.0.1 dev %s table 1' % dev)
Ejemplo n.º 23
0
def run(mptcp, net, type):
    if type == 'wifi':
        log = 'logfile_wifi'
        ip = '10.0.0.4'
    elif type == '3g':
        log = 'logfile_3g'
        ip = '10.0.1.4'
    else:
        if type == 'mptcp_noopt':
            log = 'logfile_mptcp_noopt'
        else:
            log = 'logfile_mptcp'
        ip = '10.0.0.4'

    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')

    for i in range(2):
        # Setup IPs:
        h1.cmdPrint('ifconfig h1-eth%i 10.0.%i.3 netmask 255.255.255.0' % (i, i))
        h2.cmdPrint('ifconfig h2-eth%i 10.0.%i.4 netmask 255.255.255.0' % (i, i))

        h1.cmdPrint('ifconfig h1-eth%i txqueuelen 50' % (i, ))
        h2.cmdPrint('ifconfig h2-eth%i txqueuelen 50' % (i, ))

        if mptcp:
            lg.info("configuring source-specific routing tables for MPTCP\n")
            # This creates two different routing tables, that we use based on the
            # source-address.
            dev = 'h1-eth%i' % i
            table = '%s' % (i + 1)
            h1.cmdPrint('ip rule add from 10.0.%i.3 table %s' % (i, table))
            h1.cmdPrint('ip route add 10.0.%i.0/24 dev %s scope link table %s' % (i, dev, table))
            h1.cmdPrint('ip route add default via 10.0.%i.1 dev %s table %s' % (i, dev, table))

    # verify connectivity with a ping test.
    lg.info("pinging each destination interface\n")
    for i in range(2):
        h2_out = h2.cmd('ping -c 3 10.0.%i.3' % i)
        lg.info("ping test output: %s\n" % h2_out)

    lg.info("%s: starting server and client\n" % type)
    server = h2.popen('./server', log)
    client = h1.popen('./client', ip)
    retcode = client.wait()
    if retcode != 0:
        return False
    sleep(2)
    server.terminate()
    lg.info("%s run completed\n" % type)
    return True
Ejemplo n.º 24
0
def run(args, net):
    seconds = int(args.t)
    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')

    for i in range(args.n):
        # Setup IPs:
        h1.cmdPrint('ifconfig h1-eth%i 10.0.%i.3 netmask 255.255.255.0' %
                    (i, i))
        h2.cmdPrint('ifconfig h2-eth%i 10.0.%i.4 netmask 255.255.255.0' %
                    (i, i))

        if args.mptcp:
            lg.info("configuring source-specific routing tables for MPTCP\n")
            # This creates two different routing tables, that we use based on the
            # source-address.
            dev = 'h1-eth%i' % i
            table = '%s' % (i + 1)
            h1.cmdPrint('ip rule add from 10.0.%i.3 table %s' % (i, table))
            h1.cmdPrint(
                'ip route add 10.0.%i.0/24 dev %s scope link table %s' %
                (i, dev, table))
            h1.cmdPrint('ip route add default via 10.0.%i.1 dev %s table %s' %
                        (i, dev, table))

    # TODO: expand this to verify connectivity with a ping test.
    lg.info("pinging each destination interface\n")
    for i in range(args.n):
        h2_out = h2.cmd('ping -c 1 10.0.%i.3' % i)
        lg.info("ping test output: %s\n" % h2_out)

    lg.info("iperfing")
    '''
Ejemplo n.º 25
0
def test(args, net):
    print('-------------------Test Begin---------------------')
    seconds = int(args.t)
    ct_name=args.names.client[0]
    sv_name=args.names.server[0]
    client = net.getNodeByName(ct_name)
    server = net.getNodeByName(sv_name)

    lg.info("pinging each destination interface\n")
    
    for i in range(args.n):
        ip='172.16.%i.2'%i
        output = args.output + args.prepend + '_'+ "ping_"+ip 
        opts = "-DAq "
        interval = "0.250"
        n = (float(args.t)-1)/float(interval)
        client.cmd('ping %s -c %d -i %s 172.16.%i.2 > %s &' % (opts,n,interval,i,output)) # ping pendant iperf
        

    lg.info("iperfing")
    #iperf options
    #-i report time interval
    #-s server mode
    #-c client mode
    #-m report MTU
    #-M set MSS

    #***** common_args **** 
    report = ' --reportstyle C' if args.csv else ''

    #********* server **********
    opts =' -i 1 -m -M 1460 -w %s' %args.arg2
    cmd = 'iperf -s' + opts + report
    server.sendCmd(cmd)
    
    #********* client **********
    opts =  ' -t %d -i 1 -m -M 1460 -w %s' % (seconds,args.arg2)
    ip = ' 172.16.0.2'
    cmd = 'iperf -c ' + ip + opts + report
    client.sendCmd(cmd)


    progress(seconds + 1)
    client_out = client.waitOutput()
    lg.info("client output:\n%s\n" % client_out)
    sleep(0.1)  # hack to wait for iperf server output.
    server_out = server.read(500000)#
    lg.info("server output: %s\n" % server_out)

    
    ssh_cmd ='/usr/sbin/sshd'
    
	#dirty way to kill sshd
    cmd='pkill -f "ping -DAq"'
    call(cmd,shell=True)

    print('-------------------Test End---------------------')

    return server_out,client_out
Ejemplo n.º 26
0
def iperfLaunch(h):
    lg.info("iperfing")
    sleep(1) # let the server start
    #dst.sendCmd('ping %s -c 2' % (src.IP()))
    seconds=320
    for i in range(1,4):
        cmd = 'iperf -c %s -p 500%i -n 4096M -i 1 &' % (h[0].IP(), i)
        h[i].cmd(cmd)
    # #progress(seconds + 1)
    # src_out = src.waitOutput()
    # lg.info("client output:\n%s\n" % src_out)
    # sleep(0.1)  # hack to wait for iperf server output.
    # out = dst.read(10000)
    # lg.info("server output: %s\n" % out)
    return None
Ejemplo n.º 27
0
 def icmpReply(self, pkt):
     # Reply ICMP
     pkt[ICMP].type = 0
     pkt[ICMP].chksum = None
     ip_src = pkt[IP].src
     pkt[IP].src = pkt[IP].dst
     pkt[IP].dst = ip_src
     mac_src = pkt[Ether].src
     pkt[Ether].src = pkt[Ether].dst
     pkt[Ether].dst = mac_src
     lg.info('Send ICMP Reply from %s to port %d:\n' %
             (self.sw.name, pkt[CPUMetadata].ingressPort))
     if lg.getEffectiveLevel() <= LEVELS['debug']:
         pkt.show()
     self.send(pkt, pkt[CPUMetadata].ingressPort)
Ejemplo n.º 28
0
 def _allocate_ipv6(self):
     log.info("*** Allocating IPv6 addresses\n")
     self._allocate_subnets(self._unallocated_ip6base,
                            self.broadcast_domains,
                            domainlen='len_v6',
                            net_key='net6',
                            size_key='max_v6prefixlen',
                            max_prefixlen=self.max_v6_prefixlen)
     for domain in self.broadcast_domains:
         for intf in domain:
             ips = tuple(domain.next_ipv6()
                         for _ in range(intf.interface_width[1]))
             intf.setIP6(ips)
             for ip in ips:
                 self._ip_allocs[ip.with_prefixlen] = intf.node
Ejemplo n.º 29
0
 def _allocate_ipv6(self):
     log.info("*** Allocating IPv6 addresses\n")
     self._allocate_subnets(self._unallocated_ip6base,
                            self.broadcast_domains,
                            domainlen='len_v6',
                            net_key='net6',
                            size_key='max_v6prefixlen',
                            max_prefixlen=self.max_v6_prefixlen)
     for domain in self.broadcast_domains:
         for intf in domain:
             ips = tuple(domain.next_ipv6()
                         for _ in xrange(intf.interface_width[1]))
             intf.setIP6(ips)
             for ip in ips:
                 self._ip_allocs[ip.with_prefixlen] = intf.node
Ejemplo n.º 30
0
def test(args, net):
    print ("-------------------Test Begin---------------------")
    seconds = int(args.t)
    ct_name = args.names.client[0]
    sv_name = args.names.server[0]
    client = net.getNodeByName(ct_name)
    server = net.getNodeByName(sv_name)

    lg.info("pinging each destination interface\n")

    for i in range(args.n):
        ip = "172.16.%i.2" % i
        output = args.output + args.prepend + "_" + "ping_" + ip
        opts = "-D "  # ne pas mettre Adaptative
        interval = "1"
        n = int(args.t) - 10
        server.cmd("ping %s -c %s 172.16.%i.1 > %s &" % (opts, str(n), i, output))  # ping pendant iperf
    #        client.cmd('ping %s -c %s -i %s 172.16.%i.2 &' % (opts,str(n),interval,i)) # ping pendant iperf

    lg.info("iperfing")
    # iperf options
    # -i report time interval
    # -s server mode
    # -c client mode
    # -m report MTU
    # -M set MSS

    # ***** common_args ****
    report = " --reportstyle C" if args.csv else ""

    # ********* server **********
    opts = " -i 1 -m -M 1460"

    cmd = "iperf -s" + opts + report
    server.sendCmd(cmd)

    # ********* client **********

    opts = " -t %d -i 1 -m -M 1460" % seconds
    ip = " 172.16.0.2"
    cmd = "iperf -c " + ip + opts + report
    client.sendCmd(cmd)

    progress(seconds + 1)
    client_out = client.waitOutput()
    lg.info("client output:\n%s\n" % client_out)
    sleep(0.1)  # hack to wait for iperf server output.
    server_out = server.read(500000)  #
    lg.info("server output: %s\n" % server_out)

    #  sleep(1)

    cmd = 'pkill -f "ping -Dq"'
    call(cmd, shell=True)

    print ("-------------------Test End---------------------")

    return server_out, client_out
Ejemplo n.º 31
0
def test(args, net):
    print('-------------------Test Begin---------------------')
    seconds = int(args.t)
    ct_name=args.names.client[0]
    sv_name=args.names.server[0]
    client = net.getNodeByName(ct_name)
    server = net.getNodeByName(sv_name)

    lg.info("pinging each destination interface\n")
    for i in range(args.n):
        opts = "-DAq "
        n = "500" # ping
        out_ping=client.cmdPrint('ping %s -c %s 172.16.%i.2' % (opts,n,i))
        
       # lg.info("ping test output: %s\n" % out_ping)
        
        ip='172.16.%i.2'%i
        g=open(args.output + args.prepend + '_'+ "ping_"+ip,'w')
        g.write(out_ping)
        g.close()




    lg.info("iperfing")
    #iperf options
    #-i report time interval
    #-s server mode
    #-c client mode
    #-m report MTU
    #-M set MSS

    #***** common_args **** 
    report = ' --reportstyle C' if args.csv else ''

    #********* server **********
    opts =' -i 1 -m -M 1460'
    cmd = 'iperf -s' + opts + report
    server.sendCmd(cmd)
    
    #********* client **********
    opts =  ' -t %d -i 1 -m -M 1460' % seconds
    ip = ' 172.16.0.2'
    cmd = 'iperf -c ' + ip + opts + report
    client.sendCmd(cmd)


    progress(seconds + 1)
    client_out = client.waitOutput()
    lg.info("client output:\n%s\n" % client_out)
    sleep(0.1)  # hack to wait for iperf server output.
    server_out = server.read(500000)#
    lg.info("server output: %s\n" % server_out)

    print('-------------------Test End---------------------')

    return server_out,client_out
Ejemplo n.º 32
0
def main():
    framework.preconfigure()
    args = framework.parse_args()
    lg.setLogLevel('info')
    net = sw_net.myNetwork()
    A = framework.mininet_to_networkx(net)
    node_graph = A[0]
    ###########################################
    print "-----Start PING test"
    hIpDict = framework.getAllIP(net)
    lg.info("Before configuring routing table\n")
    framework.pingAllIP(hIpDict, 1)
    ###########################################
    if (len(net.controllers) > 1):
        framework.run_configure(args, net)
    else:
        framework.run_configure_single_nw(args, net)
    ###########################################
    hIpDict = framework.getAllIP(net)
    lg.info("After configuring routing table\n")
    framework.pingAllIP(hIpDict, 3)
    ###########################################
    pathA = None
    pathA = False
    os.system("/etc/init.d/networking restart")
    path = '10.0.0.1'
    src = "h2"
    dest = "h1"
    path_stat = framework.get_path_stats(node_graph, src, dest)
    ###########################################
    net.getNodeByName(dest).cmdPrint("iperf -s&")  #h1
    test_result = net.getNodeByName(src).cmdPrint(
        "sleep 5; iperf -c %s -i 2 -t 30 -m" % (path))  #h2
    test_result = test_result.split("\n")
    Final = test_result[len(test_result) - 3]
    T.cprint("------------------------------------------------------------",
             "green",
             attrs=['bold'])
    T.cprint("SEE FILE HEADER FOR EXPLAINATION ON THE OUTPUT\n\n\n",
             "red",
             attrs=['bold'])
    T.cprint("Final Bandwidth= %s" % (Final), "green")
    T.cprint("Path stats{\'Path\':[BW,DELAY,LOSS_RATE]}=" + str(path_stat),
             "green")
    print "\n\n"
    net.stop()
    framework.end(args)
Ejemplo n.º 33
0
def set_switch_rates(net):
    lg.info("--- Adding rate limits to switches.\n")
    BANDWIDTH="100Mbit"
    BOTTLENECK_LINKS=["s0-eth1"] # This is for SimpleTopo
    BOTTLENECK_LINKS=["s0-eth5", 's1-eth5'] # This is for Dumbell Topo
    BOTTLENECK_BW="80Mbit"
    for sw in net.switches:
        for intf in sw.intfs.itervalues():
            dev = intf.name
            if dev == "lo":
                continue
            bw = BANDWIDTH
            if dev in BOTTLENECK_LINKS:
                bw = BOTTLENECK_BW
            c = "tc qdisc add dev %s root handle 1: tbf limit 150000 burst 15000 rate %s" % (dev, bw)
            rootcmd(c)
    return
Ejemplo n.º 34
0
def _config_mgmts1():
    """Configure the management network switch to behave like a
    standard layer 2 Ethernet switch.
    """
    # Get the configuration details of the nodes
    mgmts1_conf, dps1_conf, c0_conf, h1_conf, h2_conf = \
        get_node_configs()

    # Get the node object for the management network switch
    mgmts1 = _NETWORK.getNodeByName(mgmts1_conf["name"])

    # Create a flow table entry instructing the management network
    # switch to behave like a standard layer 2 Ethernet switch.
    # Because of the way that Mininet work, our switch with the name
    # 'mgmts1' is really just an Open vSwitch bridge. This is why
    # 'mgmts1' is found in bridge interface position in the command.
    lg.info("*** Disabling OpenFlow and configuring layer 2 Ethernet "
            "switch behaviour on switch %s\n" % (mgmts1_conf["name"]))
    mgmts1.cmd("ovs-ofctl add-flow mgmts1 action=normal")
Ejemplo n.º 35
0
def configMPTCP(net, args):
    # Config IP, routing table
    configIP(net, args)
    if (args.mptcp):
        # Enable MPTCP
        sysctl_set('net.mptcp.mptcp_enabled', 1)
        # Set path manager
        sysctl_set('net.mptcp.mptcp_path_manager', 'fullmesh')
        #os.system('cat /sys/module/mptcp_fullmesh/parameters/num_subflows')
        # sysctl_set('net.mptcp.mptcp_scheduler', 'redundant')
        # Config Congestion Control
        # sysctl_set('net.ipv4.tcp_congestion_control', 'lia')
    else:
        try:
            # Try to disable MPTCP, if fail, it means MPTCP is not installed
            sysctl_set('net.mptcp.mptcp_enabled', 0)
        except:
            lg.info("May be mptcp is not installed ?\n")
        sysctl_set('net.ipv4.tcp_congestion_control', args.cc)
Ejemplo n.º 36
0
def cleanup(level: str = 'info'):
    """Cleanup all possible junk that we may have started."""
    log.setLogLevel(level)
    # Standard mininet cleanup
    mnclean.cleanup()
    # Cleanup any leftover daemon
    patterns = []  # type: List[str]
    for package in [router_daemons, host_daemons]:
        for d in package.__all__:
            obj = getattr(package, d, None)
            killp = getattr(obj, 'KILL_PATTERNS', None)
            if not killp:
                continue
            if not is_container(killp):
                killp = [killp]
            patterns.extend(killp)
    log.info('*** Cleaning up daemons:\n')
    killprocs(['"^%s"' % p for p in patterns])
    log.info('\n')
Ejemplo n.º 37
0
def cleanup():
    """Cleanup all possible junk that we may have started."""
    log.setLogLevel('info')
    # Standard mininet cleanup
    mnclean.cleanup()
    # Cleanup any leftover daemon
    patterns = []
    for d in daemons.__all__:
        obj = getattr(daemons, d)
        killp = getattr(obj, 'KILL_PATTERNS', None)
        if not killp:
            continue
        if not is_container(killp):
            killp = [killp]
        patterns.extend(killp)
    log.info('*** Cleaning up daemons:\n')
    for pattern in patterns:
        mnclean.killprocs('"%s"' % pattern)
    log.info('\n')
Ejemplo n.º 38
0
def cleanup(level='info'):
    """Cleanup all possible junk that we may have started."""
    log.setLogLevel(level)
    # Standard mininet cleanup
    mnclean.cleanup()
    # Cleanup any leftover daemon
    patterns = []
    for d in daemons.__all__:
        obj = getattr(daemons, d)
        killp = getattr(obj, 'KILL_PATTERNS', None)
        if not killp:
            continue
        if not is_container(killp):
            killp = [killp]
        patterns.extend(killp)
    log.info('*** Cleaning up daemons:\n')
    for pattern in patterns:
        mnclean.killprocs('"%s"' % pattern)
    log.info('\n')
Ejemplo n.º 39
0
 def build(self):
     super().build()
     self.broadcast_domains = self._broadcast_domains()
     log.info("*** Found", len(self.broadcast_domains),
              "broadcast domains\n")
     if self.allocate_IPs:
         self._allocate_IPs()
     # Physical interfaces are their own broadcast domain
     for itf_name, n in self.physical_interface.items():
         try:
             itf = PhysicalInterface(itf_name, node=self[n])
             log.info('\n*** Adding Physical interface',
                      itf_name, 'to', n, '\n')
             self.broadcast_domains.append(BroadcastDomain(itf))
         except KeyError:
             log.error('!!! Node', n, 'not found!\n')
     try:
         self.topo.post_build(self)
     except AttributeError as e:
         log.error('*** Skipping post_build():', e, '\n')
Ejemplo n.º 40
0
 def _allocate_ipv4(self):
     log.info("*** Allocating IPv4 addresses\n")
     self._allocate_subnets(self._unallocated_ipbase,
                            self.broadcast_domains,
                            domainlen='len_v4',
                            net_key='net',
                            size_key='max_v4prefixlen',
                            max_prefixlen=self.max_v4_prefixlen,
                            allocated_subnets=self._allocated_ipv4_subnets())
     for domain in self.broadcast_domains:
         if not domain.use_ip_version(4):
             continue
         for intf in domain:
             if len(list(intf.ips())) == 0:
                 ips = tuple(domain.next_ipv4()
                             for _ in range(intf.interface_width[0]))
                 intf.setIP(ips)
             for ip in intf.ips():
                 self._ip_allocs[ip.with_prefixlen] = intf.node
                 self._ip_allocs[ip.ip.compressed] = intf.node
Ejemplo n.º 41
0
 def _allocate_ipv6(self):
     log.info("*** Allocating IPv6 addresses\n")
     self._allocate_subnets(self._unallocated_ip6base,
                            self.broadcast_domains,
                            domainlen='len_v6',
                            net_key='net6',
                            size_key='max_v6prefixlen',
                            max_prefixlen=self.max_v6_prefixlen,
                            allocated_subnets=self._allocated_ipv6_subnets())
     for domain in self.broadcast_domains:
         if not domain.use_ip_version(6):
             continue
         for intf in domain:
             if len(list(intf.ip6s(exclude_lls=True))) == 0:
                 ips = tuple(domain.next_ipv6()
                             for _ in range(intf.interface_width[1]))
                 intf.setIP6(ips)
             for ip in intf.ip6s(exclude_lls=True):
                 self._ip_allocs[ip.with_prefixlen] = intf.node
                 self._ip_allocs[ip.ip.compressed] = intf.node
Ejemplo n.º 42
0
 def build(self):
     super(IPNet, self).build()
     self.broadcast_domains = self._broadcast_domains()
     log.info("*** Found", len(self.broadcast_domains),
              "broadcast domains\n")
     if self.allocate_IPs:
         self._allocate_IPs()
     # Physical interfaces are their own broadcast domain
     for itf_name, n in self.physical_interface.iteritems():
         try:
             itf = PhysicalInterface(itf_name, node=self[n])
             log.info('\n*** Adding Physical interface',
                      itf_name, 'to', n, '\n')
             self.broadcast_domains.append(BroadcastDomain(itf))
         except KeyError:
             log.error('!!! Node', n, 'not found!\n')
     try:
         self.topo.post_build(self)
     except AttributeError as e:
         log.error('*** Skipping post_build():', str(e), '\n')
Ejemplo n.º 43
0
    def stop(self):
        try:
            self.topo.pre_stop(self)
        except AttributeError as e:
            log.error('*** Skipping pre_stop():', e, '\n')
        log.info('*** Stopping', len(self.hosts), 'hosts\n')

        log.info('*** Stopping', len(self.routers), 'routers\n')
        for router in self.routers:
            log.info(router.name + ' ')
            router.terminate()
        log.info('\n')
        super().stop()
Ejemplo n.º 44
0
def set_switch_rates(net):
    lg.info("--- Adding rate limits to switches.\n")
    BANDWIDTH="100Mbit"
    BOTTLENECK_LINKS=["s0-eth1"] # This is for SimpleTopo
    BOTTLENECK_LINKS=["s0-eth5", 's1-eth5'] # This is for Dumbell Topo
    BOTTLENECK_LINKS=[]
    BOTTLENECK_BW="80Mbit"
    for sw in net.hosts:
        if not (sw.name.startswith('l') or sw.name.startswith('s')):
            continue
        for intf in sw.intfs.itervalues():
            dev = intf.name
            if dev == "lo" or dev.startswith('bond'):
                print 'skipping', dev
                continue
            bw = BANDWIDTH
            if dev in BOTTLENECK_LINKS:
                bw = BOTTLENECK_BW
            c = "tc qdisc add dev %s root handle 1: tbf limit 150000 burst 15000 rate %s" % (dev, bw)
            rootcmd(c)
    return
Ejemplo n.º 45
0
 def stop(self):
     log.info('*** Stopping', len(self.routers),  'routers\n')
     for router in self.routers:
         log.info(router.name + ' ')
         router.terminate()
     log.info('\n')
     super(IPNet, self).stop()
Ejemplo n.º 46
0
def run(net, args):
    "Run experiment"
    # seconds = args.time
    # Prepare, start monitor, tcp_probe, etc
    monitor = Process(target=monitor_devs_ng,
            args=('%s/bwm.txt' % args.dir, 0.1))
    monitor.start()
    start_tcpprobe(args)
    if args.tcpdump:
        start_tcpdump(net, args)
    # Get receiver and clients
    # recvr = net.getNodeByName('receiver')
    # sender = net.getNodeByName('sender')
    # s1 = net.getNodeByName('s1')
    # s2 = net.getNodeByName('s2')
    # Change buffer sizes
    #configBuf(net, args)
    # Start real experiments
    sleep(1) # !!! Important, otherwise MPTCP won't start
    runIperf(net, args)
    #runWget(net, args)

    # Finish experiment
    monitor.terminate()
    lg.info("Killing tcpprobe\n")
    os.system("killall -9 cat; rmmod tcp_probe")
    lg.info("Killing bwm-ng\n")
    os.system("killall -9 bwm-ng")
    if args.tcpdump:
        lg.info("Killing tcpdump\n")
        os.system("killall -9 tcpdump")
Ejemplo n.º 47
0
def _main(autostart=False):
    graph = _PaperGraph()
    net = IPNet(topo=graph, use_v6=False)
    net.start()
    db = TopologyDB(net=net)
    for e in net.topo.egresses:
        db._network[e]['is_egress'] = True
    db.save(TOPO_DB)
    sink = net['sink']
    source = net['source']
    sink_addr = sink.IP()
    src_addr = source.IP()
    MNLOG.debug('Source is at ', src_addr, 'sink is at ', sink_addr, '\n')
    with open(REQ_FILE, 'w') as f:
        f.write('MIRROR {sink} ON [A B C D]\n'
                'CONFINE {sink} ON [A B L C D]\n'
                'USING {cnt} M DURING 500ms'.format(sink=sink_addr,
                                                    cnt=FLOW_COUNT))
    MNLOG.info('Starting sink')
    sink.filter_source(src_addr)
    MNLOG.info('Starting source')
    source.start_src(sink_addr, src_addr, FLOW_COUNT)
    time.sleep(5)
    if autostart:
        MNLOG.info('Starting collector')
        net[COLLECTOR_ID].start_collector()
    _CLI(net)
    net.stop()
    if os.path.exists(REQ_FILE):
        os.unlink(REQ_FILE)
def set_qos(switch):
    """Set the QoS parameters on a switch.

    :param switch: The switch to operate on.
    """
    lg.info("***Attempting to set QoS parameters on switch {"
            "0}. Output shown below.\n".format(switch.name))
    lg.info(switch.vsctl("clear Port s1-eth2 qos"))
    lg.info(switch.vsctl("--all destroy qos"))
    lg.info(switch.vsctl("-- set Port s1-eth2 qos=@newqos -- "
                         "--id=@newqos create QoS type=linux-htb "
                         "other-config:max-rate=1000000000 queues=0=@q0,"
                         "1=@q1 -- --id=@q0 create Queue "
                         "other-config:max-rate=1000000000 -- --id=@q1 "
                         "create Queue other-config:max-rate=100000"))
Ejemplo n.º 49
0
 def buildFromTopo(self, topo):
     log.info('\n*** Adding Routers:\n')
     for routerName in topo.routers():
         self.addRouter(routerName, **topo.nodeInfo(routerName))
         log.info(routerName + ' ')
     log.info('\n')
     self.physical_interface.update(topo.phys_interface_capture)
     super(IPNet, self).buildFromTopo(topo)
Ejemplo n.º 50
0
def test(args, net):
    print('-------------------Test Begin---------------------')
    seconds = int(args.t)
    sd_name=args.names.client[0]
    rv_name=args.names.server[0]
    client = net.getNodeByName(sd_name)
    server = net.getNodeByName(rv_name)

    lg.info("pinging each destination interface\n")
    for i in range(args.n):
        client.cmd('ping -c 1 172.16.%i.2' % i)
        
    lg.info("iperfing")
    #iperf options
    #-i report time interval
    #-s server mode
    #-c client mode
    #-m report MTU
    #-M set MSS

    #***** common_args **** 
    report = ' --reportstyle C -o /dev/null' if args.csv else ''

    #********* server **********
    opts =' -i 1 -m -M 1460'
    cmd = 'iperf -s' + opts + report
    server.sendCmd(cmd)
    
    #********* client **********
    opts =  ' -t %d -i 1 -m -M 1460' % seconds
    ip = ' 172.16.0.2'
    cmd = 'iperf -c ' + ip + opts + report
    client.sendCmd(cmd)


    progress(seconds + 1)
    client_out = client.waitOutput()
    lg.info("client output:\n%s\n" % client_out)
    sleep(0.1)  # hack to wait for iperf server output.
    server_out = server.read(500000)#
    lg.info("server output: %s\n" % server_out)

    print('-------------------Test End---------------------')

    return server_out,client_out
Ejemplo n.º 51
0
def eyeq_conf(net):
    dir = getdir()
    basedir = dir + "../../"
    testdir = dir + "../"

    lg.info("--- Please wait while we create+configure tenants through ssh.\n")
    lg.info("    This can take a while...\n")
    h1 = net.get("h1")
    cmd(h1, "python %s/tenant.py -m %d -T %d" % (testdir, args.num_hosts * 2, args.num_tenants))

    lg.info("\n--- Setting parameters for 100Mb/s\n")
    rootcmd("bash %s/100mbps.sh %s" % (dir, basedir))
Ejemplo n.º 52
0
def main():
    lg.setLogLevel('info')
    if os.geteuid() != 0:
        lg.info("This script uses Mininet, and must be run as root.\n")
        sys.exit(1)

    topo = Wifi3GTopo(bw_wifi=args.bw_wifi,
                      bw_3g=args.bw_3g,
                      latency_wifi='%fms' % (args.latency_wifi,),
                      latency_3g='%fms' % (args.latency_3g,),
                      loss_wifi=args.loss_wifi,
                      loss_3g=args.loss_3g,
                      jitter_wifi='%fms' % (args.jitter_wifi,),
                      jitter_3g='%fms' % (args.jitter_3g,))

    # Compile client and server
    os.system('gcc server.c -o server')
    os.system('gcc client.c -o client')

    signal.signal(signal.SIGABRT, signal_cleanup)
    signal.signal(signal.SIGHUP, signal_cleanup)
    signal.signal(signal.SIGINT, signal_cleanup)
    signal.signal(signal.SIGTERM, signal_cleanup)

    types = [ 'wifi', '3g', 'mptcp', 'mptcp_noopt' ]
    trylimit = 3
    for type in types:
        lg.info("Running %s\n" % type)
        success = False
        tries = 0
        while not success and tries < trylimit:
            success = genericTest(topo, setup, run, end, type)
            tries += 1
            if not success:
                lg.info("Test failed to run, retrying (%d tries remaining)\n" % (trylimit - tries,))

    return 0
def start_mininet(iface_names):
    """Start Mininet with the above topology.

    :param iface_name: Network interface name of the host computer to
    attach to the Mininet virtual network.
    """
    topo = SimpleTopo()
    net = Mininet(topo, build=False)
    net.addController("c0", controller=RemoteController, port=6633,
                      switch=OVSSwitch)
    net.build()
    switch = net.switches[0]
    for iface in iface_names:
        lg.info("***Connecting {0} to virtual switch\n".format(iface))
        # Connect the switch to the eth1 interface of this host machine!
        Intf(iface, node=switch)
    net.start()
    set_qos(switch)
    lg.info("***Dumping host connections\n")
    dumpNodeConnections(net.hosts)
    lg.info("***Dumping switch connections\n")
    dumpNodeConnections(net.switches)
    CLI(net)
    net.stop()
Ejemplo n.º 54
0
def set_TC(args, net):

    ct_name = args.names.client[0]
    sv_name = args.names.server[0]
    client = net.getNodeByName(args.names.client[0])
    server = net.getNodeByName(args.names.server[0])

    eth_dev = "-eth1"
    ct_dev = ct_name + eth_dev
    sv_dev = sv_name + eth_dev

    lg.info("****************************  set tc ****************************\n")
    print "arg:"
    print args.arg1
    lg.info("%s\n" % ct_dev)
    # client.cmdPrint('tc qdisc del dev %s root' %ct_dev)
    # client.cmdPrint('tc qdisc add dev %s root netem delay %s' %(ct_dev,args.arg1))
    eth_dev = "-eth1"
    sv_dev = sv_name + eth_dev
    ct_dev = ct_name + eth_dev

    client.cmdPrint("tc qdisc del dev %s root" % ct_dev)
    client.cmdPrint("tc qdisc add dev %s root handle 1: htb default 30" % ct_dev)
    client.cmdPrint("tc class add dev %s parent 1: classid 1:1 htb rate 2mbit" % ct_dev)
    client.cmdPrint("tc class add dev %s parent 1: classid 1:2 htb rate 2mbit" % ct_dev)
    client.cmdPrint(
        "tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip dst 172.16.0.0/16 flowid 1:1" % ct_dev
    )
    client.cmdPrint(
        "tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip src 172.16.0.0/16 flowid 1:2" % ct_dev
    )
    client.cmdPrint("tc -s qdisc ls dev %s" % ct_dev)

    server.cmdPrint("tc qdisc del dev %s root" % sv_dev)
    server.cmdPrint("tc qdisc add dev %s root handle 1: htb default 30" % sv_dev)
    server.cmdPrint("tc class add dev %s parent 1: classid 1:1 htb rate 2mbit" % sv_dev)
    server.cmdPrint("tc class add dev %s parent 1: classid 1:2 htb rate 2mbit" % sv_dev)
    server.cmdPrint(
        "tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip dst 172.16.0.0/16 flowid 1:1" % sv_dev
    )
    server.cmdPrint(
        "tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip src 172.16.0.0/16 flowid 1:2" % sv_dev
    )

    eth_dev = "-eth0"
    sv_dev = sv_name + eth_dev
    ct_dev = ct_name + eth_dev
    server.cmdPrint("tc qdisc del dev %s root" % sv_dev)
    server.cmdPrint("tc qdisc add dev %s root handle 1: htb default 30" % sv_dev)
    server.cmdPrint("tc class add dev %s parent 1: classid 1:1 htb rate 2mbit" % sv_dev)
    server.cmdPrint("tc class add dev %s parent 1: classid 1:2 htb rate 2mbit" % sv_dev)
    server.cmdPrint(
        "tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip dst 172.16.0.0/16 flowid 1:1" % sv_dev
    )
    server.cmdPrint(
        "tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip src 172.16.0.0/16 flowid 1:2" % sv_dev
    )
    server.cmdPrint("tc -s qdisc ls dev %s" % sv_dev)

    client.cmdPrint("tc qdisc del dev %s root" % ct_dev)
    client.cmdPrint("tc qdisc add dev %s root handle 1: htb default 30" % ct_dev)
    client.cmdPrint("tc class add dev %s parent 1: classid 1:1 htb rate 2mbit" % ct_dev)
    client.cmdPrint("tc class add dev %s parent 1: classid 1:2 htb rate 2mbit" % ct_dev)
    client.cmdPrint(
        "tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip dst 172.16.0.0/16 flowid 1:1" % ct_dev
    )
    client.cmdPrint(
        "tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip src 172.16.0.0/16 flowid 1:2" % ct_dev
    )
    client.cmdPrint("tc -s qdisc ls dev %s" % ct_dev)

    print
Ejemplo n.º 55
0
 def start(self):
     super(IPNet, self).start()
     log.info('*** Starting, ', len(self.routers), 'routers\n')
     for router in self.routers:
         log.info(router.name + ' ')
         router.start()
     log.info('\n')
     log.info('*** Setting default host routes\n')
     for h in self.hosts:
         if 'defaultRoute' in h.params:
             continue  # Skipping hosts with explicit default route
         default = False
         # The first router we find will become the default gateway
         for itf in realIntfList(h):
             for r in itf.broadcast_domain.routers:
                 log.info('%s via %s, ' % (h.name, r.name))
                 if self.use_v4 and len(r.addresses[4]) > 0:
                     h.setDefaultRoute('via %s' % r.ip)
                     default = True
                 if (self.use_v6 and len(r.addresses[6]) > 0 and
                         len(r.ra_prefixes)) == 0:
                     # We define a default route only if router xi
                     # advertisement are not activated. If we call the same
                     # function, the route created above might be deleted
                     h.cmd('ip route add default dev %s via %s' % (
                         h.defaultIntf(), r.ip6))
                     default = True
                 if len(r.rdnss_list) > 0:
                     # Launch a daemon able to interpret this RA option
                     process = h.popen("dhcpcd -d %s" % (itf.name,))
                     return_value = process.poll()
                     if return_value is not None and return_value != 0:
                         print("DHCP Client Failure %s" % (return_value,))
                 break
             if default:
                 break
         if not default:
             log.info('skipping %s , ' % h.name)
     log.info('\n')
Ejemplo n.º 56
0
def set_mptcp_enabled(enabled):
    """Enable MPTCP if true, disable if false"""
    e = 1 if enabled else 0
    lg.info("***** setting MPTCP enabled to %s\n *****" % e)
    sysctl_set('net.mptcp.mptcp_enabled', e)
Ejemplo n.º 57
0
def ssh_init(net):
    lg.info("--- Starting sshd inside all hosts\n")
    for host in net.hosts:
        cmd(host, "/usr/sbin/sshd", quiet=True)
    return
Ejemplo n.º 58
0
def mem_init(net):
    lg.info("--- Starting memcached inside all hosts\n")
    for host in net.hosts:
        cmd(host, "/usr/bin/memcached -m 64 -p 11211 -u memcache -d")
    return
Ejemplo n.º 59
0
def set_ndiffports(ports):
    """Set ndiffports, the number of subflows to instantiate"""
    lg.info("setting MPTCP ndiffports to %s\n" % ports)
    sysctl_set("net.mptcp.mptcp_ndiffports", ports)
Ejemplo n.º 60
0
def set_enabled(enabled):
    """Enable MPTCP if true, disable if false"""
    e = 1 if enabled else 0
    lg.info("setting MPTCP enabled to %s\n" % e)
    sysctl_set("net.mptcp.mptcp_enabled", e)