def topology():
    'Create a network and controller'
    net = Mininet(controller=RemoteController, switch=OVSKernelSwitch)

    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           port=6653)

    info("*** Creating nodes\n")

    h1 = net.addHost('h1', ip='10.0.0.1/24', position='10,10,0')
    h2 = net.addHost('h2', ip='10.0.0.2/24', position='20,10,0')

    sw1 = net.addSwitch('sw1', protocols="OpenFlow13", position='12,10,0')
    sw2 = net.addSwitch('sw2', protocols="OpenFlow13", position='15,20,0')
    sw3 = net.addSwitch('sw3', protocols="OpenFlow13", position='18,10,0')
    sw4 = net.addSwitch('sw4', protocols="OpenFlow13", position='14,10,0')
    sw5 = net.addSwitch('sw5', protocols="OpenFlow13", position='16,10,0')
    sw6 = net.addSwitch('sw6', protocols="OpenFlow13", position='14,0,0')
    sw7 = net.addSwitch('sw7', protocols="OpenFlow13", position='16,0,0')

    info("*** Adding Link\n")
    net.addLink(h1, sw1)
    net.addLink(sw1, sw2)
    net.addLink(sw1, sw4)
    net.addLink(sw1, sw6)
    net.addLink(sw2, sw3)
    net.addLink(sw4, sw5)
    net.addLink(sw5, sw3)
    net.addLink(sw6, sw7)
    net.addLink(sw7, sw3)
    net.addLink(sw3, h2)

    info("*** Starting network\n")
    net.build()
    c0.start()
    sw1.start([c0])
    sw2.start([c0])
    sw3.start([c0])
    sw4.start([c0])
    sw5.start([c0])
    sw6.start([c0])
    sw7.start([c0])

    net.pingFull()

    info("*** Running CLI\n")
    CLI(net)

    info("*** Stopping network\n")
    net.stop()
def dumbbell_test():
    """ Create and test a dumbbell network.
    """
    topo = DumbbellTopo(delay=21)
    net = Mininet(topo)
    net.start()

    print "Dumping host connections..."
    dumpNodeConnections(net.hosts)

    print "Testing network connectivity..."
    h1, h2 = net.get('h1', 'h2')
    h3, h4 = net.get('h3', 'h4')

    for i in xrange(1, 10):
        net.pingFull(hosts=(h1, h2))

    for i in xrange(1, 10):
        net.pingFull(hosts=(h2, h1))

    for i in xrange(1, 10):
        net.pingFull(hosts=(h4, h3))

    for i in xrange(1, 10):
        net.pingFull(hosts=(h3, h4))

    print "Testing bandwidth between h1 and h2..."
    net.iperf(hosts=(h1, h2), fmt='m', seconds=10, port=5001)

    print "Testing bandwidth between h3 and h4..."
    net.iperf(hosts=(h3, h4), fmt='m', seconds=10, port=5001)

    print "Stopping test..."
    net.stop()
Example #3
0
def run_tests(delay):
    print("DELAY {0}".format(delay))
    topo = Dumbbell_Topology(delay)
    net = Mininet(topo=topo, link=TCLink)
    net.start()

    print("Dumping host connections")
    dumpNodeConnections(net.hosts)

    print("Testing network connectivity")
    h1, h3 = net.get('h1', 'h3')
    h2, h4 = net.get('h2', 'h4')

    for i in range(1, 10):
        net.pingFull(hosts=(h1, h3))

    for i in range(1, 10):
        net.pingFull(hosts=(h3, h1))

    for i in range(1, 10):
        net.pingFull(hosts=(h2, h4))

    for i in range(1, 10):
        net.pingFull(hosts=(h4, h2))

    print("Testing bandwidth between h1 and h3..")
    net.iperf(hosts=(h1, h3), fmt='m', seconds=10, port=5001)

    print("Testing bandwidth between h2 and h4")
    net.iperf(hosts=(h2, h4), fmt='m', seconds=10, port=5001)

    print("Stopping test...")
    net.stop()
Example #4
0
def printTopo():
    topo=MyTopo()
    net=Mininet(topo=topo,link=TCLink,controller=None)
    controller=net.addController('controller',controller=RemoteController,port=6653)
    client=net.get('host1')
    server1=net.get('host3')
    server2=net.get('host10')
    server1.popen('iperf -s -u -i 1')
    server2.popen('iperf -s -u -i 1')
    net.start()
    dumpNodeConnections(net.hosts)
    net.pingFull()
    client.cmdPrint('iperf -c '+server1.IP()+' -u -t 10 -i 1 -b 100m')
    client.cmdPrint('iperf -c '+server2.IP()+' -u -t 10 -i 1 -b 100m')
    net.stop()
Example #5
0
def fattree():
    topo = FatTreeTopo()

    net = Mininet(topo=topo, link=TCLink, controller=None)
    net.addController(
        'controller',
        controller=RemoteController,
        ip='127.0.0.1',
        port=6653,
    )

    net.start()
    dumpNodeConnections(net.hosts)
    net.pingFull()
    iperfTest(net)
    CLI(net)
    net.stop()
def doExample():
    print "Doing the example"
    topo = simpleTopology()

    # specify the host and link settings
    net = Mininet(topo, host=CPULimitedHost, link=TCLink)
    net.start()
    print "\n\n*****Dumping network******\n\n"
    dumpNodeConnections(net.hosts)
    print "\n\n*****Pinging All Hosts******\n\n"
    net.pingAll()

    print "\n\n"

    h1 = net.get("h1")
    h2 = net.get("h2")

    print "Running full ping"
    net.pingFull((h1, h2))
    print "Testing bandwidth between h1 and h2"

    net.iperf((h1, h2))
    net.stop()
Example #7
0
def perfTest():
    topo = MyTopo()
    net = Mininet(topo=topo, link=TCLink, controller=None)
    net.addController('mycontroller',
                      controller=RemoteController,
                      ip='127.0.0.1')
    net.start()

    print('Dumping host connections')
    dumpNodeConnections(net.hosts)
    print('Testing network connectivity')
    net.pingFull()
    print('Testing bandwidth between pods')
    h01, h02, h31 = net.get('h01', 'h02', 'h31')
    # iperf server1 in pod 0
    h01.popen('iperf -s -u -i 1 > diff_pod', shell=True)
    # iperf server2 in pod 3
    h31.popen('iperf -s -u -i 1 > same_pod', shell=True)
    # iperf client send to server1 & server2
    h02.cmdPrint('iperf -c ' + h01.IP() + ' -u -t 10 -i 1 -b 100m')
    h02.cmdPrint('iperf -c ' + h31.IP() + ' -u -t 10 -i 1 -b 100m')
    net.stop()
    Cleanup()
Example #8
0
def WidestTest():
    topo = WidestTestTopo()
    net = Mininet(topo=topo,
                  host=CPULimitedHost, link=TCLink, controller=RemoteController, autoSetMacs=True)
    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    print "Testing network connectivity"
    net.pingAll()
    h1, h2 = net.get('h1', 'h2')
    print "Testing latency between h1 and h2"
    net.pingFull((h1,h2))
    print "Testing bandwidth between h1 and h2"
    net.iperf((h1, h2), seconds=60)
    for i in xrange(7):
        dstr = dump_flows('s' + str(i+1))
        lines = dstr.split('\n')
        print lines[0]
        for line in lines[1:]:
            if 'dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02' in line:
                print line

    CLI(net)
    net.stop()
Example #9
0
def random_ping_function(lengths):
    topo = LinearTestTopo(lengths)
    net = Mininet(topo=topo)
    net.start()

    node_pool = range(lengths)
    random.shuffle(node_pool)
    data_point = 0
    while node_pool:

        pings = []
        poppy = [node_pool.pop(), node_pool.pop()]
        poppy.sort()
        #print(poppy)
        sub_list = []
        for n in range(poppy[0], poppy[1] + 1):
            sub_list.append(n)
        for i, n in enumerate(sub_list):
            pings.append([])
            for j, m in enumerate(sub_list):
                if n == m:
                    pings[i].append(0.0)
                    continue

                pings[i].append(
                    net.pingFull([net.hosts[n], net.hosts[m]])[0][2][3])
        df = pd.DataFrame(pings, index=sub_list, columns=sub_list)

        low_res_list = []
        new_i = 0
        for index, row in df.iterrows():

            for item in row:
                low_res_list.append([index, item])
            ++new_i
        pp = pprint.PrettyPrinter(depth=6)
        low_rez_df = pd.DataFrame(low_res_list,
                                  columns=("origin", "destination"))
        low_rez_df.to_csv('data/test' + str(data_point) + '.csv')
        #pp.pprint(low_res_list)
        #low_rez_df.plot(kind='hexbin',x='origin',y='destination',gridsize=50,cmap='inferno')
        #plt.savefig('data/plot'+str(data_point))
        data_point += 1

    net.stop()
    def testLinkDelay(self):
        "Verify that link delays are accurate within a bound."
        # ISSUE: Compared to Mininet's default light container, DockerHost is
        # heavier and can not reach a very low latency parameter like 10ms
        DELAY_MS = 100
        DELAY_TOLERANCE = 0.6  # Delay fraction below which test should fail
        REPS = 3
        lopts = {"delay": "%sms" % DELAY_MS, "use_htb": True}
        mn = Mininet(
            topo=SingleSwitchOptionsTopo(n=N, lopts=lopts),
            link=TCLink,
            switch=self.switchClass,
            autoStaticArp=True,
            waitConnected=True,
        )
        mn.start()
        for _ in range(REPS):
            ping_delays = mn.pingFull()
        test_outputs = ping_delays[0]
        # Ignore unused variables below
        # pylint: disable=W0612
        node, dest, ping_outputs = test_outputs
        sent, received, rttmin, rttavg, rttmax, rttdev = ping_outputs
        pingFailMsg = "sent %s pings, only received %s" % (sent, received)
        self.assertEqual(sent, received, msg=pingFailMsg)
        # pylint: enable=W0612
        loptsStr = ", ".join("%s: %s" % (opt, value)
                             for opt, value in lopts.items())
        msg = ("\nTesting Link Delay of %s ms\n"
               "ping results across 4 links:\n"
               "(Sent, Received, rttmin, rttavg, rttmax, rttdev)\n"
               "%s\n"
               "Topo = SingleSwitchTopo, %s hosts\n"
               "Link = TCLink\n"
               "lopts = %s\n"
               "host = default"
               "switch = %s\n" %
               (DELAY_MS, ping_outputs, N, loptsStr, self.switchClass))

        mn.stop()
        for rttval in [rttmin, rttavg, rttmax]:
            # Multiply delay by 4 to cover there & back on two links
            self.assertWithinTolerance(rttval, DELAY_MS * 4.0, DELAY_TOLERANCE,
                                       msg)
Example #11
0
def ping_function(lengths):
    pings = []
    topo = LinearTestTopo(lengths)
    net = Mininet(topo=topo)
    net.start()
    for n in range(0, lengths):
        pings.append([])
        for m in range(0, lengths):
            if n == m:
                pings[n].append(None)
                continue

            pings[n].append(
                net.pingFull([net.hosts[n], net.hosts[m]])[0][2][3])
        #pings.append(net.pingFull( [ net.hosts[ 0 ], net.hosts[ n ] ] )[0][2][3])
        #print(len(net.hosts),n)
    with open("fullresolution.csv", "wb") as f:
        writer = csv.writer(f)
        writer.writerows(pings)
    net.stop()
Example #12
0
    def testLinkDelay(self):
        "Verify that link delays are accurate within a bound."
        DELAY_MS = 15
        DELAY_TOLERANCE = 0.8  # Delay fraction below which test should fail
        REPS = 3
        lopts = {'delay': '%sms' % DELAY_MS, 'use_htb': True}
        mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts),
                     link=TCLink,
                     switch=self.switchClass,
                     autoStaticArp=True,
                     waitConnected=True)
        mn.start()
        for _ in range(REPS):
            ping_delays = mn.pingFull()
        mn.stop()
        test_outputs = ping_delays[0]
        # Ignore unused variables below
        # pylint: disable-msg=W0612
        node, dest, ping_outputs = test_outputs
        sent, received, rttmin, rttavg, rttmax, rttdev = ping_outputs
        pingFailMsg = 'sent %s pings, only received %s' % (sent, received)
        self.assertEqual(sent, received, msg=pingFailMsg)
        # pylint: enable-msg=W0612
        loptsStr = ', '.join('%s: %s' % (opt, value)
                             for opt, value in lopts.items())
        msg = ('\nTesting Link Delay of %s ms\n'
               'ping results across 4 links:\n'
               '(Sent, Received, rttmin, rttavg, rttmax, rttdev)\n'
               '%s\n'
               'Topo = SingleSwitchTopo, %s hosts\n'
               'Link = TCLink\n'
               'lopts = %s\n'
               'host = default'
               'switch = %s\n' %
               (DELAY_MS, ping_outputs, N, loptsStr, self.switchClass))

        for rttval in [rttmin, rttavg, rttmax]:
            # Multiply delay by 4 to cover there & back on two links
            self.assertWithinTolerance(rttval, DELAY_MS * 4.0, DELAY_TOLERANCE,
                                       msg)
Example #13
0
    def testLinkDelay( self ):
        "Verify that link delays are accurate within a bound."
        DELAY_MS = 15
        DELAY_TOLERANCE = 0.8  # Delay fraction below which test should fail
        REPS = 3
        lopts = { 'delay': '%sms' % DELAY_MS, 'use_htb': True }
        mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
                      link=TCLink, switch=self.switchClass, autoStaticArp=True,
                      waitConnected=True )
        mn.start()
        for _ in range( REPS ):
            ping_delays = mn.pingFull()
        mn.stop()
        test_outputs = ping_delays[0]
        # Ignore unused variables below
        # pylint: disable=W0612
        node, dest, ping_outputs = test_outputs
        sent, received, rttmin, rttavg, rttmax, rttdev = ping_outputs
        pingFailMsg = 'sent %s pings, only received %s' % ( sent, received )
        self.assertEqual( sent, received, msg=pingFailMsg )
        # pylint: enable=W0612
        loptsStr = ', '.join( '%s: %s' % ( opt, value )
                              for opt, value in lopts.items() )
        msg = ( '\nTesting Link Delay of %s ms\n'
                'ping results across 4 links:\n'
                '(Sent, Received, rttmin, rttavg, rttmax, rttdev)\n'
                '%s\n'
                'Topo = SingleSwitchTopo, %s hosts\n'
                'Link = TCLink\n'
                'lopts = %s\n'
                'host = default'
                'switch = %s\n'
                % ( DELAY_MS, ping_outputs, N, loptsStr, self.switchClass ) )

        for rttval in [rttmin, rttavg, rttmax]:
            # Multiply delay by 4 to cover there & back on two links
            self.assertWithinTolerance( rttval, DELAY_MS * 4.0,
                                        DELAY_TOLERANCE, msg )
Example #14
0
 def testLinkDelay( self ):
     "Verify that link delays are accurate within a bound."
     DELAY_MS = 15
     DELAY_TOLERANCE = 0.8  # Delay fraction below which test should fail
     REPS = 3
     lopts = { 'delay': '%sms' % DELAY_MS, 'use_htb': True }
     mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
                   link=TCLink, switch=self.switchClass, autoStaticArp=True,
                   waitConnected=True )
     mn.start()
     for _ in range( REPS ):
         ping_delays = mn.pingFull()
     mn.stop()
     test_outputs = ping_delays[0]
     # Ignore unused variables below
     # pylint: disable-msg=W0612
     node, dest, ping_outputs = test_outputs
     sent, received, rttmin, rttavg, rttmax, rttdev = ping_outputs
     self.assertEqual( sent, received )
     # pylint: enable-msg=W0612
     for rttval in [rttmin, rttavg, rttmax]:
         # Multiply delay by 4 to cover there & back on two links
         self.assertWithinTolerance( rttval, DELAY_MS * 4.0, 
                                     DELAY_TOLERANCE)
def Start(GI=False, MCS=2, Bandwidth=20, UDP=True, TP=20, PCAP=False):
    setLogLevel( 'info' )
    #info( '*** ns-3 network demo\n' )
    net = Mininet()

    #info( '*** Creating Network\n' )
    h0 = net.addHost( 'h0' )
    #h1 = net.addHost( 'h1' )
    h2 = net.addHost( 'h2' )

    wifi = WIFISegment()

    #CONFIGURATION
    udp = UDP
    gi = GI #0,1
    bandwidth = Bandwidth #20,40,80
    mcs = MCS #2,4,7

    if udp == False:
        #TCP
        payloadSize = 1448  #bytes
        ns.core.Config.SetDefault ("ns3::TcpSocket::SegmentSize", ns.core.UintegerValue (payloadSize))
    else:
        payloadSize = 1472

    wifi.wifihelper.SetStandard(ns.wifi.WIFI_PHY_STANDARD_80211ac)

    # Enabling Shor guard intervals:
    wifi.phyhelper.Set("ShortGuardEnabled", ns.core.BooleanValue(gi))
    
    DataRate = ns.wifi.VhtWifiMacHelper.DataRateForMcs(mcs)
    #DataRate = ns.core.StringValue("VhtMcs3")

    # set datarate for node h0
    wifi.wifihelper.SetRemoteStationManager( "ns3::ConstantRateWifiManager",
                                             "DataMode", DataRate, "ControlMode", ns.wifi.VhtWifiMacHelper.DataRateForMcs(0) )
    
    wifi.machelper = ns.wifi.VhtWifiMacHelper.Default()
    
    #wifi.wifihelper.SetRemoteStationManager( "ns3::ConstantRateWifiManager",
    #                                         "DataMode", ns.core.StringValue ("VhtMcs8"), "ControlMode", ns.core.StringValue ("VhtMcs8") )
    
    Sssid = "wifi-80211acCA"
    
    wifi.addSta( h0,ext="ac",ca=True, ssid=Sssid )
 
    wifi.addAp( h2,ext="ac",ca=True, ssid=Sssid  )
    
    # set channel bandwidth
    ns.core.Config.Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", ns.core.UintegerValue (bandwidth))
    
    if PCAP == True:
        wifi.phyhelper.EnablePcap( "80211ac_Sta1.pcap", h0.nsNode.GetDevice( 0 ), True, True );
        #wifi.phyhelper.EnablePcap( "Ap-h1.pcap", h1.nsNode.GetDevice( 1 ), True, True );
        wifi.phyhelper.EnablePcap( "80211ac_Ap.pcap", h2.nsNode.GetDevice( 0 ), True, True );
   
    #info( '*** Configuring hosts\n' )
    h0.setIP('192.168.123.1/24')
    #h1.setIP('192.168.123.2/24')
    h2.setIP('192.168.123.3/24')

    mininet.ns3.start()

    #info( '\n *** Testing network connectivity\n' )
    net.pingFull([h0,h2])
    h0.cmdPrint("ping 192.168.123.3 -c 10")
    info( '*** Testing bandwidth between h0 and h2 while h1 is not transmitting\n' )
    h2.sendCmd( "iperf -s -i 1 -u" )
    val = "iperf -c 192.168.123.3 -u -b "+str(TP)+"M"
    h0.cmdPrint(val)
Example #16
0
def stringBandwidthTest(host_class, controller_class, link_class, size, tdf,
                        data_file):

    "Check bandwidth at various lengths along a switch chain."

    topo_class = StringTestTopo(size)

    net = Mininet(topo=topo_class,
                  host=host_class,
                  switch=OVSKernelSwitch,
                  controller=controller_class,
                  waitConnected=True,
                  link=link_class)
    # no tdf_adaptor to change TDF
    net.start()

    print "*** testing basic connectivity\n"
    src, dst = net.hosts
    if tdf == 1:
        num_pings = 3
        for i in irange(1, num_pings):
            ping_result = list(net.pingFull([src, dst]))
            # ping_result=[(host1), (host2)]
            # host = (src, dst, data)
            # data = (#sent, #received, rttmin, rttavg, rttmax, rttdev)
            print "Ping avg rtt = %s\n" % ping_result[0][2][3]
            rttavg = ping_result[0][2][3]
        data_file.write("RTT Avg = %s ms\n" % rttavg)
    else:
        net.ping([src, dst])

    print "*** testing bandwidth\n"
    num_rounds = 5
    client_history = []
    time = 16
    omit = 1
    for i in irange(1, num_rounds):
        # bandwidth = net.iperf( [src, dst], l4Type = 'UDP', udpBw='%sM'%set_bw, format = 'm', time=20, clifile=data_file, serfile=data_file )
        bandwidth = net.iperf([src, dst],
                              l4Type='TCP',
                              format='m',
                              time=time,
                              omit=omit,
                              clifile=data_file,
                              serfile=data_file)
        flush()
        serout = bandwidth[0]
        cliout = bandwidth[1]

        if len(serout) > 0 and len(cliout) > 0:
            serDataStr, unit = serout.split(" ")
            serData = float(serDataStr)

            cliDataStr, unit = cliout.split(" ")
            cliData = float(cliDataStr)
            client_history.append(cliData)
            data_file.write("%s\t%f\t%f\t%s\t%s\n" %
                            (size, src.tdf, net.cpu_usage, serData, cliData))

    client_mean = numpy.mean(client_history)
    client_stdev = numpy.std(client_history)
    data_file.write("Avg Throughtput = %f\n" % client_mean)
    data_file.write("STD Throughput = %f\n" % client_stdev)
    print "AVG = %f " % client_mean
    print "STD = %f " % client_stdev
    data_file.write('\n\n')
    net.stop()
    return client_mean, client_stdev
def stringBandwidthTest(host_class, controller_class,
                        link_class, size, tdf, data_file):
    "Check bandwidth at various lengths along a switch chain."
    topo_class = StringTestTopo(size)
    net = Mininet(topo=topo_class, host=host_class,
                  switch=OVSKernelSwitch, controller=controller_class,
                  waitConnected=False, link=link_class)
    net.start()

    if tdf != 1:
        net.dilateEmulation(tdf)
    
    print "*** testing basic connectivity\n"
    src, dst = net.hosts
    num_pings = 3
    for i in irange(1, num_pings):
        ping_result = list(net.pingFull( [ src, dst ] ))
        # ping_result=[(host1), (host2)]
        # host = (src, dst, data)
        # data = (#sent, #received, rttmin, rttavg, rttmax, rttdev)
        print "Ping avg rtt = %s\n" % ping_result[0][2][3]
        rttavg = ping_result[0][2][3]
    data_file.write( "RTT Avg = %s ms\n" % rttavg)

    print "*** testing bandwidth\n"
    num_rounds = 2
    client_history = []
    time = 10
    for i in irange(1, num_rounds):
        net.showDilation()
        bandwidth = net.iperf( [src, dst], l4Type = 'TCP',
                              fmt = 'm', seconds=time,
                              clifile=data_file, serfile=data_file )
        # bandwidth = net.iperf( [src, dst], l4Type = 'UDP',
                              # fmt = 'm', seconds=time,
                              # clifile=data_file, serfile=data_file )
        flush()
        net.showDilation()
 
        serout = bandwidth[0]
        cliout = bandwidth[1]

        if len(serout) > 0 and len(cliout) > 0:
            serDataStr, unit = serout.split(" ")
            serData = float(serDataStr)

            cliDataStr, unit = cliout.split(" ")
            cliData = float(cliDataStr)
            client_history.append(cliData)
            data_file.write("%s\t%f\t%s\t%s\n" % (size, tdf, serData, cliData))


    client_mean = numpy.mean(client_history)
    client_stdev = numpy.std(client_history)
    data_file.write( "Avg Throughtput = %f\n" % client_mean )
    data_file.write( "STD Throughput = %f\n" % client_stdev )
    print "AVG = %f " % client_mean
    print "STD = %f " % client_stdev
    data_file.write('\n\n')
    # CLI(net)

    net.stop()
    cleanup()
    return client_mean, client_stdev
Example #18
0
def Start(GI=False, MCS=2, Bandwidth=20, UDP=True, TP=20, PCAP=False):
    setLogLevel('info')
    #info( '*** ns-3 network demo\n' )
    net = Mininet()

    #info( '*** Creating Network\n' )
    h0 = net.addHost('h0')
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 = net.addHost('h3')
    h4 = net.addHost('h4')
    h5 = net.addHost('h5')

    wifi = WIFISegment()

    #CONFIGURATION
    udp = UDP
    gi = GI  #0,1
    bandwidth = Bandwidth  #20,40,80
    mcs = MCS  #2,4,7

    if udp == False:
        #TCP
        payloadSize = 1448  #bytes
        ns.core.Config.SetDefault("ns3::TcpSocket::SegmentSize",
                                  ns.core.UintegerValue(payloadSize))
    else:
        payloadSize = 1472

    wifi.wifihelper.SetStandard(ns.wifi.WIFI_PHY_STANDARD_80211ac)

    # Enabling Shor guard intervals:
    wifi.phyhelper.Set("ShortGuardEnabled", ns.core.BooleanValue(gi))

    DataRate = "VhtMcs" + str(mcs)

    # set datarate for node h0
    wifi.wifihelper.SetRemoteStationManager("ns3::ConstantRateWifiManager",
                                            "DataMode",
                                            ns.core.StringValue(DataRate),
                                            "ControlMode",
                                            ns.core.StringValue(DataRate))

    wifi.machelper = ns.wifi.WifiMacHelper()

    Sssid = "wifi-80211ac"

    wifi.addSta(h0, ssid=Sssid)
    wifi.addSta(h1, ssid=Sssid)
    wifi.addSta(h2, ssid=Sssid)
    wifi.addSta(h3, ssid=Sssid)
    wifi.addSta(h4, ssid=Sssid)
    wifi.addAp(h5, ssid=Sssid)

    # set channel bandwidth
    ns.core.Config.Set(
        "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth",
        ns.core.UintegerValue(bandwidth))

    if PCAP == True:
        wifi.phyhelper.EnablePcap("80211ac_Sta1.pcap", h0.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211ac_Sta2.pcap", h1.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211ac_Sta3.pcap", h2.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211ac_Sta4.pcap", h3.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211ac_Sta5.pcap", h4.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211ac_Ap.pcap", h5.nsNode.GetDevice(0),
                                  True, True)

    #info( '*** Configuring hosts\n' )
    h0.setIP('192.168.123.1/24')
    h1.setIP('192.168.123.2/24')
    h2.setIP('192.168.123.3/24')
    h3.setIP('192.168.123.4/24')
    h4.setIP('192.168.123.5/24')
    h5.setIP('192.168.123.6/24')

    mininet.ns3.start()

    #info( '\n *** Testing network connectivity\n' )
    net.pingFull([h0, h5])
    #net.pingFull([h1,h2])
    #net.pingFull([h0,h1])
    info('*** Starting UDP iperf server on AP(h5)\n')
    h5.sendCmd("iperf -s -i 1 -u")
    info('*** Testing bandwidth between h0 and h5 none is transmitting\n')
    val = "iperf -c 192.168.123.6 -u -b " + str(TP) + "M"
    h0.cmdPrint(val)
    info(
        '*** Testing bandwidth between h0 and h5 while everyone transmitting\n'
    )
    val = "iperf -c 192.168.123.6 -u -b " + str(TP) + "M"
    h1.sendCmd(val)
    h2.sendCmd(val)
    h3.sendCmd(val)
    h0.sendCmd(val)
    h4.cmdPrint(val)
Example #19
0
def linearBandwidthTest( lengths ):

    "Check bandwidth at various lengths along a switch chain."

    results = {}
    switchCount = max( lengths )
    hostCount = switchCount + 1

    switches = { 'reference user': UserSwitch,
                 'Open vSwitch kernel': OVSKernelSwitch }

    # UserSwitch is horribly slow with recent kernels.
    # We can reinstate it once its performance is fixed
    del switches[ 'reference user' ]

    topo = LinearTestTopo( hostCount )

    # Select TCP Reno
    output = quietRun( 'sysctl -w net.ipv4.tcp_congestion_control=reno' )
    assert 'reno' in output

    for datapath in switches.keys():
        print "*** testing", datapath, "datapath"
        Switch = switches[ datapath ]
        results[ datapath ] = []
        link = partial( TCLink, delay='1ms' )
        net = Mininet( topo=topo, switch=Switch,
                       controller=RemoteController, waitConnected=True,
                       link=link )
        net.start()
        print "*** testing basic connectivity"
        for n in lengths:
	    print "*** first ping***"
            net.pingFull( [ net.hosts[ 0 ], net.hosts[ n ] ] )
	    print "*** second ping***"
	    net.pingFull( [ net.hosts[ 0 ], net.hosts[ n ] ] )
        print "*** testing bandwidth"
        for n in lengths:
	    print "***h1 -> h"+str(n)
            src, dst = net.hosts[ 0 ], net.hosts[ n ]
            # Try to prime the pump to reduce PACKET_INs during test
            # since the reference controller is reactive
            #src.cmd( 'telnet', dst.IP(), '5001' )
            print "testing", src.name, "<->", dst.name,
            bandwidth = net.iperf( [ src, dst ], seconds=10 )
            print bandwidth
            flush()
            #results[ datapath ] += [ ( n, bandwidth ) ]
	    print "***h1 -> h2"
            src, dst = net.hosts[ 0 ], net.hosts[ 1 ]
            # Try to prime the pump to reduce PACKET_INs during test
            # since the reference controller is reactive
            #src.cmd( 'telnet', dst.IP(), '5001' )
            print "testing", src.name, "<->", dst.name,
            bandwidth = net.iperf( [ src, dst ], seconds=10 )
            print bandwidth
            flush()
            #results[ datapath ] += [ ( n, bandwidth ) ]
	print "Starting a web server on h1 host: python -m SimpleHTTPServer 80 >& /tmp/http.log &"
	#print net.hosts[ 0 ].cmd('ping -c 2', net.hosts[ 1 ].IP())
	print net.hosts[ 0 ].cmd( 'python -m SimpleHTTPServer 80 >& /tmp/http.log &' )
	print "Http Request from h2 to h1: h2 wget h1"
	#print net.hosts[ 1 ].cmd( 'wget http://10.0.0.1') 
	CLI(net)        
	net.stop()
    '''
net = Mininet(controller=RemoteController)
s = list()
h = list()
sInt = list()
hInt = list()

def createTopo(nSwitch):
	#create nodes
	c0 = net.addController()
	s.append(net.addSwitch('s0'))

	for i in range(0, nSwitch):
		s.append(net.addSwitch('s'+str(i+1)))
		h.append(net.addHost('h'+str(i)))
		sInt.append(linkIntfs(s[0], s[i+1]))
		hInt.append(linkIntfs(h[i],s[i+1]))

createTopo(args.n)

net.start()

if(args.lt == True):
    for j in range(0, len(h)):
        for k in range(0, len(h)):
        	if(h[j] != h[k] ):
        		for l in range(0, 4):
	        		hostPair = [h[j], h[k]]
	        		net.pingFull(hostPair)
CLI(net)
net.stop()
Example #21
0
def mynetwork():
    net = Mininet(link=TCLink)
    c0 = net.addController( 'c0',controller =  RemoteController, port=6653)
    linkopts = dict(bw=100)
    core_linkopts = dict(bw=1000,loss=2)
    s1 = net.addSwitch('s1001')
    s2 = net.addSwitch('s1002')
    s3 = net.addSwitch('s1003')
    s4 = net.addSwitch('s1004')
    for i in range(0,4):
        switch_name = 's300'+str(2*i+1)
        s31 = net.addSwitch(name = switch_name)
        switch_name = 's200'+str(2*i+1)
        s21 = net.addSwitch(name = switch_name)
        switch_name = 's300'+str(2*i+2)
        s32 = net.addSwitch(name = switch_name)
        switch_name = 's200'+str(2*i+2)
        s22 = net.addSwitch(name = switch_name)
        net.addLink(s31,s21, **linkopts)
        net.addLink(s31,s22, **linkopts)
        net.addLink(s32,s21, **linkopts)
        net.addLink(s32,s22, **linkopts)
        net.addLink(s1,s21, **core_linkopts)
        net.addLink(s2,s21, **core_linkopts)
        net.addLink(s3,s22, **core_linkopts)
        net.addLink(s4,s22, **core_linkopts)
        for j in range(1,5):
            host_name = 'h'+str(4*i+j)
            h1 = net.addHost(name = host_name)
            if i == 0:
                if j == 1:
                    client = h1
            if j < 3:
                net.addLink(h1,s31, **linkopts)
            else:
                net.addLink(h1,s32, **linkopts)
            if (i == 0) or (i == 3):
                if j == 3:
                    h1.popen('iperf -s -u -i 1')
                    if i == 0:
                        server_1 = h1
                    else:
                        server_2 = h1
    ''' each pod has 4 hosts, h1,h2,h3,h4
        server 1 is in pod 0 host 3
        server 2 is in pod 3 host 3
        client is in pod 0 host 1'''
    try:
        net.start()
        print 'Dumping host connections'
        dumpNodeConnections(net.hosts)
        print 'Testing network connectivity'
        net.pingFull()

        print 'Testing iperf'
        client.cmdPrint('iperf -c ' + server_1.IP()+' -u -t 10 -i 1 -b 100m')
        client.cmdPrint('iperf -c ' + server_2.IP()+' -u -t 10 -i 1 -b 100m')
        CLI(net)
        Cleanup().cleanup()
    except KeyboardInterrupt:
        Cleanup().cleanup()
def stringBandwidthTest(host_class, controller_class, link_class, size, tdf,
                        data_file):
    "Check bandwidth at various lengths along a switch chain."

    topo_class = StringTestTopo(size)

    net = Mininet(topo=topo_class,
                  host=host_class,
                  switch=OVSKernelSwitch,
                  controller=controller_class,
                  waitConnected=True,
                  link=link_class)
    net.start()

    src, dst = net.hosts[0], net.hosts[1]
    print "*** testing basic connectivity"
    net.ping([src, dst])

    if tdf == 1:
        num_pings = 3
        for i in irange(1, num_pings):
            ping_result = list(net.pingFull([src, dst]))
            rttavg = ping_result[0][2][3]
        data_file.write("%s\t" % rttavg)
        data_file.flush()

    print "*** testing bandwidth"
    print "testing", src, "<->", dst

    num_rounds = 8
    #cli_results = []
    ser_results = []
    omit = 1
    time = 11
    start = timeit.default_timer()
    for i in irange(1, num_rounds):
        bandwidth = net.iperf([src, dst],
                              l4Type='TCP',
                              format='m',
                              time=time,
                              omit=omit)
        flush()
        serout = bandwidth[0]
        cliout = bandwidth[1]

        if len(serout) > 0:
            serDataStr, unit = serout.split(" ")
            serData = float(serDataStr)
            if serData > 0.1:
                ser_results.append(serData)

        #if len(cliout) > 0:
        #cliDataStr, unit = cliout.split(" ")
        #cliData = float(cliDataStr)
        #if cliData > 0.1:
        #cli_results.append( cliData )

    end = timeit.default_timer()
    elapsed = end - start
    print "elapsed: %s\n" % elapsed
    # unit = Mbits/sec
    #avgCliBw = numpy.mean( cli_results )
    #stdevCliBw = numpy.std( cli_results )
    maxSerBw = numpy.amax(ser_results)
    minSerBw = numpy.amin(ser_results)
    if len(ser_results) >= 10:
        ser_results.remove(maxSerBw)
        ser_results.remove(minSerBw)

    avgSerBw = numpy.mean(ser_results)
    stdevSerBw = numpy.std(ser_results)
    print "Avg = %f" % avgSerBw
    print "Std = %f" % stdevSerBw
    #data_file.write("%s\t%s\t%s\t%s\t%s\n" % (size, avgCliBw, stdevCliBw, maxCliBw, minCliBw))
    data_file.write("%s\t%s\t%s\t%s\n" % (size, avgSerBw, stdevSerBw, elapsed))
    data_file.flush()
    net.stop()
    return avgSerBw, stdevSerBw
Example #23
0
def stringBandwidthTest(host_class, controller_class, link_class, size, tdf,
                        data_file):
    "Check bandwidth at various lengths along a switch chain."
    topo_class = StringTestTopo(size)
    net = Mininet(topo=topo_class,
                  host=host_class,
                  switch=OVSKernelSwitch,
                  controller=controller_class,
                  waitConnected=False,
                  link=link_class)
    net.start()

    if tdf != 1:
        net.dilateEmulation(tdf)

    print "*** testing basic connectivity\n"
    src, dst = net.hosts
    num_pings = 3
    for i in irange(1, num_pings):
        ping_result = list(net.pingFull([src, dst]))
        # ping_result=[(host1), (host2)]
        # host = (src, dst, data)
        # data = (#sent, #received, rttmin, rttavg, rttmax, rttdev)
        print "Ping avg rtt = %s\n" % ping_result[0][2][3]
        rttavg = ping_result[0][2][3]
    data_file.write("RTT Avg = %s ms\n" % rttavg)

    print "*** testing bandwidth\n"
    num_rounds = 2
    client_history = []
    time = 10
    for i in irange(1, num_rounds):
        net.showDilation()
        bandwidth = net.iperf([src, dst],
                              l4Type='TCP',
                              fmt='m',
                              seconds=time,
                              clifile=data_file,
                              serfile=data_file)
        # bandwidth = net.iperf( [src, dst], l4Type = 'UDP',
        # fmt = 'm', seconds=time,
        # clifile=data_file, serfile=data_file )
        flush()
        net.showDilation()

        serout = bandwidth[0]
        cliout = bandwidth[1]

        if len(serout) > 0 and len(cliout) > 0:
            serDataStr, unit = serout.split(" ")
            serData = float(serDataStr)

            cliDataStr, unit = cliout.split(" ")
            cliData = float(cliDataStr)
            client_history.append(cliData)
            data_file.write("%s\t%f\t%s\t%s\n" % (size, tdf, serData, cliData))

    client_mean = numpy.mean(client_history)
    client_stdev = numpy.std(client_history)
    data_file.write("Avg Throughtput = %f\n" % client_mean)
    data_file.write("STD Throughput = %f\n" % client_stdev)
    print "AVG = %f " % client_mean
    print "STD = %f " % client_stdev
    data_file.write('\n\n')
    # CLI(net)

    net.stop()
    cleanup()
    return client_mean, client_stdev
    #tiempo de retraso entre cada registro top a generar recibidos por consola
    delay = int(sys.argv[2])
net = Mininet()
times = (num_regs * delay)
print "-----------------------------------------------------------------"
print "PRUEBA DE RECURSOS DEL SISTEMA CORRIENDO MININET PYTHON LATENCIA"
print "Resultado disponible en Codigo/test4_res2_systconapiping.txt"
print "-----------------------------------------------------------------"
#print 'Agregando Controller'
net.addController('c0')
#print "Agregando hosts"
net.addHost("h0")
net.addHost("h1")
#print "Agregando Switch"
net.addSwitch("s1")
#print "Agregando enlaces entre hosts y sw"
net.addLink("h0", "s1")
net.addLink("h1", "s1")
#print 'Iniciando red'
net.start()
fo = open("test4_res2_systconapiping.txt", "w")
while times > 0:
    if times % 30 == 0:
        fo.write("PING " + str(times) + " segundos\n")
        fo.write(str(net.pingFull()) + "\n\n")
print "Tiempo restante: " + str(times) + " segundos"
time.sleep(1)
times = times - 1
fo.close()
net.stop()
print "Proceso en Python finalizado"
Example #25
0
def Start(OFDM_R=9, UDP=True, TP=9, PCAP=False):
    setLogLevel('info')
    #info( '*** ns-3 network demo\n' )
    net = Mininet()

    #info( '*** Creating Network\n' )
    h0 = net.addHost('h0')
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 = net.addHost('h3')
    h4 = net.addHost('h4')
    h5 = net.addHost('h5')

    wifi = WIFISegment()

    #CONFIGURATION
    udp = UDP
    bandwidth = 20
    ofdm_r = "OfdmRate" + str(OFDM_R) + "Mbps"
    OfdmRate = ofdm_r  #9,24,48
    if udp == False:
        #TCP
        payloadSize = 1448  #bytes
        ns.core.Config.SetDefault("ns3::TcpSocket::SegmentSize",
                                  ns.core.UintegerValue(payloadSize))
    else:
        payloadSize = 1472

    wifi = WIFISegment()

    wifi.wifihelper.SetStandard(ns.wifi.WIFI_PHY_STANDARD_80211a)

    wifi.wifihelper.SetRemoteStationManager(
        "ns3::ConstantRateWifiManager", "DataMode",
        ns.core.StringValue(OfdmRate), "ControlMode",
        ns.core.StringValue("OfdmRate9Mbps"))

    Sssid = "wifi-80211a"

    wifi.addSta(h0, ssid=Sssid)
    wifi.addSta(h1, ssid=Sssid)
    wifi.addSta(h2, ssid=Sssid)
    wifi.addSta(h3, ssid=Sssid)
    wifi.addSta(h4, ssid=Sssid)
    wifi.addAp(h5, ssid=Sssid)

    # set channel bandwidth
    ns.core.Config.Set(
        "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth",
        ns.core.UintegerValue(bandwidth))

    if PCAP == True:
        wifi.phyhelper.EnablePcap("80211a_sta1.pcap", h0.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211a_sta2.pcap", h1.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211a_sta3.pcap", h2.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211a_sta4.pcap", h3.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211a_sta5.pcap", h4.nsNode.GetDevice(0),
                                  True, True)
        wifi.phyhelper.EnablePcap("80211a_ap.pcap", h5.nsNode.GetDevice(0),
                                  True, True)

    #info( '*** Configuring hosts\n' )
    h0.setIP('192.168.123.1/24')
    h1.setIP('192.168.123.2/24')
    h2.setIP('192.168.123.3/24')
    h3.setIP('192.168.123.4/24')
    h4.setIP('192.168.123.5/24')
    h5.setIP('192.168.123.6/24')

    mininet.ns3.start()

    #info( '\n *** Testing network connectivity\n' )
    net.pingFull([h0, h5])
    #net.pingFull([h1,h2])
    #net.pingFull([h0,h1])
    info('*** Starting UDP iperf server on AP(h5)\n')
    h5.sendCmd("iperf -s -i 1 -u")
    info(
        '*** Testing bandwidth between h0 and h5 while others stas are not transmitting\n'
    )
    val = "iperf -c 192.168.123.6 -u -b " + str(TP) + "M"
    h0.cmdPrint(val)
    info(
        '*** Testing bandwidth between h0 and h5 while all stats are also transmitting\n'
    )
    val = "iperf -c 192.168.123.6 -u -b " + str(TP) + "M"
    h0.sendCmd(val)
    h1.sendCmd(val)
    h2.sendCmd(val)
    h3.sendCmd(val)
    h4.cmdPrint(val)