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__ (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.
 

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
 
 inited
 

Static Public Attributes

bool inited = False
 

Detailed Description

Network emulation with hosts spawned in network namespaces.

Constructor & Destructor Documentation

◆ __init__()

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
waitConnectedwait for switches to Connect? (False; True/None=wait indefinitely; time(s)=timed wait)

Member Function Documentation

◆ addController()

def mininet.net.Mininet.addController (   self,
  name = 'c0',
  controller = None,
**  params 
)

Add controller.

Parameters
controllerController class

◆ addHost()

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

◆ addLink()

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

◆ addNAT()

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

◆ addSwitch()

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 .

◆ configLinkStatus()

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

Change status of src <-> dst links.

Parameters
srcnode name
dstnode name
statusstring {up, down}

◆ delLinkBetween()

def mininet.net.Mininet.delLinkBetween (   self,
  node1,
  node2,
  index = 0,
  allLinks = False 
)

Delete link(s) between node1 and node2.

Parameters
indexindex of link to delete if multiple links (0)
allLinksignore index and delete all such links (False)
Returns
deleted link(s)

◆ delNode()

def mininet.net.Mininet.delNode (   self,
  node,
  nodes = None 
)

Delete node.

Parameters
nodenode to delete
nodesoptional list to delete from (e.g. self.hosts)

◆ iperf()

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

◆ monitor()

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

◆ ping()

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

◆ pingAll()

def mininet.net.Mininet.pingAll (   self,
  timeout = None 
)

Ping between all hosts.

Returns
ploss packet loss percentage

◆ pingAllFull()

def mininet.net.Mininet.pingAllFull (   self)

Ping between all hosts.

Returns
ploss packet loss percentage

◆ pingFull()

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.

◆ pingPair()

def mininet.net.Mininet.pingPair (   self)

Ping between first two hosts, useful for testing.

Returns
ploss packet loss percentage

◆ pingPairFull()

def mininet.net.Mininet.pingPairFull (   self)

Ping between first two hosts, useful for testing.

Returns
ploss packet loss percentage

◆ runCpuLimitTest()

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.

◆ waitConnected()

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

wait for each switch to connect to a controller

Parameters
timeouttime to wait, or None or True 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: