Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
5365831d
Commit
5365831d
authored
9 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Use 0% loss when testing examples/simpleperf.py
Also clarified the code in test_simpleperf.py. Fixes #590
parent
6a69c3c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/simpleperf.py
+17
-8
17 additions, 8 deletions
examples/simpleperf.py
examples/test/test_simpleperf.py
+5
-5
5 additions, 5 deletions
examples/test/test_simpleperf.py
with
22 additions
and
13 deletions
examples/simpleperf.py
+
17
−
8
View file @
5365831d
...
...
@@ -16,22 +16,30 @@
from
mininet.util
import
dumpNodeConnections
from
mininet.log
import
setLogLevel
from
sys
import
argv
class
SingleSwitchTopo
(
Topo
):
"
Single switch connected to n hosts.
"
def
__init__
(
self
,
n
=
2
,
**
opts
):
def
__init__
(
self
,
n
=
2
,
lossy
=
True
,
**
opts
):
Topo
.
__init__
(
self
,
**
opts
)
switch
=
self
.
addSwitch
(
'
s1
'
)
for
h
in
range
(
n
):
# Each host gets 50%/n of system CPU
host
=
self
.
addHost
(
'
h%s
'
%
(
h
+
1
),
cpu
=
.
5
/
n
)
# 10 Mbps, 5ms delay, 10% loss
self
.
addLink
(
host
,
switch
,
bw
=
10
,
delay
=
'
5ms
'
,
loss
=
10
,
use_htb
=
True
)
if
lossy
:
# 10 Mbps, 5ms delay, 10% packet loss
self
.
addLink
(
host
,
switch
,
bw
=
10
,
delay
=
'
5ms
'
,
loss
=
10
,
use_htb
=
True
)
else
:
# 10 Mbps, 5ms delay, no packet loss
self
.
addLink
(
host
,
switch
,
bw
=
10
,
delay
=
'
5ms
'
,
loss
=
0
,
use_htb
=
True
)
def
perfTest
():
def
perfTest
(
lossy
=
True
):
"
Create network and run simple performance test
"
topo
=
SingleSwitchTopo
(
n
=
4
)
topo
=
SingleSwitchTopo
(
n
=
4
,
lossy
=
lossy
)
net
=
Mininet
(
topo
=
topo
,
host
=
CPULimitedHost
,
link
=
TCLink
,
autoStaticArp
=
True
)
...
...
@@ -44,5 +52,6 @@ def perfTest():
net
.
stop
()
if
__name__
==
'
__main__
'
:
setLogLevel
(
'
info
'
)
perfTest
()
setLogLevel
(
'
info
'
)
# Prevent test_simpleperf from failing due to packet loss
perfTest
(
lossy
=
(
'
testmode
'
not
in
argv
)
)
This diff is collapsed.
Click to expand it.
examples/test/test_simpleperf.py
+
5
−
5
View file @
5365831d
...
...
@@ -16,15 +16,15 @@ class testSimplePerf( unittest.TestCase ):
@unittest.skipIf
(
'
-quick
'
in
sys
.
argv
,
'
long test
'
)
def
testE2E
(
self
):
"
Run the example and verify iperf results
"
# 10 Mb/s, plus or minus 20% tolerance
BW
=
10
TOLERANCE
=
.
8
expectedBw
=
BW
*
TOLERANCE
p
=
pexpect
.
spawn
(
'
python -m mininet.examples.simpleperf
'
)
TOLERANCE
=
.
2
p
=
pexpect
.
spawn
(
'
python -m mininet.examples.simpleperf testmode
'
)
# check iperf results
p
.
expect
(
"
Results: \[
'
10M
'
,
'
([\d\.]+) .bits/sec
"
,
timeout
=
480
)
measuredBw
=
float
(
p
.
match
.
group
(
1
)
)
lowerBound
=
expectedBw
*
TOLERANCE
upperBound
=
expectedBw
+
expectedBw
*
(
1
-
TOLERANCE
)
lowerBound
=
BW
*
(
1
-
TOLERANCE
)
upperBound
=
BW
+
(
1
+
TOLERANCE
)
self
.
assertGreaterEqual
(
measuredBw
,
lowerBound
)
self
.
assertLessEqual
(
measuredBw
,
upperBound
)
p
.
wait
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment