From 696a619d0e6c1911a1fd5e36e7897d240df7ce80 Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Tue, 15 Dec 2009 18:50:44 -0800
Subject: [PATCH] Minor tweaks and corrections. Added commentary on control
 network to mininet.py. Hopefully fixed linearbandwidth.py for real.

---
 examples/grid.py            |  2 +-
 examples/linearbandwidth.py |  2 +-
 examples/nox.py             |  2 +-
 examples/scratchnet.py      |  2 +-
 examples/scratchnetuser.py  | 10 ++++++---
 mininet.py                  | 45 +++++++++++++++++++++++++------------
 6 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/examples/grid.py b/examples/grid.py
index fea7d6ce..3abeef7b 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 6631b9e5..2f46d942 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 233f2a67..8a9c0242 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 e3fde16c..43b63161 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 8aab551d..f9460418 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 eb34ef6f..f503cf79 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
 
-- 
GitLab