本文整理汇总了Python中mininet.net.Mininet.dilateEmulation方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.dilateEmulation方法的具体用法?Python Mininet.dilateEmulation怎么用?Python Mininet.dilateEmulation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.dilateEmulation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stringBandwidthTest
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import dilateEmulation [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