carlosmscabral | f40ecd1 | 2013-02-01 18:15:58 -0200 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | """ |
| 4 | This example shows how to create a network and run multiple tests. |
| 5 | For a more complicated test example, see udpbwtest.py. |
| 6 | """ |
| 7 | |
| 8 | from mininet.cli import CLI |
| 9 | from mininet.log import lg, info |
| 10 | from mininet.net import Mininet |
| 11 | from mininet.node import OVSKernelSwitch |
| 12 | from mininet.topolib import TreeTopo |
| 13 | |
| 14 | def ifconfigTest( net ): |
| 15 | "Run ifconfig on all hosts in net." |
| 16 | hosts = net.hosts |
| 17 | for host in hosts: |
| 18 | info( host.cmd( 'ifconfig' ) ) |
| 19 | |
| 20 | if __name__ == '__main__': |
| 21 | lg.setLogLevel( 'info' ) |
| 22 | info( "*** Initializing Mininet and kernel modules\n" ) |
| 23 | OVSKernelSwitch.setup() |
| 24 | info( "*** Creating network\n" ) |
| 25 | network = Mininet( TreeTopo( depth=2, fanout=2 ), switch=OVSKernelSwitch) |
| 26 | info( "*** Starting network\n" ) |
| 27 | network.start() |
| 28 | info( "*** Running ping test\n" ) |
| 29 | network.pingAll() |
| 30 | info( "*** Running ifconfig test\n" ) |
| 31 | ifconfigTest( network ) |
| 32 | info( "*** Starting CLI (type 'exit' to exit)\n" ) |
| 33 | CLI( network ) |
| 34 | info( "*** Stopping network\n" ) |
| 35 | network.stop() |