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
60d9ead6
Commit
60d9ead6
authored
15 years ago
by
David Erickson
Committed by
Brandon Heller
15 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added a RemoteController object
Now you can run a controller on a remote PC that is not on the same pc as Mininet.
parent
54037995
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
+12
-0
12 additions, 0 deletions
bin/mn_run.py
mininet/node.py
+37
-6
37 additions, 6 deletions
mininet/node.py
with
49 additions
and
6 deletions
bin/mn_run.py
+
12
−
0
View file @
60d9ead6
...
...
@@ -16,6 +16,7 @@
from
mininet.logging_mod
import
lg
,
set_loglevel
,
LEVELS
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
# built in topologies, created only when run
...
...
@@ -46,6 +47,7 @@
CONTROLLERS
=
{
'
ref
'
:
Controller
,
'
nox_dump
'
:
lambda
a
,
b
:
NOX
(
a
,
b
,
'
packetdump
'
),
'
nox_pysw
'
:
lambda
a
,
b
:
NOX
(
a
,
b
,
'
pyswitch
'
),
'
remote
'
:
lambda
a
,
b
:
None
,
'
none
'
:
lambda
a
,
b
:
None
}
# optional tests to run
...
...
@@ -106,6 +108,12 @@ def parse_args(self):
opts
.
add_option
(
'
--verbosity
'
,
'
-v
'
,
type
=
'
choice
'
,
choices
=
LEVELS
.
keys
(),
default
=
'
info
'
,
help
=
'
[
'
+
'
'
.
join
(
LEVELS
.
keys
())
+
'
]
'
)
opts
.
add_option
(
'
--ip
'
,
type
=
'
string
'
,
help
=
'
[ip address as a dotted decimal string for a
'
'
remote controller]
'
)
opts
.
add_option
(
'
--port
'
,
type
=
'
string
'
,
help
=
'
[port integer for a listening remote
'
'
controller]
'
)
self
.
options
=
opts
.
parse_args
()[
0
]
def
setup
(
self
):
...
...
@@ -132,6 +140,10 @@ def begin(self):
switch
=
SWITCHES
[
self
.
options
.
switch
]
host
=
HOSTS
[
self
.
options
.
host
]
controller
=
CONTROLLERS
[
self
.
options
.
controller
]
if
self
.
options
.
controller
==
'
remote
'
:
controller
=
lambda
a
,
b
:
RemoteController
(
a
,
b
,
ip_address
=
self
.
options
.
ip
,
port
=
self
.
options
.
port
)
controller_params
=
ControllerParams
(
0x0a000000
,
8
)
# 10.0.0.0/8
xterms
=
self
.
options
.
xterms
...
...
This diff is collapsed.
Click to expand it.
mininet/node.py
+
37
−
6
View file @
60d9ead6
...
...
@@ -3,6 +3,7 @@
from
subprocess
import
Popen
,
PIPE
,
STDOUT
import
os
,
signal
,
sys
,
select
flush
=
sys
.
stdout
.
flush
from
mininet.logging_mod
import
lg
...
...
@@ -36,7 +37,7 @@ def __init__(self, name, inNamespace = True):
self
.
pid
=
self
.
shell
.
pid
self
.
intfCount
=
0
self
.
intfs
=
[]
# list of interface names, as strings
self
.
ips
=
{}
self
.
ips
=
{}
# dict of interfaces to ip addresses as strings
self
.
connection
=
{}
self
.
waiting
=
False
self
.
execed
=
False
...
...
@@ -186,7 +187,7 @@ def setIP(self, intf, ip, bits):
'''
Set the IP address for an interface.
@param intf string, interface name
@param ip IP address as
integer
@param ip IP address as
a string
@param bits
'''
result
=
self
.
cmd
([
'
ifconfig
'
,
intf
,
ip
+
bits
,
'
up
'
])
...
...
@@ -303,7 +304,7 @@ def __init__(self, name, dp = None, dpid = None):
self
.
dp
=
dp
self
.
dpid
=
dpid
def
start
(
self
,
ignore
):
def
start
(
self
,
controllers
):
'''
Start up reference kernel datapath.
'''
ofplog
=
'
/tmp/
'
+
self
.
name
+
'
-ofp.log
'
quietRun
(
'
ifconfig lo up
'
)
...
...
@@ -318,7 +319,8 @@ def start(self, ignore):
self
.
cmdPrint
(
'
dpctl addif nl:
'
+
str
(
self
.
dp
)
+
'
'
+
'
'
.
join
(
self
.
intfs
))
# Run protocol daemon
self
.
cmdPrint
(
'
ofprotocol nl:
'
+
str
(
self
.
dp
)
+
'
tcp:127.0.0.1
'
+
self
.
cmdPrint
(
'
ofprotocol nl:
'
+
str
(
self
.
dp
)
+
'
tcp:
'
+
controllers
[
'
c0
'
].
IP
()
+
'
:
'
+
str
(
controllers
[
'
c0
'
].
port
)
+
'
--fail=closed 1>
'
+
ofplog
+
'
2>
'
+
ofplog
+
'
&
'
)
self
.
execed
=
False
# XXX until I fix it
...
...
@@ -340,10 +342,13 @@ class Controller(Node):
OpenFlow controller.
'''
def
__init__
(
self
,
name
,
inNamespace
=
False
,
controller
=
'
controller
'
,
cargs
=
'
-v ptcp:
'
,
cdir
=
None
):
cargs
=
'
-v ptcp:
'
,
cdir
=
None
,
ip_address
=
"
127.0.0.1
"
,
port
=
6633
):
self
.
controller
=
controller
self
.
cargs
=
cargs
self
.
cdir
=
cdir
self
.
ip_address
=
ip_address
self
.
port
=
port
Node
.
__init__
(
self
,
name
,
inNamespace
=
inNamespace
)
def
start
(
self
):
...
...
@@ -363,6 +368,10 @@ def stop(self):
self
.
cmd
(
'
kill %
'
+
self
.
controller
)
self
.
terminate
()
def
IP
(
self
):
'''
Return IP address of the Controller
'''
return
self
.
ip_address
class
ControllerParams
(
object
):
'''
Container for controller IP parameters.
'''
...
...
@@ -395,4 +404,26 @@ def __init__(self, name, inNamespace = False, nox_args = None, **kwargs):
controller
=
nox_core_dir
+
'
/nox_core
'
,
cargs
=
'
--libdir=/usr/local/lib -v -i ptcp:
'
+
\
'
'
.
join
(
nox_args
),
cdir
=
nox_core_dir
,
**
kwargs
)
\ No newline at end of file
cdir
=
nox_core_dir
,
**
kwargs
)
class
RemoteController
(
Controller
):
'''
Controller running remotely.
'''
def
__init__
(
self
,
name
,
inNamespace
=
False
,
ip_address
=
None
,
port
=
6633
):
'''
Init.
@param name name to give controller
@param ip_address the IP address where the remote controller is
listening
@param port the port where the remote controller is listening
'''
if
not
ip_address
:
raise
Exception
(
'
please set ip_address
\n
'
)
Controller
.
__init__
(
self
,
name
,
ip_address
=
ip_address
,
port
=
port
)
def
start
(
self
):
'''
Overridden to do nothing.
'''
return
def
stop
(
self
):
'''
Overridden to do nothing.
'''
return
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