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

Data center network representation for structured multi-trees. More...

Inheritance diagram for mininet.topo.Topo:
mininet.topo.LinearTopo mininet.topo.SingleSwitchReversedTopo mininet.topo.SingleSwitchTopo mininet.topolib.TorusTopo mininet.topolib.TreeTopo mininet.topo.MinimalTopo

Public Member Functions

def __init__ (self, *args, **params)
 Topo object. More...
 
def build (self, *args, **params)
 Override this method to build your topology.
 
def addNode (self, name, **opts)
 Add Node to graph. More...
 
def addHost (self, name, **opts)
 Convenience. More...
 
def addSwitch (self, name, **opts)
 Convenience. More...
 
def addLink (self, node1, node2, port1=None, port2=None, key=None, **opts)
 node1, More...
 
def nodes (self, sort=True)
 Return nodes in graph.
 
def isSwitch (self, n)
 Returns true if node is a switch.
 
def switches (self, sort=True)
 Return switches. More...
 
def hosts (self, sort=True)
 Return hosts. More...
 
def iterLinks (self, withKeys=False, withInfo=False)
 Return links (iterator) More...
 
def links (self, sort=False, withKeys=False, withInfo=False)
 Return links. More...
 
def addPort (self, src, dst, sport=None, dport=None)
 Generate port mapping for new edge. More...
 
def port (self, src, dst)
 Get port numbers. More...
 
def linkInfo (self, src, dst, key=None)
 Return link metadata dict.
 
def setlinkInfo (self, src, dst, info, key=None)
 Set link metadata dict.
 
def nodeInfo (self, name)
 Return metadata (dict) for node.
 
def setNodeInfo (self, name, info)
 Set metadata (dict) for node.
 
def convertTo (self, cls, data=True, keys=True)
 Convert to a new object of networkx.MultiGraph-like class cls. More...
 

Static Public Member Functions

def sorted (items)
 Items sorted in natural (i.e. More...
 

Public Attributes

 g
 
 hopts
 
 sopts
 
 lopts
 
 ports
 

Detailed Description

Data center network representation for structured multi-trees.

Constructor & Destructor Documentation

◆ __init__()

def mininet.topo.Topo.__init__ (   self,
args,
**  params 
)

Topo object.

Optional named

Parameters
parameters
hinfodefault host options
soptsdefault switch options
loptsdefault link options calls build()

Member Function Documentation

◆ addHost()

def mininet.topo.Topo.addHost (   self,
  name,
**  opts 
)

Convenience.

Parameters
methodAdd host to graph.
namehost name
optshost options
Returns
host name

◆ addLink()

def mininet.topo.Topo.addLink (   self,
  node1,
  node2,
  port1 = None,
  port2 = None,
  key = None,
**  opts 
)

node1,

Parameters
node2nodes to link together port1,
port2ports (optional)
optslink options (optional)
Returns
link info key

◆ addNode()

def mininet.topo.Topo.addNode (   self,
  name,
**  opts 
)

Add Node to graph.

Parameters
namename
optsnode options
Returns
node name

◆ addPort()

def mininet.topo.Topo.addPort (   self,
  src,
  dst,
  sport = None,
  dport = None 
)

Generate port mapping for new edge.

Parameters
srcsource switch name
dstdestination switch name

◆ addSwitch()

def mininet.topo.Topo.addSwitch (   self,
  name,
**  opts 
)

Convenience.

Parameters
methodAdd switch to graph.
nameswitch name
optsswitch options
Returns
switch name

◆ convertTo()

def mininet.topo.Topo.convertTo (   self,
  cls,
  data = True,
  keys = True 
)

Convert to a new object of networkx.MultiGraph-like class cls.

Parameters
datainclude node and edge data (default True)
keysinclude edge keys as well as edge data (default True)

◆ hosts()

def mininet.topo.Topo.hosts (   self,
  sort = True 
)

Return hosts.

Parameters
sortsort hosts alphabetically
Returns
list of hosts

◆ iterLinks()

def mininet.topo.Topo.iterLinks (   self,
  withKeys = False,
  withInfo = False 
)

Return links (iterator)

Parameters
withKeysreturn link keys
withInforeturn link info
Returns
list of ( src, dst [,key, info ] )

◆ links()

def mininet.topo.Topo.links (   self,
  sort = False,
  withKeys = False,
  withInfo = False 
)

Return links.

Parameters
sortsort links alphabetically, preserving (src, dst) order
withKeysreturn link keys
withInforeturn link info
Returns
list of ( src, dst [,key, info ] )

◆ port()

def mininet.topo.Topo.port (   self,
  src,
  dst 
)

Get port numbers.

Parameters
srcsource switch name
dstdestination switch name
sportoptional source port (otherwise use lowest src port)
Returns
tuple (sport, dport), where sport = port on source switch leading to the destination switch dport = port on destination switch leading to the source switch Note that you can also look up ports using linkInfo()

◆ sorted()

def mininet.topo.Topo.sorted (   items)
static

Items sorted in natural (i.e.

alphabetical) order

◆ switches()

def mininet.topo.Topo.switches (   self,
  sort = True 
)

Return switches.

Parameters
sortsort switches alphabetically
Returns
dpids list of dpids

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