Revision 696a619d

View differences:

examples/grid.py
13 13
   
14 14
if __name__ == '__main__':
15 15
   init()   
16
   network = GridNet( 2, 2, kernel=True, Controller=NoxController)
16
   network = GridNet( 2, 2, kernel=True, Controller=NoxController )
17 17
   network.run( Cli )
examples/linearbandwidth.py
26 26
      results[ datapath ] = []
27 27
      for switchCount in switchCounts: 
28 28
         print "*** Creating linear network of size", switchCount
29
         network = LinearNet( switchCount, k)
29
         network = LinearNet( switchCount, kernel=k)
30 30
         bandwidth = network.run( iperfTest )
31 31
         results[ datapath ] += [ ( switchCount, bandwidth ) ]
32 32
         
examples/nox.py
13 13
   
14 14
if __name__ == '__main__':
15 15
   init()   
16
   network = TreeNet( depth=2, fanout=4, kernel=True, Controller=NoxController)
16
   network = TreeNet( depth=2, fanout=4, kernel=True, Controller=NoxController )
17 17
   network.run( Cli )
examples/scratchnet.py
3 3
"""
4 4
Build a simple network from scratch, using mininet primitives.
5 5
This is more complicated than using the higher-level classes,
6
but it exposes the configuration details and allows cusomization.
6
but it exposes the configuration details and allows customization.
7 7
"""
8 8

  
9 9
from mininet import init, Node, createLink
examples/scratchnetuser.py
3 3
"""
4 4
Build a simple network from scratch, using mininet primitives.
5 5
This is more complicated than using the higher-level classes,
6
but it exposes the configuration details and allows cusomization.
6
but it exposes the configuration details and allows customization.
7 7

  
8 8
This version uses the user datapath.
9 9
"""
10 10

  
11 11
from mininet import init, Node, createLink
12 12

  
13
def scratchNet( cname='controller', cargs='ptcp:'):
13
def scratchNetUser( cname='controller', cargs='ptcp:'):
14 14
   # Create Network
15
   # It's not strictly necessary for the controller and switches
16
   # to be in separate namespaces. For performance, they probably
17
   # should be in the root namespace. However, it's interesting to
18
   # see how they could work even if they are in separate namespaces.
15 19
   controller = Node( 'c0' )
16 20
   switch = Node( 's0')
17 21
   h0 = Node( 'h0' )
......
40 44
   
41 45
if __name__ == '__main__':
42 46
   init()   
43
   scratchNet()
47
   scratchNetUser()
mininet.py
50 50
   For the moment, specifying configurations and tests in Python
51 51
   is straightforward and relatively concise.
52 52
   Soon, we may want to split the various subsystems (core,
53
   cli, tests, etc.) into multiple modules.
54
   We don't support nox nicely just yet - you have to hack this file
55
   or subclass things aggressively.
53
   topology/network, cli, tests, etc.) into multiple modules.
54
   Currently nox support is in nox.py.
56 55
   We'd like to support OpenVSwitch as well as the reference
57 56
   implementation.
58 57
   
......
396 395
   i = 0
397 396
   while True: yield prefix + `i`; i += 1
398 397
      
399
# Control network support
400
# For the user datapath, we create an explicit control network.
401
# Note: Instead of routing, we could bridge or use "in-band" control
402
   
398
# Control network support:
399
#
400
# Create an explicit control network. Currently this is only
401
# used by the user datapath configuration.
402
#
403
# Notes:
404
#
405
# 1. If the controller and switches are in the same (e.g. root)
406
#    namespace, they can just use the loopback connection.
407
#    We may wish to do this for the user datapath as well as the
408
#    kernel datapath.
409
#
410
# 2. If we can get unix domain sockets to work, we can use them
411
#    instead of an explicit control network.
412
#
413
# 3. Instead of routing, we could bridge or use "in-band" control.
414
#
415
# 4. Even if we dispense with this in general, it could still be
416
#    useful for people who wish to simulate a separate control
417
#    network (since real networks may need one!)
418

  
403 419
def configureRoutedControlNetwork( controller, switches, ips):
404 420
   """Configure a routed control network on controller and switches,
405 421
      for use with the user datapath."""
......
542 558
   def __init__( self, depth, fanout, **kwargs):
543 559
      self.depth, self.fanout = depth, fanout
544 560
      Network.__init__( self, **kwargs )
545
   def treeNet( self, controller, depth, fanout, kernel=True, snames=None,
561
   def treeNet( self, controller, depth, fanout, snames=None,
546 562
      hnames=None, dpnames=None ):
547 563
      """Return a tree network of the given depth and fanout as a triple:
548 564
         ( root, switches, hosts ), using the given switch, host and
......
555 571
         host = Host( hnames.next() )
556 572
         print host.name, ; flush()
557 573
         return host, [], [ host ]
558
      dp = dpnames.next() if kernel else None
574
      dp = dpnames.next() if self.kernel else None
559 575
      switch = Switch( snames.next(), dp )
560
      if not kernel: createLink( switch, controller )
576
      if not self.kernel: createLink( switch, controller )
561 577
      print switch.name, ; flush()
562 578
      switches, hosts = [ switch ], []
563 579
      for i in range( 0, fanout ):
564 580
         child, slist, hlist = self.treeNet( controller, 
565
            depth - 1, fanout, kernel, snames, hnames, dpnames )
581
            depth - 1, fanout, snames, hnames, dpnames )
566 582
         createLink( switch, child )
567 583
         switches += slist
568 584
         hosts += hlist
569 585
      return switch, switches, hosts
570 586
   def makeNet( self, controller ):
571 587
      root, switches, hosts = self.treeNet( controller,
572
         self.depth, self.fanout, self.kernel)
588
         self.depth, self.fanout )
573 589
      return switches, hosts
574 590
   
575 591
# Grid network
......
630 646
      return switches, hosts
631 647

  
632 648
class LinearNet( GridNet ):
633
   def __init__( self, switchCount, kernel=True ):
649
   "A network consisting of two hosts connected by a string of switches."
650
   def __init__( self, switchCount, **kwargs ):
634 651
      self.switchCount = switchCount
635
      GridNet.__init__( self, switchCount, 1, linear=True )
652
      GridNet.__init__( self, switchCount, 1, linear=True, **kwargs )
636 653
      
637 654
# Tests
638 655

  

Also available in: Unified diff