Ejemplo n.º 1
0
def main():
    "Create and run experiment"
    start = time()

    topo = MNTopo()

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)

    print "*** Testing connectivity"

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        print "*** Running experiment"
        run_topology_experiment(net)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    print "Experiment took %.3f seconds" % (end - start)
Ejemplo n.º 2
0
def run_debug():
    if not os.path.exists(TEST_DIR):
        os.mkdir(TEST_DIR)
    
    logfile = '%s/tp_log' % TEST_DIR
    init_log(logfile, 'Throughput (Mbps)\n')

    topo = BurstTestTopo()
    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink)
    net.start()
    dumpNetConnections(net)
    net.pingAll()
    """
    verify_latency(net)
    verify_bandwidth(net)
    verify_throughput(net)
    """
    start_senders(net, n_senders=1)
    start_receiver(net, n_senders=1, sim_duration=3,
                   max_window_list=[SIM2_MAX_WINDOW_LOW])
    rates = get_rates('s1-eth0', nsamples=200, period=0.01, wait=1.0)
    for z in rates:
        write_to_log(logfile, str(z) + '\n')

    net.stop()
Ejemplo n.º 3
0
def run_debug():
    if not os.path.exists(TEST_DIR):
        os.mkdir(TEST_DIR)

    logfile = '%s/tp_log' % TEST_DIR
    init_log(logfile, 'Throughput (Mbps)\n')

    topo = BurstTestTopo()
    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink)
    net.start()
    dumpNetConnections(net)
    net.pingAll()
    """
    verify_latency(net)
    verify_bandwidth(net)
    verify_throughput(net)
    """
    start_senders(net, n_senders=1)
    start_receiver(net,
                   n_senders=1,
                   sim_duration=3,
                   max_window_list=[SIM2_MAX_WINDOW_LOW])
    rates = get_rates('s1-eth0', nsamples=200, period=0.01, wait=1.0)
    for z in rates:
        write_to_log(logfile, str(z) + '\n')

    net.stop()
Ejemplo n.º 4
0
def main():
    "Parse argument"
    args = parse_args()

    if not os.path.exists(args.dir):
        os.makedirs(args.dir)

    "Create network topology, running experiments"
    lg.setLogLevel('info')
    start = time()
    cprint("*** Creating network topology:", "yellow")
    topo = MMwaveTestTopo(mmwavebw=args.bw)
    host = custom(CPULimitedHost, cpu=0.2)  # 20% of system bandwidth (why?)
    link = custom(TCLink)
    net = Mininet(topo=topo, host=host, link=link)
    net.start()
    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)
    cprint("*** Configure MPTCP", "red")
    configMPTCP(net, args)
    cprint("*** Testing connectivity", "blue")
    net.pingAll()
    cprint("*** Running experiment", "magenta")
    #CLI(net)
    run(net, args)
    end = time()
    cprint("*** Finishing experiment, took %.3f seconds" % (end - start), "yellow")
    net.stop()
Ejemplo n.º 5
0
def main():
    "Create and run experiment"
    start = time()

    topo = NetworkTopo()

    host = custom(CPULimitedHost)
    net = Mininet(topo=topo, host=host)

    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        print "*** Running experiment"
        #run_topology_experiment(net)

    net.stop()

    end = time()
    #    os.system("killall -9 tshark")
    #    os.system("chown mininet:mininet /tmp/*.cap ; mv /tmp/*.cap %s" % (args.dir))
    print "Experiment took %.3f seconds" % (end - start)
Ejemplo n.º 6
0
def main():
    "Create and run experiment"
    start = time()

    topo = MNTopo()

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)

    print "*** Testing connectivity"

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        print "*** Running experiment"
        run_topology_experiment(net)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    print "Experiment took %.3f seconds" % (end - start)
Ejemplo n.º 7
0
def main():
    "Create and run experiment"
    start = time()

    topo = ParkingLotTopo(n=args.n)

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, bw=args.bw, delay='1ms',
                  max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)

    cprint("*** Testing connectivity", "blue")

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        cprint("*** Running experiment", "magenta")
        run_parkinglot_expt(net, n=args.n)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    cprint("Experiment took %.3f seconds" % (end - start), "yellow")
Ejemplo n.º 8
0
def main():
    topo = KLTopo()
    host = custom(CPULimitedHost, cpu=.15)
    link = custom(TCLink, bw=10, delay='1ms', max_queue_size=200)
    net = Mininet(topo=topo, host=host, link=link, controller=RemoteController)
    net.start()
    dumpNetConnections(net)
    CLI(net)
Ejemplo n.º 9
0
def run_experiment( output = "sender.dump"):
    topo = MyTopo()
    host = custom(CPULimitedHost, cpu = .15)
    link = custom(TCLink, bw=1000, delay='100ms')

    net = Mininet(topo=topo, host=host, link=link)
    net.start()
    dumpNetConnections(net)
    net.pingAll()

    sender = net.getNodeByName('sender')
    receiver = net.getNodeByName('receiver')

    if CAPTURE_ACKS:
        sender.cmd("tcpdump -tt -nn 'tcp port 5001' &> %s &" % output)
    else:
        sender.cmd("tcpdump -tt -nn 'tcp dst port 5001' &> %s &" % output)
    sleep(1)


    # randomize address, because after a few repeats, the slow start is not observed anymore
    rand = str(random.randint(0,99)).zfill(2)
    receiver_IP = '1%s.11.0.2' % rand
    gateway_IP = '1%s.11.0.1' % rand


    receiver.cmd('../lwip/tcpsink -p 5001 -i %s -g %s &> receiver.out &' % (receiver_IP, gateway_IP))

    #make receiver forward packets from sender to internal tap interface
    receiver.cmd('sysctl net.ipv4.ip_forward=1')


    sender.cmd('sysctl net.core.netdev_max_backlog=500000')
    sender.cmd('sysctl net.ipv4.tcp_congestion_control=cubic')

    #add default route so that sender can sender to receiver's tap interface through the mininet link
    sender.cmd('route add default gw %s' % receiver.IP())

    #reduce MTU because otherwise the receive window is the limiting factor
    sender.cmd('ifconfig sender-eth0 mtu 200')

    print "starting transmission of data to %s" % receiver_IP
    sender.sendCmd('python sender.py --receiver=%s &> sender.out' % receiver_IP)


    print "waiting for transmission to complete"
    sender.waitOutput()

    print "killing tcpdump"
    sender.cmd('killall tcpdump')

    sleep(1)
    print "killing tcpsink"
    receiver.cmd("killall tcpsink")

    net.stop()
Ejemplo n.º 10
0
def main():
    "Create and run experiment"
    start = time()

    topo = DaSDNTopo(n=args.n)

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, bw=args.bw, delay='1ms',
                  max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)

    cprint("*** Setting default port config", "green")
    # 设置默认的端口带宽策略
    port_default_config("s2-eth99", bw=50, tx_queue_len=10)

    cprint("*** Testing connectivity", "blue")

    net.pingAll()

    # if args.cli:
        # Run CLI instead of experiment
    #    CLI(net)
    #else:


    if True:
        cprint("*** Running experiment", "magenta")

        print 'thread %s is running...' % threading.current_thread().name
        # Start Bandwith control thread to Simulation SDN Ctl
        if args.switch_bw:
            t1 = threading.Thread(target=monitor_thread_switch_bw, name='ThreadBwCtl')
            t1.start()

        t2 = threading.Thread(target=run_dasdn_expt, args=(net, args.n), name='ThreadRunExpt')
        t2.start()

        if args.switch_bw: # t1.join需要放在  t2.join  cli 之前
            t1.join()
        t2.join()




    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    cprint("Experiment took %.3f seconds" % (end - start), "yellow")
Ejemplo n.º 11
0
def run_experiment(output="sender.dump"):
    topo = MyTopo()
    host = custom(CPULimitedHost, cpu=.15)
    link = custom(TCLink, bw=1000, delay='100ms')

    net = Mininet(topo=topo, host=host, link=link)
    net.start()
    dumpNetConnections(net)
    net.pingAll()

    sender = net.getNodeByName('sender')
    receiver = net.getNodeByName('receiver')

    if CAPTURE_ACKS:
        sender.cmd("tcpdump -tt -nn 'tcp port 5001' &> %s &" % output)
    else:
        sender.cmd("tcpdump -tt -nn 'tcp dst port 5001' &> %s &" % output)
    sleep(1)

    # randomize address, because after a few repeats, the slow start is not observed anymore
    rand = str(random.randint(0, 99)).zfill(2)
    receiver_IP = '1%s.11.0.2' % rand
    gateway_IP = '1%s.11.0.1' % rand

    receiver.cmd('../lwip/tcpsink -p 5001 -i %s -g %s &> receiver.out &' %
                 (receiver_IP, gateway_IP))

    #make receiver forward packets from sender to internal tap interface
    receiver.cmd('sysctl net.ipv4.ip_forward=1')

    sender.cmd('sysctl net.core.netdev_max_backlog=500000')
    sender.cmd('sysctl net.ipv4.tcp_congestion_control=cubic')

    #add default route so that sender can sender to receiver's tap interface through the mininet link
    sender.cmd('route add default gw %s' % receiver.IP())

    #reduce MTU because otherwise the receive window is the limiting factor
    sender.cmd('ifconfig sender-eth0 mtu 200')

    print "starting transmission of data to %s" % receiver_IP
    sender.sendCmd('python sender.py --receiver=%s &> sender.out' %
                   receiver_IP)

    print "waiting for transmission to complete"
    sender.waitOutput()

    print "killing tcpdump"
    sender.cmd('killall tcpdump')

    sleep(1)
    print "killing tcpsink"
    receiver.cmd("killall tcpsink")

    net.stop()
Ejemplo n.º 12
0
def main():
    mode = args.mode

    topo = DiamondTopo(args.behavioral_exe, args.json, args.thrift_port,
                       args.pcap_dump, args.num_senders, args.num_rcvrs)
    net = Mininet(topo=topo, host=P4Host, switch=P4Switch, controller=None)
    net.start()

    # takes in switch ID and port
    def mac(i, j):
        return "00:aa:bb:00:%02x:%02x" % (i - 1, j)

    # takes in switch ID
    def sw_ip(i):
        return "10.%d.0.1" % (i)

    num_senders = args.num_senders
    num_rcvrs = args.num_rcvrs
    sw_mac = [mac(1, n) for n in xrange(num_senders)]
    sw_addr = ["10.0.%d.1" % n for n in xrange(num_senders)]

    sw_mac2 = [mac(4, n) for n in xrange(num_rcvrs)]
    sw_addr2 = ["10.0.%d.1" % (n + num_senders) for n in xrange(num_rcvrs)]
    print 'Connecting hosts to s1...'

    # Connect all hosts to s1
    for n in xrange(num_senders):
        h = net.get('h%d' % (n + 1))
        h.setARP(sw_addr[n], sw_mac[n])
        h.setDefaultRoute("dev eth0 via %s" % sw_addr[n])

    for n in xrange(num_rcvrs):
        h = net.get('h%d' % (num_rcvrs + n))
        h.setARP(sw_addr2[n], sw_mac2[n])
        h.setDefaultRoute("dev eth0 via %s" % sw_addr2[n])

    net.get('s1').setARP(sw_ip(2), mac(2, 1))
    net.get('s1').setARP(sw_ip(3), mac(3, 1))
    net.get('s2').setARP(sw_ip(1), mac(1, num_senders))
    net.get('s2').setARP(sw_ip(4), mac(4, num_rcvrs))
    net.get('s3').setARP(sw_ip(1), mac(1, num_senders + 1))
    net.get('s3').setARP(sw_ip(4), mac(4, num_rcvrs + 1))
    net.get('s4').setARP(sw_ip(2), mac(2, 2))
    net.get('s4').setARP(sw_ip(3), mac(3, 2))

    sleep(1)
    dumpNetConnections(net)
    print "Ready !"

    CLI(net)
    net.stop()
Ejemplo n.º 13
0
def perfTest():
    '''
    This function runs only when executing the script with python: "sudo python <script_name>"
    If instead the script is executed like "sudo mn --custom <script_name> ...." 
    then you can only use the options added to "topos" and "controllers" list, by specifying parameters to the "sudo mn" command.
    '''
    topo = MyTopo()
    net = Mininet(topo=topo,controller=FLController,link=TCLink,listenPort=6634)

    # specify the MAC addresses for the hosts and switches
    hosts = net.hosts
    hosts[0].setMAC("00:00:00:00:00:01", intf='h1-eth0')
    hosts[1].setMAC("00:00:00:00:00:02", intf='h2-eth0')
    hosts[2].setMAC("00:00:00:00:00:03", intf='h3-eth0')

    switches = net.switches
    switches[0].setMAC("00:00:00:01:00:01", intf='s1-eth1')
    switches[0].setMAC("00:00:00:01:00:02", intf='s1-eth2')
    switches[0].setMAC("00:00:00:01:00:03", intf='s1-eth3')
    switches[0].setMAC("00:00:00:01:00:04", intf='s1-eth4')
    switches[0].setMAC("00:00:00:01:00:05", intf='s1-eth5')

    switches[1].setMAC("00:00:00:02:00:01", intf='s2-eth1')
    switches[1].setMAC("00:00:00:02:00:02", intf='s2-eth2')

    switches[2].setMAC("00:00:00:03:00:01", intf='s3-eth1')
    switches[2].setMAC("00:00:00:03:00:02", intf='s3-eth2')

    switches[3].setMAC("00:00:00:04:00:01", intf='s4-eth1')
    switches[3].setMAC("00:00:00:04:00:02", intf='s4-eth2')

    switches[4].setMAC("00:00:00:05:00:01", intf='s5-eth1')
    switches[4].setMAC("00:00:00:05:00:02", intf='s5-eth2')

    switches[5].setMAC("00:00:00:06:00:01", intf='s6-eth1')
    switches[5].setMAC("00:00:00:06:00:02", intf='s6-eth2')
    switches[5].setMAC("00:00:00:06:00:03", intf='s6-eth3')
    switches[5].setMAC("00:00:00:06:00:04", intf='s6-eth4')

    hosts[0].setIP('10.0.0.1/24',intf='h1-eth0')
    hosts[1].setIP('10.0.0.2/24',intf='h2-eth0')
    hosts[2].setIP('10.0.0.9/24',intf='h3-eth0')

    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    dumpNetConnections(net)
    CLI(net)
    net.stop()
Ejemplo n.º 14
0
def main():
    num_hosts = args.num_hosts
    mode = args.mode

    topo = SingleSwitchTopo(args.behavioral_exe, args.json, args.thrift_port,
                            args.pcap_dump, num_hosts)
    net = Mininet(topo=topo, host=P4Host, switch=DemoSwitch, controller=None)
    net.start()

    def sw_mac(n, p):
        return "00:aa:bb:00:%02x:%02x" % (n, p)

    def sw_addr(n):
        return "10.0.%d.1" % n

    h1 = net.get('h1')
    h2 = net.get('h2')
    h3 = net.get('h3')
    h4 = net.get('h4')
    h1.setARP(sw_addr(0), sw_mac(0, 0))
    h1.setDefaultRoute("dev eth0 via %s" % sw_addr(0))
    h2.setARP(sw_addr(1), sw_mac(1, 1))
    h2.setDefaultRoute("dev eth0 via %s" % sw_addr(1))
    h3.setARP(sw_addr(2), sw_mac(0, 1))
    h3.setDefaultRoute("dev eth0 via %s" % sw_addr(2))
    h4.setARP(sw_addr(3), sw_mac(1, 2))
    h4.setDefaultRoute("dev eth0 via %s" % sw_addr(3))

    s1 = net.get('s1')
    print 's1-eth1 IP = %s' % s1.intf('s1-eth1').IP()
    print 's1-eth2 IP = %s' % s1.intf('s1-eth2').IP()
    for n in xrange(num_hosts):
        h = net.get('h%d' % (n + 1))
        h.describe()

    sleep(5)
    subprocess.call(
        "~/behavioral-model/targets/simple_switch/sswitch_CLI < table_commands1.txt",
        shell=True)
    subprocess.call(
        "~/behavioral-model/targets/simple_switch/sswitch_CLI --thrift-port 9091 < table_commands2.txt",
        shell=True)
    dumpNetConnections(net)
    print "Ready !"
    CLI(net)
    net.stop()
def main():
    "Create and run experiment"
    start = time()

    topo = SimpleTopo()

    # create very simple mininet
    net = Mininet(topo=topo, link=TCLink)

    net.start()

    # increase clients rwnd before anything else
    increase_client_rwnd(net)
    
    # test stuff before starting
    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)

    cprint("*** Testing connectivity", "blue")
    net.pingAll()

   # verify_latency(net) 
    sleep(2)
   # verify_bandwidth(net)

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)

    # start server
    start_server(net)

    #run simple experiment
    run_simple_exp(net, args.numruns)

    # client before and after to track changes
    if args.cli:
        # Run CLI instead of experiment
        CLI(net)

    # end the experiment, output stats
    net.stop()
    end = time()
    cprint("Experiment took %.3f seconds" % (end - start), "yellow")
def main():
    "Create and run experiment"
    start = time()

    topo = SimpleTopo()

    # create very simple mininet
    net = Mininet(topo=topo, link=TCLink)

    net.start()

    # increase clients rwnd before anything else
    increase_client_rwnd(net)

    # test stuff before starting
    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)

    cprint("*** Testing connectivity", "blue")
    net.pingAll()

    # verify_latency(net)
    sleep(2)
    # verify_bandwidth(net)

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)

    # start server
    start_server(net)

    #run simple experiment
    run_simple_exp(net, args.numruns)

    # client before and after to track changes
    if args.cli:
        # Run CLI instead of experiment
        CLI(net)

    # end the experiment, output stats
    net.stop()
    end = time()
    cprint("Experiment took %.3f seconds" % (end - start), "yellow")
Ejemplo n.º 17
0
def main():
    "Create and run experiment"
    start = time()

    topo = MNTopo()

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    sender = net.getNodeByName('sender')
    receiver = net.getNodeByName('receiver')

    print('IP of sender:' + sender.IP())
    print('IP of receiver:' + receiver.IP())

    sender.sendCmd('ping -c 2 ' + receiver.IP())
    result = sender.waitOutput()
    print(result.strip())

    print "*** Dumping network connections:"
    dumpNetConnections(net)

    print "*** Testing connectivity"

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        print "*** Running experiment"


#        run_topology_experiment(net)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    print "Experiment took %.3f seconds" % (end - start)
Ejemplo n.º 18
0
def main():
    "Create and run experiment"
    start = time()
    m = args.n
    topo = RingTopo(n=m)
    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink,
                  bw=args.bw,
                  delay=args.delay,
                  loss=args.loss,
                  max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link, controller=POXBridge)

    net.start()
    for i in range(m):
        net.get('s%s' % (i + 1)).cmd(
            'ovs-vsctl set bridge s%s stp-enable=true' % (i + 1))
        print "start STP on s%s" % (i + 1)
    print "sleep 30s for STP"
    sleep(30)
    print "wake up"
    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)

    cprint("*** Testing connectivity", "blue")

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        cprint("*** Running experiment", "magenta")
        run_parkinglot_expt(net, n=m)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    cprint("Experiment took %.3f seconds" % (end - start), "yellow")
Ejemplo n.º 19
0
def main():
    "Create and run experiment"
    start = time()

    topo = DCellTopo()

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, bw=args.bw, delay='1ms',
                  max_queue_size=20000)
    
    net = Mininet(topo=topo, host=host, link=link, controller=RemoteController, autoStaticArp=True)

    
    for i in range(1, 6):
        for j in range(1, 5):
            h = net.getNodeByName('h'+str(i)+str(j))
            h.setMAC('00:0'+str(i)+':0'+str(j)+':00:00:00')
            h.setIP('10.0.'+str(i)+'.'+str(j))
                
    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)
    
    print "***Run Controller."
    c = raw_input("***Wait untill all switches are connected to controller then press Return...")

   # print "*** Testing connectivity"
   # net.pingAll()
    
    if args.n == 1:
        print "***Runing the link-node failure experiment"
        run_DCell_link_node_failure(net)
    elif args.n == 2:    
        print "***Runing the data transmission experiment"
        run_DCell_data(net)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
Ejemplo n.º 20
0
def main():
    num_hosts = args.num_hosts
    mode = args.mode

    topo = SingleSwitchTopo(
        args.behavioral_exe,
        args.json,
        args.thrift_port,
        False,  #args.pcap_dump,
        num_hosts)
    net = Mininet(topo=topo, host=P4Host, switch=DemoSwitch, controller=None)
    net.start()

    sw_mac = ["00:aa:bb:00:00:%02x" % n for n in xrange(num_hosts)]

    sw_addr = ["10.0.%d.1" % n for n in xrange(num_hosts)]

    for n in xrange(num_hosts):
        h = net.get('h%d' % (n + 1))
        if mode == "l2":
            h.setDefaultRoute("dev eth0")
        else:
            h.setARP(sw_addr[n], sw_mac[n])
            h.setDefaultRoute("dev eth0 via %s" % sw_addr[n])
    s1 = net.get('s1')
    print 's1-eth1 IP = %s' % s1.intf('s1-eth1').IP()
    print 's1-eth2 IP = %s' % s1.intf('s1-eth2').IP()
    for n in xrange(num_hosts):
        h = net.get('h%d' % (n + 1))
        h.describe()

    sleep(1)
    dumpNetConnections(net)
    print "Ready !"

    CLI(net)
    net.stop()
Ejemplo n.º 21
0
def main():
    k = int(args.n)
    topo = FatTreeTopo(k=k)

    host = custom(CPULimitedHost, cpu=.5)  # 15% of system bandwidth
    link = custom(TCLink, bw=args.bw, delay='.05ms',
                  max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link, controller=RemoteController,autoSetMacs=True)

    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)
    raw_args = shlex.split("/home/ubuntu/pox/pox.py riplpox.riplpox --topo=ft,%s --routing=%s" % (k, args.routing))

    proc = Popen(raw_args)

    print "********************************************************"
    print "*******************STARTED RIPLPOX**********************"

    #This sleep 10 is to give the riplpox controller time to start up before you start sending.  Seems to work well.
    sleep(10)


    # 
    # Actual Experiment
    #

    seconds = args.time

    # Start the bandwidth and cwnd monitors in the background
    monitor = Process(target=monitor_devs_ng, 
            args=('%s/bwm.txt' % args.dir, 1.0))
    monitor.start()
    start_tcpprobe()

    # Get receiver and clients
    recvr = net.getNodeByName('0_0_2')
    sender1 = net.getNodeByName('0_0_3')

    # Start the receiver
    port = 5001
    recvr.cmd('iperf -Z reno -s -p', port,
              '> %s/iperf_server.txt' % args.dir, '&')

    waitListening(sender1, recvr, port)

    # TODO: start the sender iperf processes and wait for the flows to finish
    # Hint: Use getNodeByName() to get a handle on each sender.
    # Hint: Use sendCmd() and waitOutput() to start iperf and wait for them to finish
    # iperf command to start flow: 'iperf -c %s -p %s -t %d -i 1 -yc > %s/iperf_%s.txt' % (recvr.IP(), 5001, seconds, args.dir, node_name)
    # Hint (not important): You may use progress(t) to track your experiment progress
    
    for p in range(k):  # Pod Range
        for e in range(2):  # Edge range
            for h in range(2, (k/2)+2):  # Host Range
                if p == 0 and e == 0: 
                    continue
                
                node_name = '_'.join(str(x) for x in [p, e, h])
                sender = net.getNodeByName(node_name)
                sender.sendCmd('iperf -Z reno -c %s -p %s -t %d -i 1 -yc > %s/iperf_%s.txt' % (recvr.IP(), 5001, seconds, args.dir, node_name))
   
    for p in range(k):  # Pod Range
        for e in range(2):  # Edge range
            for h in range(2, (k/2)+2):  # Host Range
                if p == 0 and e == 0: 
                    continue
                node_name = '_'.join(str(x) for x in [p, e, h])
                sender = net.getNodeByName(node_name)
                sender.waitOutput()

    recvr.cmd('kill %iperf')

    # Shut down monitors
    monitor.terminate()
    stop_tcpprobe()





    #Here just use p.terminate() to stop the process when you are done
    net.stop()
    proc.terminate()
Ejemplo n.º 22
0
 def do_net(self, line):
     "List network connections."
     dumpNetConnections(self.mn)
Ejemplo n.º 23
0
def main():
    k = int(args.n)
    topo = FatTreeTopo(k=k)

    host = custom(CPULimitedHost, cpu=.5)  # 15% of system bandwidth
    link = custom(TCLink, bw=args.bw, delay='.05ms', max_queue_size=200)

    net = Mininet(topo=topo,
                  host=host,
                  link=link,
                  controller=RemoteController,
                  autoSetMacs=True)

    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)
    raw_args = shlex.split(
        "/home/ubuntu/pox/pox.py riplpox.riplpox --topo=ft,%s --routing=%s" %
        (k, args.routing))

    proc = Popen(raw_args)

    print "********************************************************"
    print "*******************STARTED RIPLPOX**********************"

    #This sleep 10 is to give the riplpox controller time to start up before you start sending.  Seems to work well.
    sleep(10)

    #
    # Actual Experiment
    #

    seconds = args.time

    # Start the bandwidth and cwnd monitors in the background
    monitor = Process(target=monitor_devs_ng,
                      args=('%s/bwm.txt' % args.dir, 1.0))
    monitor.start()
    start_tcpprobe()

    # Get receiver and clients
    recvr = net.getNodeByName('0_0_2')
    sender1 = net.getNodeByName('0_0_3')

    # Start the receiver
    port = 5001
    recvr.cmd('iperf -Z reno -s -p', port, '> %s/iperf_server.txt' % args.dir,
              '&')

    waitListening(sender1, recvr, port)

    # TODO: start the sender iperf processes and wait for the flows to finish
    # Hint: Use getNodeByName() to get a handle on each sender.
    # Hint: Use sendCmd() and waitOutput() to start iperf and wait for them to finish
    # iperf command to start flow: 'iperf -c %s -p %s -t %d -i 1 -yc > %s/iperf_%s.txt' % (recvr.IP(), 5001, seconds, args.dir, node_name)
    # Hint (not important): You may use progress(t) to track your experiment progress

    for p in range(k):  # Pod Range
        for e in range(2):  # Edge range
            for h in range(2, (k / 2) + 2):  # Host Range
                if p == 0 and e == 0:
                    continue

                node_name = '_'.join(str(x) for x in [p, e, h])
                sender = net.getNodeByName(node_name)
                sender.sendCmd(
                    'iperf -Z reno -c %s -p %s -t %d -i 1 -yc > %s/iperf_%s.txt'
                    % (recvr.IP(), 5001, seconds, args.dir, node_name))

    for p in range(k):  # Pod Range
        for e in range(2):  # Edge range
            for h in range(2, (k / 2) + 2):  # Host Range
                if p == 0 and e == 0:
                    continue
                node_name = '_'.join(str(x) for x in [p, e, h])
                sender = net.getNodeByName(node_name)
                sender.waitOutput()

    recvr.cmd('kill %iperf')

    # Shut down monitors
    monitor.terminate()
    stop_tcpprobe()

    #Here just use p.terminate() to stop the process when you are done
    net.stop()
    proc.terminate()
Ejemplo n.º 24
0
def perfTest():
    '''
    This function runs only when executing the script with python: "sudo python topo_one.py"
    If instead the script is executed like "sudo mn --custom topo_one.py ...." then you can only use the options added to "topos" and "controllers" list, by specifying parameters to the "sudo mn" command.
    '''
    web1="""<!doctype html><html lang=\"en\"><head> <meta charset=\"utf-8\"> <title>VPN 1</title>
         <meta name=\"description\" content=\"Website of VPN1\"> <meta name=\"author\" content=\"Eder Ollora Zaballa\">
         </head><body> <p>Connected to VPN 1</p></body></html>"""

    web2="""<!doctype html><html lang=\"en\"><head> <meta charset=\"utf-8\"> <title>VPN 2</title>
         <meta name=\"description\" content=\"Website of VPN 2\"> <meta name=\"author\" content=\"Eder Ollora Zaballa\">
         </head><body> <p>Connected to VPN 2</p></body></html>"""

    topo = MyTopo()
    net = Mininet(topo=topo,controller=FLController,link=TCLink, listenPort=6634)
   
    switchInterfaces = [3,4,3,4,5,3,4,3,2]
    hostInterfaces = [1,1,1]
    """hostIPs = [
        '10.0.0.1/24',
        '10.0.0.2/24',
        '192.168.1.3/24',
        '10.0.0.2/24',
        '192.168.1.5/24'
        ]"""

    hostIPs = [
        '10.0.0.1/24',
        '10.0.0.2/24',
        '10.0.0.2/24'
        ]

    hosts = net.hosts

    for i,numOfIntfs in enumerate(hostInterfaces):
        for j in range(1,numOfIntfs+1):
            if(i==1 or i==2):
                hosts[i].setMAC('00:00:00:00:0'+str(2)+':0'+str(j), intf='h'+str(i+1)+'-eth'+str(j-1))
            else:
                hosts[i].setMAC('00:00:00:00:0'+str(i+1)+':0'+str(j), intf='h'+str(i+1)+'-eth'+str(j-1))


        #intf = host.defaultIntf()
        hosts[i].setIP(hostIPs[i])
        #host.cmdPrint('ifconfig')
        #host.setDefaultRoute(intf)
        #host.cmdPrint('route')


    switches = net.switches

    for i,numOfIntfs in enumerate(switchInterfaces):
        for intf in range(1,numOfIntfs+1): 
        # +1 because we want to include last number (intfs 1 to 5, include as index 5). 
        # and +1 because we need 1 more for controller
            #print('s'+str(i+1)+'-eth'+str(intf))
            switches[i].setMAC('00:00:00:0'+str(i+1)+':00:0'+str(intf), intf='s'+str(i+1)+'-eth'+str(intf))



    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    dumpNetConnections(net)
    #hosts[1].cmd('mkdir www')
    hosts[1].cmd('cd www')
    #hosts[1].cmd('echo \"'+web2+'\" > index.html')
    hosts[1].cmd('python -m SimpleHTTPServer 80 &')
    #hosts[2].cmd('mkdir www2')
    hosts[2].cmd('cd www2')
    #hosts[2].cmd('echo \"'+web1+'\" > index.html')
    hosts[2].cmd('python -m SimpleHTTPServer 80 &')
    CLI(net)
    net.stop()
Ejemplo n.º 25
0
    h3.setARP(ip='172.16.0.254', mac='00:00:00:00:44:44')
    h3.cmdPrint('cd vm3 && sudo python -m SimpleHTTPServer 80 &')

    h4 = net.getNodeByName('h_vm4')
    h4.cmdPrint('route add default gw 172.16.0.254 h_vm4-eth0')
    h4.setARP(ip='172.16.0.254', mac='00:00:00:00:55:55')
    h4.cmdPrint('cd vm4 && sudo python -m SimpleHTTPServer 80 &')

    os.system("ovs-vsctl del-controller northbound")
    os.system("ovs-vsctl del-controller southbound")

    os.system("sudo ovs-vsctl add-port main to_northbound -- "
              "set interface to_northbound type=patch ofport_request=1 "
              "option:peer=to_main -- "
              "add-port northbound to_main -- "
              "set interface to_main type=patch "
              "option:peer=to_northbound")
    os.system("sudo ovs-vsctl add-port main to_southbound -- "
              "set interface to_southbound type=patch ofport_request=2 "
              "option:peer=to_main2 -- "
              "add-port southbound to_main2 -- "
              "set interface to_main2 type=patch "
              "option:peer=to_southbound")

    os.system("ovs-ofctl add-flows northbound northbound_flows.txt")
    os.system("ovs-ofctl add-flows southbound southbound_flows.txt")

    dumpNetConnections(net)

    CLI(net)
    net.stop()
Ejemplo n.º 26
0
def main(duration_sec,
         delay_sec,
         delay_ms,
         cc_alg,
         results_path,
         interactive=False,
         use_linux_router=True,
         use_asym=False):
    topo = DumbbellTopo(delay_ms=delay_ms,
                        use_linux_router=use_linux_router,
                        use_asym=use_asym)
    net = Mininet(topo=topo, link=TCLink, autoStaticArp=True)
    net.start()

    try:
        if use_asym:
            # Update our access router interfaces to limit their transmit speeds to only 252 Mbps. Note that
            # this has to come after we start the network because during testing it seemed that net.start()
            # reloaded the original bandwidth that was set when the associated link was first created.
            ars = (net["ar1"], net["ar2"])
            ar_neighbors = ((net["s1"], net["s2"], net["bb1"]),
                            (net["r1"], net["r2"], net["bb2"]))

            for ar, neighbors in izip(ars, ar_neighbors):
                for neighbor in neighbors:
                    # This basically returns a list of pairs where for each pair the first item is the
                    # interface on self and the second item is the interface on the node passed to
                    # connectionsTo.
                    #
                    # According to the NIST study, bandwidth on the access router interfaces is 252 Mbps and
                    # queue size is 20% of bandwidth delay product.
                    #
                    ar_iface, _ = ar.connectionsTo(neighbor)[0]
                    ar_iface.config(
                        bw=DumbbellTopo.ACCESS_ROUTER_BANDWIDTH_MBPS,
                        max_queue_size=topo.access_router_queue_size)

        # TCLink ignores any sort of IP address we might specify for non-default interfaces when we are
        # creating links via Topo.addLink. This reassigns the addresses we want for those interfaces on
        # our backbone routers. We also add routing rules to each backbone router so that each router
        # can forward traffic to the subnet they are not directly connected to.
        if use_linux_router:
            net["bb1"].intf("bb1-eth1").setIP("10.0.1.1/24")
            net["bb2"].intf("bb2-eth1").setIP("10.0.2.1/24")
            net["bb1"].cmd(
                "route add -net 10.0.2.0 netmask 255.255.255.0 gw 10.0.0.2 dev bb1-eth0"
            )
            net["bb2"].cmd(
                "route add -net 10.0.1.0 netmask 255.255.255.0 gw 10.0.0.1 dev bb2-eth0"
            )

        info("Dumping host connections\n")
        dumpNodeConnections(net.hosts)

        info("Dumping net connections\n")
        dumpNetConnections(net)

        # Get rid of initial delay in network.
        net.pingAll()

        if interactive:
            CLI(net)
        else:
            # Restart tcp_probe.
            print "Restarting tcp_probe"
            subprocess.call('modprobe -r tcp_probe', shell=True)
            subprocess.call('modprobe tcp_probe full=1', shell=True)

            read_tcp_probe_command = 'dd if=/proc/net/tcpprobe of=%s' % results_path
            subprocess.call('%s &' % read_tcp_probe_command, shell=True)

            try:
                # Run one iperf stream between r1 and s1 and another between r2 and s2.
                print "Running iperf tests"
                print "Sender 1 duration: %d" % duration_sec
                print "Sender 2 duration: %d" % (duration_sec - delay_sec)
                print "Sender 2 delay: %d" % delay_sec

                r1_output = "r1-output-%d-%s.txt" % (delay_ms, cc_alg)
                r2_output = "r2-output-%d-%s.txt" % (delay_ms, cc_alg)
                s1_output = "s1-output-%d-%s.txt" % (delay_ms, cc_alg)
                s2_output = "s2-output-%d-%s.txt" % (delay_ms, cc_alg)

                # 1500 == MTU.
                #iperf_window = DumbbellTopo.ACCESS_ROUTER_BANDWIDTH_PPMS * delay_ms * 1500
                iperf_window = DumbbellTopo.HOST_BANDWIDTH_PPMS * delay_ms * 1500
                print "Iperf window (bytes): %d" % iperf_window

                net["r1"].sendCmd('iperf -s -p 5001 -w %d &> %s' %
                                  (iperf_window, r1_output))
                net["r2"].sendCmd('iperf -s -p 5002 -w %d &> %s' %
                                  (iperf_window, r2_output))

                net["s1"].sendCmd(
                    'iperf -c %s -p 5001 -i 1 -w %d -t %d -Z %s &> %s' %
                    (net["r1"].IP(), iperf_window, duration_sec, cc_alg,
                     s1_output))

                # Delay the second sender by a certain amount and then start it.
                time.sleep(delay_sec)
                net["s2"].sendCmd(
                    'iperf -c %s -p 5002 -i 1 -w %d -t %d -Z %s &> %s' %
                    (net["r2"].IP(), iperf_window, duration_sec - delay_sec,
                     cc_alg, s2_output))

                # Wait for all iperfs to close. On server side, we need to send sentinel to output for
                # waitOutput to return.
                net["s2"].waitOutput()
                net["s1"].waitOutput()

                net["r2"].sendInt()
                net["r2"].waitOutput()

                net["r1"].sendInt()
                net["r1"].waitOutput()
                print "Completed iperf tests"
            finally:
                # Stop tcp_probe.
                print "Stopping tcp_probe"
                subprocess.call('pkill -f "%s"' % read_tcp_probe_command,
                                shell=True)
                subprocess.call('modprobe -r tcp_probe', shell=True)
    finally:
        net.stop()
Ejemplo n.º 27
0
def main():
    host = custom(CPULimitedHost, cpu=.15) # 15% of system bandwidth
    link = custom(TCLink, max_queue_size=500)

    #net = Mininet(host=host, link=link, controller=RemoteController, switch=OVSKernelSwitch)
    net = Mininet(host=host, link=link, controller=DefaultController, switch=OVSKernelSwitch)
    
    print "*** Creating controllers"
    #c1 = RemoteController('c1', ip='127.0.0.1', port=6633)
    #c2 = RemoteController('c2', ip='127.0.0.1', port=6634)
    #c1 = net.addController('c1', controller=RemoteController, ip="127.0.0.1", port=6633)
    #c2 = net.addController('c2', controller=RemoteController, ip="127.0.0.1", port=6634)

    c1 = net.addController('c1')
    c2 = net.addController('c2')

    print "*** Creating switches"
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')

    # Create data transfer machines (DTMs)
    print "*** Creating hosts"
    hostConfig = {'cpu': .25}
    dtm1 = net.addHost('sender',   ip='10.0.0.1', **hostConfig)
    dtm2 = net.addHost('receiver', ip='10.0.0.2', **hostConfig)

    # Add network links
    print "*** Adding links"
    linkConfig = {'bw': args.bw, 'delay': '5ms', 'loss': 0, 'max_queue_size': None}
    net.addLink(dtm1, s1, **linkConfig)
    net.addLink(s1, s2, **linkConfig)
    net.addLink(s2, dtm2, **linkConfig)
    
    # Build the network and start experiment
    print "\n*** Building the network"
    net.build()
    
#    c1.start()
#    c2.start()
    s1.start([ c1 ])
    s2.start([ c2 ])

    net.start()
    start = time()
    
    print "*** Dumping network connections:"
    dumpNetConnections(net)

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

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        iperf_experiment(net)
        transfer_experiment(net, "scp")

    end = time()
    net.stop()

    print "Experiment took %.3f seconds" % (end - start)
def figure5(graph_num):
    "Create and run RTT/bandwidth/BDP experiments, as in figure 5"
    start = time()

    abs_improvs = []
    pct_improvs = []
    variables = []
    
    title = 'Figure %d' % graph_num
    filename = 'figure%d' % graph_num
    x_units = 'x units'
    y_units = 'y units'

    if graph_num == 1:
        x_units = 'RTT (ms)'
        y_units = 'Improvement (ms)'
        variables = [20, 50, 100, 200, 500, 1000, 3000]
    elif graph_num == 2:
        x_units = 'Bandwidth (kbps)'
        y_units = 'Improvement (ms)'
        variables = [56, 256, 512, 1000, 2000, 3000, 5000, 10000]
        #variables = [3000, 5000, 10000]
    elif graph_num == 3:
        x_units = 'BDP (bytes)'
        y_units = 'Improvement (ms)'
        # tuples are (B/W (KiloBytes per second), RTT (ms))
	# The paper says BDP is in bytes, so it must be the case that its KB
        variables = [(20, 50), (50, 100), (100, 100), (250, 200), (250, 400)]
        #variables = [(50, 100), (100, 100), (250, 200), (250, 400)]
    elif graph_num == 4:
        variables = [1] #dummy var

    for var in variables:

        if graph_num == 1:
            cprint("Testing network with a RTT of %s" % var, "blue")
            topo = SimpleTopo(delay='%dms' % (var/2))
        elif graph_num == 2:
            cprint("Testing network with bottleneck bandwidth of %f kbps" % var, "blue")
            topo = SimpleTopo(bw = var/1000.0)
        elif graph_num == 3:
            cprint("Testing network with bottleneck bandwidth of %f kbps" % var[0], "blue")
            cprint("and a RTT of %d ms" % var[1], "blue")
            delay = "%dms" % (var[1]/2)
            topo = SimpleTopo(bw = var[0]/125.0, delay=delay) #make sure its KBps, not Kbps
        elif graph_num == 4:
            topo = SimpleTopo() #use default args

        # create very simple mininet
        net = Mininet(topo=topo, link=TCLink)
        net.start()

        # increase clients rwnd before anything else
        increase_client_rwnd(net)

    	if args.cli:
            # Run CLI before experiment
            CLI(net)

        # test stuff before starting
        cprint("*** Dumping network connections:", "green")
        dumpNetConnections(net)

        cprint("*** Testing connectivity", "blue")
        net.pingAll()

        # start server
        start_server(net)

        # run experiement
        if graph_num == 4:
            run_figure7_exp(net, args.numruns)
            return # terminate experiment
        else:
            (abs_i, pct_i) = run_simple_exp(net, args.numruns)

        # end this instance of mininet
        net.stop()

        abs_improvs.append(abs_i)
        pct_improvs.append(pct_i)

    end = time()
    cprint("Experiment took %.3f seconds" % (end - start), "yellow")

    # fixup the bdp x-axis before we graph if we are testing bdp
    if graph_num == 3:
        variables = [1000, 5000, 10000, 50000, 100000]

    save_graph(variables, abs_improvs, pct_improvs, title, x_units, y_units,filename)
def figure5(graph_num):
    "Create and run RTT/bandwidth/BDP experiments, as in figure 5"
    start = time()

    abs_improvs = []
    pct_improvs = []
    variables = []

    title = 'Figure %d' % graph_num
    filename = 'figure%d' % graph_num
    x_units = 'x units'
    y_units = 'y units'

    if graph_num == 1:
        x_units = 'RTT (ms)'
        y_units = 'Improvement (ms)'
        variables = [20, 50, 100, 200, 500, 1000, 3000]
    elif graph_num == 2:
        x_units = 'Bandwidth (kbps)'
        y_units = 'Improvement (ms)'
        variables = [56, 256, 512, 1000, 2000, 3000, 5000, 10000]
        #variables = [3000, 5000, 10000]
    elif graph_num == 3:
        x_units = 'BDP (bytes)'
        y_units = 'Improvement (ms)'
        # tuples are (B/W (KiloBytes per second), RTT (ms))
        # The paper says BDP is in bytes, so it must be the case that its KB
        variables = [(20, 50), (50, 100), (100, 100), (250, 200), (250, 400)]
        #variables = [(50, 100), (100, 100), (250, 200), (250, 400)]
    elif graph_num == 4:
        variables = [1]  #dummy var

    for var in variables:

        if graph_num == 1:
            cprint("Testing network with a RTT of %s" % var, "blue")
            topo = SimpleTopo(delay='%dms' % (var / 2))
        elif graph_num == 2:
            cprint(
                "Testing network with bottleneck bandwidth of %f kbps" % var,
                "blue")
            topo = SimpleTopo(bw=var / 1000.0)
        elif graph_num == 3:
            cprint(
                "Testing network with bottleneck bandwidth of %f kbps" %
                var[0], "blue")
            cprint("and a RTT of %d ms" % var[1], "blue")
            delay = "%dms" % (var[1] / 2)
            topo = SimpleTopo(bw=var[0] / 125.0,
                              delay=delay)  #make sure its KBps, not Kbps
        elif graph_num == 4:
            topo = SimpleTopo()  #use default args

        # create very simple mininet
        net = Mininet(topo=topo, link=TCLink)
        net.start()

        # increase clients rwnd before anything else
        increase_client_rwnd(net)

        if args.cli:
            # Run CLI before experiment
            CLI(net)

        # test stuff before starting
        cprint("*** Dumping network connections:", "green")
        dumpNetConnections(net)

        cprint("*** Testing connectivity", "blue")
        net.pingAll()

        # start server
        start_server(net)

        # run experiement
        if graph_num == 4:
            run_figure7_exp(net, args.numruns)
            return  # terminate experiment
        else:
            (abs_i, pct_i) = run_simple_exp(net, args.numruns)

        # end this instance of mininet
        net.stop()

        abs_improvs.append(abs_i)
        pct_improvs.append(pct_i)

    end = time()
    cprint("Experiment took %.3f seconds" % (end - start), "yellow")

    # fixup the bdp x-axis before we graph if we are testing bdp
    if graph_num == 3:
        variables = [1000, 5000, 10000, 50000, 100000]

    save_graph(variables, abs_improvs, pct_improvs, title, x_units, y_units,
               filename)