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
b5962e8e
Commit
b5962e8e
authored
10 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Added TorusTopo, a 2D torus topology
parent
ece509d5
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
bin/mn
+3
-2
3 additions, 2 deletions
bin/mn
mininet/topolib.py
+34
-0
34 additions, 0 deletions
mininet/topolib.py
with
37 additions
and
2 deletions
bin/mn
+
3
−
2
View file @
b5962e8e
...
...
@@ -30,7 +30,7 @@ from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
from
mininet.nodelib
import
LinuxBridge
from
mininet.link
import
Link
,
TCLink
from
mininet.topo
import
SingleSwitchTopo
,
LinearTopo
,
SingleSwitchReversedTopo
from
mininet.topolib
import
TreeTopo
from
mininet.topolib
import
TreeTopo
,
TorusTopo
from
mininet.util
import
custom
,
customConstructor
from
mininet.util
import
buildTopo
...
...
@@ -41,7 +41,8 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
'
linear
'
:
LinearTopo
,
'
reversed
'
:
SingleSwitchReversedTopo
,
'
single
'
:
SingleSwitchTopo
,
'
tree
'
:
TreeTopo
}
'
tree
'
:
TreeTopo
,
'
torus
'
:
TorusTopo
}
SWITCHDEF
=
'
ovsk
'
SWITCHES
=
{
'
user
'
:
UserSwitch
,
...
...
This diff is collapsed.
Click to expand it.
mininet/topolib.py
+
34
−
0
View file @
b5962e8e
...
...
@@ -34,3 +34,37 @@ def TreeNet( depth=1, fanout=2, **kwargs ):
"
Convenience function for creating tree networks.
"
topo
=
TreeTopo
(
depth
,
fanout
)
return
Mininet
(
topo
,
**
kwargs
)
class
TorusTopo
(
Topo
):
"""
2-D Torus topology
WARNING: this topology has LOOPS and WILL NOT WORK
with the default controller or any Ethernet bridge
without STP turned on! It can be used with STP, e.g.:
# mn --topo torus,3,3 --switch lxbr,stp=1 --test pingall
"""
def
__init__
(
self
,
x
,
y
,
*
args
,
**
kwargs
):
Topo
.
__init__
(
self
,
*
args
,
**
kwargs
)
if
x
<
3
or
y
<
3
:
raise
Exception
(
'
Please use 3x3 or greater for compatibility
'
'
with Mininet 2.1.0
'
)
hosts
,
switches
,
dpid
=
{},
{},
0
# Create and wire interior
for
i
in
range
(
0
,
x
):
for
j
in
range
(
0
,
y
):
loc
=
'
%dx%d
'
%
(
i
+
1
,
j
+
1
)
# dpid cannot be zero for OVS
dpid
=
(
i
+
1
)
*
256
+
(
j
+
1
)
switch
=
switches
[
i
,
j
]
=
self
.
addSwitch
(
'
s
'
+
loc
,
dpid
=
'
%016x
'
%
dpid
)
host
=
hosts
[
i
,
j
]
=
self
.
addHost
(
'
h
'
+
loc
)
self
.
addLink
(
host
,
switch
)
# Connect switches
for
i
in
range
(
0
,
x
):
for
j
in
range
(
0
,
y
):
sw1
=
switches
[
i
,
j
]
sw2
=
switches
[
i
,
(
j
+
1
)
%
y
]
sw3
=
switches
[
(
i
+
1
)
%
x
,
j
]
self
.
addLink
(
sw1
,
sw2
)
self
.
addLink
(
sw1
,
sw3
)
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