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
d27a3c52
Commit
d27a3c52
authored
13 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Allow various subsets of (delay, bw, loss) and clean up status output.
parent
2db4268b
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
mininet/link.py
+63
-56
63 additions, 56 deletions
mininet/link.py
with
63 additions
and
56 deletions
mininet/link.py
+
63
−
56
View file @
d27a3c52
...
...
@@ -33,11 +33,11 @@ class Intf( object ):
"
Basic interface object that can configure itself.
"
def
__init__
(
self
,
n
od
e
,
n
am
e
=
None
,
link
=
None
,
**
kwargs
):
"""
n
od
e:
owning node (where this intf most likely lives
)
n
am
e:
interface name (e.g. h1-eth0
)
link: parent link if
any
other arguments are
u
sed to config
ure link parameters
"""
def
__init__
(
self
,
n
am
e
,
n
od
e
=
None
,
link
=
None
,
**
kwargs
):
"""
n
am
e:
interface name (e.g. h1-eth0
)
n
od
e:
owning node (where this intf most likely lives
)
link: parent link if
we
'
re part of a link
other arguments are
pas
sed to config
()
"""
self
.
node
=
node
self
.
name
=
name
self
.
link
=
link
...
...
@@ -152,9 +152,9 @@ def __str__( self ):
class
TCIntf
(
Intf
):
"
Interface customized by tc (traffic control) utility
"
def
config
(
self
,
bw
=
None
,
delay
=
None
,
loss
=
0
,
disable_gro
=
True
,
def
config
(
self
,
bw
=
None
,
delay
=
None
,
loss
=
None
,
disable_gro
=
True
,
speedup
=
0
,
use_hfsc
=
False
,
use_tbf
=
False
,
enable_ecn
=
False
,
enable_red
=
False
,
max_queue_size
=
1000
,
**
params
):
enable_red
=
False
,
max_queue_size
=
None
,
**
params
):
"
Configure the port and set its properties.
"
result
=
Intf
.
config
(
self
,
**
params
)
...
...
@@ -163,7 +163,8 @@ def config( self, bw=None, delay=None, loss=0, disable_gro=True,
if
disable_gro
:
self
.
cmd
(
'
ethtool -K %s gro off
'
%
self
)
if
bw
is
None
and
not
delay
and
not
loss
:
if
(
bw
is
None
and
not
delay
and
not
loss
and
max_queue_size
is
None
):
return
if
bw
and
(
bw
<
0
or
bw
>
1000
):
...
...
@@ -177,59 +178,65 @@ def config( self, bw=None, delay=None, loss=0, disable_gro=True,
if
loss
and
(
loss
<
0
or
loss
>
100
):
error
(
'
Bad loss percentage
'
,
loss
,
'
%%
\n
'
)
return
if
delay
is
None
:
delay
=
'
0ms
'
if
bw
is
not
None
and
delay
is
not
None
:
info
(
self
,
'
(bw %.2fMbit, delay %s, loss %d%%)
'
%
(
bw
,
delay
,
loss
)
)
# BL: hmm... what exactly is this???
# This seems kind of brittle
if
speedup
>
0
and
self
.
node
.
name
[
0
:
2
]
==
'
sw
'
:
bw
=
speedup
# Ugly but functional
stuff
=
(
(
[
'
%.2fMbit
'
%
bw
]
if
bw
is
not
None
else
[]
)
+
(
[
'
%s delay
'
%
delay
]
if
delay
is
not
None
else
[]
)
+
(
[
'
%d%% loss
'
%
loss
]
if
loss
is
not
None
else
[]
)
+
(
[
'
ECN
'
]
if
enable_ecn
else
[
'
RED
'
]
if
enable_red
else
[]
)
)
info
(
'
(
'
+
'
'
.
join
(
stuff
)
+
'
)
'
)
cmds
=
[
'
%s qdisc del dev %s root
'
]
tc
=
'
tc
'
# was getCmd( 'tc' )
# Bandwidth control algorithms
if
use_hfsc
:
cmds
=
[
'
%s qdisc del dev %s root
'
,
'
%s qdisc add dev %s root handle 1:0 hfsc default 1
'
]
if
bw
is
not
None
:
cmds
.
append
(
'
%s class add dev %s parent 1:0 classid 1:1 hfsc sc
'
+
'
rate %fMbit ul rate %fMbit
'
%
(
bw
,
bw
)
)
elif
use_tbf
:
latency_us
=
10
*
1500
*
8
/
bw
cmds
=
[
'
%s qdisc del dev %s root
'
,
'
%s qdisc add dev %s root handle 1: tbf
'
+
'
rate %fMbit burst 15000 latency %fus
'
%
(
bw
,
latency_us
)
]
if
bw
is
None
:
parent
=
'
root
'
else
:
cmds
=
[
'
%s qdisc del dev %s root
'
,
'
%s qdisc add dev %s root handle 1:0 htb default 1
'
,
'
%s class add dev %s parent 1:0 classid 1:1 htb
'
+
'
rate %fMbit burst 15k
'
%
bw
]
# ECN or RED
if
enable_ecn
:
info
(
'
Enabling ECN
\n
'
)
cmds
+=
[
'
%s qdisc add dev %s parent 1:1
'
+
'
handle 10: red limit 1000000
'
+
'
min 20000 max 25000 avpkt 1000
'
+
'
burst 20
'
+
'
bandwidth %fmbit probability 1 ecn
'
%
bw
]
elif
enable_red
:
info
(
'
Enabling RED
\n
'
)
cmds
+=
[
'
%s qdisc add dev %s parent 1:1
'
+
'
handle 10: red limit 1000000
'
+
'
min 20000 max 25000 avpkt 1000
'
+
'
burst 20
'
+
'
bandwidth %fmbit probability 1
'
%
bw
]
else
:
cmds
+=
[
'
%s qdisc add dev %s parent 1:1 handle 10:0 netem
'
+
'
delay
'
+
'
%s
'
%
delay
+
'
loss
'
+
'
%d
'
%
loss
+
'
limit %d
'
%
(
max_queue_size
)
]
parent
=
'
parent 1:1
'
# BL: hmm... this seems a bit brittle
if
speedup
>
0
and
self
.
node
.
name
[
0
:
2
]
==
'
sw
'
:
bw
=
speedup
if
use_hfsc
:
cmds
+=
[
'
%s qdisc add dev %s root handle 1:0 hfsc default 1
'
,
'
%s class add dev %s parent 1:0 classid 1:1 hfsc sc
'
+
'
rate %fMbit ul rate %fMbit
'
%
(
bw
,
bw
)
]
elif
use_tbf
:
latency_us
=
10
*
1500
*
8
/
bw
cmds
+=
[
'
%s qdisc add dev %s root handle 1: tbf
'
+
'
rate %fMbit burst 15000 latency %fus
'
%
(
bw
,
latency_us
)
]
else
:
cmds
+=
[
'
%s qdisc add dev %s root handle 1:0 htb default 1
'
,
'
%s class add dev %s parent 1:0 classid 1:1 htb
'
+
'
rate %fMbit burst 15k
'
%
bw
]
parent
=
'
parent 1:1
'
# ECN or RED
if
enable_ecn
:
cmds
+=
[
'
%s qdisc add dev %s
'
+
parent
+
'
handle 10: red limit 1000000
'
+
'
min 20000 max 25000 avpkt 1000
'
+
'
burst 20
'
+
'
bandwidth %fmbit probability 1 ecn
'
%
bw
]
parent
=
'
parent 10:
'
elif
enable_red
:
cmds
+=
[
'
%s qdisc add dev %s
'
+
parent
+
'
handle 10: red limit 1000000
'
+
'
min 20000 max 25000 avpkt 1000
'
+
'
burst 20
'
+
'
bandwidth %fmbit probability 1
'
%
bw
]
parent
=
'
parent 10:
'
# Delay/loss/max queue size
netemargs
=
'
%s%s%s
'
%
(
'
delay %s
'
%
delay
if
delay
is
not
None
else
''
,
'
loss %d
'
%
loss
if
loss
is
not
None
else
''
,
'
limit %d
'
%
max_queue_size
if
max_queue_size
is
not
None
else
''
)
if
netemargs
:
cmds
+=
[
'
%s qdisc add dev %s
'
+
parent
+
'
netem
'
+
netemargs
]
# Execute all the commands in the container
debug
(
"
at map stage w/cmds: %s
\n
"
%
cmds
)
...
...
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