Statistics
| Branch: | Tag: | Revision:

mininet / examples / multitest.py @ 0b7c277e

History | View | Annotate | Download (1.02 KB)

1 22f807fc Bob Lantz
#!/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 259d7133 Bob Lantz
from mininet.net import Mininet
11 11782ae0 Bob Lantz
from mininet.node import OVSKernelSwitch
12 22f807fc Bob Lantz
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 11782ae0 Bob Lantz
    OVSKernelSwitch.setup()
24 22f807fc Bob Lantz
    info( "*** Creating network\n" )
25 11782ae0 Bob Lantz
    network = Mininet( TreeTopo( depth=2, fanout=2 ), switch=OVSKernelSwitch)
26 22f807fc Bob Lantz
    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()