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
6d2cd77b
Commit
6d2cd77b
authored
15 years ago
by
Brandon Heller
Browse files
Options
Downloads
Patches
Plain Diff
Add reversed version of the SingleSwitch topology
Possibly useful for adding custom port mappings.
parent
80b3dbbd
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_run.py
+2
-1
2 additions, 1 deletion
bin/mn_run.py
mininet/topo.py
+33
-0
33 additions, 0 deletions
mininet/topo.py
with
35 additions
and
1 deletion
bin/mn_run.py
+
2
−
1
View file @
6d2cd77b
...
...
@@ -17,11 +17,12 @@
from
mininet.net
import
Mininet
,
init
from
mininet.node
import
KernelSwitch
,
Host
,
Controller
,
ControllerParams
,
NOX
from
mininet.node
import
RemoteController
from
mininet.topo
import
SingleSwitchTopo
,
LinearTopo
from
mininet.topo
import
SingleSwitchTopo
,
LinearTopo
,
SingleSwitchReversedTopo
# built in topologies, created only when run
TOPO_DEF
=
'
minimal
'
TOPOS
=
{
'
minimal
'
:
(
lambda
:
SingleSwitchTopo
(
k
=
2
)),
'
reversed
'
:
(
lambda
:
SingleSwitchReversedTopo
(
k
=
2
)),
'
single4
'
:
(
lambda
:
SingleSwitchTopo
(
k
=
4
)),
'
single100
'
:
(
lambda
:
SingleSwitchTopo
(
k
=
100
)),
'
linear2
'
:
(
lambda
:
LinearTopo
(
k
=
2
)),
...
...
This diff is collapsed.
Click to expand it.
mininet/topo.py
+
33
−
0
View file @
6d2cd77b
...
...
@@ -334,6 +334,39 @@ def __init__(self, k = 2, enable_all = True):
self
.
enable_all
()
class
SingleSwitchReversedTopo
(
SingleSwitchTopo
):
'''
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.
'''
def
port
(
self
,
src
,
dst
):
'''
Get port number.
@param src source switch DPID
@param dst destination switch DPID
@return tuple (src_port, dst_port):
src_port: port on source switch leading to the destination switch
dst_port: port on destination switch leading to the source switch
'''
if
src
==
1
:
if
dst
in
range
(
2
,
self
.
k
+
2
):
dst_index
=
dst
-
2
highest
=
self
.
k
-
1
return
(
highest
-
dst_index
,
0
)
else
:
raise
Exception
(
'
unexpected dst: %i
'
%
dst
)
elif
src
in
range
(
2
,
self
.
k
+
2
):
if
dst
==
1
:
raise
Exception
(
'
unexpected dst: %i
'
%
dst
)
else
:
src_index
=
src
-
2
highest
=
self
.
k
-
1
return
(
0
,
highest
-
src_index
)
class
LinearTopo
(
Topo
):
'''
Linear topology of k switches, with one host per switch.
'''
...
...
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