diff --git a/examples/README b/examples/README index a48a899..bb3e0c2 100644 --- a/examples/README +++ b/examples/README @@ -1,22 +1,34 @@ Mininet Examples ---- - These examples are intended to help you get started using -Mininet's Python API: +Mininet's Python API. + +--- linearbandwidth.py: This example shows how to create a custom topology programatically by subclassing Topo, and how to run a series of tests on it. +multitest.py: + +This example creates a network and runs multiple tests on it. + scratchnet.py, scratchnetuser.py: These two examples demonstrate how to create a network by using the lowest- level Mininet functions. Generally the higher-level API is easier to use, but scratchnet shows what is going on behind the scenes. +sshd.py: + +This example shows how to run an sshd process in each host, allowing +you to log in via ssh. This requires connecting the Mininet data network +to an interface in the root namespace (generaly the control network +already lives in the root namespace, so it does not need to be explicitly +connected.) + udpbwtest.py: This example shows how to run a test across an entire network, and monitor diff --git a/examples/multitest.py b/examples/multitest.py new file mode 100755 index 0000000..acb0d4b --- /dev/null +++ b/examples/multitest.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + +""" +This example shows how to create a network and run multiple tests. +For a more complicated test example, see udpbwtest.py. +""" + +from mininet.cli import CLI +from mininet.log import lg, info +from mininet.net import init, Mininet +from mininet.node import KernelSwitch +from mininet.topolib import TreeTopo + +def ifconfigTest( net ): + "Run ifconfig on all hosts in net." + hosts = net.hosts + for host in hosts: + info( host.cmd( 'ifconfig' ) ) + +if __name__ == '__main__': + lg.setLogLevel( 'info' ) + info( "*** Initializing Mininet and kernel modules\n" ) + KernelSwitch.setup() + init() + info( "*** Creating network\n" ) + network = Mininet( TreeTopo( depth=2, fanout=2 ), switch=KernelSwitch) + info( "*** Starting network\n" ) + network.start() + info( "*** Running ping test\n" ) + network.pingAll() + info( "*** Running ifconfig test\n" ) + ifconfigTest( network ) + info( "*** Starting CLI (type 'exit' to exit)\n" ) + CLI( network ) + info( "*** Stopping network\n" ) + network.stop()