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
1b2c7a31
Commit
1b2c7a31
authored
10 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Clean up standard topologies to use build
parent
b5962e8e
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
mininet/topo.py
+30
-50
30 additions, 50 deletions
mininet/topo.py
mininet/topolib.py
+3
-4
3 additions, 4 deletions
mininet/topolib.py
with
33 additions
and
54 deletions
mininet/topo.py
+
30
−
50
View file @
1b2c7a31
...
@@ -201,76 +201,56 @@ def sorted( items ):
...
@@ -201,76 +201,56 @@ def sorted( items ):
"
Items sorted in natural (i.e. alphabetical) order
"
"
Items sorted in natural (i.e. alphabetical) order
"
return
sorted
(
items
,
key
=
natural
)
return
sorted
(
items
,
key
=
natural
)
class
SingleSwitchTopo
(
Topo
):
'''
Single switch connected to k hosts.
'''
def
__init__
(
self
,
k
=
2
,
**
opts
):
class
SingleSwitchTopo
(
Topo
):
'''
Init.
"
Single switch connected to k hosts.
"
@param k number of hosts
@param enable_all enables all nodes and switches?
'''
super
(
SingleSwitchTopo
,
self
).
__init__
(
**
opts
)
def
build
(
self
,
k
=
2
,
**
opts
):
"
k: number of hosts
"
self
.
k
=
k
self
.
k
=
k
switch
=
self
.
addSwitch
(
'
s1
'
)
for
h
in
irange
(
1
,
k
):
host
=
self
.
addHost
(
'
h%s
'
%
h
)
self
.
addLink
(
host
,
switch
)
switch
=
self
.
addSwitch
(
'
s1
'
)
for
h
in
irange
(
1
,
k
):
host
=
self
.
addHost
(
'
h%s
'
%
h
)
self
.
addLink
(
host
,
switch
)
class
SingleSwitchReversedTopo
(
Topo
):
'''
Single switch connected to k hosts, with reversed ports.
The lowest-numbered host is connected to the highest-numbered port.
Useful to verify that Mininet properly handles custom port numberings.
class
SingleSwitchReversedTopo
(
Topo
):
'''
"""
Single switch connected to k hosts, with reversed ports.
def
__init__
(
self
,
k
=
2
,
**
opts
):
The lowest-numbered host is connected to the highest-numbered port.
'''
Init.
Useful to verify that Mininet properly handles custom port numberings.
"""
@param k number of hosts
def
build
(
self
,
k
=
2
):
@param enable_all enables all nodes and switches?
"
k: number of hosts
"
'''
super
(
SingleSwitchReversedTopo
,
self
).
__init__
(
**
opts
)
self
.
k
=
k
self
.
k
=
k
switch
=
self
.
addSwitch
(
'
s1
'
)
switch
=
self
.
addSwitch
(
'
s1
'
)
for
h
in
irange
(
1
,
k
):
for
h
in
irange
(
1
,
k
):
host
=
self
.
addHost
(
'
h%s
'
%
h
)
host
=
self
.
addHost
(
'
h%s
'
%
h
)
self
.
addLink
(
host
,
switch
,
self
.
addLink
(
host
,
switch
,
port1
=
0
,
port2
=
(
k
-
h
+
1
)
)
port1
=
0
,
port2
=
(
k
-
h
+
1
)
)
class
LinearTopo
(
Topo
):
class
LinearTopo
(
Topo
):
"
Linear topology of k switches, with n hosts per switch.
"
"
Linear topology of k switches, with n hosts per switch.
"
def
__init__
(
self
,
k
=
2
,
n
=
1
,
**
opts
):
def
build
(
self
,
k
=
2
,
n
=
1
,
**
opts
):
"""
Init.
"""
k: number of switches
k: number of switches
n: number of hosts per switch
"""
n: number of hosts per switch
hconf: host configuration options
lconf: link configuration options
"""
super
(
LinearTopo
,
self
).
__init__
(
**
opts
)
self
.
k
=
k
self
.
k
=
k
self
.
n
=
n
self
.
n
=
n
if
n
==
1
:
if
n
==
1
:
genHostName
=
lambda
i
,
j
:
'
h%s
'
%
i
genHostName
=
lambda
i
,
j
:
'
h%s
'
%
i
else
:
else
:
genHostName
=
lambda
i
,
j
:
'
h%ss%d
'
%
(
j
,
i
)
genHostName
=
lambda
i
,
j
:
'
h%ss%d
'
%
(
j
,
i
)
lastSwitch
=
None
lastSwitch
=
None
for
i
in
irange
(
1
,
k
):
for
i
in
irange
(
1
,
k
):
# Add switch
# Add switch
switch
=
self
.
addSwitch
(
'
s%s
'
%
i
)
switch
=
self
.
addSwitch
(
'
s%s
'
%
i
)
# Add hosts to switch
# Add hosts to switch
for
j
in
irange
(
1
,
n
):
for
j
in
irange
(
1
,
n
):
host
=
self
.
addHost
(
genHostName
(
i
,
j
)
)
host
=
self
.
addHost
(
genHostName
(
i
,
j
)
)
self
.
addLink
(
host
,
switch
)
self
.
addLink
(
host
,
switch
)
# Connect switch to previous
# Connect switch to previous
if
lastSwitch
:
if
lastSwitch
:
self
.
addLink
(
switch
,
lastSwitch
)
self
.
addLink
(
switch
,
lastSwitch
)
lastSwitch
=
switch
lastSwitch
=
switch
This diff is collapsed.
Click to expand it.
mininet/topolib.py
+
3
−
4
View file @
1b2c7a31
...
@@ -6,8 +6,7 @@
...
@@ -6,8 +6,7 @@
class
TreeTopo
(
Topo
):
class
TreeTopo
(
Topo
):
"
Topology for a tree network with a given depth and fanout.
"
"
Topology for a tree network with a given depth and fanout.
"
def
__init__
(
self
,
depth
=
1
,
fanout
=
2
):
def
build
(
self
,
depth
=
1
,
fanout
=
2
):
super
(
TreeTopo
,
self
).
__init__
()
# Numbering: h1..N, s1..M
# Numbering: h1..N, s1..M
self
.
hostNum
=
1
self
.
hostNum
=
1
self
.
switchNum
=
1
self
.
switchNum
=
1
...
@@ -42,8 +41,8 @@ class TorusTopo( Topo ):
...
@@ -42,8 +41,8 @@ class TorusTopo( Topo ):
with the default controller or any Ethernet bridge
with the default controller or any Ethernet bridge
without STP turned on! It can be used with STP, e.g.:
without STP turned on! It can be used with STP, e.g.:
# mn --topo torus,3,3 --switch lxbr,stp=1 --test pingall
"""
# mn --topo torus,3,3 --switch lxbr,stp=1 --test pingall
"""
def
__init__
(
self
,
x
,
y
,
*
args
,
**
kwargs
):
Topo
.
__init__
(
self
,
*
args
,
**
kwargs
)
def
build
(
self
,
x
,
y
)
:
if
x
<
3
or
y
<
3
:
if
x
<
3
or
y
<
3
:
raise
Exception
(
'
Please use 3x3 or greater for compatibility
'
raise
Exception
(
'
Please use 3x3 or greater for compatibility
'
'
with Mininet 2.1.0
'
)
'
with Mininet 2.1.0
'
)
...
...
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