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
95f6e7b7
Commit
95f6e7b7
authored
15 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
linearbandwidth.py now works for kernel switch.
parent
47e26cce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/linearbandwidth.py
+72
-65
72 additions, 65 deletions
examples/linearbandwidth.py
with
72 additions
and
65 deletions
examples/linearbandwidth.py
+
72
−
65
View file @
95f6e7b7
...
...
@@ -4,85 +4,92 @@
Test bandwidth (using iperf) on linear networks of varying size,
using both kernel and user datapaths.
Each
network
has
N switches and N+1 hosts, connected as follows:
We construct a
network
of
N switches and N+1 hosts, connected as follows:
h
0
<-> s0 <-> s1 .. sN-1
h
N
<-> s0 <-> s1 .. sN-1
| | |
h1
h2
hN
h
N+
1
hN+2
hN
+N
Note: by default, the reference controller only supports 16
switches, so this test WILL NOT WORK unless you have recompiled
your controller to support 100 switches (or more.)
"""
from
mininet.mininet
import
init
,
Network
,
defaultNames
,
Host
,
Switch
from
mininet.mininet
import
createLink
,
flush
,
iperf
,
pingTestVerbose
,
Cli
class
LinearNet
(
Network
):
def
__init__
(
self
,
switchCount
,
**
kwargs
):
self
.
switchCount
=
switchCount
Network
.
__init__
(
self
,
**
kwargs
)
def
makeNet
(
self
,
controller
):
snames
,
hnames
,
dpnames
=
defaultNames
()
previous
=
None
hosts
=
[]
switches
=
[]
def
newHost
(
switch
):
host
=
Host
(
hnames
.
next
()
)
createLink
(
host
,
switch
)
print
host
.
name
,
;
flush
()
return
[
host
]
print
"
*** Creating linear network of size
"
,
self
.
switchCount
for
s
in
range
(
0
,
self
.
switchCount
):
dp
=
dpnames
.
next
()
if
self
.
kernel
else
None
switch
=
Switch
(
snames
.
next
(),
dp
)
switches
+=
[
switch
]
print
switch
.
name
,
;
flush
()
if
not
self
.
kernel
:
createLink
(
controller
,
switch
)
if
s
==
0
:
hosts
+=
newHost
(
switch
)
hosts
+=
newHost
(
switch
)
if
previous
is
not
None
:
createLink
(
previous
,
switch
)
previous
=
switch
return
switches
,
hosts
import
sys
flush
=
sys
.
stdout
.
flush
from
mininet.net
import
init
,
Mininet
from
mininet.node
import
Host
,
KernelSwitch
,
UserSwitch
from
mininet.topo
import
Topo
,
Node
from
mininet.log
import
lg
class
LinearTopo
(
Topo
):
"
Topology for a string of N switches and 1+N hosts.
"
def
__init__
(
self
,
N
):
# Add default members to class.
super
(
LinearTopo
,
self
).
__init__
()
# Create switch and host nodes
switches
=
range
(
0
,
N
)
hosts
=
range
(
N
,
2
*
N
+
1
)
for
id
in
switches
:
self
.
_add_node
(
id
,
Node
(
is_switch
=
True
)
)
for
id
in
hosts
:
self
.
_add_node
(
id
,
Node
(
is_switch
=
False
)
)
# Connect switches
for
s
in
switches
[
:
-
1
]:
self
.
_add_edge
(
s
,
s
+
1
)
# Connect hosts
self
.
_add_edge
(
hosts
[
0
],
switches
[
0
]
)
for
s
in
switches
:
self
.
_add_edge
(
s
,
s
+
N
+
1
)
# Consider all switches and hosts 'on'
self
.
enable_all
()
def
linearBandwidthTest
(
lengths
):
"
Check bandwidth at various lengths along a switch chain.
"
datapaths
=
[
'
kernel
'
,
'
user
'
]
results
=
{}
switchCount
=
max
(
lengths
)
for
datapath
in
datapaths
:
k
=
datapath
==
'
kernel
'
results
[
datapath
]
=
[]
network
=
LinearNet
(
switchCount
,
kernel
=
k
)
network
.
start
()
for
n
in
lengths
:
def
test
(
controllers
,
switches
,
hosts
):
"
Check bandwidth at various lengths along a switch chain.
"
datapaths
=
[
'
kernel
'
,
'
user
'
]
results
=
{}
switchCount
=
max
(
lengths
)
for
datapath
in
datapaths
:
Switch
=
KernelSwitch
if
datapath
==
'
kernel
'
else
UserSwitch
results
[
datapath
]
=
[]
net
=
Mininet
(
topo
=
LinearTopo
(
switchCount
),
switch
=
Switch
)
net
.
start
()
print
"
*** testing basic connectivity
"
net
.
ping
(
[
net
.
hosts
[
0
],
net
.
hosts
[
-
1
]
]
)
print
"
*** testing bandwidth
"
for
n
in
lengths
:
print
"
testing h0 <-> h
"
+
`n`
,
;
flush
()
result
=
iperf
(
[
hosts
[
0
],
hosts
[
n
]
]
)
print
result
;
flush
()
return
result
bandwidth
=
network
.
runTest
(
test
)
results
[
datapath
]
+=
[
(
n
,
bandwidth
)
]
network
.
stop
()
bandwidth
=
net
.
iperf
(
[
net
.
hosts
[
0
],
net
.
hosts
[
n
]
]
)
print
bandwidth
;
flush
()
results
[
datapath
]
+=
[
(
n
,
bandwidth
)
]
net
.
stop
()
for
datapath
in
datapaths
:
print
print
"
*** Linear network results for
"
,
datapath
,
"
datapath:
"
print
result
=
results
[
datapath
]
print
"
SwitchCount
\t
iperf Results
"
for
switchCount
,
bandwidth
in
result
:
print
switchCount
,
'
\t\t
'
,
print
bandwidth
[
0
],
'
server,
'
,
bandwidth
[
1
],
'
client
'
print
print
for
datapath
in
datapaths
:
print
print
"
*** Linear network results for
"
,
datapath
,
"
datapath:
"
print
result
=
results
[
datapath
]
print
"
SwitchCount
\t
iperf Results
"
for
switchCount
,
bandwidth
in
result
:
print
switchCount
,
'
\t\t
'
,
print
bandwidth
[
0
],
'
server,
'
,
bandwidth
[
1
],
'
client
'
print
print
if
__name__
==
'
__main__
'
:
init
()
print
"
*** Running linearBandwidthTest
"
linearBandwidthTest
(
[
1
,
10
,
20
,
40
,
60
,
80
,
100
]
)
lg
.
setLogLevel
(
'
info
'
)
init
()
print
"
*** Running linearBandwidthTest
"
linearBandwidthTest
(
[
1
,
10
]
)
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