From 0d94548a09015f7b882f240a1a30d8c132433a5d Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Thu, 10 May 2012 22:36:20 -0700 Subject: [PATCH] Fix default dpid which should be 12 digits for reference user switch. --- mininet/node.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mininet/node.py b/mininet/node.py index ae03d9d..8a5e991 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -725,6 +725,7 @@ class Switch( Node ): an OpenFlow switch.""" portBase = 1 # Switches start with port 1 in OpenFlow + dpidLen = 16 # digits in dpid passed to switch def __init__( self, name, dpid=None, opts='', listenPort=None, **params): """dpid: dpid for switch (or None to derive from name, e.g. s1 -> 1) @@ -742,7 +743,7 @@ class Switch( Node ): try: dpid = int( re.findall( '\d+', self.name )[ 0 ] ) dpid = hex( dpid )[ 2: ] - dpid = '0' * ( 16 - len( dpid ) ) + dpid + dpid = '0' * ( self.dpidLen - len( dpid ) ) + dpid return dpid except IndexError: raise Exception( 'Unable to derive default datapath ID - ' @@ -776,6 +777,8 @@ class Switch( Node ): class UserSwitch( Switch ): "User-space switch." + dpidLen = 12 + def __init__( self, name, **kwargs ): """Init. name: name for the switch"""