Mininet Python API Reference Manual
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
mininet.net.Mininet Class Reference

Network emulation with hosts spawned in network namespaces. More...

Inheritance diagram for mininet.net.Mininet:
mininet.net.MininetWithControlNet

Public Member Functions

def __init__
 Create Mininet object. More...
 
def waitConnected
 wait for each switch to connect to a controller, up to 5 seconds More...
 
def addHost
 Add host. More...
 
def addSwitch
 Add switch. More...
 
def addController
 Add controller. More...
 
def addNAT
 Add a NAT to the Mininet network. More...
 
def getNodeByName
 Return node(s) with given name(s)
 
def get
 Convenience alias for getNodeByName.
 
def __getitem__
 net [ name ] More...
 
def __iter__
 return iterator over node names
 
def __len__
 returns number of nodes in net
 
def __contains__
 returns True if net contains named node
 
def keys
 return a list of all node names or net's keys
 
def values
 return a list of all nodes or net's values
 
def items
 return (key,value) tuple list for every node in net
 
def addLink
 "Add a link from node1 to node2 More...
 
def configHosts
 Configure a set of hosts. More...
 
def buildFromTopo
 Build mininet from a topology object At the end of this function, everything should be connected and up. More...
 
def configureControlNetwork
 Control net config hook: override in subclass.
 
def build
 Build mininet. More...
 
def startTerms
 Start a terminal for each node. More...
 
def stopXterms
 Kill each xterm. More...
 
def staticArp
 Add all-pairs ARP entries to remove the need to handle broadcast. More...
 
def start
 Start controller and switches. More...
 
def stop
 Stop the controller(s), switches and hosts.
 
def run
 Perform a complete start/test/stop cycle. More...
 
def monitor
 Monitor a set of hosts (or all hosts by default), and return their output, a line at a time. More...
 
def ping
 Ping between all specified hosts. More...
 
def pingFull
 Ping between all specified hosts and return all data. More...
 
def pingAll
 Ping between all hosts. More...
 
def pingPair
 Ping between first two hosts, useful for testing. More...
 
def pingAllFull
 Ping between all hosts. More...
 
def pingPairFull
 Ping between first two hosts, useful for testing. More...
 
def iperf
 Run iperf between two hosts. More...
 
def runCpuLimitTest
 run CPU limit test with 'while true' processes. More...
 
def configLinkStatus
 Change status of src <-> dst links. More...
 
def interact
 Start network and run our simple CLI. More...
 
def init
 Initialize Mininet.
 

Static Public Member Functions

def randMac
 Return a random, non-multicast MAC address.
 

Public Attributes

 topo
 
 switch
 
 host
 
 controller
 
 link
 
 intf
 
 ipBase
 
 prefixLen
 
 nextIP
 
 inNamespace
 
 xterms
 
 cleanup
 
 autoSetMacs
 
 autoStaticArp
 
 autoPinCpus
 
 numCores
 
 nextCore
 
 listenPort
 
 waitConn
 
 hosts
 
 switches
 
 controllers
 
 links
 
 nameToNode
 
 terms
 
 built
 

Static Public Attributes

 inited = False
 

Detailed Description

Network emulation with hosts spawned in network namespaces.

Constructor & Destructor Documentation

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.

Parameters
topoTopo (topology) object or None
switchdefault Switch class
hostdefault Host class/constructor
controllerdefault Controller class/constructor
linkdefault Link class/constructor
intfdefault Intf class/constructor
ipBasebase IP address for hosts,
buildbuild now from topo?
xtermsif build now, spawn xterms?
cleanupif build now, cleanup before creating?
inNamespacespawn switches and controller in net namespaces?
autoSetMacsset MAC addrs automatically like IP addresses?
autoStaticArpset all-pairs static MAC addrs?
autoPinCpuspin hosts to (real) cores (requires CPULimitedHost)?
listenPortbase listening port to open; will be incremented for each additional switch in the net if inNamespace=False

Member Function Documentation

def mininet.net.Mininet.__getitem__ (   self,
  key 
)

net [ name ]

Parameters
operatorReturn node(s) with given name(s)
def mininet.net.Mininet.addController (   self,
  name = 'c0',
  controller = None,
  params 
)

Add controller.

Parameters
controllerController class
def mininet.net.Mininet.addHost (   self,
  name,
  cls = None,
  params 
)

Add host.

Parameters
namename of host to add
clscustom host class/constructor (optional)
paramsparameters for host
Returns
added host
def mininet.net.Mininet.addLink (   self,
  node1,
  node2,
  port1 = None,
  port2 = None,
  cls = None,
  params 
)

"Add a link from node1 to node2

Parameters
node1source node (or name)
node2dest node (or name)
port1source port (optional)
port2dest port (optional)
clslink class (optional)
paramsadditional link params (optional)
Returns
link object
def mininet.net.Mininet.addNAT (   self,
  name = 'nat0',
  connect = True,
  inNamespace = False,
  params 
)

Add a NAT to the Mininet network.

Parameters
namename of NAT node
connectswitch to connect to | True (s1) | None
inNamespacecreate in a network namespace
paramsother NAT node params,
notably
ipused as default gateway address
def mininet.net.Mininet.addSwitch (   self,
  name,
  cls = None,
  params 
)

Add switch.

Parameters
namename of switch to add
clscustom switch class/constructor (optional)
Returns
added switch side
Parameters
effectincrements listenPort ivar .
def mininet.net.Mininet.build (   self)

Build mininet.

def mininet.net.Mininet.buildFromTopo (   self,
  topo = None 
)

Build mininet from a topology object At the end of this function, everything should be connected and up.

def mininet.net.Mininet.configHosts (   self)

Configure a set of hosts.

def mininet.net.Mininet.configLinkStatus (   self,
  src,
  dst,
  status 
)

Change status of src <-> dst links.

Parameters
srcnode name
dstnode name
statusstring {up, down}
def mininet.net.Mininet.interact (   self)

Start network and run our simple CLI.

def mininet.net.Mininet.iperf (   self,
  hosts = None,
  l4Type = 'TCP',
  udpBw = '10M',
  fmt = None,
  seconds = 5,
  port = 5001 
)

Run iperf between two hosts.

Parameters
hostslist of hosts; if None, uses first and last hosts
l4Typestring, one of [ TCP, UDP ]
udpBwbandwidth target for UDP test
fmtiperf format argument if any
secondsiperf time to transmit
portiperf port
Returns
two-element array of [ server, client ] speeds
Parameters
notesend() 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.

Parameters
hosts(optional) set of hosts to monitor
timeoutms(optional) timeout value in ms
Returns
iterator which returns host, line
def mininet.net.Mininet.ping (   self,
  hosts = None,
  timeout = None 
)

Ping between all specified hosts.

Parameters
hostslist of hosts
timeouttime to wait for a response, as string
Returns
ploss packet loss percentage
def mininet.net.Mininet.pingAll (   self,
  timeout = None 
)

Ping between all hosts.

Returns
ploss packet loss percentage
def mininet.net.Mininet.pingAllFull (   self)

Ping between all hosts.

Returns
ploss packet loss percentage
def mininet.net.Mininet.pingFull (   self,
  hosts = None,
  timeout = None 
)

Ping between all specified hosts and return all data.

Parameters
hostslist of hosts
timeouttime to wait for a response, as string
Returns
all ping data; see function body.
def mininet.net.Mininet.pingPair (   self)

Ping between first two hosts, useful for testing.

Returns
ploss packet loss percentage
def mininet.net.Mininet.pingPairFull (   self)

Ping between first two hosts, useful for testing.

Returns
ploss packet loss percentage
def mininet.net.Mininet.run (   self,
  test,
  args,
  kwargs 
)

Perform a complete start/test/stop cycle.

def mininet.net.Mininet.runCpuLimitTest (   self,
  cpu,
  duration = 5 
)

run CPU limit test with 'while true' processes.

Parameters
cpudesired CPU fraction of each host
durationtest duration in seconds (integer) returns a single list of measured CPU fractions as floats.
def mininet.net.Mininet.start (   self)

Start controller and switches.

def mininet.net.Mininet.startTerms (   self)

Start a terminal for each node.

def mininet.net.Mininet.staticArp (   self)

Add all-pairs ARP entries to remove the need to handle broadcast.

def mininet.net.Mininet.stopXterms (   self)

Kill each xterm.

def mininet.net.Mininet.waitConnected (   self,
  timeout = None,
  delay = .5 
)

wait for each switch to connect to a controller, up to 5 seconds

Parameters
timeouttime to wait, or None to wait indefinitely
delayseconds to sleep per iteration
Returns
True if all switches are connected

The documentation for this class was generated from the following file: