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
7cb340b7
Commit
7cb340b7
authored
12 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Pass code check.
parent
92b601ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/multiping.py
+7
-15
7 additions, 15 deletions
examples/multiping.py
examples/multipoll.py
+3
-5
3 additions, 5 deletions
examples/multipoll.py
examples/simpleperf.py
+26
-27
26 additions, 27 deletions
examples/simpleperf.py
with
36 additions
and
47 deletions
examples/multiping.py
+
7
−
15
View file @
7cb340b7
...
...
@@ -26,20 +26,19 @@ def startpings( host, targetips ):
targetips
.
append
(
'
10.0.0.200
'
)
targetips
=
'
'
.
join
(
targetips
)
# BL: Not sure why loopback intf isn't up!
host
.
cmd
(
'
ifconfig lo up
'
)
# Simple ping loop
cmd
=
(
'
while true; do
'
'
for ip in %s; do
'
%
targetips
+
'
for ip in %s; do
'
%
targetips
+
'
echo -n %s
"
->
"
$ip
'
%
host
.
IP
()
+
'
`ping -c1 -w 1 $ip | grep packets` ;
'
'
sleep 1;
'
'
done;
'
'
done &
'
)
print
(
'
*** Host %s (%s) will be pinging ips: %s
'
%
(
host
.
name
,
host
.
IP
(),
targetips
)
)
...
...
@@ -47,7 +46,7 @@ def startpings( host, targetips ):
def
multiping
(
netsize
,
chunksize
,
seconds
):
"
Ping subsets of size chunksize in net of size netsize
"
# Create network and identify subnets
topo
=
SingleSwitchTopo
(
netsize
)
net
=
Mininet
(
topo
=
topo
)
...
...
@@ -60,13 +59,13 @@ def multiping( netsize, chunksize, seconds):
poller
=
poll
()
for
fd
in
fds
:
poller
.
register
(
fd
,
POLLIN
)
# Start pings
for
subnet
in
subnets
:
ips
=
[
host
.
IP
()
for
host
in
subnet
]
for
host
in
subnet
:
startpings
(
host
,
ips
)
# Monitor output
endTime
=
time
()
+
seconds
while
time
()
<
endTime
:
...
...
@@ -78,17 +77,10 @@ def multiping( netsize, chunksize, seconds):
# Stop pings
for
host
in
hosts
:
host
.
cmd
(
'
kill %while
'
)
net
.
stop
()
if
__name__
==
'
__main__
'
:
setLogLevel
(
'
info
'
)
multiping
(
netsize
=
20
,
chunksize
=
4
,
seconds
=
10
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
examples/multipoll.py
+
3
−
5
View file @
7cb340b7
...
...
@@ -8,13 +8,13 @@
from
mininet.topo
import
SingleSwitchTopo
from
mininet.net
import
Mininet
from
mininet.log
import
setLogLevel
from
mininet.util
import
quietRun
from
time
import
time
,
sleep
from
time
import
time
from
select
import
poll
,
POLLIN
from
subprocess
import
Popen
,
PIPE
def
monitorFiles
(
outfiles
,
seconds
,
timeoutms
):
"
Monitor set of files and return [(host, line)...]
"
devnull
=
open
(
'
/dev/null
'
,
'
w
'
)
tails
,
fdToFile
,
fdToHost
=
{},
{},
{}
for
h
,
outfile
in
outfiles
.
iteritems
():
...
...
@@ -63,7 +63,7 @@ def monitorTest( N=3, seconds=3 ):
h
.
cmd
(
'
echo >
'
,
outfiles
[
h
]
)
h
.
cmd
(
'
echo >
'
,
errfiles
[
h
]
)
# Start pings
h
.
cmdPrint
(
'
ping
'
,
server
.
IP
(),
h
.
cmdPrint
(
'
ping
'
,
server
.
IP
(),
'
>
'
,
outfiles
[
h
],
'
2>
'
,
errfiles
[
h
],
'
&
'
)
...
...
@@ -79,5 +79,3 @@ def monitorTest( N=3, seconds=3 ):
if
__name__
==
'
__main__
'
:
setLogLevel
(
'
info
'
)
monitorTest
()
This diff is collapsed.
Click to expand it.
examples/simpleperf.py
+
26
−
27
View file @
7cb340b7
...
...
@@ -12,34 +12,33 @@
from
mininet.log
import
setLogLevel
class
SingleSwitchTopo
(
Topo
):
"
Single switch connected to n hosts.
"
def
__init__
(
self
,
n
=
2
,
**
opts
):
Topo
.
__init__
(
self
,
**
opts
)
switch
=
self
.
add_switch
(
'
s1
'
)
for
h
in
range
(
n
):
# Each host gets 50%/n of system CPU
host
=
self
.
add_host
(
'
h%s
'
%
(
h
+
1
),
cpu
=
.
5
/
n
)
# 10 Mbps, 5ms delay, 10% loss
self
.
add_link
(
host
,
switch
,
bw
=
10
,
delay
=
'
5ms
'
,
loss
=
10
,
use_htb
=
True
)
"
Single switch connected to n hosts.
"
def
__init__
(
self
,
n
=
2
,
**
opts
):
Topo
.
__init__
(
self
,
**
opts
)
switch
=
self
.
add_switch
(
'
s1
'
)
for
h
in
range
(
n
):
# Each host gets 50%/n of system CPU
host
=
self
.
add_host
(
'
h%s
'
%
(
h
+
1
),
cpu
=
.
5
/
n
)
# 10 Mbps, 5ms delay, 10% loss
self
.
add_link
(
host
,
switch
,
bw
=
10
,
delay
=
'
5ms
'
,
loss
=
10
,
use_htb
=
True
)
def
perfTest
():
"
Create network and run simple performance test
"
topo
=
SingleSwitchTopo
(
n
=
4
)
net
=
Mininet
(
topo
=
topo
,
host
=
CPULimitedHost
,
link
=
TCLink
)
net
.
start
()
print
"
Dumping host connections
"
dumpNodeConnections
(
net
.
hosts
)
print
"
Testing network connectivity
"
net
.
pingAll
()
print
"
Testing bandwidth between h1 and h4
"
h1
=
net
.
getNodeByName
(
'
h1
'
)
h4
=
net
.
getNodeByName
(
'
h4
'
)
net
.
iperf
((
h1
,
h4
))
net
.
stop
()
"
Create network and run simple performance test
"
topo
=
SingleSwitchTopo
(
n
=
4
)
net
=
Mininet
(
topo
=
topo
,
host
=
CPULimitedHost
,
link
=
TCLink
)
net
.
start
()
print
"
Dumping host connections
"
dumpNodeConnections
(
net
.
hosts
)
print
"
Testing network connectivity
"
net
.
pingAll
()
print
"
Testing bandwidth between h1 and h4
"
h1
,
h4
=
net
.
getNodeByName
(
'
h1
'
,
'
h4
'
)
net
.
iperf
((
h1
,
h4
))
net
.
stop
()
if
__name__
==
'
__main__
'
:
setLogLevel
(
'
info
'
)
perfTest
()
setLogLevel
(
'
info
'
)
perfTest
()
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