Example #1
1
def main():
    seconds = int(args.t)
    topo = LineTopo(n=args.n, bw=args.bw)
    net = Mininet(topo=topo,switch=Switch, host=CPULimitedHost, link=TCLink)
    net.start()
    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')
    h1.sendCmd('ifconfig')
    h1.waitOutput()
    for p in xrange(args.parallel):
        h2 = net.getNodeByName('h%d' % (2*p+2))
        h2.sendCmd('iperf -s')
    clients = []
    for p in xrange(args.parallel):
        h1 = net.getNodeByName('h%d' % (2*p+1))
        h2 = net.getNodeByName('h%d' % (2*p+2))
        if args.proto == "udp":
            cmd = 'iperf -c %s -t %d -i 1 -u -b %sM > %s/iperf_%s.txt' % (h2.IP(), seconds, args.bw, args.dir, 'h%d' % (2*p+1))
        else:
            cmd = 'iperf -c %s -t %d -i 1 > %s/iperf_%s.txt' % (h2.IP(), seconds, args.dir, 'h%d' % (2*p+1))
        h1.sendCmd(cmd)

    progress(seconds)
    #CLI(net)
    Popen("killall -9 top bwm-ng", shell=True).wait()
    net.stop()
Example #2
0
def topoTest():
    topo = Topo2()
    net = Mininet(topo = topo,controller = lambda name : RemoteController(name, ip = '192.168.42.1'),link = TCLink, switch = OVSSwitch)
    serverList = []
    c = net.getNodeByName('c0')
    for i in range(1, 17):
        serverName = 'hs'+ str(i)
        serverList.append(net.getNodeByName(serverName))
    clientList = []
    for i in range(1, 65):
        clientName = 'hc'+ str(i)
        clientList.append(net.getNodeByName(clientName))
    

    it1List = []
    it2List = []
    cIpList = []
    sIpList = []
    
    for i in range(16):
        server = serverList[i]
        link = server.linkTo(c)
        i1 = link.intf1
        i2 = link.intf2
        sIp = '123.123.123.' + str(i)
        cIp = '125.125.125.' + str(i)
        #msk = '255.255.255.255'
        sIpList.append(sIp)
        cIpList.append(cIp)
        it1List.append(i1)
        it2List.append(i2)
        server.setIP(sIp, 8, i1)
        c.setIP(cIp, 8, i2)
        server.cmd('route add -net ' + cIp + ' netmask 255.255.255.255' + ' dev' + str(i1))
        #c.cmd('route add -net ' + sIp + ' dev' + str(i2))
    net.start()
    for i in range(16):
        server = serverList[i]
        sIp = sIpList[i]
        cIp = cIpList[i]
        it1 = it1List[i]
        it2 = it2List[i]
        #print str(server) + "," + str(ip) + "," + str(it)
        server.cmd('route del -net ' + '123.0.0.0' + ' netmask 255.0.0.0  dev ' + str(it1))
        server.cmd('route add -net ' + cIp + ' netmask 255.255.255.255  dev ' + str(it1))
        c.cmd('route del -net ' + '125.0.0.0' ' netmask 255.0.0.0  dev ' + str(it2))
        c.cmd('route add -net ' + sIp + ' netmask 255.255.255.255  dev ' + str(it2))
        
        server.cmd('cd ~/proj/host/mongoose')
        server.cmd('./mongoose ' + str(i + 1) + ' 125.125.125.' + str(i) + ' &')

    #Test Cases
    for i in range(64):
        client = clientList[i]
        client.cmd('cd ~/proj/host')
        client.cmd('./test.sh &')
        time.sleep(2)

    CLI(net)
    net.stop()
Example #3
0
def topoTest():
  topo = Topo2()
  net = Mininet(topo = topo,controller = lambda name : RemoteController(name, defaultIP = '192.168.42.1'), link = TCLink, switch = OVSSwitch)
  c0 = net.getNodeByName('c0')

  s1 = net.getNodeByName('h7')
  l1 = s1.linkTo(c0)
  i1 = l1.intf1
  i2 = l1.intf2
  s1.setIP('123.123.123.1', 8, i1)
  c0.setIP('123.123.125.1', 8, i2)

  s2 = net.getNodeByName('h8')
  l1 = s2.linkTo(c0)
  i11 = l1.intf1
  i22 = l1.intf2
  s2.setIP('123.123.123.2', 8, i1)
  c0.setIP('123.123.125.2', 8, i2)

  net.start()
  s1.cmd('route add -net 123.123.125.1 netmask 255.255.255.255 dev ' + str(i1))
  s1.cmd('route add -net 123.123.125.1 netmask 255.255.255.255 dev ' + str(i1))
  s2.cmd('route add -net 123.123.125.2 netmask 255.255.255.255 dev ' + str(i11))  s2.cmd('route add -net 123.123.125.2 netmask 255.255.255.255 dev ' + str(i11))

  CLI(net)
  net.stop()
def small_test():
    topo = Rect()
    net = Mininet(topo=topo, switch=UserSwitch, controller=lambda name:RemoteController(name, ip=ip), listenPort=port)
    print len(net.hosts)
    net.start()
    print "mininet started" 
    sleep(15) 
    print "iperf test start"
    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')
    h3 = net.getNodeByName('h3')
    #setup all servers
    print "server start"
    iperf_server(h2)
    #h3.cmd('iperf -s');
    #setup all clients
    print "client start"
    iperf_client(h1, h2, 10)
    print "ping start"
    ping_client(h1, h2, 10)
    #h1.cmd('iperf -c ', h3.IP(), ' -t 10 -i 1')
    sleep(3)
    add_policy('{"rules":[{"ip-dst":"10.0.0.2"}], "speed":1}')
    sleep(3)
    delete_policy('{"rules":[{"ip-dst":"10.0.0.2"}], "speed":1}')
    sleep(7)
    print "iperf test end"
    net.stop()
Example #5
0
def run_cellsim_topology(qdisc, random_seed):
    print_welcome_message()

    os.system( "killall -q controller" )
    os.system( "killall -q cellsim" )
    os.system( "killall -q datagrump-sender" )
    os.system( "killall -q datagrump-receiver" )
    os.system( "service apache2 stop" )
    os.system( "killall -q apache2" )
    os.system( "killall -q on-off.py")

    topo = ProtoTester()
    net = Mininet(topo=topo, host=Host, link=Link)
    net.start()

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

    set_all_IP(net, sender, LTE, receiver)
    
    #Dump connections
    #dumpNodeConnections(net.hosts)
    #display_routes(net, sender, LTE, receiver)

    run_apache(sender)
    run_flowrequestr(receiver, random_seed)

    run_cellsim(LTE, qdisc)

#    CLI(net)

    net.stop()
def run_cellsim_topology():
    print_welcome_message()

    os.system( "killall -q controller" )
    os.system( "killall -q cellsim" )
    os.system( "killall -q mysender" )
    os.system( "killall -q myreceiver" )

    topo = ProtoTester()
    net = Mininet(topo=topo, host=Host, link=Link)
    net.start()

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

    set_all_IP(net, sender, LTE, receiver)

    #Dump connections
    #dumpNodeConnections(net.hosts)
    #display_routes(net, sender, LTE, receiver)
    
    #run_cellsim(LTE)
    run_datagrump(sender, receiver)

    run_cellsim(LTE)

#    CLI(net)

    net.stop()
Example #7
0
def simpleTest():
   "Create and test a simple network"
   topo = DiamondTopo(k=4)
   net = Mininet(topo=topo,link=TCLink,controller=RemoteController)
   if args.sim!=1:
        print "Adding real interfaces" 
   	s1 = net.getNodeByName('s1')
   	s3 = net.getNodeByName('s3')
   	addRealIntf(net,args.intf1,s1)
   	addRealIntf(net,args.intf2,s3)
   	opts = '-D -o UseDNS=no -u0'
   	rootnode=sshd(net, opts=opts)
	h2 = net.getNodeByName('h2')
   	h2.cmd('iperf -s -p 5001 -i 1 > iperf-recv_TCP.txt &')
   	h2.cmd('iperf -s -p 5003 -u -i 1 > iperf-recv_UDP.txt &')
   else:
   	net.start()
   CLI(net)

   os.system('killall -9 iperf' )
   
   if args.sim!=1:
	net.hosts[0].cmd('killall -9 dhcpd')   
	for host in net.hosts:
       		host.cmd('kill %'+ '/usr/sbin/sshd')
   	stopNAT(rootnode)
   net.stop()
Example #8
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()
def inicializaRed():
    "Create network and run simple performance test"
    topo = MyTopo()
    net = Mininet(topo=topo, link=TCLink, controller=RemoteController)
    net.start()
    print "*** Pruebas en h1"
    switches = net.getNodeByName('I1', 's2', 'E3', 'E4')
    for i in switches:
        for j in i.intfNames()[1:]:
            if j in ['s2-eth2', 's3-eth3']:
                continue
            #if j in ['s1-eth3', 's3-eth2', 's3-eth4', 's4-eth5', 's2-eth3', 's4-eth3']:
            cmd  = 'ovs-vsctl -- set port ' + j + ' qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=1500000\
                    queues:0=@newqueue -- --id=@newqueue create queue other-config:min-rate=1000 other-config:max-rate=1500000'
            cmd2 = 'ovs-vsctl -- set port ' + j + ' qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=1500000\
                    queues:1=@newqueue -- --id=@newqueue create queue other-config:min-rate=1500000 other-config:max-rate=1500000'
            cmd3 = 'ovs-vsctl -- set Port ' + j + ' qos=@newqos\
                    -- --id=@newqos create QoS type=linux-htb  other-config:max-rate=3000000 queues=0=@q0,1=@q1\
                    -- --id=@q0 create Queue other-config:min-rate=2300000 other-config:max-rate=2800000\
                    -- --id=@q1 create Queue other-config:min-rate=80000   other-config:max-rate=1500000'
            #cmd4 = 'tc class change dev ' + j + ' parent 1:fffe classid 1:1 htb rate 1kbit ceil 1500kbit burst 1563b cburst 1563b'
            #i.cmd(cmd)                   # Usar i.cmdPrint(cmd) para imprimir el resultado
            #i.cmd(cmd2)
            i.cmd(cmd3)
            #i.cmdPrint(cmd4)
    #for i in switches:
        #for j in i.intfNames()[1:]:
            #cmd4 = 'tc class change dev ' + j + ' parent 1:fffe classid 1:1 htb rate 1kbit ceil 770kbit burst 1563b cburst 1563b'
            #i.cmd(cmd4)
            #for k in [1, 2]:
            #   cmd5 = 'tc qdisc add dev ' + j +' parent 1:' + str(k) + ' handle ' + str(k) + '0: sfq perturb 10'
            #   i.cmd(cmd5)

#def testQoS():
    h1 = net.getNodeByName('h1')
    h5 = net.getNodeByName('h5')
    print 'Waiting for topology recognition ...'
    h1.cmd('sleep 12')
    print 'Initiating clients at h5, h6 and h8 (SMART) ...'
    h5.cmd('source ~/Documents/mininet_scripts/tests1/client1.sh &')
    h5.cmd('sleep 2')
    h5.cmd('source ~/Documents/mininet_scripts/tests1/client2.sh &')
    h5.cmd('sleep 2')
    h5.cmd('source ~/Documents/mininet_scripts/tests1/client3_SMART.sh &')
    print 'Initiating servers at h1 ...'
    h5.cmd('sleep 2')
    h1.cmd('source ~/Documents/mininet_scripts/tests1/server1.sh &')
    h5.cmd('sleep 1')
    h1.cmd('source ~/Documents/mininet_scripts/tests1/server2.sh &')
    h5.cmd('sleep 1')
    h1.cmd('source ~/Documents/mininet_scripts/tests1/server3_SMART.sh')
    print 'Experiment finished.'
    #CLI(net)
    net.stop()
Example #10
0
def startNetworkWithLinearTopo( hostCount ):
    global net
    net = Mininet(topo=LinearTopo(hostCount), build=False)

    remote_ip = getControllerIP()
    info('** Adding Floodlight Controller\n')
    net.addController('c1', controller=RemoteController,
                      ip=remote_ip, port=6653)

    # Build the network
    net.build()
    net.start()

    # Start L3 Routing
    ret = enableL3Routing()
    print (ret)

    ret = addVirtualGateway('mininet-gateway-1')
    print (ret)

    ret = addInterfaceToGateway('mininet-gateway-1')
    print (ret)

    ret = addNodePortTupleToGateway('mininet-gateway-1')
    print (ret)

    # Need to configure default gw for host
    host1 = net.getNodeByName('h1')
    host1.setIP('10.0.0.10', prefixLen=24)
    defaultGatewayIP1 = "10.0.0.1"
    configureDefaultGatewayForHost(host1, defaultGatewayIP1)

    host2 = net.getNodeByName('h2')
    host2.setIP('20.0.0.10', prefixLen=24)
    defaultGatewayIP2 = "20.0.0.1"
    configureDefaultGatewayForHost(host2, defaultGatewayIP2)

    host3 = net.getNodeByName('h3')
    host3.setIP('30.0.0.10', prefixLen=24)
    defaultGatewayIP3 = "30.0.0.1"
    configureDefaultGatewayForHost(host3, defaultGatewayIP3)

    host4 = net.getNodeByName('h4')
    host4.setIP('40.0.0.10', prefixLen=24)
    defaultGatewayIP4 = "40.0.0.1"
    configureDefaultGatewayForHost(host4, defaultGatewayIP4)

    host5 = net.getNodeByName('h5')
    host5.setIP('50.0.0.10', prefixLen=24)
    defaultGatewayIP5 = "50.0.0.1"
    configureDefaultGatewayForHost(host5, defaultGatewayIP5)
Example #11
0
def Test():
   "Create network and run simple performance test"
   topo = SimpleTopo(k=2)
   net = Mininet(topo=topo,
                 host=CPULimitedHost, link=TCLink)#, controller=RemoteController)
   s1 = net.getNodeByName('s1')
   s2 = net.getNodeByName('s2')
   if args.intf1 is not None:
	addRealIntf(net,args.intf1,s1)
   if args.intf2 is not None:
   	addRealIntf(net,args.intf2,s2)
#   net.start()
   opts = '-D -o UseDNS=no -u0'

#' '.join( sys.argv[ 1: ] ) if len( sys.argv ) > 1 else (
   rootnode=sshd(net, opts=opts)
#   print "Dumping host connections"
   dumpNodeConnections(net.hosts)
    
#   net.pingAll()
   h2 = net.getNodeByName('h2')
#   dhcp = net.getNodeByName('dhcp')
#   out = dhcp.cmd('sudo dhcpd')
#   print "DHCPD = "+ out
   #h1.cmd("bash tc_cmd_diff.sh h1-eth0")
   #h1.cmd("tc -s show dev h1-eth0")
   h2.cmd('iperf -s -p 5001 -i 1 > iperf-recv_TCP.txt &')
   h2.cmd('iperf -s -p 5003 -u -i 1 > iperf-recv_UDP.txt &')
   #h2.cmd('iperf -s -p %s -i 1 > iperf_server_TCP.txt &' % 5001)
#               (CUSTOM_IPERF_PATH, 5001, args.dir))
   #monitoring the network
  #monitor = Process(target=monitor_qlen,
                     #args=("%s"%args.iface,float(args.sampleR),int(args.nQ), "%s_%s"% (args.exp,args.out)))   
       

   for host in net.hosts:
       #host.cmd('tc qdisc del dev %s-eth0 root'%host)              
       #host.cmd('tc qdisc add dev %s-eth0 root tbf rate 10Mbit latency 2s burst 15k mtu 1512'%host)              
       host.cmd('ethtool -K %s-eth0 tso off gso off ufo off'%host)
   #start mininet CLI
   CLI(net)
   #terminate
   for host in net.hosts:
       host.cmd('kill %'+ '/usr/sbin/sshd')
   os.system('killall -9 iperf' )
   net.hosts[0].cmd('killall -9 dhcpd')
   stopNAT(rootnode)
   net.stop()

   Popen("killall -9 cat", shell=True).wait()
def general_rule_test():
    topo = FatTreeTopo()
    net = Mininet(topo=topo, switch=UserSwitch, controller=lambda name:RemoteController(name, ip=ip), listenPort=port)
    print len(net.hosts)
    net.start()
    print "mininet started" 
    sleep(15) 
    print "iperf test start"
    add_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}, {"ip-src":"10.2.1.2"}, {"ip-src":"10.3.1.3"}], "speed":30}')
    h1 = net.getNodeByName('0_0_2')
    h2 = net.getNodeByName('0_0_3')
    h3 = net.getNodeByName('0_1_2')
    h4 = net.getNodeByName('0_1_3')
    h5 = net.getNodeByName('1_0_2')
    h6 = net.getNodeByName('1_0_3')
    h7 = net.getNodeByName('2_1_2')
    h8 = net.getNodeByName('3_1_3')
    #setup all servers
    print "server start"
    iperf_server_tcp(h5)
    iperf_server_tcp(h6)
    iperf_server_tcp(h3)
    #iperf_server_tcp(h4)
    #setup all clients
    print "client start"
    sleep(10)
    iperf_client_tcp(h1, h5, 30, '2K')
    ping_client(h1, h5, 30)
    sleep(10)
    iperf_client_tcp(h2, h6, 20, '2K')
    ping_client(h2, h6, 20)
    sleep(10)
    iperf_client_tcp(h7, h3, 10, '2K')
    ping_client(h7, h3, 10)
    #iperf_client_tcp(h8, h4, 60, '2K')
    print "ping start"
    #ping_client(h8, h4, 60)
    #h1.cmd('iperf -c ', h3.IP(), ' -t 10 -i 1')
    #sleep(10)
    #add_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}, {"ip-src":"10.2.1.2"}, {"ip-src":"10.3.1.3"}], "speed":50}')
    #sleep(10)
    #add_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}], "speed":10}')
    #sleep(10)
    #delete_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}], "speed":10}')
    #sleep(10)
    #delete_policy('{"rules":[{"ip-src":"10.0.0.2"}, {"ip-src":"10.0.0.3"}, {"ip-src":"10.2.1.2"}, {"ip-src":"10.3.1.3"}], "speed":50}')
    sleep(20)
    print "iperf test end"
    net.stop()
Example #13
0
def main(logFile, depth, uMin, uMax, runtime, seeding, cli):

    # create residential WiFi topology
    mytopo = MnTopo(depth, uMin, uMax, seeding)

    # create & start Mininet
    net = Mininet(topo=mytopo, controller=None, link=TCLink, autoStaticArp=True)
    net.addController(Controller('c0'))
    net.start()
    # assign IP addresses to interfaces
    linklist = mytopo.links(sort=True)
    linklist.reverse()

    idx = 1
    while linklist:
        item = linklist.pop()
        if re.match("gsw\d", item[1]):
            apid = re.findall(r'\d+',item[0])[0]
            swid = str(int(re.findall(r'\d+',item[1])[0]))
            net.getNodeByName(item[0]).setIP("192.168.%s.%s/24" % (swid, str(int(apid)+1)), intf="ap%s-eth%s" % (apid, idx))
            idx += 1
        else:
            idx = 1

    if cli == 1:
        CLI( net )
    time.sleep(10)
    nodelist = mytopo.nodes(sort=True)
    no_nodes = 0
    while nodelist:
        item = nodelist.pop()
        if re.match("ap\d", item):
            with open("measurements/stdout" + item + ".txt","wb") as out, open("measurements/stderr" + item + ".txt","wb") as err:
                time.sleep(5)
                net.getNodeByName(item).popen("python ../resfi_loader.py -r %s" % runtime, stdout=out, stderr=err)
                no_nodes = no_nodes + 1

    print "script running. please wait."

    # wait until end time is reached
    start = datetime.datetime.now()
    while True:
        now = datetime.datetime.now()
        if (now - start).seconds < runtime:
            time.sleep(0.5)
        else:
            break

    net.stop()
def createTopo():
    "Creating network"
    
    topo = SwitchHostTopo()
    net = Mininet(topo=topo, 
                  controller=OVSController, link=TCLink)
    net.start()
    print "Testing network connectivity"
    net.pingAll()

    print "Testing bandwidth between odd hosts"
    net.iperf((net.getNodeByName(hosts_array[0]), net.getNodeByName(hosts_array[2])))
    print "Testing bandwidth between even hosts"
    net.iperf((net.getNodeByName(hosts_array[1]), net.getNodeByName(hosts_array[3])))
    net.stop()
Example #15
0
def topoTest():
  topo = Topo2()
  net = Mininet(topo = topo,controller = RemoteController, link = TCLink, switch = OVSSwitch)
  net.start()
  hc1, hc2, hc3, hc4, hc5, hc6, hs1, hs2, hs3 = net.getNodeByName('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8', 'h9')
  servers = [hs1, hs2, hs3]
  clients = [hc1, hc2, hc3, hc4, hc5, hc6]
  filenames = ['test1.dat', 'test2.dat', 'test3.dat', 'test4.dat', 'test5.dat']
  for server in servers:
    result = server.cmd('cd ~/proj/host/mongoose/')
    server.cmd('./mongoose &')
  timeList = []
  for filename in filenames:
    downloadTime = []
    for i in range(2):
      for client in clients:
        client.cmd('cd ~/proj/host/')
        wgetCmd = 'wget 10.0.0.10:8080/cs258/' + filename
        result = client.cmd(wgetCmd).split('\n')
        for line in result:
           if line.find('saved') != -1 or line.find('100%') != -1:
            if line.find('100%') != -1:
              start = line.find('=')
              if start != -1:
                downloadTime.append(float(line[start+1: start+4]))
              print client.IP()
            print line
    print downloadTime
    avg = sum(downloadTime)/len(downloadTime)
    timeList.append(avg)
  print timeList
  net.stop()
Example #16
0
def run_net_model_1():
	topo = NetModel_1_topo()
	netopts = dict( topo = topo, controller = RemoteController, link = TCLink, autoSetMacs = True, autoStaticArp = True, cleanup = True)
	
	print "***Starting NetModel_1 configuration..."
	net = Mininet (**netopts)
	net.start()
	
	srv1 = net.getNodeByName("srv1")
	srv2 = net.getNodeByName("srv2")    
	
	print "***Starting UDP Server..."
	srv1.cmd('iperf --single_udp -s -u &')
	srv2.cmd('iperf --single_udp -s -u &')
    
	srv1_udp_pid = int( srv1.cmd('echo $!') )
	srv2_udp_pid = int( srv2.cmd('echo $!') )
	print "UDP Server started on srv1 with PID ", srv1_udp_pid
	print "UDP Server started on srv2 with PID ", srv2_udp_pid
    
	print "***Starting TCP Server..."
	srv1.cmd('iperf -s  &')
	srv2.cmd('iperf -s  &')
	srv1_tcp_pid = int(srv1.cmd('echo $!'))
	srv2_tcp_pid = int(srv2.cmd('echo $!'))
	print "TCP Server started on srv1 with PID ", srv1_tcp_pid
	print "TCP Server started on srv2 with PID ", srv2_tcp_pid
    
	print "Running CLI..."
	CLI(net)
	
	print "Killing mininet..."
	cleaner.cleanup()
Example #17
0
def bbnet():
    "Create network and run Buffer Bloat experiment"
    print "starting mininet ...."
    # Seconds to run iperf; keep this very high
    seconds = 3600
    start = time()
    # Reset to known state
    topo = StarTopo(n=args.n, bw_host=args.bw_host,
                    delay='%sms' % args.delay,
                    bw_net=args.bw_net, maxq=args.maxq, diff=args.diff)
    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink,
                  autoPinCpus=True, controller=OVSController)
    net.start()
    dumpNodeConnections(net.hosts)
    net.pingAll()
    print args.diff
    if args.diff:
        print "Differentiate Traffic Between iperf and wget"
        os.system("bash tc_cmd_diff.sh")
    else:
        print "exec tc_cmd.sh"
        os.system("bash tc_cmd.sh %s" % args.maxq)
    sleep(2)
    ping_latency(net)
    print "Initially, the delay between two hosts is around %dms" % (int(args.delay)*2)
    h2 = net.getNodeByName('h2')
    h1 = net.getNodeByName('h1')
    h1.cmd('cd ./http/; nohup python2.7 ./webserver.py &')
    h1.cmd('cd ../')
    h2.cmd('iperf -s -w 16m -p 5001 -i 1 > iperf-recv.txt &')
    CLI( net )
    h1.cmd("sudo pkill -9 -f webserver.py")
    h2.cmd("rm -f index.html*")
    Popen("killall -9 cat", shell=True).wait()
Example #18
0
def perfTest():
	topo = MyTopo()
	net = Mininet(topo=topo)
	dumpNodeConnections(net.hosts)
	h1, h2 = net.getNodeByName('h1', 'h2')	
	
	@route('/cmd/<node>/<cmd>')
	def cmd( node='h1', cmd='hostname' ):
    		out, err, code = net.get( node ).pexec( cmd )
    		return out + err
	
	@route('/stop')
	def stop():
		net.stop()

	@route('/run_http_client')
	def function():	
		result = h2.cmd('curl -o /dev/null -s -S -w data=%{url_effective},%{time_total},%{time_starttransfer},%{size_download},%{speed_download}\\n http://h1/getsize.py?length=6856')
		print result
		return 
	
	@route('/goto_cli')
	def function():
		CLI(net)
		print "stopping"
		net.stop()
		return 0

	net.start()
	run(host='localhost', port=8080 )
def inicializaRed():
    "Create network and run simple performance test"
    topo = MyTopo()
    net = Mininet(topo=topo, link=TCLink, controller=RemoteController)
    net.start()
    print "*** Pruebas en h1"
    switches = net.getNodeByName('I1', 's2', 'E3', 'E4')
    for i in switches:
        for j in i.intfNames()[1:]:
            if j in ['s2-eth2', 's3-eth3']:
                continue
            #if j in ['s1-eth3', 's3-eth2', 's3-eth4', 's4-eth5', 's2-eth3', 's4-eth3']:
            cmd  = 'ovs-vsctl -- set port ' + j + ' qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=1500000\
                    queues:0=@newqueue -- --id=@newqueue create queue other-config:min-rate=1000 other-config:max-rate=1500000'
            cmd2 = 'ovs-vsctl -- set port ' + j + ' qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=1500000\
                    queues:1=@newqueue -- --id=@newqueue create queue other-config:min-rate=1500000 other-config:max-rate=1500000'
            cmd3 = 'ovs-vsctl -- set Port ' + j + ' qos=@newqos\
                    -- --id=@newqos create QoS type=linux-htb  other-config:max-rate=3000000 queues=0=@q0,1=@q1\
                    -- --id=@q0 create Queue other-config:min-rate=1800000 other-config:max-rate=2000000\
                    -- --id=@q1 create Queue other-config:min-rate=80000   other-config:max-rate=1500000'
            #cmd4 = 'tc class change dev ' + j + ' parent 1:fffe classid 1:1 htb rate 1kbit ceil 1500kbit burst 1563b cburst 1563b'
            #i.cmd(cmd)                   # Usar i.cmdPrint(cmd) para imprimir el resultado
            #i.cmd(cmd2)
            i.cmd(cmd3)
            #i.cmdPrint(cmd4)
    #for i in switches:
        #for j in i.intfNames()[1:]:
            #cmd4 = 'tc class change dev ' + j + ' parent 1:fffe classid 1:1 htb rate 1kbit ceil 770kbit burst 1563b cburst 1563b'
            #i.cmd(cmd4)
            #for k in [1, 2]:
            #   cmd5 = 'tc qdisc add dev ' + j +' parent 1:' + str(k) + ' handle ' + str(k) + '0: sfq perturb 10'
            #   i.cmd(cmd5)
    CLI(net)
    net.stop()
def test_relsend():
    "Create network and run reliable transport experiment"
    print "starting mininet ...."
    seconds = 3600
    start = time()
    # Reset to known state
    topo = StarTopo( bw_host=args.bw_host,
                    delay='%sms' % args.delay,
					loss='%s' % args.loss,
                   maxq=args.maxq)
    print 'Loss is %s, delay is %s, case is %s' % (args.loss, args.delay, args.case)
    net = Mininet(topo=topo, link=TCLink)
                  
    net.start()
    h2 = net.getNodeByName('h2')
    h1 = net.getNodeByName('h1')
    h1ip = h1.IP()
    h2ip = h2.IP()
    print "running experiment"
    now = time()
    h1.cmd('./hw6_receiver 5000 > RECVD_FILE_%s 2> /dev/null &' % args.case)
    h2.cmd('cat 1000lines | ./hw6_sender %s 5000 2> sender_output &' % h1ip)
    h2.cmd('wait')
    elapsed = time() - now
    print "finished experiment in %s sec"%  str(elapsed)
    resultmd5 = h1.cmd('md5sum output.h1').split()[0]
    print "resulting file has md5 sum %s" % resultmd5
    h1.cmd('kill %hw6_receiver')
    h2.cmd('kill %hw6_sender')

    # this will drop you to a mininet shell if you need it
    # CLI( net )    
    net.stop()
def inicializaRed():
    "Create network and run simple performance test"
    topo = MyTopo()
    #net = Mininet(topo=topo, link=TCLink, controller=RemoteController)
    net = Mininet(topo=topo, link=TCLink)
    net.start()
    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')
                
    print '*** cleaning'
    h1.cmdPrint('killall -9 ccn-lite-relay >/dev/null 2>&1')
    h1.cmdPrint('killall -9 ccn-lite-crtl >/dev/null 2>&1')
    h1.cmdPrint('killall -9 ccn-lite-ccnb2x >/dev/null 2>&1')
    h1.cmdPrint('rm -f /tmp/ccnlite1.log /tmp/ccnlite2.sock')
    h1.cmdPrint('rm -f /tmp/mgnt-relay-a.sock /tmp/mgmt-relay-b.sock.sock')

    print '*** initializing servers:'
    h1.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-relay -v trace -s ndn2013 -u 9998 -x /tmp/mgmt-relay-a.sock -v debug >/tmp/ccnlite1.log 2>&1 &')
    h2.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-relay -v trace -s ndn2013 -u 9999 -x /tmp/mgmt-relay-b.sock -d /home/user/ccn-lite/test/ndntlv -v debug >/tmp/ccnlite2.log 2>&1 &')

    print '*** waiting for servers to wake up ...'

    #Connect mgntA with mgntB
    time.sleep(5)
    h1.cmdPrint("""export FACEID=`/home/user/ccn-lite/bin/ccn-lite-ctrl -x /tmp/mgmt-relay-a.sock newUDPface any 10.0.0.2 9999 | /home/user/ccn-lite/bin/ccn-lite-ccnb2xml | grep FACEID | sed -e 's/^[^0-9]*\\([0-9]\\+\\).*/\\1/'`""")
    h1.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-ctrl -x /tmp/mgmt-relay-a.sock prefixreg /ndn $FACEID ndn2013 | /home/user/ccn-lite/bin/ccn-lite-ccnb2xml')

    #Execute tests
    print '*** executing NFN tests ...'
    h1.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-peek -s ndn2013 -u 127.0.0.1/9998 "/ndn/test/mycontent" | /home/user/ccn-lite/bin/ccn-lite-pktdump -f 2')

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

    # remove old files
    os.system( "rm /tmp/client-*")
    os.system( "rm /tmp/server-*")

    # kill old processes
    os.system( "killall -q controller" )
    os.system( "killall -q quic_client" )
    os.system( "killall -q quic_server" )

    topo = QuicTester()
    net = Mininet(topo=topo, host=Host, link=Link)
    net.start()

    client = net.getNodeByName('client')
    server = net.getNodeByName('server')
    
    set_all_IP(net, client, server)
    
    #Dump connections
    dumpNodeConnections(net.hosts)
    display_routes(net, client, server)

    run_quic(client, server)

    CLI(net)

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

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

    results = {}

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

    return results
def test_relsend():
    "Create network and run reliable transport experiment"
    print "starting mininet ...."
    seconds = 3600
    start = time()
    # Reset to known state
    topo = StarTopo( bw_host=args.bw_host,
                    delay='%sms' % args.delay,
					loss='%s' % args.loss,
                   maxq=args.maxq)
    print 'Loss is %s, delay is %s, buffer size is %s, port number is %d, filename is %s, case is %d' % (args.loss, args.delay, args.maxq, args.port, args.filename, args.case)
    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink)
                  
    net.start()
    h2 = net.getNodeByName('h2')
    h1 = net.getNodeByName('h1')
    h1ip = h1.IP()
    h2ip = h2.IP()
    print "running experiment"
    now = time()
    h1.cmd('./hw7_receiver %d > RECVD_FILE%s 2> /dev/null &' % (args.port, args.case))
    h2.cmd('cat %s | ./hw7_sender %s %d 2> sender_output%s &' % (args.filename, h1ip, args.port, args.case))
    h2.cmd('wait')
    elapsed = time() - now
    print "finished experiment in %s sec"%  str(elapsed)
#resultmd5 = h1.cmd('md5sum RECVD_FILE%s' % args.case).split()[0]
#    print "resulting file has md5 sum %s" % resultmd5

    # this will drop you to a mininet shell if you need it
    # CLI( net )    
    net.stop()
Example #25
0
def bwtest( cpuLimits, period_us=100000, seconds=5 ):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

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

    results = {}

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

    return results
Example #26
0
def perfTest():
   "Create network and run simple performance test"
   topo = LinearTopo(k=2)
   net = Mininet(topo=topo,
                 host=CPULimitedHost, link=TCLink)
   net.start()
   print "Dumping host connections"
   dumpNodeConnections(net.hosts)
   print "Testing network connectivity"
   net.pingAll()
   ping_latency(net)
   h1 = net.getNodeByName('h1')
   h2 = net.getNodeByName('h2')
   h3 = net.getNodeByName('h3')
   #h1.cmd("tc -s qdisc show dev h1-eth0")
   print "Allocate two Qs to s1"
   #os.system("tc -s qdisc show dev %s" % args.iface)

   os.system("bash tc_cmd_diff.sh %s" % args.iface)
   #h1.cmd("bash tc_cmd_diff.sh h1-eth0")
   #h1.cmd("tc -s show dev h1-eth0")

  # h2.cmd('iperf -s -w 16m -p 5001 -i 1 > iperf-recv.txt &')
   h2.cmd('iperf -s -p %s -i 1 > iperf_server_TCP.txt &' % 5001)
#               (CUSTOM_IPERF_PATH, 5001, args.dir))
   h3.cmd('iperf -s -p %s -u -i 1 > iperf_server_UDP.txt &' % 5003)
   
   monitor = Process(target=monitor_qlen,
                     args=("%s"%args.iface,float(args.sampleR),int(args.nQ), "%s_%s"% (args.exp,args.out)))
   
   monitor.start()                        

   
   #h1.cmd("./monitor.sh test1 h1-eth0")
   CLI(net)

   monitor.terminate()
   
   os.system('killall -9 iperf' )

   net.stop()
   for i in xrange(int(args.nQ)):
       print "Saving and ploting output files..."
       plot_st("Q%d%s_%s" % (i+1,args.exp,args.out),int(args.btn),i+1)

   Popen("killall -9 cat", shell=True).wait()
def main():
    # Initialize mininet
    net = Mininet(topo=RingTopo(k=3, n=1, lopts={"bw": 50}), controller=RemoteController, switch=OVSSwitch,
                  link=TCLink, autoSetMacs=True)
    net.start()
    h1 = net.getNodeByName("h1")
    # sys.stdin.read(1)
    h1.cmd('ping -c 10 10.0.0.2')

    # Generate example of 'move' API request
    text = requests.get(APIS['routes'][URL_EXAMPLE_KEY]).text
    js = json.loads(text)
    r1 = js[0]
    r2 = js[1]
    if not js[0]['flows']:
        r1, r2 = r2, r1

    r1_id = r1['id']
    r2_id = r2['id']
    f1_id = r1['flows'][0]['id']
    APIS['move'][URL_EXAMPLE_KEY] = APIS['move'][URL_FORMAT_KEY].format(fromRoute=r1_id, flow=f1_id, toRoute=r2_id)

    # Print out documentation
    print """Interfaces of TEE northbound API (REST) with example input and output.
Base location {}/{{API_NAME}}/{{PARAMETERS}}, where localhost is address of running OpenDaylight controller.\n""".format(BASE_URL)

    print """Example topology:

                     S3
H1 - 10.0.0.1       /  \\
H2 - 10.0.0.2      /    \\
                  /      \\
        H1 ---- S1 ------ S2 --- H2

    """

    for i, api in enumerate(APIS.values(), start=1):
        print "{}. {}".format(i, api['description'])
        if URL_FORMAT_KEY in api:
            print "URL format: {}".format(api[URL_FORMAT_KEY])
        print "Example:"
        print "URL: {url} \nRequest type: {type}".format(url=api['url_example'], type=api['type'])
        if api['type'] == 'GET':
            r = requests.get(api['url_example'])
            print "Return code: {}".format(r.status_code)
            print "Result:"
            parsed = json.loads(r.text)
            print json.dumps(parsed, indent=4, sort_keys=True)

        elif api['type'] == 'PUT':
            r = requests.put(api['url_example'])
            print "Return code: {}".format(r.status_code)
        else:
            print "Request type not supported : {}".format(api['type'])
            exit(1)
        print ""

    net.stop()
def BwidthTest( lossy=True ):
    "Create network and run simple performance test"
    topo = TwoSwitchTopo( n=4, lossy=lossy )
    net = Mininet( topo=topo,
                   host=CPULimitedHost, link=TCLink,
                   autoStaticArp=True )
    net.start()
    f = open('output.txt','w')
    print( "Testing throughput between h1 and h4" )
    #Return node(s) with given name(s) 
    h1, h2, h3, h4 = net.getNodeByName('h1', 'h2','h3','h4')
    #Creating a UDP Server on H4
    h4.popen("iperf -s -u", shell = True)
    #Creating a TCP Server for the long running TCP Process
    processC=h4.popen("iperf -s -p 5201 -i 1 -1", shell = True)
    processD=h4.popen("iperf -s -p 5202 -i 1", shell = True)
    processA  = h1.popen("iperf -c 10.0.0.4 -p 5201 -t 120 -i 1 ", shell=True)
    sleep(5)
    print( "Throughput between h1 and h4, bwidth of 2" )
    process  = h1.popen("iperf -u -c 10.0.0.4 -p 5202 -t 10 -b 2M", shell=True)
    stdout, stderr = process.communicate()
    #f.write(stdout)
    print( stdout)
    sleep(10)
    print( "Throughput between h1 and h4, bwidth of 4" )
    process  = h1.popen("iperf -u -c 10.0.0.4 -p 5202 -t 10 -b 4M", shell=True)
    stdout, stderr = process.communicate()
    print( stdout )
    #f.write(stdout)
    sleep(5)
    print( "Throughput between h1 and h4, bwidth of 6" )
    process  = h1.popen("iperf -u -c 10.0.0.4 -p 5202 -t 10 -b 6M", shell=True)
    stdout, stderr = process.communicate()
    print( stdout )
    sleep(5)
    print( "Throughput between h1 and h4, bwidth of 8" )
    process = h1.popen("iperf -u -c 10.0.0.4 -p 5202 -t 10 -b 8M", shell=True)
    stdout, stderr = process.communicate()
    print( stdout )
    sleep(5)
    print( "Throughput between h1 and h4, bwidth of 10" )
    process = h1.popen("iperf -u -c 10.0.0.4 -p 5202 -t 10 -b 10M", shell=True)
    stdout, stderr = process.communicate()
    print( stdout )
    sleep(5)
    print( "Throughput between h1 and h4, bwidth of 12" )
    process = h1.popen("iperf -u -c 10.0.0.4 -p 5202 -t 10 -b 12M", shell=True)
    stdout, stderr = process.communicate()
    print( stdout )
    sleep(5)

    stdout1, stderr1 = processC.communicate()
    print( stdout1 )
    f.write(stdout1)
    stdout2, stderr2 = processA.communicate()
    print( stdout2 )
    print ("hello")
    net.stop()
Example #29
0
def Test():
   "Create network and run simple performance test"
   topo = SimpleTopo(k=2)
   net = Mininet(topo=topo,
                 host=CPULimitedHost, link=TCLink)
   addrealintf(net,args.intf,args.btn,args.maxq)
   rootnode = connectToInternet(net)
   print "Dumping host connections"
   dumpNodeConnections(net.hosts)
   print "Testing network connectivity"
   net.pingAll()
   h1 = net.getNodeByName('h1')
   h2 = net.getNodeByName('dhcp')
   #h1.cmd("tc -s qdisc show dev h1-eth0")
   print "Allocate two Qs to s1"
   #os.system("tc -s qdisc show dev %s" % args.iface)
#   os.system("bash tc_cmd_diff.sh %s" % args.iface)
   os.system("bash tc_diablo.sh %s" % args.iface)
   #h1.cmd("bash tc_cmd_diff.sh h1-eth0")
   #h1.cmd("tc -s show dev h1-eth0")
  # h2.cmd('iperf -s -w 16m -p 5001 -i 1 > iperf-recv.txt &')
   #h2.cmd('iperf -s -p %s -i 1 > iperf_server_TCP.txt &' % 5001)
#               (CUSTOM_IPERF_PATH, 5001, args.dir))
   #monitoring the network
   monitor = Process(target=monitor_qlen,
                     args=("%s"%args.iface,float(args.sampleR),int(args.nQ), "%s_%s"% (args.exp,args.out)))   
       
   threadq = myThread(1,args.iface,120) 
   monitor.start() 
   threadq.start()                  
   #start mininet CLI
   CLI(net)
   #terminate
   monitor.terminate()
   threadq.stop()
   os.system('killall -9 iperf' )
   net.hosts[0].cmd('killall -9 dhcpd')
   stopNAT( rootnode )
   net.stop()
   #plot
   for i in xrange(int(args.nQ)):
       print "Saving and ploting output files..."
       plot_st("Q%d%s_%s" % (i+1,args.exp,args.out),int(args.btn),i+1)

   Popen("killall -9 cat", shell=True).wait()
Example #30
0
def simpleTest():
    "Create and test a simple network"
    topo = BasicTopo()
    net = Mininet(topo,link=TCLink)
    net.start()
    client = net.getNodeByName('c1')
    router = net.getNodeByName('r1')
    server = net.getNodeByName('s1')
    client.setIP('1.0.0.1')
    router.setIP('1.0.1.1',intf='r1-eth0')
    router.setIP('2.0.1.2',intf='r1-eth1')
    server.setIP('2.0.0.1')
    print net.hosts
    server.cmd("su carlos -c 'twistd --logfile=server.log --pidfile=server.pid --python server.py'")
    router.cmd("su carlos -c 'twistd --logfile=router.log --pidfile=router.pid --python router.py'")
    client.cmd("su carlos -c 'twistd --logfile=client.log --pidfile=client.pid --python client.py'")
    CLI(net)
    net.stop()
Example #31
0
def perfTest():
    "Create network and run simple performance test"
    topo = SingleSwitchTopo(n=4)
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  link=TCLink,
                  autoStaticArp=True)
    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    print "Testing bandwidth between h1 and h4"
    h1, h4 = net.getNodeByName('h1', 'h4')
    net.iperf((h1, h4), l4Type='UDP')
    net.stop()
Example #32
0
def Test():
    "Create network and run simple performance test"
    topo = SingleSwitchTopo()
    net = Mininet( topo=topo,
                   host=CPULimitedHost, link=TCLink,
                   autoStaticArp=False )
    net.start()
    info( "Dumping host connections\n" )
    dumpNodeConnections(net.hosts)
    info( "Testing bandwidth between h1 and h4\n" )
    h1, h2, h3 = net.getNodeByName('h1', 'h2', 'h3')
    #s1, s2 = net.getNodeByName('s1', 's2')
    CLI(net)
    net.stop()
Example #33
0
def perfTest(loss=0):
    "Create network and run performance tests, one for each protocol"
    topo = SingleSwitchTopo(n=4, _loss=loss)
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  link=TCLink,
                  autoStaticArp=True)
    net.start()
    info("Dumping host connections\n")
    dumpNodeConnections(net.hosts)

    # Assume h1 as server, h2 as the client

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

    pid = server.cmd("./server.sh")
    time.sleep(1)

    with open("http.dat", "a+") as f:
        for protocol in protocols:
            # Set the congestion protocol
            os.system("echo '" + protocol +
                      "'| sudo tee /proc/sys/net/ipv4/tcp_congestion_control")

            info("Running test for " + protocol + " congestion protocol\n")
            # info("timeout "+str(time)+" wget -r " + server.IP()+":8000")
            # Run the test
            results = test(net, server, h2)

            # File output
            if results:
                f.write(("%i\t%s\t%s\n" % (loss, protocol, results)))
        f.close()

    server.cmd("kill -9 " + pid)
    net.stop()
def testtopology():
    tkinter.messagebox.showinfo("Deploy topology to mininet ", "Press ok button and wait for a seconds to see result")

    with open('./stdout.txt', 'w') as outfile:
        with redirect_stdout(outfile), redirect_stderr(outfile):

            topo = CustomTopology()
            net = Mininet(topo=topo, cleanup=True)

            print('\n =================================================> Start the topology \n')
            net.start()

            print('\n =================================================> Test the topology by running a ping command \n')

            ping_all_full = net.pingAllFull()
            print('Result from ping Test: \n' + '\n' + str(ping_all_full) + '\n' + '\n % of packets dropped.\n')

            ping_pair = net.pingPairFull()
            print('Result from Regression Test : \n' + '\n' + str(ping_pair) + '\n' + '\n % of packets dropped.\n')

            print('\n ==============> Testing TCP bandwidth between: \n')

            iperf_origin = net.getNodeByName(node_1)
            iperf_destination = net.getNodeByName(node_2)

            iPerf = net.iperf([iperf_origin, iperf_destination])

            print('Result from iPerf between node ' + node_1 + ' and node ' + node_2 + '\n' + '\n' + str(iPerf) + '\n')

            stop = net.stop()
            print('Stop the network:' + str(stop) + '\n')

            clean = net.cleanup
            print('cleanup the mininet network: ' + str(clean) + '\n')

    with open('./stdout.txt') as infile:
        mnOutput.insert(END, infile.read())
def IncastTest():
    num_TOR = int(args.size)
    topo = FacebookFatTree(num_TOR)
    host_number = num_TOR * num_TOR * HOST_PER_NODE
    print(host_number)
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  switch=LinuxBridge,
                  link=TCLink,
                  autoStaticArp=True)
    print("end create net")
    net.start()
    net.waitConnected()

    h1 = net.getNodeByName('host_0')
    print(h1.cmd('ping -c 2 10.0.0.2'))
    h1.sendCmd('iperf -s -t %d -i 2 > %s/iperf_host_0.txt' %
               (int(args.duration) + 5, path))

    clients = [
        net.getNodeByName('host_%d' % (i)) for i in xrange(1, host_number)
    ]
    sleep(1)

    monitors = []
    # add more switch interface for fat-tree topo
    # may consider using mtr to test ping, -s PACKETSIZE, --psize PACKETSIZE
    monitor = multiprocessing.Process(target=monitor_qlen,
                                      args=('rack_0-eth5', 0.1,
                                            '%s/qlen_rack0-eth5.txt' % path))
    monitor.start()
    monitors.append(monitor)

    for i in xrange(1, host_number):
        node_name = 'host_%d' % (i)
        cmd = 'iperf -c 10.0.0.1 -t %d -i 2 -O 2 -Z %s' % (int(
            args.duration), args.congestion)
        # cmd = 'iperf -c 10.0.0.1 -t %d -i 2 -O 2 -Z %s > %s/iperf_%s.txt' % (int(args.duration), args.congestion ,path, node_name)
        h = net.getNodeByName(node_name)
        h.sendCmd(cmd)

    progress(int(args.duration))
    for monitor in monitors:
        monitor.terminate()

    net.getNodeByName('host_0').pexec("/sbin/ifconfig > %s/ifconfig.txt" %
                                      path,
                                      shell=True)
    for i in xrange(0, host_number):
        net.getNodeByName('host_%d' % (i)).waitOutput()
        print('host_%d finished' % (i))
    net.stop()
Example #36
0
def startNetworkWithLinearTopo( hostCount ):
    global net
    net = Mininet(topo=LinearTopo(hostCount), build=False)

    remote_ip = getControllerIP()
    info('** Adding Floodlight Controller\n')
    net.addController('c1', controller=RemoteController,
                      ip=remote_ip, port=6653)

    # Build the network
    net.build()
    net.start()

    # Start L3 Routing
    ret = enableL3Routing()
    print (ret)

    ret = addVirtualGateway('mininet-gateway-1')
    print (ret)

    ret = addInterfaceToGateway('mininet-gateway-1')
    # ret = updateInterfaceToGateway('mininet-gateway-1')   # Just for test if gateway interface update correctly
    print (ret)

    ret = addSwitchToGateway('mininet-gateway-1')
    print (ret)

    # Need to configure default gw for host
    host1 = net.getNodeByName('h1')
    host1.setIP('10.0.0.10', prefixLen=24)
    defaultGatewayIP1 = "10.0.0.1"
    configureDefaultGatewayForHost(host1, defaultGatewayIP1)

    host2 = net.getNodeByName('h2')
    host2.setIP('10.0.0.20', prefixLen=24)
    defaultGatewayIP2 = "10.0.0.1"
    configureDefaultGatewayForHost(host2, defaultGatewayIP2)

    host3 = net.getNodeByName('h3')
    host3.setIP('10.0.0.30', prefixLen=24)
    defaultGatewayIP3 = "10.0.0.1"
    configureDefaultGatewayForHost(host3, defaultGatewayIP3)

    host4 = net.getNodeByName('h4')
    host4.setIP('40.0.0.10', prefixLen=24)
    defaultGatewayIP4 = "40.0.0.1"
    configureDefaultGatewayForHost(host4, defaultGatewayIP4)

    host5 = net.getNodeByName('h5')
    host5.setIP('50.0.0.10', prefixLen=24)
    defaultGatewayIP5 = "50.0.0.1"
    configureDefaultGatewayForHost(host5, defaultGatewayIP5)

    host6 = net.getNodeByName('h6')
    host6.setIP('60.0.0.10', prefixLen=24)
    defaultGatewayIP6 = "60.0.0.1"
    configureDefaultGatewayForHost(host6, defaultGatewayIP6)
Example #37
0
def run():
    topo = FatTree(6)
    net = Mininet(topo=topo, link=TCLink, controller=None)
    net.start()
    # sleep(5)
    # Mininet API for the experiment
    #  sysctl -w net.ipv4.neigh.default.gc_thresh1=4098
    # increase the arp table cache
    print("ARP TABLES")

    net.staticArp()
    ft = FatTreeConverted.from_mininet(net)
    rules, s_d = ft.getRules()
    ovs_rules = ft.getOVSRules(rules=rules)
    for switch in net.switches:
        print(switch.name)
        rl = ovs_rules[switch.name]
        for r in rl:
            cmd = "bash -c 'ovs-ofctl add-flow {} {}'".format(switch.name, r)
            print(switch.name, cmd)
            switch.cmd(cmd)
        print()
    print(ovs_rules)
    # Run the CLI
    for s, d in s_d:
        print(s, d)
        ploss = net.ping([net.getNodeByName(s), net.getNodeByName(d)])
        if ploss > 0:
            print(s, d, "PACKET LOSS!")
            break
        print(ploss)

    results = iperf(net, s_d)
    print(results)

    CLI(net)
    net.stop()
Example #38
0
def build_and_run(pkl, algo, nflows, out=None):

    topo = JellyFishTop(pkl)
    net = Mininet(topo=topo, host=CPULimitedHost, link = TCLink, controller=JELLYPOX("jelly", cargs2=("--p=%s --algo=%s" % (pkl, algo))))

    host_mac_base = len(topo.mn_switches)
    for i, h in enumerate(topo.mn_hosts):
        mn_host = net.getNodeByName(h)
        mn_host.setMAC(mac_from_value(host_mac_base + i + 1))
        for j, h2 in enumerate(topo.mn_hosts):
            if i == j: continue
            mn_host2 = net.getNodeByName(h2)
            mn_host.setARP('10.0.' + str(j) + '.1', mac_from_value(host_mac_base + j + 1))

    output = experiment(net, topo, nflows)
    parsed = { "output": [], "algo": algo, "nflows": nflows }
    for cmd in output:
        parsed["output"].append(cmd.split("\r\n"))

    if out:
        with open(out, 'wb') as f:
            pickle.dump(parsed, f)
    else:
        print parsed
def main():
    # topo = FacebookFatTree(4)
    host_number = 4
    topo = StarTopo(host_number)
    print("end create topo")
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  link=TCLink,
                  switch=Switch,
                  autoStaticArp=True)
    print("end create net")
    net.start()

    h1 = net.getNodeByName('host_1')
    print(h1.cmd('ping -c 2 10.0.0.2'))
    h1.sendCmd('iperf -s -t 20', printPid=True)

    clients = [
        net.getNodeByName('host_%d' % (i + 1)) for i in xrange(1, host_number)
    ]
    waitListening(clients[0], h1, 5001)

    monitors = []
    # add more switch interface for fat-tree topo
    # may consider using mtr to test ping, -s PACKETSIZE, --psize PACKETSIZE
    monitor = multiprocessing.Process(
        target=monitor_qlen,
        args=('s1-eth1', 0.1,
              '%s/qlen_s1-eth1.txt' % "/home/ubuntu/test/output"))
    monitor.start()
    monitors.append(monitor)

    for i in xrange(1, host_number):
        node_name = 'host_%d' % (i + 1)
        cmd = 'iperf -c 10.0.0.1 -t %d -i 1 -Z dctcp > %s/iperf_%s.txt' % (
            5, "/home/ubuntu/test/output", node_name)
        h = net.getNodeByName(node_name)
        h.sendCmd(cmd)

    progress(5)
    for monitor in monitors:
        monitor.terminate()

    net.getNodeByName('host_1').pexec("/sbin/ifconfig > %s/ifconfig.txt" %
                                      "/home/ubuntu/test/output",
                                      shell=True)
    for i in xrange(0, host_number):
        net.getNodeByName('host_%d' % (i + 1)).waitOutput()
        print('host_%d finished' % (i + 1))
    net.stop()
Example #40
0
def run():
    topo = MyTopo()
    net = Mininet(topo=topo, controller=None, link=TCLink)
    net.addController('c0', controller=RemoteController, ip='127.0.0.1', port=6653)

    net.start()

    print("[+] Run DHCP server")
    dhcp = net.getNodeByName('h4')
    # dhcp.cmdPrint('service isc-dhcp-server restart &')
    dhcp.cmdPrint('/usr/sbin/dhcpd 4 -pf /run/dhcp-server-dhcpd.pid -cf ./dhcpd.conf %s' % dhcp.defaultIntf())

    CLI(net)
    print("[-] Killing DHCP server")
    dhcp.cmdPrint("kill -9 `ps aux | grep h4-eth0 | grep dhcpd | awk '{print $2}'`")
    net.stop()
Example #41
0
def routerNet():
    "Create a network with a router and two switches"
    c = RemoteController
    net = Mininet(controller=c,
                  switch=Switch,
                  autoSetMacs=True,
                  autoStaticArp=True)

    print "*** Creating controller"
    if len(sys.argv) > 1:
        print sys.argv[0]
        c1 = net.addController('c1', port=6633, ip=sys.argv[1])
    else:
        c1 = net.addController('c1', port=6633)

    print "*** Creating switches"
    s1 = net.addSwitch('s1', dpid='0000000000000101')
    s2 = net.addSwitch('s2', dpid='0000000000000201')
    r1 = net.addSwitch('r1', dpid='0000000000000001')

    print "*** Creating hosts"
    h1 = net.addHost('h1', ip='10.0.1.2/24', mac='00:00:00:00:01:02')
    h2 = net.addHost('h2', ip='10.0.2.2/24', mac='00:00:00:00:02:02')

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

    print "*** Starting network"
    net.start()
    net.getNodeByName('h1').cmd(
        'route add -net 10.0.2.0 netmask 255.255.255.0 gw 10.0.1.1')
    net.getNodeByName('h1').cmd('arp -s 10.0.1.1 00:00:00:00:01:01')
    net.getNodeByName('h2').cmd(
        'route add -net 10.0.1.0 netmask 255.255.255.0 gw 10.0.2.1')
    net.getNodeByName('h2').cmd('arp -s 10.0.2.1 00:00:00:00:02:01')

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

    print "*** Stopping network"
    net.stop()
Example #42
0
def bwtest(cpuLimits, period_us=100000, seconds=10):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

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

    results = {}

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

    return results
Example #43
0
def inicializaRed():
    "Create network and run simple performance test"
    topo = MyTopo()
    net = Mininet(topo=topo, link=TCLink, controller=RemoteController)
    net.start()

    print "*** Creating queues ..."
    s1 = net.getNodeByName('s1')
    for j in s1.intfNames()[1:]:
        cmd3 = 'ovs-vsctl -- set Port ' + j + ' qos=@newqos\
                -- --id=@newqos create QoS type=linux-htb  other-config:max-rate=3000000 queues=0=@q0,1=@q1\
                -- --id=@q0 create Queue other-config:min-rate=2300000 other-config:max-rate=2800000\
                -- --id=@q1 create Queue other-config:min-rate=80000   other-config:max-rate=1500000'

        s1.cmd(cmd3)
    CLI(net)
    net.stop()
def inicializaRed():
    "Create network and run simple performance test"
    topo = MyTopo()
    #net = Mininet(topo=topo, link=TCLink, controller=RemoteController)
    net = Mininet(topo=topo, link=TCLink)
    net.start()
    #switches = net.getNodeByName('s1', 's2', 's3', 's4')
    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')
    #for i in switches:
        #cmd = 'touch DOCTOR'
        #i.cmdPrint(cmd+i.__str__())
        #i.cmd(cmd)   
                
    print '*** cleaning:'
    h1.cmdPrint('killall -9 ccn-nfn-relay >/dev/null 2>&1')
    h1.cmdPrint('killall -9 ccn-nfn-proxy.py >/dev/null 2>&1')
    h1.cmdPrint('rm -f /tmp/mgmt1.sock /tmp/mgmt2.sock')
    h1.cmdPrint('rm -f /tmp/nfn0.log /tmp/nfn1.log /tmp/nfn2.log')

    print '*** initializing servers:'    
    h1.cmdPrint('/home/user/ccn-lite/bin/ccn-nfn-relay -s ndn2013 -u 9000 -x /tmp/mgmt1.sock -v debug >/tmp/nfn0.log 2>&1 &')
    h2.cmdPrint('/home/user/ccn-lite/bin/ccn-nfn-relay -s ndn2013 -u 9001 -x /tmp/mgmt2.sock -v debug >/tmp/nfn1.log 2>&1 &')
    h2.cmdPrint('/home/user/ccn-lite/src/py/ccn-nfn-proxy.py -u 127.0.0.1/9001 9002 >/tmp/nfn2.log 2>&1 &')

    print '*** waiting for servers to wake up ...'
    
    #Connect mgmt1 with mgmt2
    time.sleep(5)
    h1.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-ctrl -x /tmp/mgmt1.sock newUDPface any 10.0.0.2 9001 | /home/user/ccn-lite/bin/ccn-lite-ccnb2xml | grep ACTION')
    h1.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-ctrl -x /tmp/mgmt1.sock prefixreg /pynfn 2 | /home/user/ccn-lite/bin/ccn-lite-ccnb2xml | grep ACTION')

    #Connect mgmt2 with proxy (=computeserver)
    h2.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-ctrl -x /tmp/mgmt2.sock newUDPface any 127.0.0.1 9002 | /home/user/ccn-lite/bin/ccn-lite-ccnb2xml | grep ACTION')
    h2.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-ctrl -x /tmp/mgmt2.sock prefixreg /pynfn 2 | /home/user/ccn-lite/bin/ccn-lite-ccnb2xml | grep ACTION')

    #Add content to mgmt2, register it
    h2.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-ctrl -x /tmp/mgmt2.sock addContentToCache /home/user/ccn-lite/test/py/computation_content.ndntlv | /home/user/ccn-lite/bin/ccn-lite-ccnb2xml | grep ACTION')
    h1.cmdPrint('/home/user/ccn-lite/bin/ccn-lite-ctrl -x /tmp/mgmt1.sock prefixreg /test 2 | /home/user/ccn-lite/bin/ccn-lite-ccnb2xml | grep ACTION')
    
    #Execute tests
    print '*** executing NFN tests ...'
    h1.cmdPrint('/home/user/ccn-lite/test/py/nfnproxy-test3B.py')

    CLI(net)
    net.stop()
Example #45
0
def inicializaRed():
    "Create network and run simple performance test"
    topo = MyTopo()
    net = Mininet(topo=topo, link=TCLink, controller=RemoteController)
    net.start()
    print "*** Pruebas en h1"
    switches = net.getNodeByName('s1', 's2', 's3', 's4')
    for i in switches:
        for j in i.intfNames()[1:]:
            cmd = 'ovs-vsctl -- set port ' + j + ' qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=7700000\
                   queues:0=@newqueue -- --id=@newqueue create queue other-config:min-rate=1000000 other-config:max-rate=77000000'

            #i.cmdPrint(cmd)
            i.cmd(cmd)

    CLI(net)
    net.stop()
Example #46
0
def Test(tcp):
    "Create network and run simple performance test"
    topo = SingleSwitchTopo()
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  link=TCLink,
                  autoStaticArp=False)
    net.start()
    info("Dumping host connections\n")
    dumpNodeConnections(net.hosts)
    # set up tcp congestion control algorithm
    output = quietRun('sysctl -w net.ipv4.tcp_congestion_control=' + tcp)
    assert tcp in output
    info("Testing bandwidth between h1 and h4 under TCP " + tcp + "\n")
    h1, h2, h3, h4, h5, h6, h7, h8, h9, h10 = net.getNodeByName(
        'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8', 'h9', 'h10')
    t1 = MyThread(net.iperf, kargs={"hosts": [h1, h6], "seconds": 10})
    t2 = MyThread(net.iperf, kargs={"hosts": [h2, h7], "seconds": 10})
    t3 = MyThread(net.iperf, kargs={"hosts": [h3, h8], "seconds": 10})
    t4 = MyThread(net.iperf, kargs={"hosts": [h4, h9], "seconds": 10})
    t5 = MyThread(net.iperf, kargs={"hosts": [h5, h10], "seconds": 10})
    t1.start()
    t2.start()
    t3.start()
    t4.start()
    t5.start()
    t1.join()
    t2.join()
    t3.join()
    t4.join()
    t5.join()
    res1 = t1.get_result()
    res2 = t2.get_result()
    res3 = t3.get_result()
    res4 = t4.get_result()
    res5 = t5.get_result()
    #_serverbw, clientbw = net.iperf( [ h1, h2 ], seconds=10 )
    info(res1, '\n')
    info(res2, '\n')
    info(res3, '\n')
    info(res4, '\n')
    info(res5, '\n')
    CLI(net)
    net.stop()
Example #47
0
def emptyNet(inicio):
	net = Mininet(controller=Controller)

	info('*** Adding hosts ***\n')
	for host in listHosts:
		net.addHost(host.label)

	info('*** Creating links ***\n')
	for link in listLink:
		hostFrom = link.source
		hostTo = link.dest
		net.addLink(hostFrom, hostTo)

	info('*** Configuring hosts ***\n')
	for host in listHosts:
		hostNET = net.getNodeByName(host.label)
		list_fw_cmd = host.fwCommand
		list_iface_hosts = host.iface

		for iface in list_iface_hosts:
			cmd = Command(iface)
			hostNET.cmd(cmd.configIface())
			hostNET.cmd(cmd.configMask())
			hostNET.cmd(cmd.addGateway())

			hostNET.config()

		for fwCmd in list_fw_cmd:
			hostNET.cmd(fwCmd)

		if host.type == 'router':
			hostNET.cmd(cmd.configRouter())

	info('*** Init tests ***\n')
	tests(net)
	fim = timeit.default_timer()
	info("hosts criados e configurados em: " + str(fim-inicio) + '\n')
	info('*** Starting CLI ***\n')
	#CLI(net)

	info('*** Stopping newtwork ***\n')
	net.stop()
	exit()
Example #48
0
def Test():
    num_host = 6  # number of hosts
    num_peer = num_host - 1  # number of peers
    topo = SingleSwitchTopo(num_host)
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  link=TCLink,
                  autoStaticArp=False)
    net.start()
    info('* Dumping host connections\n')
    dumpNodeConnections(net.hosts)
    hosts = [net.getNodeByName('h{}'.format(i)) for i in range(num_host)]
    hosts[0].cmd('python server.py ./src/test > ./log/server &')
    for i in range(num_peer):
        hosts[i + 1].cmd('python client.py ./dst/data%d/test > ./log/h%d &' %
                         (i + 1, i + 1))
    # CLI(net)
    time.sleep(120)
    net.stop()
Example #49
0
def main():
    "Create specified topology and launch the command line interface"
    topo = DynamicTopo(n=args.n, delay=args.delay, z=args.z, bw=args.bw)
    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink)
    net.start()

    #TODO: Since this topology contains a cycle, we must enable the Spanning Tree Protocol (STP) on each switch.
    #      This is done with the following line of code: s1.cmd('ovs-vsctl set bridge s1 stp-enable=true')
    #      Here, you will need to generate this line of code for each switch.
    #HINT: You will need to get the switch objects from the net object defined above.

    for i in range(args.z):
        name = 's' + str(i + 1)
        switch = net.getNodeByName(name)
        command = 'ovs-vsctl set bridge ' + name + " stp-enable=true"
        switch.cmd(command)

    CLI(net)
    net.stop()
Example #50
0
def Test(tcp):
    "Create network and run simple performance test"
    topo = SingleSwitchTopo()
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  link=TCLink,
                  autoStaticArp=False)
    net.start()
    info("Dumping host connections\n")
    dumpNodeConnections(net.hosts)
    # set up tcp congestion control algorithm
    output = quietRun('sysctl -w net.ipv4.tcp_congestion_control=' + tcp)
    assert tcp in output
    info("Testing bandwidth between h1 and h4 under TCP " + tcp + "\n")
    h1, h2 = net.getNodeByName('h1', 'h2')
    _serverbw, clientbw = net.iperf([h1, h2], seconds=10)
    info(clientbw, '\n')
    # CLI(net)
    net.stop()
Example #51
0
def topoTest():
    topo = Topo2()
    net = Mininet(topo=topo,
                  controller=lambda name: RemoteController(
                      name, defaultIP='192.168.42.1'),
                  link=TCLink,
                  switch=OVSSwitch)
    c0 = net.getNodeByName('c0')
    s1 = net.getNodeByName('h7')
    l1 = s1.linkTo(c0)
    i1 = l1.intf1
    i2 = l1.intf2
    s1.setIP('123.123.123.1', 8, i1)
    c0.setIP('123.123.123.2', 8, i2)
    net.start()
    s1.cmd('route add -net 123.123.123.2 dev' + str(i1))

    CLI(net)
    net.stop()
Example #52
0
def perfTest():
    "Create network and run simple performance test"
    topo = SingleSwitchTopo()
    net = Mininet(controller=RemoteController,
                  topo=topo,
                  link=TCLink,
                  switch=OVSSwitch)
    c1 = net.addController('c1', ip='192.168.33.101', port=6033)
    c2 = net.addController('c2', ip='192.168.33.101', port=6133)
    c3 = net.addController('c3', ip='192.168.33.101', port=6233)

    net.start()
    h1, h2 = net.getNodeByName('h1', 'h2')
    h1.cmd("./Server 1v5 &")
    h2.cmd("./Server 2v5 &")
    h1.cmd("./Client 1v5 12.0.0.2 &")
    h2.cmd("./Client 2v5 12.0.0.1 ")
    #CLI(net)
    net.stop()
Example #53
0
def bbnet():
    "Create network and run Buffer Bloat experiment"
    print "starting mininet ...."
    # Seconds to run iperf; keep this very high
    seconds = 3600
    start = time()
    # Reset to known state
    topo = StarTopo(n=args.n,
                    bw_host=args.bw_host,
                    delay='%sms' % args.delay,
                    bw_net=args.bw_net,
                    maxq=args.maxq,
                    diff=args.diff)
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  link=TCLink,
                  autoPinCpus=True,
                  controller=OVSController)
    net.start()
    print "net started"
    dumpNodeConnections(net.hosts)
    net.pingAll()
    print args.diff
    if args.diff:
        print "Differentiate Traffic Between iperf and wget"
        os.system("bash tc_cmd_diff.sh")
    else:
        print "exec tc_cmd.sh"
        os.system("bash tc_cmd.sh %s" % args.maxq)
    sleep(2)
    ping_latency(net)
    print "Initially, the delay between two hosts is around %dms" % (
        int(args.delay) * 2)
    h2 = net.getNodeByName('h2')
    h1 = net.getNodeByName('h1')
    h1.cmd('cd ./http/; nohup python2.7 ./webserver.py &')
    h1.cmd('cd ../')
    h2.cmd('iperf -s -w 16m -p 5001 -i 1 > iperf-recv.txt &')
    CLI(net)
    h1.cmd("sudo pkill -9 -f webserver.py")
    h2.cmd("rm -f index.html*")
    Popen("killall -9 cat", shell=True).wait()
Example #54
0
def launchNet():
    "Create and test a 2-node network"
    seconds = 3600
    start = time()

    topo = NodeGenerator()
    net = Mininet(topo, link=TCLink)

    print "Starting network"
    net.start()

    print "exec tc_cmd.sh"
    loss_str = "%f%%" % args.loss_in
    rate_str = "%fMbit" % args.bw_in
    os.system("bash tc_cmd.sh %s %s %s %s" %
              (args.qsize_in, args.delay_in, loss_str, rate_str))
    sleep(2)

    # Retrieve nodes.
    h1 = net.getNodeByName('h1')
    h2 = net.getNodeByName('h2')

    # Launch basic traffic ... measure bandwidth.
    # Reference: How to generate traffic in a network topology.
    # Shivakumar 2013]
    print "Launching iperf: Measuring BW"
    h2.cmd('iperf -s -w 32m -M 1024 -p 5001 -i 1 > output/iperf-recv.txt &')

    print "Launching ping: Measuring RTTM"
    h1.cmd('ping -i 1 10.0.0.2 > output/ping-recv.txt &')

    print "Streaming large file"
    h2.cmd('nc -l 5001 > /dev/null/ &')
    h1.cmd('nc 10.0.0.2 5001 < input/big_file.txt &')

    sleep(args.t_in)

    Popen("pkill -KILL iperf", shell=True).wait()
    Popen("pkill -KILL ping", shell=True).wait()
    Popen("pkill -KILL nc", shell=True).wait()

    net.stop()
def topology(n=3,flows_number=128):
    switch = partial( OVSSwitch, protocols='OpenFlow13' )

    topo = LinearTopo(k=1, n=n)


    net = Mininet(controller=RemoteController, switch=switch, topo=topo, build=False, autoSetMacs=True)

    for i in range(n):
        controllers.append(net.addController('c{0}'.format(i+1), controller=RemoteController, ip="192.168.247.{0}".format(125+i), port=6633))


    net.build()
    net.start()

    time.sleep(15)

    # No que enviara trafego
    h1s1 = net.getNodeByName("h1s1")

#    tester = Tester(api="192.168.247.125")
    tester = Tester()

    # master do switch atual
    master = tester.getMaster()


    # Envio de mensagens 1000 pcks_in/s
    t = Thread(target=host_send, args=[h1s1,])
    t.start()

    # Pausa para contagem de fluxos
    time.sleep(5)

    # comando para parar servico remoto
    print(os.popen("sudo -u ti ssh ti@{master} sudo systemctl stop opendaylight".format(master=master)))

    time.sleep(60)

    # Desnecessario visto que sera automatico
#    CLI(net)
    net.stop()
Example #56
0
def emptyNet():
    net = Mininet(controller=Controller)

    info('*** Adding hosts ***\n')
    for host in listHosts:
        net.addHost(host.get_label())

    info('*** Creating links ***\n')
    for link in listLink:
        hostFrom = link.get_from().replace("\n", "")
        hostTo = link.get_to().replace("\n", "")
        net.addLink(hostFrom, hostTo)

    info('*** Configuring hosts ***\n')
    for host in listHosts:
        hostNET = net.getNodeByName(host.get_label())
        list_fw_cmd = host.get_fwCmd()
        list_iface_hosts = host.get_iface()

        for iface in list_iface_hosts:
            cmd = Command(iface)
            hostNET.cmd(cmd.configIface())
            hostNET.cmd(cmd.configMask())
            hostNET.cmd(cmd.addGateway())

            hostNET.config()

        for fwCmd in list_fw_cmd:
            hostNET.cmd(fwCmd)

        if host.get_type() == 'router':
            hostNET.cmd(cmd.configRouter())

    info('*** Init tests ***\n')
    tests(net)

    #info('*** Starting CLI ***\n')
    CLI(net)

    info('*** Stopping newtwork ***\n')
    net.stop()
    exit()
def emptyNet():
    switch = partial(OVSSwitch, protocols='OpenFlow13')
    link = partial(TCLink, bw=100)
    topo = SpineLeaf(leaves=3)
    f = Flows()

    net = Mininet(controller=RemoteController,
                  switch=switch,
                  link=link,
                  topo=topo,
                  build=False,
                  autoSetMacs=True)

    controllers.append(
        net.addController('c1',
                          controller=RemoteController,
                          ip="172.17.0.5",
                          port=6633))
    controllers.append(
        net.addController('c2',
                          controller=RemoteController,
                          ip="172.17.0.6",
                          port=6633))
    controllers.append(
        net.addController('c3',
                          controller=RemoteController,
                          ip="172.17.0.7",
                          port=6633))

    capture("inicio-conexao-com-testes", "docker0", timeout=30)

    net.build()
    net.start()

    f.test()

    h1 = net.getNodeByName("h1")
    h3 = net.getNodeByName("h3")

    os.system("killall tcpdump")
    #    CLI(net)
    net.stop()
Example #58
0
def main():

    net = Mininet(
        topo=SimpleTopo(), 
        switch=P4Switch, 
        controller = None,
        autoSetMacs = True
    )

    net.start()
    output = open('bench.log', 'w')
    popen = net.getNodeByName('H1').popen('python test.py', stdout=output, stderr=sys.stderr)
    try:
        popen.wait()
    except KeyboardInterrupt:
        popen.send_signal(signal.SIGTERM)
        raise

    #CLI(net)
    net.stop()
def perfTest():
    "Create network and run simple performance test"
    topo = SingleSwitchTopo(n=4)
    net = Mininet(topo=topo,
                  autoSetMacs=True,
                  host=CPULimitedHost,
                  link=TCLink,
                  autoStaticArp=False,
                  controller=RemoteController)
    print "Dumping host connections"
    net.start()
    dumpNodeConnections(net.hosts)
    for i in range(1, 5):
        h = net.getNodeByName('h%d' % i)
        h.cmd('ifconfig h%d-eth0 0' % i)
        h.cmd('dhclient h%d-eth0' % i)
        print 'Done with h%d' % i
    time.sleep(5)
    CLI(net)
    net.stop()
Example #60
0
def simpleTest():
    "Create and test a simple network"
    topo = MyTopo(n=4)
    net = Mininet(topo)
    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)

    config = topo.buildConfigIDS(net)
    f = open('/home/vagrant/middleclick/tmp.config.click', 'wb')
    f.write(config)
    f.close()
    #print("Launching Cheetah with config:")
    #print(config)
    mb = net.get(topo.mb1)
    for i in mb.intfList():
        mb.cmd('ethtool -K %s gro off' % i)
    cmd = "cd /home/vagrant/middleclick && ./bin/click --dpdk -l 1-1 --vdev=eth_af_packet0,iface=" + mb.intfList(
    )[0].name + " --vdev=eth_af_packet1,iface=" + mb.intfList(
    )[1].name + " -- tmp.config.click checksumoffload=0 word=nginx.com " + ' '.join(
        sys.argv[1:]) + " &> click.log &"
    print("Launching MiddleClick with " + cmd)
    mb.cmd(cmd)

    print("Waiting for MB to set up...")
    time.sleep(3)

    msrv = net.getNodeByName("ws1")
    msrv.cmd("sudo nginx")

    client = net.get("h1")
    print("Waiting for everything to set up...")
    time.sleep(2)

    print("Verifying connectivity")
    client.sendCmd(
        "timeout 2 wget -o /dev/null -O /dev/stdout http://10.220.0.1/")
    result = client.waitOutput()
    print(result)
    CLI(net)
    net.stop()