Merge branch 'patches/examplesdoc' of github.com:ryancox/mininet into ryancox-patches/examplesdoc
Conflicts: examples/README
This commit is contained in:
+31
-36
@@ -1,105 +1,106 @@
|
|||||||
|
|
||||||
Mininet Examples
|
Mininet Examples
|
||||||
|
========================================================
|
||||||
|
|
||||||
These examples are intended to help you get started using
|
These examples are intended to help you get started using
|
||||||
Mininet's Python API.
|
Mininet's Python API.
|
||||||
|
|
||||||
---
|
========================================================
|
||||||
|
|
||||||
baresshd.py:
|
### baresshd.py:
|
||||||
|
|
||||||
This example uses Mininet's medium-level API to create an sshd
|
This example uses Mininet's medium-level API to create an sshd
|
||||||
process running in a namespace. Doesn't use OpenFlow.
|
process running in a namespace. Doesn't use OpenFlow.
|
||||||
|
|
||||||
consoles.py:
|
### consoles.py:
|
||||||
|
|
||||||
This example creates a grid of console windows, one for each node,
|
This example creates a grid of console windows, one for each node,
|
||||||
and allows interaction with and monitoring of each console, including
|
and allows interaction with and monitoring of each console, including
|
||||||
graphical monitoring.
|
graphical monitoring.
|
||||||
|
|
||||||
controllers.py:
|
### controllers.py:
|
||||||
|
|
||||||
This example creates a network with multiple controllers, by
|
This example creates a network with multiple controllers, by
|
||||||
using a custom Switch() subclass.
|
using a custom Switch() subclass.
|
||||||
|
|
||||||
controllers2.py:
|
### controllers2.py:
|
||||||
|
|
||||||
This example creates a network with multiple controllers by
|
This example creates a network with multiple controllers by
|
||||||
creating an empty network, adding nodes to it, and manually
|
creating an empty network, adding nodes to it, and manually
|
||||||
starting the switches.
|
starting the switches.
|
||||||
|
|
||||||
controlnet.py:
|
### controlnet.py:
|
||||||
|
|
||||||
This examples shows how you can model the control network as well
|
This examples shows how you can model the control network as well
|
||||||
as the data network, by actually creating two Mininet objects.
|
as the data network, by actually creating two Mininet objects.
|
||||||
|
|
||||||
cpu.py:
|
### cpu.py:
|
||||||
|
|
||||||
This example tests iperf bandwidth for varying CPU limits.
|
This example tests iperf bandwidth for varying CPU limits.
|
||||||
|
|
||||||
emptynet.py:
|
### emptynet.py:
|
||||||
|
|
||||||
This example demonstrates creating an empty network (i.e. with no
|
This example demonstrates creating an empty network (i.e. with no
|
||||||
topology object) and adding nodes to it.
|
topology object) and adding nodes to it.
|
||||||
|
|
||||||
hwintf.py:
|
### hwintf.py:
|
||||||
|
|
||||||
This example shows how to add an interface (for example a real
|
This example shows how to add an interface (for example a real
|
||||||
hardware interface) to a network after the network is created.
|
hardware interface) to a network after the network is created.
|
||||||
|
|
||||||
limit.py:
|
### limit.py:
|
||||||
|
|
||||||
This example shows how to use link and CPU limits.
|
This example shows how to use link and CPU limits.
|
||||||
|
|
||||||
linearbandwidth.py:
|
### linearbandwidth.py:
|
||||||
|
|
||||||
This example shows how to create a custom topology programatically
|
This example shows how to create a custom topology programatically
|
||||||
by subclassing Topo, and how to run a series of tests on it.
|
by subclassing Topo, and how to run a series of tests on it.
|
||||||
|
|
||||||
miniedit.py:
|
### miniedit.py:
|
||||||
|
|
||||||
This example demonstrates creating a network via a graphical editor.
|
This example demonstrates creating a network via a graphical editor.
|
||||||
|
|
||||||
multiping.py:
|
### multiping.py:
|
||||||
|
|
||||||
This example demonstrates one method for
|
This example demonstrates one method for
|
||||||
monitoring output from multiple hosts, using node.monitor().
|
monitoring output from multiple hosts, using `node.monitor()`.
|
||||||
|
|
||||||
multipoll.py:
|
### multipoll.py:
|
||||||
|
|
||||||
This example demonstrates monitoring output files from multiple hosts.
|
This example demonstrates monitoring output files from multiple hosts.
|
||||||
|
|
||||||
multitest.py:
|
### multitest.py:
|
||||||
|
|
||||||
This example creates a network and runs multiple tests on it.
|
This example creates a network and runs multiple tests on it.
|
||||||
|
|
||||||
nat.py:
|
### nat.py:
|
||||||
|
|
||||||
This example shows how to connect a Mininet network to the Internet
|
This example shows how to connect a Mininet network to the Internet
|
||||||
using NAT. It also answers the eternal question "why can't I ping
|
using NAT. It also answers the eternal question "why can't I ping
|
||||||
google?"
|
google?"
|
||||||
|
|
||||||
popen.py:
|
### popen.py:
|
||||||
|
|
||||||
This example monitors a number of hosts using host.popen() and
|
This example monitors a number of hosts using `host.popen()` and
|
||||||
pmonitor().
|
`pmonitor()`.
|
||||||
|
|
||||||
popenpoll.py:
|
### popenpoll.py:
|
||||||
|
|
||||||
This example demonstrates monitoring output from multiple hosts using
|
This example demonstrates monitoring output from multiple hosts using
|
||||||
the node.popen() interface (which returns Popen objects) and pmonitor().
|
the `node.popen()` interface (which returns Popen objects) and `pmonitor()`.
|
||||||
|
|
||||||
scratchnet.py, scratchnetuser.py:
|
### scratchnet.py, scratchnetuser.py:
|
||||||
|
|
||||||
These two examples demonstrate how to create a network by using the lowest-
|
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,
|
level Mininet functions. Generally the higher-level API is easier to use,
|
||||||
but scratchnet shows what is going on behind the scenes.
|
but scratchnet shows what is going on behind the scenes.
|
||||||
|
|
||||||
simpleperf.py:
|
### simpleperf.py:
|
||||||
|
|
||||||
A simple example of configuring network and CPU bandwidth limits.
|
A simple example of configuring network and CPU bandwidth limits.
|
||||||
|
|
||||||
sshd.py:
|
### sshd.py:
|
||||||
|
|
||||||
This example shows how to run an sshd process in each host, allowing
|
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
|
you to log in via ssh. This requires connecting the Mininet data network
|
||||||
@@ -107,19 +108,13 @@ 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
|
already lives in the root namespace, so it does not need to be explicitly
|
||||||
connected.)
|
connected.)
|
||||||
|
|
||||||
treeping64.py:
|
### tree1024.py:
|
||||||
|
|
||||||
This example creates a 64-host tree network, and attempts to check full
|
|
||||||
connectivity using ping, for different switch/datapath types.
|
|
||||||
|
|
||||||
tree1024.py:
|
|
||||||
|
|
||||||
This example attempts to create a 1024-host network, and then runs the
|
This example attempts to create a 1024-host network, and then runs the
|
||||||
CLI on it. It may run into scalability limits, depending on available
|
CLI on it. It may run into scalability limits, depending on available
|
||||||
memory and sysctl configuration (see INSTALL.)
|
memory and sysctl configuration (see `INSTALL`.)
|
||||||
|
|
||||||
dynamicnet.py:
|
### treeping64.py:
|
||||||
|
|
||||||
This example builds a network based on command line arguments and uses
|
This example creates a 64-host tree network, and attempts to check full
|
||||||
a remote controller. It is a good option to use with POX controller and
|
connectivity using ping, for different switch/datapath types.
|
||||||
develop Software Defined Networks.
|
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
"""
|
|
||||||
This script builds a network using mininet for using with
|
|
||||||
a remote controller like POX.
|
|
||||||
|
|
||||||
The script receives from command line two arguments. The number
|
|
||||||
of Switches and the number of Hosts per Switch. Then, it will build
|
|
||||||
the network topology based on this arguments.
|
|
||||||
|
|
||||||
First of all, it build a topology and add the Switches to the network.
|
|
||||||
After that, add the same number of Hosts for each Switch added. Lastly
|
|
||||||
it make links between each switch.
|
|
||||||
|
|
||||||
@author: Gustavo Pantuza
|
|
||||||
@since: 18.07.2013
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from optparse import OptionParser
|
|
||||||
|
|
||||||
from mininet.topo import LinearTopo
|
|
||||||
from mininet.log import setLogLevel
|
|
||||||
from mininet.net import Mininet
|
|
||||||
from mininet.cli import CLI
|
|
||||||
from mininet.node import RemoteController
|
|
||||||
|
|
||||||
def main():
|
|
||||||
# Defines the log level
|
|
||||||
setLogLevel('info')
|
|
||||||
|
|
||||||
# parses command line arguments
|
|
||||||
parser = OptionParser()
|
|
||||||
parser.add_option('-H', dest='hosts', default=5,
|
|
||||||
help='Number of hosts per switch')
|
|
||||||
parser.add_option('-S', dest='switches', default=2,
|
|
||||||
help='Number of switches')
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
# Build network topology (see mininet/topo.py)
|
|
||||||
topo = LinearTopo(int(options.switches), int(options.hosts))
|
|
||||||
|
|
||||||
# Creates the Network using a remote controller
|
|
||||||
net = Mininet(topo,
|
|
||||||
controller=lambda a: RemoteController(a, ip='127.0.0.1'))
|
|
||||||
|
|
||||||
# Starts the network
|
|
||||||
net.start()
|
|
||||||
# Run the mininet client
|
|
||||||
CLI(net)
|
|
||||||
# Stop the network
|
|
||||||
net.stop()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user