Thomas Vachuska | e76f653 | 2015-07-08 09:40:53 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import sys |
| 4 | |
| 5 | from mininet.net import Mininet |
| 6 | from mininet.cli import CLI |
| 7 | from mininet.log import setLogLevel |
| 8 | from mininet.node import RemoteController |
| 9 | |
| 10 | from rftesttopo import ReactiveForwardingTestTopo |
| 11 | |
| 12 | setLogLevel( 'info' ) |
| 13 | |
| 14 | def pingloop( net ): |
| 15 | setLogLevel( 'error' ) |
| 16 | try: |
| 17 | while True: |
| 18 | net.ping() |
| 19 | finally: |
| 20 | setLogLevel( 'info' ) |
| 21 | |
| 22 | def run(controllers=[ '127.0.0.1' ]): |
| 23 | Mininet.pingloop = pingloop |
| 24 | net = Mininet( topo=ReactiveForwardingTestTopo(), build=False, autoSetMacs=True ) |
| 25 | ctrl_count = 0 |
| 26 | for controllerIP in controllers: |
| 27 | net.addController( 'c%d' % ctrl_count, RemoteController, ip=controllerIP ) |
| 28 | ctrl_count = ctrl_count + 1 |
| 29 | net.build() |
| 30 | net.start() |
| 31 | CLI( net ) |
| 32 | net.stop() |
| 33 | |
| 34 | if __name__ == '__main__': |
| 35 | if len( sys.argv ) > 1: |
| 36 | controllers = sys.argv[ 1: ] |
| 37 | else: |
| 38 | print 'Usage: rf-test.py <c0 IP> <c1 IP> ...' |
| 39 | exit( 1 ) |
| 40 | run( controllers ) |