当前位置: 首页>>代码示例>>Python>>正文


Python Mininet.pingFull方法代码示例

本文整理汇总了Python中mininet.net.Mininet.pingFull方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.pingFull方法的具体用法?Python Mininet.pingFull怎么用?Python Mininet.pingFull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mininet.net.Mininet的用法示例。


在下文中一共展示了Mininet.pingFull方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: printTopo

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingFull [as 别名]
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()
开发者ID:heychen8118,项目名称:heychen,代码行数:17,代码来源:0456089-2.py

示例2: doExample

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingFull [as 别名]
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()
开发者ID:kapeterson,项目名称:mininetprojects,代码行数:25,代码来源:linksettings.py

示例3: testLinkDelay

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingFull [as 别名]
    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 )
开发者ID:1514louluo,项目名称:mininet,代码行数:40,代码来源:test_hifi.py

示例4: testLinkDelay

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingFull [as 别名]
 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)
开发者ID:rr2vicky,项目名称:Mininet1,代码行数:26,代码来源:test_hifi.py

示例5: stringBandwidthTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingFull [as 别名]
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
开发者ID:XianliangJ,项目名称:VirtualTimeKernel,代码行数:66,代码来源:vtmn_fidelity_tcp.py

示例6: linearBandwidthTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingFull [as 别名]
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()
    '''
开发者ID:sds-st,项目名称:odl,代码行数:68,代码来源:linearTopology.py

示例7: mynetwork

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingFull [as 别名]
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()
开发者ID:heychen8118,项目名称:heychenMAC,代码行数:63,代码来源:0456101.py


注:本文中的mininet.net.Mininet.pingFull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。