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
4ac1148e
Commit
4ac1148e
authored
13 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Example/test of link and CPU bandwidth limits.
parent
84a91a14
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/limit.py
+52
-0
52 additions, 0 deletions
examples/limit.py
with
52 additions
and
0 deletions
examples/limit.py
0 → 100755
+
52
−
0
View file @
4ac1148e
#!/usr/bin/python
"""
limit.py: example of using link and CPU limits
"""
from
mininet.net
import
Mininet
from
mininet.link
import
TCIntf
,
Link
from
mininet.node
import
CPULimitedHost
from
mininet.topolib
import
TreeTopo
from
mininet.util
import
custom
,
quietRun
from
mininet.log
import
setLogLevel
from
time
import
sleep
def
testLinkLimit
(
net
):
print
'
*** Testing network bandwidth limit
'
net
.
iperf
()
def
testCpuLimit
(
net
):
print
'
*** Testing CPU bandwidth limit
'
h1
,
h2
=
net
.
hosts
h1
.
cmd
(
'
while true; do a=1; done &
'
)
h2
.
cmd
(
'
while true; do a=1; done &
'
)
pid1
=
h1
.
cmd
(
'
echo $!
'
).
strip
()
pid2
=
h2
.
cmd
(
'
echo $!
'
).
strip
()
cmd
=
'
ps -p %s,%s -o pid,%%cpu,args
'
%
(
pid1
,
pid2
)
for
i
in
range
(
0
,
5
):
sleep
(
1
)
print
quietRun
(
cmd
)
h1
.
cmd
(
'
kill %1
'
)
h2
.
cmd
(
'
kill %1
'
)
def
limit
():
"
Example/test of link and CPU bandwidth limits
"
# 1 Mbps interfaces limited using tc
intf1Mbps
=
custom
(
TCIntf
,
bw
=
1
)
# Links consisting of two 10 Mbps interfaces
link1Mbps
=
custom
(
Link
,
intf
=
intf1Mbps
,
cls2
=
TCIntf
)
# Hosts with 30% of system bandwidth
host30pct
=
custom
(
CPULimitedHost
,
cpu
=
.
3
)
myTopo
=
TreeTopo
(
depth
=
1
,
fanout
=
2
)
net
=
Mininet
(
topo
=
myTopo
,
link
=
link1Mbps
,
host
=
host30pct
)
net
.
start
()
testLinkLimit
(
net
)
testCpuLimit
(
net
)
net
.
stop
()
if
__name__
==
'
__main__
'
:
setLogLevel
(
'
info
'
)
limit
()
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