本文整理汇总了Python中mininet.net.Mininet.run方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.run方法的具体用法?Python Mininet.run怎么用?Python Mininet.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testNet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testNet():
net = Mininet(topo = LobaTopo(), build = False, switch = UserSwitch)
# Add my remote controller
info('*** Adding controller\n')
net.addController('c0', RemoteController, ip = '10.37.129.2', port = 8888)
info('c0\n')
net.run(CLI, net)
示例2: testLinkBandwidth
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testLinkBandwidth( self ):
"Verify that link bandwidths are accurate within a bound."
if self.switchClass is UserSwitch:
self.skipTest( 'UserSwitch has very poor performance -'
' skipping for now' )
BW = 5 # Mbps
BW_TOLERANCE = 0.8 # BW fraction below which test should fail
# Verify ability to create limited-link topo first;
lopts = { 'bw': BW, 'use_htb': True }
# Also verify correctness of limit limitng within a bound.
mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
link=TCLink, switch=self.switchClass,
waitConnected=True )
bw_strs = mn.run( mn.iperf, fmt='m' )
loptsStr = ', '.join( '%s: %s' % ( opt, value )
for opt, value in lopts.items() )
msg = ( '\nTesting link bandwidth limited to %d Mbps per link\n'
'iperf results[ client, server ]: %s\n'
'Topo = SingleSwitchTopo, %s hosts\n'
'Link = TCLink\n'
'lopts = %s\n'
'host = default\n'
'switch = %s\n'
% ( BW, bw_strs, N, loptsStr, self.switchClass ) )
# On the client side, iperf doesn't wait for ACKs - it simply
# reports how long it took to fill up the TCP send buffer.
# As long as the kernel doesn't wait a long time before
# delivering bytes to the iperf server, its reported data rate
# should be close to the actual receive rate.
serverRate, _clientRate = bw_strs
bw = float( serverRate.split(' ')[0] )
self.assertWithinTolerance( bw, BW, BW_TOLERANCE, msg )
示例3: runOptionsTopoTest
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def runOptionsTopoTest( self, n, hopts=None, lopts=None ):
"Generic topology-with-options test runner."
mn = Mininet( topo=SingleSwitchOptionsTopo( n=n, hopts=hopts,
lopts=lopts ),
host=CPULimitedHost, link=TCLink, switch=self.switchClass )
dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 )
示例4: testLinkBandwidth
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testLinkBandwidth( self ):
"Verify that link bandwidths are accurate within a bound."
if self.switchClass is UserSwitch:
self.skipTest ( 'UserSwitch has very poor performance, so skip for now' )
BW = 5 # Mbps
BW_TOLERANCE = 0.8 # BW fraction below which test should fail
# Verify ability to create limited-link topo first;
lopts = { 'bw': BW, 'use_htb': True }
# Also verify correctness of limit limitng within a bound.
mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
link=TCLink, switch=self.switchClass,
waitConnected=True )
bw_strs = mn.run( mn.iperf, format='m' )
loptsStr = ', '.join( '%s: %s' % ( opt, value )
for opt, value in lopts.items() )
msg = ( '\nTesting link bandwidth limited to %d Mbps per link\n'
'iperf results[ client, server ]: %s\n'
'Topo = SingleSwitchTopo, %s hosts\n'
'Link = TCLink\n'
'lopts = %s\n'
'host = default\n'
'switch = %s\n'
% ( BW, bw_strs, N, loptsStr, self.switchClass ) )
for bw_str in bw_strs:
bw = float( bw_str.split(' ')[0] )
self.assertWithinTolerance( bw, BW, BW_TOLERANCE, msg )
示例5: testLinear5
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testLinear5( self ):
"Ping test with both datapaths on a 5-switch topology"
init()
for switch in SWITCHES.values():
controllerParams = ControllerParams( '10.0.0.0', 8 )
mn = Mininet( LinearTopo( k=5 ), switch, Host, Controller,
controllerParams )
dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 )
示例6: testMinimal
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testMinimal( self ):
"Ping test with both datapaths on minimal topology"
init()
for switch in SWITCHES.values():
controllerParams = ControllerParams( '10.0.0.0', 8 )
mn = Mininet( SingleSwitchTopo(), switch, Host, Controller,
controllerParams )
dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 )
示例7: testLinkBandwidth
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testLinkBandwidth(self):
"Verify that link bandwidths are accurate within a bound."
BW = 5 # Mbps
BW_TOLERANCE = 0.8 # BW fraction below which test should fail
# Verify ability to create limited-link topo first;
lopts = {"bw": BW, "use_htb": True}
# Also verify correctness of limit limitng within a bound.
mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts), link=TCLink)
bw_strs = mn.run(mn.iperf)
for bw_str in bw_strs:
bw = float(bw_str.split(" ")[0])
self.assertWithinTolerance(bw, BW, BW_TOLERANCE)
示例8: testLinkBandwidth
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testLinkBandwidth( self ):
"Verify that link bandwidths are accurate within a bound."
if self.switchClass is UserSwitch:
self.skipTest ( 'UserSwitch has very poor performance, so skip for now' )
BW = 5 # Mbps
BW_TOLERANCE = 0.8 # BW fraction below which test should fail
# Verify ability to create limited-link topo first;
lopts = { 'bw': BW, 'use_htb': True }
# Also verify correctness of limit limitng within a bound.
mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
link=TCLink, switch=self.switchClass,
waitConnected=True )
bw_strs = mn.run( mn.iperf, format='m' )
for bw_str in bw_strs:
bw = float( bw_str.split(' ')[0] )
self.assertWithinTolerance( bw, BW, BW_TOLERANCE )
示例9: testLinkDelay
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [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
lopts = {"delay": "%sms" % DELAY_MS, "use_htb": True}
mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts), link=TCLink)
ping_delays = mn.run(mn.pingFull)
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)
示例10: runOptionsTopoTest
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def runOptionsTopoTest( self, n, msg, hopts=None, lopts=None ):
"Generic topology-with-options test runner."
mn = Mininet( topo=SingleSwitchOptionsTopo( n=n, hopts=hopts,
lopts=lopts ),
host=CPULimitedHost, link=TCLink,
switch=self.switchClass, waitConnected=True )
dropped = mn.run( mn.ping )
hoptsStr = ', '.join( '%s: %s' % ( opt, value )
for opt, value in hopts.items() )
loptsStr = ', '.join( '%s: %s' % ( opt, value )
for opt, value in lopts.items() )
msg += ( '%s%% of pings were dropped during mininet.ping().\n'
'Topo = SingleSwitchTopo, %s hosts\n'
'hopts = %s\n'
'lopts = %s\n'
'host = CPULimitedHost\n'
'link = TCLink\n'
'Switch = %s\n'
% ( dropped, n, hoptsStr, loptsStr, self.switchClass ) )
self.assertEqual( dropped, 0, msg=msg )
示例11: range
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
for i in range(sw_head, sw_head + max_sw):
Switchs.append('sw%d' %i)
self.addNode('sw%d' %i)
for i in range(h_head, h_head + max_h):
Hosts.append('h%d' %i)
self.addNode('h%d' %i)
#"""偶数と奇数をここで分ける"""
Hostknum = Hosts[0::2] #偶数
Hostgnum = Hosts[1::2] #奇数
for (i,j,sw) in zip(Hostknum, Hostgnum, Switchs):
if i != None: self.addLink(sw,i)
if j != None: self.addLink(sw,j)
for i in range(0, max_sw-1):
self.addLink(Switchs[i], Switchs[i+1])
self.addLink(Switchs[max_sw-1], Switchs[0])
# topos = { 'myringtopo': ( lambda: MyRingTopo() ) }
if __name__ == '__main__':
setLogLevel( 'info' )
topo = MyRingTopo( max_sw=22 )
network = Mininet(topo, switch=OVSSwitch )
network.run( CLI, network )
示例12: testLinear5
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testLinear5( self ):
"Ping test on a 5-switch topology"
mn = Mininet( LinearTopo( k=5 ), self.switchClass, Host, Controller )
dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 )
示例13: testSingle5
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testSingle5( self ):
"Ping test on 5-host single-switch topology"
mn = Mininet( SingleSwitchTopo( k=5 ), self.switchClass, Host, Controller )
dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 )
示例14: testMinimal
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testMinimal( self ):
"Ping test on minimal topology"
mn = Mininet( SingleSwitchTopo(), self.switchClass, Host, Controller )
dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 )
示例15: testLinear5
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import run [as 别名]
def testLinear5( self ):
"Ping test with both datapaths on a 5-switch topology"
for switch in SWITCHES.values():
mn = Mininet( LinearTopo( k=5 ), switch, Host, Controller )
dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 )