Revision 8f20b95d mininet/net.py

View differences:

mininet/net.py
1 1
#!/usr/bin/python
2
"""Mininet: A simple networking testbed for OpenFlow!
2 3

  
3
"""
4
Mininet: A simple networking testbed for OpenFlow!
4
@author Bob Lantz (rlantz@cs.stanford.edu)
5
@author Brandon Heller (brandonh@stanford.edu)
5 6

  
6 7
Mininet creates scalable OpenFlow test networks by using
7 8
process-based virtualization and network namespaces. 
......
16 17
   A parent shell (and possibly some child processes) in a namespace
17 18
   
18 19
Hosts have a network interface which is configured via ifconfig/ip
19
link/etc. with data network IP addresses (e.g. 192.168.123.2 )
20
link/etc.
20 21

  
21 22
This version supports both the kernel and user space datapaths
22 23
from the OpenFlow reference implementation.
......
43 44
   Switch nodes are named s0-sN
44 45
   Interfaces are named {nodename}-eth0 .. {nodename}-ethN,
45 46

  
46
Thoughts/TBD:
47

  
48
   It should be straightforward to add a function to read
49
   OpenFlowVMS spec files, but I haven't done so yet.
50
   For the moment, specifying configurations and tests in Python
51
   is straightforward and relatively concise.
52
   Soon, we may want to split the various subsystems (core,
53
   topology/network, cli, tests, etc.) into multiple modules.
54
   Currently nox support is in nox.py.
55
   We'd like to support OpenVSwitch as well as the reference
56
   implementation.
57
   
58
Bob Lantz
59
rlantz@cs.stanford.edu
60

  
61
History:
62
11/19/09 Initial revision (user datapath only)
63
11/19/09 Mininet demo at OpenFlow SWAI meeting
64
12/08/09 Kernel datapath support complete
65
12/09/09 Moved controller and switch routines into classes
66
12/12/09 Added subdivided network driver workflow
67
12/13/09 Added support for custom controller and switch classes
68 47
"""
69 48
import os
70 49
import re
71 50
from subprocess import call
72 51
import sys
73 52
from time import sleep
74
#flush = sys.stdout.flush
75
#import os, re, signal, sys, select
76 53

  
77
from mininet.logging_mod import lg, set_loglevel
78
from mininet.node import Host, Controller, Switch, ControllerParams
79
from mininet.topo import TreeTopo
54
from mininet.logging_mod import lg
80 55
from mininet.util import quietRun, fixLimits
81 56
from mininet.util import make_veth_pair, move_intf, retry, MOVEINTF_DELAY
82 57

  
......
517 492
            else:
518 493
                lg.error('CLI: unknown node or command: < %s >\n' % first)
519 494
            #lg.info('*** CLI: command complete\n')
520
        return 'exited by user command'
521

  
522

  
523
if __name__ == '__main__':
524
    if len(sys.argv) > 1:
525
        set_loglevel(sys.argv[1])
526
    else:
527
        set_loglevel('info')
528

  
529
    init()
530
    results = {}
531
    lg.info("*** Welcome to Mininet!\n")
532
    lg.info("*** Look in examples/ for more examples\n\n")
533
    lg.info("*** Testing Mininet with kernel and user datapath\n")
534
    for datapath in DATAPATHS:
535
        k = datapath == 'kernel'
536
        controller_params = ControllerParams(0x0a000000, 8) # 10.0.0.0/8
537
        mn = Mininet(TreeTopo(), Switch, Host, Controller,
538
                         controller_params)
539
        mn.start()
540
        dropped = mn.ping_test()
541
        results[datapath] = "%i%% dropped" % dropped
542
        mn.stop()
543

  
544
    lg.info("*** Test results: %s\n", results)
495
        return 'exited by user command'

Also available in: Unified diff