Mininet Python API Reference Manual
|
Network emulation with hosts spawned in network namespaces. More...
Public Member Functions | |
def | __init__ (self, topo=None, switch=OVSKernelSwitch, host=Host, controller=DefaultController, link=Link, intf=Intf, build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8', inNamespace=False, autoSetMacs=False, autoStaticArp=False, autoPinCpus=False, listenPort=None, waitConnected=False) |
Create Mininet object. More... | |
def | waitConnected (self, timeout=None, delay=.5) |
wait for each switch to connect to a controller More... | |
def | addHost (self, name, cls=None, **params) |
Add host. More... | |
def | delNode (self, node, nodes=None) |
Delete node. More... | |
def | delHost (self, host) |
Delete a host. | |
def | addSwitch (self, name, cls=None, **params) |
Add switch. More... | |
def | delSwitch (self, switch) |
Delete a switch. | |
def | addController (self, name='c0', controller=None, **params) |
Add controller. More... | |
def | delController (self, controller) |
Delete a controller Warning - does not reconfigure switches, so they may still attempt to connect to it! | |
def | addNAT (self, name='nat0', connect=True, inNamespace=False, **params) |
Add a NAT to the Mininet network. More... | |
def | getNodeByName (self, *args) |
Return node(s) with given name(s) | |
def | get (self, *args) |
Convenience alias for getNodeByName. | |
def | __getitem__ (self, key) |
net[ name ] operator: Return node with given name | |
def | __delitem__ (self, key) |
del net[ name ] operator - delete node with given name | |
def | __iter__ (self) |
return iterator over node names | |
def | __len__ (self) |
returns number of nodes in net | |
def | __contains__ (self, item) |
returns True if net contains named node | |
def | keys (self) |
return a list of all node names or net's keys | |
def | values (self) |
return a list of all nodes or net's values | |
def | items (self) |
return (key,value) tuple list for every node in net | |
def | addLink (self, node1, node2, port1=None, port2=None, cls=None, **params) |
"Add a link from node1 to node2 More... | |
def | delLink (self, link) |
Remove a link from this network. | |
def | linksBetween (self, node1, node2) |
Return Links between node1 and node2. | |
def | delLinkBetween (self, node1, node2, index=0, allLinks=False) |
Delete link(s) between node1 and node2. More... | |
def | configHosts (self) |
Configure a set of hosts. | |
def | buildFromTopo (self, topo=None) |
Build mininet from a topology object At the end of this function, everything should be connected and up. | |
def | configureControlNetwork (self) |
Control net config hook: override in subclass. | |
def | build (self) |
Build mininet. | |
def | startTerms (self) |
Start a terminal for each node. | |
def | stopXterms (self) |
Kill each xterm. | |
def | staticArp (self) |
Add all-pairs ARP entries to remove the need to handle broadcast. | |
def | start (self) |
Start controller and switches. | |
def | stop (self) |
Stop the controller(s), switches and hosts. | |
def | run (self, test, *args, **kwargs) |
Perform a complete start/test/stop cycle. | |
def | monitor (self, hosts=None, timeoutms=-1) |
Monitor a set of hosts (or all hosts by default), and return their output, a line at a time. More... | |
def | ping (self, hosts=None, timeout=None) |
Ping between all specified hosts. More... | |
def | pingFull (self, hosts=None, timeout=None) |
Ping between all specified hosts and return all data. More... | |
def | pingAll (self, timeout=None) |
Ping between all hosts. More... | |
def | pingPair (self) |
Ping between first two hosts, useful for testing. More... | |
def | pingAllFull (self) |
Ping between all hosts. More... | |
def | pingPairFull (self) |
Ping between first two hosts, useful for testing. More... | |
def | iperf (self, hosts=None, l4Type='TCP', udpBw='10M', fmt=None, seconds=5, port=5001) |
Run iperf between two hosts. More... | |
def | runCpuLimitTest (self, cpu, duration=5) |
run CPU limit test with 'while true' processes. More... | |
def | configLinkStatus (self, src, dst, status) |
Change status of src <-> dst links. More... | |
def | interact (self) |
Start network and run our simple CLI. | |
def | init (cls) |
Initialize Mininet. | |
Static Public Member Functions | |
def | randMac () |
Return a random, non-multicast MAC address. | |
Static Public Attributes | |
bool | inited = False |
Network emulation with hosts spawned in network namespaces.
def mininet.net.Mininet.__init__ | ( | self, | |
topo = None , |
|||
switch = OVSKernelSwitch , |
|||
host = Host , |
|||
controller = DefaultController , |
|||
link = Link , |
|||
intf = Intf , |
|||
build = True , |
|||
xterms = False , |
|||
cleanup = False , |
|||
ipBase = '10.0.0.0/8' , |
|||
inNamespace = False , |
|||
autoSetMacs = False , |
|||
autoStaticArp = False , |
|||
autoPinCpus = False , |
|||
listenPort = None , |
|||
waitConnected = False |
|||
) |
Create Mininet object.
topo | Topo (topology) object or None |
switch | default Switch class |
host | default Host class/constructor |
controller | default Controller class/constructor |
link | default Link class/constructor |
intf | default Intf class/constructor |
ipBase | base IP address for hosts, |
build | build now from topo? |
xterms | if build now, spawn xterms? |
cleanup | if build now, cleanup before creating? |
inNamespace | spawn switches and controller in net namespaces? |
autoSetMacs | set MAC addrs automatically like IP addresses? |
autoStaticArp | set all-pairs static MAC addrs? |
autoPinCpus | pin hosts to (real) cores (requires CPULimitedHost)? |
listenPort | base listening port to open; will be incremented for each additional switch in the net if inNamespace=False |
waitConnected | wait for switches to Connect? (False; True/None=wait indefinitely; time(s)=timed wait) |
def mininet.net.Mininet.addController | ( | self, | |
name = 'c0' , |
|||
controller = None , |
|||
** | params | ||
) |
Add controller.
controller | Controller class |
def mininet.net.Mininet.addHost | ( | self, | |
name, | |||
cls = None , |
|||
** | params | ||
) |
Add host.
name | name of host to add |
cls | custom host class/constructor (optional) |
params | parameters for host |
def mininet.net.Mininet.addLink | ( | self, | |
node1, | |||
node2, | |||
port1 = None , |
|||
port2 = None , |
|||
cls = None , |
|||
** | params | ||
) |
"Add a link from node1 to node2
node1 | source node (or name) |
node2 | dest node (or name) |
port1 | source port (optional) |
port2 | dest port (optional) |
cls | link class (optional) |
params | additional link params (optional) |
def mininet.net.Mininet.addNAT | ( | self, | |
name = 'nat0' , |
|||
connect = True , |
|||
inNamespace = False , |
|||
** | params | ||
) |
Add a NAT to the Mininet network.
name | name of NAT node |
connect | switch to connect to | True (s1) | None |
inNamespace | create in a network namespace |
params | other NAT node params, |
notably | |
ip | used as default gateway address |
def mininet.net.Mininet.addSwitch | ( | self, | |
name, | |||
cls = None , |
|||
** | params | ||
) |
Add switch.
name | name of switch to add |
cls | custom switch class/constructor (optional) |
effect | increments listenPort ivar . |
def mininet.net.Mininet.configLinkStatus | ( | self, | |
src, | |||
dst, | |||
status | |||
) |
Change status of src <-> dst links.
src | node name |
dst | node name |
status | string {up, down} |
def mininet.net.Mininet.delLinkBetween | ( | self, | |
node1, | |||
node2, | |||
index = 0 , |
|||
allLinks = False |
|||
) |
Delete link(s) between node1 and node2.
index | index of link to delete if multiple links (0) |
allLinks | ignore index and delete all such links (False) |
def mininet.net.Mininet.delNode | ( | self, | |
node, | |||
nodes = None |
|||
) |
Delete node.
node | node to delete |
nodes | optional list to delete from (e.g. self.hosts) |
def mininet.net.Mininet.iperf | ( | self, | |
hosts = None , |
|||
l4Type = 'TCP' , |
|||
udpBw = '10M' , |
|||
fmt = None , |
|||
seconds = 5 , |
|||
port = 5001 |
|||
) |
Run iperf between two hosts.
hosts | list of hosts; if None, uses first and last hosts |
l4Type | string, one of [ TCP, UDP ] |
udpBw | bandwidth target for UDP test |
fmt | iperf format argument if any |
seconds | iperf time to transmit |
port | iperf port |
note | send() is buffered, so client rate can be much higher than the actual transmission rate; on an unloaded system, server rate should be much closer to the actual receive rate |
def mininet.net.Mininet.monitor | ( | self, | |
hosts = None , |
|||
timeoutms = -1 |
|||
) |
Monitor a set of hosts (or all hosts by default), and return their output, a line at a time.
hosts | (optional) set of hosts to monitor |
timeoutms | (optional) timeout value in ms |
def mininet.net.Mininet.ping | ( | self, | |
hosts = None , |
|||
timeout = None |
|||
) |
Ping between all specified hosts.
hosts | list of hosts |
timeout | time to wait for a response, as string |
def mininet.net.Mininet.pingAll | ( | self, | |
timeout = None |
|||
) |
Ping between all hosts.
def mininet.net.Mininet.pingAllFull | ( | self | ) |
Ping between all hosts.
def mininet.net.Mininet.pingFull | ( | self, | |
hosts = None , |
|||
timeout = None |
|||
) |
Ping between all specified hosts and return all data.
hosts | list of hosts |
timeout | time to wait for a response, as string |
def mininet.net.Mininet.pingPair | ( | self | ) |
Ping between first two hosts, useful for testing.
def mininet.net.Mininet.pingPairFull | ( | self | ) |
Ping between first two hosts, useful for testing.
def mininet.net.Mininet.runCpuLimitTest | ( | self, | |
cpu, | |||
duration = 5 |
|||
) |
run CPU limit test with 'while true' processes.
cpu | desired CPU fraction of each host |
duration | test duration in seconds (integer) returns a single list of measured CPU fractions as floats. |
def mininet.net.Mininet.waitConnected | ( | self, | |
timeout = None , |
|||
delay = .5 |
|||
) |
wait for each switch to connect to a controller
timeout | time to wait, or None or True to wait indefinitely |
delay | seconds to sleep per iteration |