Revision 0a9ea29f

View differences:

INSTALL
4 4
- This is not (yet) a 'release'; things may be broken.
5 5

  
6 6
- Mininet is not currently 'installed.' If you want to install it,
7
  so that you can 'import mininet', place it somewhere in your
7
  so that you can 'import mininet', place mininet.py somewhere in your
8 8
  python path.
9 9
  
10 10
- A functional netns binary is required to run mininet, but currently you
README
21 21
In order to run Mininet, you must have:
22 22

  
23 23
* A Linux 2.6.26 or greater kernel compiled with network namespace support
24
  enabled. (debian-testing seems to have such a kernel.)
24
  enabled. (debian-testing seems to have such a kernel, but it doesn't
25
  work for compiling nox, unfortunately.)
25 26

  
26 27
* The OpenFlow reference implementation (either the user or kernel
27 28
  datapath may be used, and the tun or ofdatapath kernel modules must be
cleanup
31 31
   print "*** Removing all links of the pattern foo-ethX"
32 32
   links = sh( "ip link show | egrep -o '(\w+-eth\w+)'" ).split( '\n' )
33 33
   for link in links: 
34
      if link: sh( "ip link del " + link )
34
      if link != '': sh( "ip link del " + link )
35 35

  
36 36
   print "*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes"
37 37
   zombies = 'controller ofprotocol ofdatapath ping nox_core lt-nox_core'
......
43 43
   print "*** Removing excess kernel datapaths"
44 44
   dps = sh( "ps ax | egrep -o 'dp[0-9]+' | sed 's/dp/nl:/'" ).split( '\n')
45 45
   for dp in dps: 
46
      if dp: sh( 'ip link del ' + link )
46
      if dp != '': sh( 'ip link del ' + link )
47 47

  
48 48
   print "*** Removing junk from /tmp"
49 49
   sh( 'rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log' )
mininet.py
346 346
def moveIntf( intf, node ):
347 347
   "Move intf to node."
348 348
   cmd = 'ip link set ' + intf + ' netns ' + `node.pid`
349
   checkRun( cmd )
349
   quietRun( cmd )
350 350
   links = node.cmd( 'ip link show' )
351 351
   if not intf in links:
352 352
      print "*** Error: moveIntf:", intf, "not successfully moved to",
353 353
      print node.name,":"
354
      exit( 1 )
355
   return
354
      return False
355
   return True
356

  
357
def retry( n, fn, *args):
358
   "Try something N times before giving up."
359
   tries = 0
360
   while not apply( fn, args ) and tries < 3:
361
      sleep( 1 )
362
      print "*** retrying..."; flush()
363
      tries += 1
364
   if tries > 3: exit( 1 )
356 365
   
357 366
def createLink( node1, node2 ):
358 367
   "Create a link node1-intf1 <---> node2-intf2."
359 368
   intf1 = node1.newIntf()
360 369
   intf2 = node2.newIntf()
361 370
   makeIntfPair( intf1, intf2 )
362
   if node1.inNamespace: moveIntf( intf1, node1 )
363
   if node2.inNamespace: moveIntf( intf2, node2 )
371
   if node1.inNamespace: retry( 3, moveIntf, intf1, node1 )
372
   if node2.inNamespace: retry( 3, moveIntf, intf2, node2 )
364 373
   node1.connection[ intf1 ] = ( node2, intf2 )
365 374
   node2.connection[ intf2 ] = ( node1, intf1 )
366 375
   return intf1, intf2

Also available in: Unified diff