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
d5f57784
Commit
d5f57784
authored
11 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:mininet/mininet
parents
1ecc63df
1e4e8b70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/README
+5
-0
5 additions, 0 deletions
examples/README
examples/dynamicnet.py
+55
-0
55 additions, 0 deletions
examples/dynamicnet.py
mininet/topo.py
+13
-6
13 additions, 6 deletions
mininet/topo.py
with
73 additions
and
6 deletions
examples/README
+
5
−
0
View file @
d5f57784
...
...
@@ -118,3 +118,8 @@ This example attempts to create a 1024-host network, and then runs the
CLI on it. It may run into scalability limits, depending on available
memory and sysctl configuration (see INSTALL.)
dynamicnet.py:
This example builds a network based on command line arguments and uses
a remote controller. It is a good option to use with POX controller and
develop Software Defined Networks.
This diff is collapsed.
Click to expand it.
examples/dynamicnet.py
0 → 100755
+
55
−
0
View file @
d5f57784
#!/usr/bin/python
"""
This script builds a network using mininet for using with
a remote controller like POX.
The script receives from command line two arguments. The number
of Switches and the number of Hosts per Switch. Then, it will build
the network topology based on this arguments.
First of all, it build a topology and add the Switches to the network.
After that, add the same number of Hosts for each Switch added. Lastly
it make links between each switch.
@author: Gustavo Pantuza
@since: 18.07.2013
"""
from
optparse
import
OptionParser
from
mininet.topo
import
LinearTopo
from
mininet.log
import
setLogLevel
from
mininet.net
import
Mininet
from
mininet.cli
import
CLI
from
mininet.node
import
RemoteController
def
main
():
# Defines the log level
setLogLevel
(
'
info
'
)
# parses command line arguments
parser
=
OptionParser
()
parser
.
add_option
(
'
-H
'
,
dest
=
'
hosts
'
,
default
=
5
,
help
=
'
Number of hosts per switch
'
)
parser
.
add_option
(
'
-S
'
,
dest
=
'
switches
'
,
default
=
2
,
help
=
'
Number of switches
'
)
(
options
,
args
)
=
parser
.
parse_args
()
# Build network topology (see mininet/topo.py)
topo
=
LinearTopo
(
int
(
options
.
switches
),
int
(
options
.
hosts
))
# Creates the Network using a remote controller
net
=
Mininet
(
topo
,
controller
=
lambda
a
:
RemoteController
(
a
,
ip
=
'
127.0.0.1
'
))
# Starts the network
net
.
start
()
# Run the mininet client
CLI
(
net
)
# Stop the network
net
.
stop
()
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
mininet/topo.py
+
13
−
6
View file @
d5f57784
...
...
@@ -236,23 +236,30 @@ def __init__(self, k=2, **opts):
port1
=
0
,
port2
=
(
k
-
h
+
1
))
class
LinearTopo
(
Topo
):
"
Linear topology of k switches, with
one
host per switch.
"
"
Linear topology of k switches, with
n
host
s
per switch.
"
def
__init__
(
self
,
k
=
2
,
**
opts
):
def
__init__
(
self
,
k
=
2
,
n
=
1
,
**
opts
):
"""
Init.
k: number of switches (and hosts)
k: number of switches
n: number of hosts per switch
hconf: host configuration options
lconf: link configuration options
"""
super
(
LinearTopo
,
self
).
__init__
(
**
opts
)
self
.
k
=
k
self
.
n
=
n
lastSwitch
=
None
for
i
in
irange
(
1
,
k
):
host
=
self
.
addHost
(
'
h%s
'
%
i
)
# Add switch
switch
=
self
.
addSwitch
(
'
s%s
'
%
i
)
self
.
addLink
(
host
,
switch
)
# Add hosts to switch
for
j
in
irange
(
1
,
n
):
hostNum
=
(
i
-
1
)
*
n
+
j
host
=
self
.
addHost
(
'
h%s
'
%
hostNum
)
self
.
addLink
(
host
,
switch
)
# Connect switch to previous
if
lastSwitch
:
self
.
addLink
(
switch
,
lastSwitch
)
self
.
addLink
(
switch
,
lastSwitch
)
lastSwitch
=
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