diff --git a/examples/grid.py b/examples/grid.py index fea7d6ce73a49f165b4022c9039316fcd0113248..3abeef7ba0b4d6818e89612360590a4323e8e896 100755 --- a/examples/grid.py +++ b/examples/grid.py @@ -13,5 +13,5 @@ def __init__( self, name, **kwargs ): if __name__ == '__main__': init() - network = GridNet( 2, 2, kernel=True, Controller=NoxController) + network = GridNet( 2, 2, kernel=True, Controller=NoxController ) network.run( Cli ) diff --git a/examples/linearbandwidth.py b/examples/linearbandwidth.py index 6631b9e5903754a449b5cd49ec9f753be0079064..2f46d942f6469f9937aa3b811d82d610ed498d1f 100755 --- a/examples/linearbandwidth.py +++ b/examples/linearbandwidth.py @@ -26,7 +26,7 @@ def linearBandwidthTest(): results[ datapath ] = [] for switchCount in switchCounts: print "*** Creating linear network of size", switchCount - network = LinearNet( switchCount, k) + network = LinearNet( switchCount, kernel=k) bandwidth = network.run( iperfTest ) results[ datapath ] += [ ( switchCount, bandwidth ) ] diff --git a/examples/nox.py b/examples/nox.py index 233f2a67c93e619f45f42749aa711b8b9fed6cd8..8a9c02424ee4eee50e1bf4b8c2dc1dc365f54a92 100755 --- a/examples/nox.py +++ b/examples/nox.py @@ -13,5 +13,5 @@ def __init__( self, name, **kwargs ): if __name__ == '__main__': init() - network = TreeNet( depth=2, fanout=4, kernel=True, Controller=NoxController) + network = TreeNet( depth=2, fanout=4, kernel=True, Controller=NoxController ) network.run( Cli ) diff --git a/examples/scratchnet.py b/examples/scratchnet.py index e3fde16c88ce0937d955c7b17901959c54d2a9e6..43b63161147b0a31727658e4bf562138070d0958 100755 --- a/examples/scratchnet.py +++ b/examples/scratchnet.py @@ -3,7 +3,7 @@ """ Build a simple network from scratch, using mininet primitives. This is more complicated than using the higher-level classes, -but it exposes the configuration details and allows cusomization. +but it exposes the configuration details and allows customization. """ from mininet import init, Node, createLink diff --git a/examples/scratchnetuser.py b/examples/scratchnetuser.py index 8aab551df0fdfe2c3132c07e4af2a6e52c1abaa2..f9460418de99b34e36503bd4a765d498dd2d98fa 100755 --- a/examples/scratchnetuser.py +++ b/examples/scratchnetuser.py @@ -3,15 +3,19 @@ """ Build a simple network from scratch, using mininet primitives. This is more complicated than using the higher-level classes, -but it exposes the configuration details and allows cusomization. +but it exposes the configuration details and allows customization. This version uses the user datapath. """ from mininet import init, Node, createLink -def scratchNet( cname='controller', cargs='ptcp:'): +def scratchNetUser( cname='controller', cargs='ptcp:'): # Create Network + # It's not strictly necessary for the controller and switches + # to be in separate namespaces. For performance, they probably + # should be in the root namespace. However, it's interesting to + # see how they could work even if they are in separate namespaces. controller = Node( 'c0' ) switch = Node( 's0') h0 = Node( 'h0' ) @@ -40,4 +44,4 @@ def scratchNet( cname='controller', cargs='ptcp:'): if __name__ == '__main__': init() - scratchNet() + scratchNetUser() diff --git a/mininet.py b/mininet.py index eb34ef6f1d34b475ba786a23c3f2d27dafd57395..f503cf7972525ee33250c3bcecda6e3344364590 100755 --- a/mininet.py +++ b/mininet.py @@ -50,9 +50,8 @@ For the moment, specifying configurations and tests in Python is straightforward and relatively concise. Soon, we may want to split the various subsystems (core, - cli, tests, etc.) into multiple modules. - We don't support nox nicely just yet - you have to hack this file - or subclass things aggressively. + topology/network, cli, tests, etc.) into multiple modules. + Currently nox support is in nox.py. We'd like to support OpenVSwitch as well as the reference implementation. @@ -396,10 +395,27 @@ def nameGen( prefix ): i = 0 while True: yield prefix + `i`; i += 1 -# Control network support -# For the user datapath, we create an explicit control network. -# Note: Instead of routing, we could bridge or use "in-band" control - +# Control network support: +# +# Create an explicit control network. Currently this is only +# used by the user datapath configuration. +# +# Notes: +# +# 1. If the controller and switches are in the same (e.g. root) +# namespace, they can just use the loopback connection. +# We may wish to do this for the user datapath as well as the +# kernel datapath. +# +# 2. If we can get unix domain sockets to work, we can use them +# instead of an explicit control network. +# +# 3. Instead of routing, we could bridge or use "in-band" control. +# +# 4. Even if we dispense with this in general, it could still be +# useful for people who wish to simulate a separate control +# network (since real networks may need one!) + def configureRoutedControlNetwork( controller, switches, ips): """Configure a routed control network on controller and switches, for use with the user datapath.""" @@ -542,7 +558,7 @@ class TreeNet( Network ): def __init__( self, depth, fanout, **kwargs): self.depth, self.fanout = depth, fanout Network.__init__( self, **kwargs ) - def treeNet( self, controller, depth, fanout, kernel=True, snames=None, + def treeNet( self, controller, depth, fanout, snames=None, hnames=None, dpnames=None ): """Return a tree network of the given depth and fanout as a triple: ( root, switches, hosts ), using the given switch, host and @@ -555,21 +571,21 @@ def treeNet( self, controller, depth, fanout, kernel=True, snames=None, host = Host( hnames.next() ) print host.name, ; flush() return host, [], [ host ] - dp = dpnames.next() if kernel else None + dp = dpnames.next() if self.kernel else None switch = Switch( snames.next(), dp ) - if not kernel: createLink( switch, controller ) + if not self.kernel: createLink( switch, controller ) print switch.name, ; flush() switches, hosts = [ switch ], [] for i in range( 0, fanout ): child, slist, hlist = self.treeNet( controller, - depth - 1, fanout, kernel, snames, hnames, dpnames ) + depth - 1, fanout, snames, hnames, dpnames ) createLink( switch, child ) switches += slist hosts += hlist return switch, switches, hosts def makeNet( self, controller ): root, switches, hosts = self.treeNet( controller, - self.depth, self.fanout, self.kernel) + self.depth, self.fanout ) return switches, hosts # Grid network @@ -630,9 +646,10 @@ def makeNet( self, controller ): return switches, hosts class LinearNet( GridNet ): - def __init__( self, switchCount, kernel=True ): + "A network consisting of two hosts connected by a string of switches." + def __init__( self, switchCount, **kwargs ): self.switchCount = switchCount - GridNet.__init__( self, switchCount, 1, linear=True ) + GridNet.__init__( self, switchCount, 1, linear=True, **kwargs ) # Tests