Example/test of link and CPU bandwidth limits bw: interface bandwidth limit in Mbps cpu: cpu limit as fraction of overall CPU time
( bw=10, cpu=.1 )
| 18 | net.iperf() |
| 19 | |
| 20 | def limit( bw=10, cpu=.1 ): |
| 21 | """Example/test of link and CPU bandwidth limits |
| 22 | bw: interface bandwidth limit in Mbps |
| 23 | cpu: cpu limit as fraction of overall CPU time""" |
| 24 | intf = custom( TCIntf, bw=bw ) |
| 25 | myTopo = TreeTopo( depth=1, fanout=2 ) |
| 26 | for sched in 'rt', 'cfs': |
| 27 | info( '*** Testing with', sched, 'bandwidth limiting\n' ) |
| 28 | if sched == 'rt': |
| 29 | release = quietRun( 'uname -r' ).strip('\r\n') |
| 30 | output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' |
| 31 | % release ) |
| 32 | if output == '# CONFIG_RT_GROUP_SCHED is not set\n': |
| 33 | info( '*** RT Scheduler is not enabled in your kernel. ' |
| 34 | 'Skipping this test\n' ) |
| 35 | continue |
| 36 | host = custom( CPULimitedHost, sched=sched, cpu=cpu ) |
| 37 | net = Mininet( topo=myTopo, intf=intf, host=host, waitConnected=True ) |
| 38 | net.start() |
| 39 | testLinkLimit( net, bw=bw ) |
| 40 | net.runCpuLimitTest( cpu=cpu ) |
| 41 | net.stop() |
| 42 | |
| 43 | def verySimpleLimit( bw=150 ): |
| 44 | "Absurdly simple limiting test" |
no test coverage detected