You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Library of potentially useful topologies for Mininet"
from mininet.topo import Topo
from mininet.net import Mininet
class TreeTopo( Topo ):
<
4B73
div id="LC7" class="react-file-line html-div" data-testid="code-cell" data-line-number="7" style="position:relative"> "Topology for a tree network with a given depth and fanout."
def __init__( self, depth=1, fanout=2 ):
super( TreeTopo, self ).__init__()
# Numbering: h1..N, s1..M
self.hostNum = 1
self.switchNum = 1
# Build topology
self.addTree( depth, fanout )
def addTree( self, depth, fanout ):
"""Add a subtree starting with node n.
returns: last node added"""
isSwitch = depth > 0
if isSwitch:
node = self.addSwitch( 's%s' % self.switchNum )
self.switchNum += 1
for _ in range( fanout ):
child = self.addTree( depth - 1, fanout )
self.addLink( node, child )
else:
node = self.addHost( 'h%s' % self.hostNum )
self.hostNum += 1
return node
def TreeNet( depth=1, fanout=2, **kwargs ):
"Convenience function for creating tree networks."