Merge pull request #388 from cdburkard/patches/intfOptions
measure loss with udp iperf
This commit is contained in:
@@ -13,7 +13,7 @@ from mininet.link import TCLink
|
|||||||
|
|
||||||
def intfOptions():
|
def intfOptions():
|
||||||
"run various traffic control commands on a single interface"
|
"run various traffic control commands on a single interface"
|
||||||
net = Mininet()
|
net = Mininet( autoStaticArp=True )
|
||||||
net.addController( 'c0' )
|
net.addController( 'c0' )
|
||||||
h1 = net.addHost( 'h1' )
|
h1 = net.addHost( 'h1' )
|
||||||
h2 = net.addHost( 'h2' )
|
h2 = net.addHost( 'h2' )
|
||||||
@@ -32,13 +32,12 @@ def intfOptions():
|
|||||||
|
|
||||||
info( '\n*** Configuring one intf with loss of 50%\n' )
|
info( '\n*** Configuring one intf with loss of 50%\n' )
|
||||||
link1.intf1.config( loss=50 )
|
link1.intf1.config( loss=50 )
|
||||||
info( '\n*** Running 20 pings to test\n' )
|
info( '\n' )
|
||||||
info( net.hosts[ 0 ].cmd( 'ping -c 20 -i .2 10.0.0.2' ) )
|
net.iperf( ( h1, h2 ), l4Type='UDP' )
|
||||||
|
|
||||||
|
|
||||||
info( '\n*** Configuring one intf with delay of 15ms\n' )
|
info( '\n*** Configuring one intf with delay of 15ms\n' )
|
||||||
link1.intf1.config( delay='15ms' )
|
link1.intf1.config( delay='15ms' )
|
||||||
info( '\n*** Run a ping to confirm delay' )
|
info( '\n*** Run a ping to confirm delay\n' )
|
||||||
net.pingPairFull()
|
net.pingPairFull()
|
||||||
|
|
||||||
info( '\n*** Done testing\n' )
|
info( '\n*** Done testing\n' )
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class testIntfOptions( unittest.TestCase ):
|
|||||||
p = pexpect.spawn( 'python -m mininet.examples.intfOptions ' )
|
p = pexpect.spawn( 'python -m mininet.examples.intfOptions ' )
|
||||||
tolerance = .8
|
tolerance = .8
|
||||||
opts = [ "Results: \['([\d\.]+) .bits/sec",
|
opts = [ "Results: \['([\d\.]+) .bits/sec",
|
||||||
"(\d+) packets transmitted, (\d+) received, (\d+)% packet loss, time (\d+)ms",
|
"Results: \['10M', '([\d\.]+) .bits/sec",
|
||||||
"h(\d+)->h(\d+): (\d)/(\d), rtt min/avg/max/mdev ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms",
|
"h(\d+)->h(\d+): (\d)/(\d), rtt min/avg/max/mdev ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms",
|
||||||
pexpect.EOF ]
|
pexpect.EOF ]
|
||||||
while True:
|
while True:
|
||||||
@@ -25,17 +25,14 @@ class testIntfOptions( unittest.TestCase ):
|
|||||||
self.assertGreaterEqual( bw, float( 5 * tolerance ) )
|
self.assertGreaterEqual( bw, float( 5 * tolerance ) )
|
||||||
self.assertLessEqual( bw, float( 5 + 5 * ( 1 - tolerance ) ) )
|
self.assertLessEqual( bw, float( 5 + 5 * ( 1 - tolerance ) ) )
|
||||||
elif index == 1:
|
elif index == 1:
|
||||||
loss = int( p.match.group( 3 ) )
|
BW = 10
|
||||||
msg = ( "testing packet loss at 50%\n",
|
measuredBw = float( p.match.group( 1 ) )
|
||||||
"this test will sometimes fail\n",
|
loss = ( measuredBw / BW ) * 100
|
||||||
"ran 20 pings accross network\n",
|
self.assertGreaterEqual( loss, 50 * tolerance )
|
||||||
"packet loss is %d%%\n\n"
|
self.assertLessEqual( loss, 50 + 50 * ( 1 - tolerance ) )
|
||||||
% loss )
|
|
||||||
self.assertGreaterEqual( loss, 50 * .8, msg )
|
|
||||||
self.assertLessEqual( loss, 50 + 50 * ( 1 - tolerance ), msg )
|
|
||||||
elif index == 2:
|
elif index == 2:
|
||||||
delay = float( p.match.group( 6 ) )
|
delay = float( p.match.group( 6 ) )
|
||||||
self.assertGreaterEqual( delay, 15 * .8 )
|
self.assertGreaterEqual( delay, 15 * tolerance )
|
||||||
self.assertLessEqual( delay, 15 + 15 * ( 1 - tolerance ) )
|
self.assertLessEqual( delay, 15 + 15 * ( 1 - tolerance ) )
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user