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
eeb9cb3c
Commit
eeb9cb3c
authored
15 years ago
by
Brandon Heller
Browse files
Options
Downloads
Patches
Plain Diff
Restore iperf test
Also simplify test running.
parent
83086439
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
bin/mn_run.py
+4
-16
4 additions, 16 deletions
bin/mn_run.py
mininet/net.py
+74
-20
74 additions, 20 deletions
mininet/net.py
with
78 additions
and
36 deletions
bin/mn_run.py
+
4
−
16
View file @
eeb9cb3c
...
@@ -117,29 +117,17 @@ def begin(self):
...
@@ -117,29 +117,17 @@ def begin(self):
controller_params
=
ControllerParams
(
0x0a000000
,
8
)
# 10.0.0.0/8
controller_params
=
ControllerParams
(
0x0a000000
,
8
)
# 10.0.0.0/8
mn
=
Mininet
(
topo
,
switch
,
host
,
controller
,
controller_params
)
mn
=
Mininet
(
topo
,
switch
,
host
,
controller
,
controller_params
)
if
self
.
options
.
test
!=
'
build
'
:
test
=
self
.
options
.
test
if
test
!=
'
build
'
:
if
self
.
options
.
test
==
'
cli
'
:
if
test
==
'
cli
'
:
mn
.
interact
()
mn
.
interact
()
elif
self
.
options
.
test
==
'
ping_all
'
:
mn
.
start
()
dropped
=
mn
.
ping_test
(
verbose
=
True
)
lg
.
info
(
"
*** Test results: %i%% dropped
\n
"
,
dropped
)
mn
.
stop
()
elif
self
.
options
.
test
==
'
ping_pair
'
:
mn
.
start
()
hosts_unsorted
=
sorted
(
mn
.
topo
.
hosts
())
hosts
=
[
hosts_unsorted
[
0
],
hosts_unsorted
[
1
]]
dropped
=
mn
.
ping_test
(
hosts
=
hosts
,
verbose
=
True
)
lg
.
info
(
"
*** Test results: %i%% dropped
\n
"
,
dropped
)
elif
test
==
'
all
'
:
elif
test
==
'
all
'
:
mn
.
start
()
mn
.
start
()
mn
.
ping
()
mn
.
ping
()
mn
.
iperf
()
mn
.
iperf
()
mn
.
stop
()
mn
.
stop
()
else
:
else
:
raise
NotImplementedError
(
'
unknown test: %s
'
%
mn
.
run
(
test
)
self
.
options
.
test
)
elapsed
=
float
(
time
.
time
()
-
start
)
elapsed
=
float
(
time
.
time
()
-
start
)
print
(
'
completed in %0.3f seconds
'
%
elapsed
)
print
(
'
completed in %0.3f seconds
'
%
elapsed
)
...
...
This diff is collapsed.
Click to expand it.
mininet/net.py
+
74
−
20
View file @
eeb9cb3c
...
@@ -324,7 +324,7 @@ def run(self, test, **params):
...
@@ -324,7 +324,7 @@ def run(self, test, **params):
'''
Perform a complete start/test/stop cycle.
'''
'''
Perform a complete start/test/stop cycle.
'''
self
.
start
()
self
.
start
()
lg
.
info
(
'
*** Running test
\n
'
)
lg
.
info
(
'
*** Running test
\n
'
)
result
=
test
(
self
,
**
params
)
result
=
getattr
(
self
,
test
)(
**
params
)
self
.
stop
()
self
.
stop
()
return
result
return
result
...
@@ -340,11 +340,10 @@ def _parse_ping(pingOutput):
...
@@ -340,11 +340,10 @@ def _parse_ping(pingOutput):
sent
,
received
=
int
(
m
.
group
(
1
)),
int
(
m
.
group
(
2
))
sent
,
received
=
int
(
m
.
group
(
1
)),
int
(
m
.
group
(
2
))
return
sent
,
received
return
sent
,
received
def
ping
_test
(
self
,
hosts
=
None
,
verbose
=
False
):
def
ping
(
self
,
hosts
=
None
):
'''
Ping between all specified hosts.
'''
Ping between all specified hosts.
@param hosts list of host DPIDs
@param hosts list of host DPIDs
@param verbose verbose printing
@return ploss packet loss percentage
@return ploss packet loss percentage
'''
'''
#self.start()
#self.start()
...
@@ -354,10 +353,10 @@ def ping_test(self, hosts = None, verbose = False):
...
@@ -354,10 +353,10 @@ def ping_test(self, hosts = None, verbose = False):
ploss
=
None
ploss
=
None
if
not
hosts
:
if
not
hosts
:
hosts
=
self
.
topo
.
hosts
()
hosts
=
self
.
topo
.
hosts
()
lg
.
info
(
'
*** Ping: testing ping reachability
\n
'
)
for
node_dpid
in
hosts
:
for
node_dpid
in
hosts
:
node
=
self
.
nodes
[
node_dpid
]
node
=
self
.
nodes
[
node_dpid
]
if
verbose
:
lg
.
info
(
'
%s ->
'
%
node
.
name
)
lg
.
info
(
'
%s ->
'
%
node
.
name
)
for
dest_dpid
in
hosts
:
for
dest_dpid
in
hosts
:
dest
=
self
.
nodes
[
dest_dpid
]
dest
=
self
.
nodes
[
dest_dpid
]
if
node
!=
dest
:
if
node
!=
dest
:
...
@@ -370,26 +369,79 @@ def ping_test(self, hosts = None, verbose = False):
...
@@ -370,26 +369,79 @@ def ping_test(self, hosts = None, verbose = False):
node
.
cmdPrint
(
'
route
'
)
node
.
cmdPrint
(
'
route
'
)
exit
(
1
)
exit
(
1
)
lost
+=
sent
-
received
lost
+=
sent
-
received
if
verbose
:
lg
.
info
((
'
%s
'
%
dest
.
name
)
if
received
else
'
X
'
)
lg
.
info
((
'
%s
'
%
dest
.
name
)
if
received
else
'
X
'
)
lg
.
info
(
'
\n
'
)
if
verbose
:
lg
.
info
(
'
\n
'
)
ploss
=
100
*
lost
/
packets
ploss
=
100
*
lost
/
packets
if
verbose
:
lg
.
info
(
"
*** Results: %i%% dropped (%d/%d lost)
\n
"
%
lg
.
info
(
'
%d%% packet loss (%d/%d lost)
\n
'
%
(
ploss
,
lost
,
packets
))
(
ploss
,
lost
,
packets
))
#flush()
#self.stop()
return
ploss
return
ploss
def
ping_all
(
self
):
'''
Ping between all hosts.
'''
self
.
ping
()
def
ping_pair
(
self
):
'''
Ping between first two hosts, useful for testing.
'''
hosts_sorted
=
sorted
(
self
.
topo
.
hosts
())
hosts
=
[
hosts_sorted
[
0
],
hosts_sorted
[
1
]]
self
.
ping
(
hosts
=
hosts
)
@staticmethod
def
_parseIperf
(
iperfOutput
):
'''
Parse iperf output and return bandwidth.
@param iperfOutput string
@return result string
'''
r
=
r
'
([\d\.]+ \w+/sec)
'
m
=
re
.
search
(
r
,
iperfOutput
)
if
m
:
return
m
.
group
(
1
)
else
:
raise
Exception
(
'
could not parse iperf output
'
)
def
iperf
(
self
,
hosts
=
None
,
verbose
=
False
):
'''
Run iperf between two hosts.
@param hosts list of host DPIDs; if None, uses opposite hosts
@param verbose verbose printing
@return results two-element array of server and client speeds
'''
if
not
hosts
:
hosts_sorted
=
sorted
(
self
.
topo
.
hosts
())
hosts
=
[
hosts_sorted
[
0
],
hosts_sorted
[
-
1
]]
else
:
assert
len
(
hosts
)
==
2
host0
=
self
.
nodes
[
hosts
[
0
]]
host1
=
self
.
nodes
[
hosts
[
1
]]
lg
.
info
(
'
*** Iperf: testing bandwidth between
'
)
lg
.
info
(
"
%s and %s
\n
"
%
(
host0
.
name
,
host1
.
name
))
host0
.
cmd
(
'
killall -9 iperf
'
)
server
=
host0
.
cmd
(
'
iperf -s &
'
)
if
verbose
:
lg
.
info
(
'
%s
\n
'
%
server
)
client
=
host1
.
cmd
(
'
iperf -t 5 -c
'
+
host0
.
IP
())
if
verbose
:
lg
.
info
(
'
%s
\n
'
%
client
)
server
=
host0
.
cmd
(
'
killall -9 iperf
'
)
if
verbose
:
lg
.
info
(
'
%s
\n
'
%
server
)
result
=
[
self
.
_parseIperf
(
server
),
self
.
_parseIperf
(
client
)]
lg
.
info
(
'
*** Results: %s
\n
'
%
result
)
return
result
def
interact
(
self
):
def
interact
(
self
):
'''
Start network and run our simple CLI.
'''
'''
Start network and run our simple CLI.
'''
self
.
run
(
MininetCLI
)
self
.
start
()
result
=
MininetCLI
(
self
)
self
.
stop
()
return
result
class
MininetCLI
(
object
):
class
MininetCLI
(
object
):
'''
Simple command-line interface to talk to nodes.
'''
'''
Simple command-line interface to talk to nodes.
'''
cmds
=
[
'
?
'
,
'
help
'
,
'
nodes
'
,
'
net
'
,
'
sh
'
,
'
ping_all
'
,
'
exit
'
,
\
cmds
=
[
'
?
'
,
'
help
'
,
'
nodes
'
,
'
net
'
,
'
sh
'
,
'
ping_all
'
,
'
exit
'
,
\
'
ping_pair
'
]
#
'iperf'
'
ping_pair
'
,
'
iperf
'
]
def
__init__
(
self
,
mininet
):
def
__init__
(
self
,
mininet
):
self
.
mn
=
mininet
self
.
mn
=
mininet
...
@@ -438,17 +490,19 @@ def net(self, args):
...
@@ -438,17 +490,19 @@ def net(self, args):
def
sh
(
self
,
args
):
def
sh
(
self
,
args
):
'''
Run an external shell command
'''
'''
Run an external shell command
'''
call
(
[
'
sh
'
,
'
-c
'
]
+
args
)
call
(
[
'
sh
'
,
'
-c
'
]
+
args
)
def
ping_all
(
self
,
args
):
def
ping_all
(
self
,
args
):
'''
Ping between all hosts.
'''
'''
Ping between all hosts.
'''
self
.
mn
.
ping_
test
(
verbose
=
True
)
self
.
mn
.
ping_
all
(
)
def
ping_pair
(
self
,
args
):
def
ping_pair
(
self
,
args
):
'''
Ping between first two hosts, useful for testing.
'''
'''
Ping between first two hosts, useful for testing.
'''
hosts_unsorted
=
sorted
(
self
.
mn
.
topo
.
hosts
())
self
.
mn
.
ping_pair
()
hosts
=
[
hosts_unsorted
[
0
],
hosts_unsorted
[
1
]]
self
.
mn
.
ping_test
(
hosts
=
hosts
,
verbose
=
True
)
def
iperf
(
self
,
args
):
'''
Simple iperf test between two hosts.
'''
self
.
mn
.
iperf
()
def
run
(
self
):
def
run
(
self
):
'''
Read and execute commands.
'''
'''
Read and execute commands.
'''
...
...
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