Revision 748e35d5

View differences:

README
1 1

  
2
	Mininet: A Simple Virtual Testbed for OpenFlow
3
						aka
2
    Mininet: A Simple Virtual Testbed for OpenFlow
3
                        aka
4 4
How to Squeeze a 1024-node OpenFlow Network onto your Laptop
5 5

  
6 6
(Extremely Experimental Development Version 0.1, December 2009)
......
10 10
Mininet creates simple OpenFlow test networks by using process-based
11 11
virtualization and network namespaces.
12 12

  
13
Simulated hosts (as well as switches and controllers with the user datapath)
14
are created as processes in separate network namespaces. This allows a
15
complete OpenFlow network to be simulated on top of a single Linux kernel.
13
Simulated hosts (as well as switches and controllers with the user
14
datapath) are created as processes in separate network namespaces. This
15
allows a complete OpenFlow network to be simulated on top of a single
16
Linux kernel.
16 17

  
17 18
In order to run Mininet, you must have:
18 19

  
19 20
* A Linux 2.6.26 or greater kernel compiled with network namespace support
20
  enabled. (Debian-testing should work.)
21
  enabled. (Debian 5.0 or greater should work.)
21 22

  
22
* The OpenFlow reference implementation (either the user or kernel datapath
23
  may be used, and the tun or ofdatapath kernel modules must be loaded,
24
  respectively)
23
* The OpenFlow reference implementation (either the user or kernel
24
  datapath may be used, and the tun or ofdatapath kernel modules must be
25
  loaded, respectively)
25 26

  
26 27
* Python, Bash, etc.
27 28

  
28 29
* Root privilieges (required for network device access)
29 30

  
30
* The netns program or equivalent (included as netns.c)
31
* The netns program or equivalent (included as netns.c) installed
32
  in an appropriate path location.
33
  
34
* mininet.py installed in an appropriate Python path location.
31 35

  
32 36
Currently mininet includes:
33 37

  
34
	A simple node infrastructure (Host, Switch, Controller classes) for
35
	creating virtual OpenFlow networks.
38
- A simple node infrastructure (Host, Switch, Controller classes) for
39
  creating virtual OpenFlow networks.
36 40
	
37
	A simple network infrastructure (class Network and its descendants
38
	TreeNet, GridNet and LinearNet) for creating scalable topologies and
39
	running experiments (using someNetwork.run( test ) )
41
- A simple network infrastructure (class Network and its descendants
42
  TreeNet, GridNet and LinearNet) for creating scalable topologies and
43
  running experiments (using someNetwork.run( test ) )
40 44
	
41
	Some simple tests which can be run by someNetwork.run( test )
45
- Some simple tests which can be run using someNetwork.run( test )
42 46
	
43
	A simple command-line interface which may be invoked on a network
44
	using .run( Cli )
47
- A simple command-line interface which may be invoked on a network using
48
  .run( Cli )
45 49
	
46
	Examples (in examples/ directory) to help you get started.
50
- Examples (in examples/ directory) to help you get started.
47 51
	
48 52
Notes and Advice:
49 53

  
examples/bigTreePing64.py
1 1
#!/usr/bin/python
2 2

  
3
"""Create a tree network of depth 4 and fanout 2, and 
4
   test connectivity using pingTest."""
5
   
3 6
from mininet import init, TreeNet, iperfTest
4 7

  
5 8
def bigTreePing64():
6
   """Create a tree network of depth 4 and fanout 2, and 
7
      test connectivity using pingTest."""
8

  
9 9
   results = {}
10
   
10

  
11 11
   print "*** Testing Mininet with kernel and user datapath"
12 12
   
13 13
   for datapath in [ 'kernel', 'user' ]:
14 14
      k = datapath == 'kernel'
15 15
      results[ datapath ] = []
16 16
      for switchCount in range( 1, 4 ):
17
         print "*** Creating Linear Network of size", switchCount
18
         network = TreeNet( depth=4, fanout=2, kernel=k )
19
         testResult = network.run( iperfTest )
17
         network = TreeNet( depth=4, fanout=4, kernel=k )
18
         testResult = network.run( pingTest )
20 19
         results[ datapath ] += testResult
21 20
         
22 21
   print "*** Test results:", results
examples/linearBandwidth.py
1 1
#!/usr/bin/python
2 2

  
3
"""
4
Test bandwidth on a linear network of varying size, using both
5
the kernel and user datapaths.
6

  
7
The network looks like:
8

  
9
h0 <-> s0 <-> s1 .. sN <-> h1
10
"""
11
   
3 12
from mininet import init, LinearNet, iperfTest
4 13

  
5 14
def linearBandwidthTest():
6
   """Test bandwidth on a linear network of varying size, using both
7
      the kernel and user datapaths."""
8
  
9
   print "*** Testing Mininet with kernel and user datapath"
10
   
11
   datapaths = [ 'kernel' ]
15

  
16
   datapaths = [ 'kernel', 'user' ]
17
   switchCounts = [ 1, 20, 40, 60, 80, 100 ]
12 18
   results = {}
13
      
19

  
14 20
   for datapath in datapaths:
15 21
      k = datapath == 'kernel'
16 22
      results[ datapath ] = []
17
      for switchCount in range( 1, 17, 2 ):
18
         print "*** Creating Linear Network of size", switchCount
23
      for switchCount in switchCounts: 
24
         print "*** Creating linear network of size", switchCount
19 25
         network = LinearNet( switchCount, k)
20 26
         bandwidth = network.run( iperfTest )
21 27
         results[ datapath ] += [ ( switchCount, bandwidth ) ]
22 28
         
23 29
   for datapath in datapaths:
24 30
      print
25
      print "*** Linear network results for", datapath, "datapath"
31
      print "*** Linear network results for", datapath, "datapath:"
26 32
      print
27 33
      result = results[ datapath ]  
34
      print "SwitchCount\tiPerf results"
28 35
      for switchCount, bandwidth in result:
29
         print "switchCount:", switchCount, "bandwidth:", bandwidth[ 0 ]
30
       
36
         print switchCount, '\t\t', 
37
         print bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client'
38
      print
39
   print
40
      
31 41
if __name__ == '__main__':
32 42
   init()
43
   print "*** Running linearBandwidthTest"
33 44
   linearBandwidthTest()
34 45
   exit( 1 )
35 46

  
36
   
47
   
examples/treeInteract.py
1
#!/usr/bin/python
2

  
3
"""Create a tree network and run the CLI on it."""
4

  
5
from mininet import init, TreeNet, Cli
6

  
7
def treeInteract():
8
   network = TreeNet( depth=2, fanout=4, kernel=True )
9
   network.run( Cli )
10
      
11
if __name__ == '__main__':
12
   init()
13
   treeInteract()
14

  
examples/xterms.py
1
#!/usr/bin/python
2

  
3
"Create a network and run an xterm (connected via screen) on each host."
4

  
5
import os
6
from subprocess import Popen
7
from mininet import init, TreeNet, Cli, quietRun
8

  
9
def makeXterm( node, title ):
10
   "Run screen on a node, and hook up an xterm."
11
   node.cmdPrint( 'screen -dmS ' + node.name )
12
   cmd = 'xterm -title ' + title + ':' + node.name
13
   cmd += ' -e screen -D -RR -S ' + node.name
14
   return Popen( cmd.split( ' ' ) )
15

  
16
def makeXterms( nodes, title ):
17
   terms = []
18
   for node in nodes:
19
      if not node.execed:
20
         terms += [ makeXterm( node, title ) ]
21
   return terms
22

  
23
def xterms( controllers, switches, hosts ):
24
   terms = []
25
   terms += makeXterms( controllers, 'controller' )
26
   terms += makeXterms( switches, 'switch' )
27
   terms += makeXterms( hosts, 'host' )
28
   # Wait for completion
29
   for term in terms:
30
      os.waitpid( term.pid, 0 )
31
   
32
def treeXterms():
33
   print "Running xterms on", os.environ[ 'DISPLAY' ]
34
   network = TreeNet( depth=2, fanout=4, kernel=True )
35
   network.run( xterms )
36
      
37
if __name__ == '__main__':
38
   init()
39
   treeXterms()
mininet.py
126 126
      self.ips = {}
127 127
      self.connection = {}
128 128
      self.waiting = False
129
      self.execed = False
130
   def cleanup( self ):
131
      # Help python collect its garbage
132
      self.shell = None
129 133
   # Subshell I/O, commands and control
130 134
   def read( self, max ): return os.read( self.stdout.fileno(), max )
131 135
   def write( self, data ): os.write( self.stdin.fileno(), data )
132
   def terminate( self ): os.kill( self.pid, signal.SIGKILL )
136
   def terminate( self ):
137
      self.cleanup()
138
      os.kill( self.pid, signal.SIGKILL )
133 139
   def waitReadable( self ): self.pollOut.poll()
134 140
   def sendCmd( self, cmd ):
135 141
      """Send a command, followed by a command to echo a sentinel,
......
251 257
      an OpenFlow switch."""
252 258
   def __init__( self, name, datapath=None ):
253 259
      self.dp = datapath
254
      self.execed = False
255 260
      Node.__init__( self, name, inNamespace=( datapath == None ) )
256 261
   def startUserDatapath( self, controller ):
257 262
      """Start OpenFlow reference user datapath, 
......
470 475
      print "*** Running test"
471 476
      result = test( [ controller ], switches, hosts )
472 477
      print "*** Stopping controller"
473
      controller.stop()
478
      controller.stop(); controller.terminate()
474 479
      print "*** Stopping switches"
475 480
      for switch in switches:
476
         switch.stop()
481
         switch.stop() ; switch.terminate()
482
      print "*** Stopping hosts"
483
      for host in hosts: host.terminate()
477 484
      print "*** Test complete"
478 485
      return result
479 486
   def interact( self ):

Also available in: Unified diff