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
7ad48292
Commit
7ad48292
authored
14 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Added iperf command.
parent
a650b8e6
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/consoles.py
+47
-5
47 additions, 5 deletions
examples/consoles.py
with
47 additions
and
5 deletions
examples/consoles.py
+
47
−
5
View file @
7ad48292
...
...
@@ -12,6 +12,7 @@
from
mininet.log
import
setLogLevel
from
mininet.topolib
import
TreeNet
from
mininet.term
import
makeTerms
,
cleanUpScreens
from
mininet.util
import
quietRun
class
Console
(
Frame
):
"
A simple console on a host.
"
...
...
@@ -86,19 +87,30 @@ def handleReturn( self, event ):
def
handleInt
(
self
,
event
=
None
):
"
Handle control-c.
"
self
.
node
.
sendInt
()
def
sendCmd
(
self
,
cmd
):
"
Send a command to our node.
"
text
,
node
=
self
.
text
,
self
.
node
node
.
sendCmd
(
cmd
)
if
not
node
.
waiting
:
node
.
sendCmd
(
cmd
)
def
handleReadable
(
self
,
file
,
mask
):
def
handleReadable
(
self
,
file
=
None
,
mask
=
None
):
"
Handle file readable event.
"
data
=
self
.
node
.
monitor
()
self
.
append
(
data
)
if
not
self
.
node
.
waiting
:
# Print prompt, just for the heck of it
self
.
append
(
self
.
prompt
)
def
waitOutput
(
self
):
"
Wait for any remaining output.
"
while
self
.
node
.
waiting
:
self
.
handleReadable
(
self
)
def
clear
(
self
):
"
Clear all of our text.
"
self
.
text
.
delete
(
'
1.0
'
,
'
end
'
)
class
ConsoleApp
(
Frame
):
def
__init__
(
self
,
net
,
nodes
,
parent
=
None
,
width
=
4
):
...
...
@@ -111,6 +123,8 @@ def __init__( self, net, nodes, parent=None, width=4 ):
self
.
consoles
=
self
.
createConsoles
(
nodes
,
width
)
self
.
pack
(
expand
=
True
,
fill
=
'
both
'
)
cleanUpScreens
()
# Close window gracefully
Wm
.
wm_protocol
(
self
.
top
,
name
=
'
WM_DELETE_WINDOW
'
,
func
=
self
.
quit
)
def
createConsoles
(
self
,
nodes
,
width
):
"
Create a grid of consoles in a frame.
"
...
...
@@ -135,7 +149,9 @@ def createMenuBar( self, font ):
f
=
Frame
(
self
)
buttons
=
[
(
'
Ping
'
,
self
.
ping
),
(
'
Iperf
'
,
self
.
iperf
),
(
'
Interrupt
'
,
self
.
stop
),
(
'
Clear
'
,
self
.
clear
),
(
'
Quit
'
,
self
.
quit
)
]
for
name
,
cmd
in
buttons
:
...
...
@@ -144,6 +160,11 @@ def createMenuBar( self, font ):
f
.
pack
(
padx
=
4
,
pady
=
4
,
fill
=
'
x
'
)
return
f
def
clear
(
self
):
"
Clear all consoles.
"
for
console
in
self
.
consoles
:
console
.
clear
()
def
ping
(
self
):
"
Tell each console to ping the next one.
"
consoles
=
self
.
consoles
...
...
@@ -153,13 +174,34 @@ def ping( self ):
i
=
(
i
+
1
)
%
count
ip
=
consoles
[
i
].
node
.
IP
()
console
.
sendCmd
(
'
ping
'
+
ip
)
def
iperf
(
self
):
"
Tell each console to ping the next one.
"
consoles
=
self
.
consoles
count
=
len
(
consoles
)
for
console
in
consoles
:
console
.
node
.
cmd
(
'
iperf -sD &
'
)
i
=
0
for
console
in
consoles
:
i
=
(
i
+
1
)
%
count
ip
=
consoles
[
i
].
node
.
IP
()
console
.
sendCmd
(
'
iperf -i 1 -c
'
+
ip
)
def
stop
(
self
):
"
Interrupt all consoles.
"
for
console
in
self
.
consoles
:
console
.
handleInt
()
for
console
in
self
.
consoles
:
console
.
waitOutput
()
# Shut down any iperfs that might still be running
quietRun
(
'
killall -9 iperf
'
)
def
quit
(
self
):
"
Stope everything and quit.
"
print
"
Quit
"
self
.
stop
()
Frame
.
quit
(
self
)
if
__name__
==
'
__main__
'
:
setLogLevel
(
'
info
'
)
net
=
TreeNet
(
depth
=
2
,
fanout
=
4
)
...
...
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