Fixed user datapath support.
This commit is contained in:
+14
-12
@@ -407,7 +407,7 @@ def configRoutedControlNetwork( controller, switches,
|
|||||||
while not switch.intfIsUp( switch.intfs[ 0 ] ):
|
while not switch.intfIsUp( switch.intfs[ 0 ] ):
|
||||||
print "*** Waiting for ", switch.intfs[ 0 ], "to come up"
|
print "*** Waiting for ", switch.intfs[ 0 ], "to come up"
|
||||||
sleep( 1 )
|
sleep( 1 )
|
||||||
if pingTest( [ switch, controller ] ) != 0:
|
if pingTest( hosts=[ switch, controller ] ) != 0:
|
||||||
print "*** Error: control network test failed"
|
print "*** Error: control network test failed"
|
||||||
exit( 1 )
|
exit( 1 )
|
||||||
|
|
||||||
@@ -444,7 +444,7 @@ class Network( object ):
|
|||||||
print "*** Creating controller"
|
print "*** Creating controller"
|
||||||
controller = Controller( 'c0', kernel )
|
controller = Controller( 'c0', kernel )
|
||||||
print "*** Creating network"
|
print "*** Creating network"
|
||||||
switches, hosts = self.makeNet()
|
switches, hosts = self.makeNet( controller )
|
||||||
print
|
print
|
||||||
if not kernel:
|
if not kernel:
|
||||||
print "*** Configuring control network"
|
print "*** Configuring control network"
|
||||||
@@ -457,13 +457,14 @@ class Network( object ):
|
|||||||
for switch in switches:
|
for switch in switches:
|
||||||
switch.start( controller )
|
switch.start( controller )
|
||||||
print "*** Running test"
|
print "*** Running test"
|
||||||
test( [ controller ], switches, hosts )
|
result = test( [ controller ], switches, hosts )
|
||||||
print "*** Stopping controller"
|
print "*** Stopping controller"
|
||||||
controller.stop()
|
controller.stop()
|
||||||
print "*** Stopping switches"
|
print "*** Stopping switches"
|
||||||
for switch in switches:
|
for switch in switches:
|
||||||
switch.stop()
|
switch.stop()
|
||||||
print "*** Test complete"
|
print "*** Test complete"
|
||||||
|
return result
|
||||||
def interact( self ):
|
def interact( self ):
|
||||||
"Create a network and run our simple CLI."
|
"Create a network and run our simple CLI."
|
||||||
self.run( self, Cli )
|
self.run( self, Cli )
|
||||||
@@ -482,7 +483,7 @@ class TreeNet( Network ):
|
|||||||
def __init__( self, depth, fanout, kernel=True):
|
def __init__( self, depth, fanout, kernel=True):
|
||||||
self.depth, self.fanout = depth, fanout
|
self.depth, self.fanout = depth, fanout
|
||||||
Network.__init__( self, kernel )
|
Network.__init__( self, kernel )
|
||||||
def treeNet( self, depth, fanout, kernel=True, snames=None,
|
def treeNet( self, controller, depth, fanout, kernel=True, snames=None,
|
||||||
hnames=None, dpnames=None ):
|
hnames=None, dpnames=None ):
|
||||||
"""Return a tree network of the given depth and fanout as a triple:
|
"""Return a tree network of the given depth and fanout as a triple:
|
||||||
( root, switches, hosts ), using the given switch, host and
|
( root, switches, hosts ), using the given switch, host and
|
||||||
@@ -501,26 +502,26 @@ class TreeNet( Network ):
|
|||||||
print switch.name, ; flush()
|
print switch.name, ; flush()
|
||||||
switches, hosts = [ switch ], []
|
switches, hosts = [ switch ], []
|
||||||
for i in range( 0, fanout ):
|
for i in range( 0, fanout ):
|
||||||
child, slist, hlist = self.treeNet(
|
child, slist, hlist = self.treeNet( controller,
|
||||||
depth - 1, fanout, kernel, snames, hnames, dpnames )
|
depth - 1, fanout, kernel, snames, hnames, dpnames )
|
||||||
createLink( switch, child )
|
createLink( switch, child )
|
||||||
switches += slist
|
switches += slist
|
||||||
hosts += hlist
|
hosts += hlist
|
||||||
return switch, switches, hosts
|
return switch, switches, hosts
|
||||||
def makeNet( self ):
|
def makeNet( self, controller ):
|
||||||
root, switches, hosts = self.treeNet(
|
root, switches, hosts = self.treeNet( controller,
|
||||||
self.depth, self.fanout, self.kernel)
|
self.depth, self.fanout, self.kernel)
|
||||||
return switches, hosts
|
return switches, hosts
|
||||||
|
|
||||||
# Grid network
|
# Grid network
|
||||||
|
|
||||||
class GridNet( Network ):
|
class GridNet( Network ):
|
||||||
"An n x m grid/mesh network of switches, with hosts at the edges."
|
"An N x M grid/mesh network of switches, with hosts at the edges."
|
||||||
def __init__( self, n, m, kernel=True, linear=False ):
|
def __init__( self, n, m, kernel=True, linear=False ):
|
||||||
self.n, self.m, self.linear = n, m, linear and m == 1
|
self.n, self.m, self.linear = n, m, linear and m == 1
|
||||||
print "m=",m
|
print "m=",m
|
||||||
Network.__init__( self, kernel )
|
Network.__init__( self, kernel )
|
||||||
def makeNet( self ):
|
def makeNet( self, controller ):
|
||||||
snames, hnames, dpnames = defaultNames()
|
snames, hnames, dpnames = defaultNames()
|
||||||
n, m = self.n, self.m
|
n, m = self.n, self.m
|
||||||
hosts = []
|
hosts = []
|
||||||
@@ -587,7 +588,7 @@ def parsePing( pingOutput ):
|
|||||||
sent, received = int( m.group( 1 ) ), int( m.group( 2 ) )
|
sent, received = int( m.group( 1 ) ), int( m.group( 2 ) )
|
||||||
return sent, received
|
return sent, received
|
||||||
|
|
||||||
def pingTest( controllers, switches, hosts, verbose=False ):
|
def pingTest( controllers=[], switches=[], hosts=[], verbose=False ):
|
||||||
"Test that each host can reach every other host."
|
"Test that each host can reach every other host."
|
||||||
packets = 0 ; lost = 0
|
packets = 0 ; lost = 0
|
||||||
for node in hosts:
|
for node in hosts:
|
||||||
@@ -719,6 +720,7 @@ def fixLimits():
|
|||||||
setrlimit( RLIMIT_NOFILE, ( 16384, 32768 ) )
|
setrlimit( RLIMIT_NOFILE, ( 16384, 32768 ) )
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
"Initialize Mininet."
|
||||||
# Note: this script must be run as root
|
# Note: this script must be run as root
|
||||||
# Perhaps we should do so automatically!
|
# Perhaps we should do so automatically!
|
||||||
if os.getuid() != 0:
|
if os.getuid() != 0:
|
||||||
@@ -735,6 +737,6 @@ def init():
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
init()
|
init()
|
||||||
for kernel in [ False, True ]:
|
for kernel in [ False, True ]:
|
||||||
TreeNet( depth=2, fanout=2).run( pingTestVerbose )
|
TreeNet( depth=2, fanout=2, kernel=kernel).run( pingTestVerbose )
|
||||||
LinearNet( switchCount=10 ).run( iperfTest)
|
LinearNet( switchCount=10, kernel=kernel ).run( iperfTest)
|
||||||
# GridNet( 2, 2 ).run( Cli )
|
# GridNet( 2, 2 ).run( Cli )
|
||||||
Reference in New Issue
Block a user