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

A virtual network node is simply a shell in a network namespace. More...

Inheritance diagram for mininet.node.Node:
mininet.node.Controller mininet.node.Host mininet.node.Switch mininet.nodelib.NAT mininet.node.NOX mininet.node.OVSController mininet.node.RemoteController mininet.node.Ryu mininet.node.CPULimitedHost mininet.node.IVSSwitch mininet.node.OVSSwitch mininet.node.UserSwitch mininet.nodelib.LinuxBridge

Public Member Functions

def __init__
 
def fdToNode
 Return node corresponding to given file descriptor. More...
 
def startShell
 Start a shell process for running commands.
 
def mountPrivateDirs
 mount private directories
 
def unmountPrivateDirs
 mount private directories
 
def cleanup
 Help python collect its garbage. More...
 
def read
 Buffered read from node, potentially blocking. More...
 
def readline
 Buffered readline from node, potentially blocking. More...
 
def write
 Write data to node. More...
 
def terminate
 Send kill signal to Node and clean up after it. More...
 
def stop
 Stop node. More...
 
def waitReadable
 Wait until node's output is readable. More...
 
def sendCmd
 Send a command, followed by a command to echo a sentinel, and return without waiting for the command to complete. More...
 
def sendInt
 Interrupt running command. More...
 
def monitor
 Monitor and return the output of a command. More...
 
def waitOutput
 Wait for a command to complete. More...
 
def cmd
 Send a command, wait for output, and return it. More...
 
def cmdPrint
 Call cmd and printing its output. More...
 
def popen
 Return a Popen() object in our namespace. More...
 
def pexec
 Execute a command using popen. More...
 
def newPort
 Return the next port number to allocate. More...
 
def addIntf
 Add an interface. More...
 
def defaultIntf
 Return interface for lowest port.
 
def intf
 Return our interface object with given string name, default intf if name is falsy (None, empty string, etc). More...
 
def connectionsTo
 Return [ intf1, intf2... More...
 
def deleteIntfs
 Delete all of our interfaces. More...
 
def setARP
 Add an ARP entry. More...
 
def setHostRoute
 Add route to host. More...
 
def setDefaultRoute
 Set the default route to go through intf. More...
 
def setMAC
 Set the MAC address for an interface. More...
 
def setIP
 Set the IP address for an interface. More...
 
def IP
 Return IP address of a node or specific interface. More...
 
def MAC
 Return MAC address of a node or specific interface. More...
 
def intfIsUp
 Check if an interface is up. More...
 
def setParam
 Internal. More...
 
def config
 Configure Node according to (optional) More...
 
def configDefault
 Configure with default parameters.
 
def linkTo
 (Deprecated) Link to another node replace with Link( node1, node2)
 
def intfList
 List of our interfaces sorted by port number.
 
def intfNames
 The names of our interfaces sorted by port number.
 
def __repr__
 More informative string representation.
 
def __str__
 Abbreviated string representation.
 
def checkSetup
 Make sure our class and superclasses are set up.
 
def setup
 Make sure our class dependencies are available.
 

Public Attributes

 name
 
 privateDirs
 
 inNamespace
 
 params
 
 intfs
 
 ports
 
 nameToIntf
 
 waiting
 
 readbuf
 
 shell
 
 stdin
 
 stdout
 
 pid
 
 pollOut
 
 execed
 
 lastCmd
 
 lastPid
 

Static Public Attributes

int portBase = 0
 
dictionary inToNode = {}
 
dictionary outToNode = {}
 
 isSetup = False
 

Detailed Description

A virtual network node is simply a shell in a network namespace.

We communicate with it using pipes.

Constructor & Destructor Documentation

def mininet.node.Node.__init__ (   self,
  name,
  inNamespace = True,
  params 
)
Parameters
namename of node
inNamespacein network namespace?
privateDirslist of private directory strings or tuples
paramsNode parameters (see config() for details)

Member Function Documentation

def mininet.node.Node.addIntf (   self,
  intf,
  port = None,
  moveIntfFn = moveIntf 
)

Add an interface.

Parameters
intfinterface
portport number (optional, typically OpenFlow port number)
moveIntfFnfunction to move interface (optional)
def mininet.node.Node.cleanup (   self)

Help python collect its garbage.

def mininet.node.Node.cmd (   self,
  args,
  kwargs 
)

Send a command, wait for output, and return it.

Parameters
cmdstring
def mininet.node.Node.cmdPrint (   self,
  args 
)

Call cmd and printing its output.

Parameters
cmdstring
def mininet.node.Node.config (   self,
  mac = None,
  ip = None,
  defaultRoute = None,
  lo = 'up',
  _params 
)

Configure Node according to (optional)

Parameters
parameters
macMAC address for default interface
ipIP address for default interface
ifconfigarbitrary interface configuration Subclasses should override this method and call the parent class's config(**params)
def mininet.node.Node.connectionsTo (   self,
  node 
)

Return [ intf1, intf2...

] for all intfs that connect self to node.

def mininet.node.Node.deleteIntfs (   self,
  checkName = True 
)

Delete all of our interfaces.

Parameters
checkNameonly delete interfaces that contain our name
def mininet.node.Node.fdToNode (   cls,
  fd 
)

Return node corresponding to given file descriptor.

Parameters
fdfile descriptor
Returns
node
def mininet.node.Node.intf (   self,
  intf = None 
)

Return our interface object with given string name, default intf if name is falsy (None, empty string, etc).

or the input intf arg.

Having this fcn return its arg for Intf objects makes it easier to construct functions with flexible input args for interfaces (those that accept both string names and Intf objects).

def mininet.node.Node.intfIsUp (   self,
  intf = None 
)

Check if an interface is up.

def mininet.node.Node.IP (   self,
  intf = None 
)

Return IP address of a node or specific interface.

def mininet.node.Node.MAC (   self,
  intf = None 
)

Return MAC address of a node or specific interface.

def mininet.node.Node.monitor (   self,
  timeoutms = None,
  findPid = True 
)

Monitor and return the output of a command.

Set self.waiting to False if command has completed.

Parameters
timeoutmstimeout in ms or None to wait indefinitely
findPidlook for PID from mnexec -p
def mininet.node.Node.newPort (   self)

Return the next port number to allocate.

def mininet.node.Node.pexec (   self,
  args,
  kwargs 
)

Execute a command using popen.

Returns
out, err, exitcode
def mininet.node.Node.popen (   self,
  args,
  kwargs 
)

Return a Popen() object in our namespace.

Parameters
argsPopen() args, single list, or string
kwargsPopen() keyword args
def mininet.node.Node.read (   self,
  maxbytes = 1024 
)

Buffered read from node, potentially blocking.

Parameters
maxbytesmaximum number of bytes to return
def mininet.node.Node.readline (   self)

Buffered readline from node, potentially blocking.

Returns
line (minus newline) or None
def mininet.node.Node.sendCmd (   self,
  args,
  kwargs 
)

Send a command, followed by a command to echo a sentinel, and return without waiting for the command to complete.

Parameters
argscommand and arguments, or string
printPidprint command's PID? (False)
def mininet.node.Node.sendInt (   self,
  intr = chr( 3 ) 
)

Interrupt running command.

def mininet.node.Node.setARP (   self,
  ip,
  mac 
)

Add an ARP entry.

Parameters
ipIP address as string
macMAC address as string
def mininet.node.Node.setDefaultRoute (   self,
  intf = None 
)

Set the default route to go through intf.

Parameters
intfIntf or {dev <intfname> via <gw-ip> ...}
def mininet.node.Node.setHostRoute (   self,
  ip,
  intf 
)

Add route to host.

Parameters
ipIP address as dotted decimal
intfstring, interface name
def mininet.node.Node.setIP (   self,
  ip,
  prefixLen = 8,
  intf = None,
  kwargs 
)

Set the IP address for an interface.

Parameters
intfintf or intf name
ipIP address as a string
prefixLenprefix length, e.g. 8 for /8 or 16M addrs
kwargsany additional arguments for intf.setIP
def mininet.node.Node.setMAC (   self,
  mac,
  intf = None 
)

Set the MAC address for an interface.

Parameters
intfintf or intf name
macMAC address as string
def mininet.node.Node.setParam (   self,
  results,
  method,
  param 
)

Internal.

Parameters
methodconfigure a single parameter
resultsdict of results to update
methodconfig method name
paramarg=value (ignore if value=None) value may also be list or dict
def mininet.node.Node.stop (   self,
  deleteIntfs = False 
)

Stop node.

Parameters
deleteIntfsdelete interfaces? (False)
def mininet.node.Node.terminate (   self)

Send kill signal to Node and clean up after it.

def mininet.node.Node.waitOutput (   self,
  verbose = False,
  findPid = True 
)

Wait for a command to complete.

Completion is signaled by a sentinel character, ASCII(127) appearing in the output stream. Wait for the sentinel and return the output, including trailing newline.

Parameters
verboseprint output interactively
def mininet.node.Node.waitReadable (   self,
  timeoutms = None 
)

Wait until node's output is readable.

Parameters
timeoutmstimeout in ms or None to wait indefinitely.
Returns
result of poll()
def mininet.node.Node.write (   self,
  data 
)

Write data to node.

Parameters
datastring

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