Add passive listening port

This commit is contained in:
Brandon Heller
2010-08-18 00:18:09 -07:00
parent 2d48b4633c
commit ccca871ae6
3 changed files with 22 additions and 8 deletions
+5 -1
View File
@@ -176,6 +176,9 @@ class MininetRunner( object ):
' controller]' )
opts.add_option( '--innamespace', action='store_true',
default=False, help='sw and ctrl in namespace?' )
opts.add_option( '--listenport', type='int', default=6634,
help='[base port for passive switch listening'
' controller]' )
opts.add_option( '--pre', type='string', default=None,
help='[CLI script to run before tests]' )
opts.add_option( '--post', type='string', default=None,
@@ -222,10 +225,11 @@ class MininetRunner( object ):
xterms = self.options.xterms
mac = self.options.mac
arp = self.options.arp
listenPort = self.options.listenport
mn = Mininet( topo, switch, host, controller, controllerParams,
inNamespace=inNamespace,
xterms=xterms, autoSetMacs=mac,
autoStaticArp=arp )
autoStaticArp=arp, listenPort=listenPort )
if self.options.pre:
CLI( mn, script=self.options.pre )
+13 -6
View File
@@ -108,7 +108,7 @@ class Mininet( object ):
cparams=ControllerParams( '10.0.0.0', 8 ),
build=True, xterms=False, cleanup=False,
inNamespace=False,
autoSetMacs=False, autoStaticArp=False ):
autoSetMacs=False, autoStaticArp=False, listenPort=None ):
"""Create Mininet object.
topo: Topo (topology) object or None
switch: Switch class
@@ -120,7 +120,9 @@ class Mininet( object ):
cleanup: if build now, cleanup before creating?
inNamespace: spawn switches and controller in net namespaces?
autoSetMacs: set MAC addrs from topo?
autoStaticArp: set all-pairs static MAC addrs?"""
autoStaticArp: set all-pairs static MAC addrs?
listenPort: base listening port to open; will be incremented for
each additional switch in the net if inNamespace=False"""
self.switch = switch
self.host = host
self.controller = controller
@@ -131,6 +133,7 @@ class Mininet( object ):
self.cleanup = cleanup
self.autoSetMacs = autoSetMacs
self.autoStaticArp = autoStaticArp
self.listenPort = listenPort
self.hosts = []
self.switches = []
@@ -162,13 +165,17 @@ class Mininet( object ):
"""Add switch.
name: name of switch to add
mac: default MAC address for kernel/OVS switch intf 0
returns: added switch"""
returns: added switch
side effect: increments the listenPort member variable."""
if self.switch == UserSwitch:
sw = self.switch( name, defaultMAC=mac, defaultIP=ip,
inNamespace=self.inNamespace )
sw = self.switch( name, listenPort=self.listenPort,
defaultMAC=mac, defaultIP=ip, inNamespace=self.inNamespace )
else:
sw = self.switch( name, defaultMAC=mac, defaultIP=ip, dp=self.dps,
sw = self.switch( name, listenPort=self.listenPort,
defaultMAC=mac, defaultIP=ip, dp=self.dps,
inNamespace=self.inNamespace )
if not self.inNamespace:
self.listenPort += 1
self.dps += 1
self.switches.append( sw )
self.nameToNode[ name ] = sw
+4 -1
View File
@@ -434,9 +434,12 @@ class Switch( Node ):
portBase = SWITCH_PORT_BASE # 0 for OF < 1.0, 1 for OF >= 1.0
def __init__( self, name, opts='', **kwargs):
def __init__( self, name, opts='', listenPort=None, **kwargs):
Node.__init__( self, name, **kwargs )
self.opts = opts
self.listenPort = listenPort
if self.listenPort:
self.opts += ' --listen=ptcp:%i ' % self.listenPort
def sendCmd( self, *cmd, **kwargs ):
"""Send command to Node.