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


Python Mininet.showDilation方法代码示例

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


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

示例1: stringBandwidthTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import showDilation [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


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