Revision 73360ab9 examples/udpbwtest.py

View differences:

examples/udpbwtest.py
19 19
from mininet.log import lg   
20 20
from mininet.net import init, Mininet
21 21
from mininet.node import Host, KernelSwitch
22
from mininet.topo import Topo, Node
22
from mininet.topolib import TreeTopo
23 23
from mininet.util import quietRun
24 24

  
25
class TreeTopo( Topo ):
26
    "Topology for a tree network with a given depth and fanout."
27

  
28
    def __init__( self, depth=1, fanout=2 ):
29
        super( TreeTopo, self ).__init__()
30
        # Build topology
31
        self.treeNet( 1, depth, fanout )
32
        # Consider all switches and hosts 'on'
33
        self.enable_all()
34

  
35
    def treeNet( self, id, depth, fanout ):
36
        """Add a subtree with a given id.
37
           returns: last id added"""
38
        me = id
39
        isSwitch = (depth > 0 )
40
        self._add_node( me, Node( is_switch=isSwitch ) )
41
        if isSwitch:
42
            for i in range( 0, fanout ):
43
                child = id + 1
44
                self._add_edge( me, child )
45
                id = self.treeNet( child, depth-1, fanout )
46
        return id
47

  
48 25
# Some useful stuff: buffered readline and host monitoring
49 26

  
50 27
def readline( host, buffer ):

Also available in: Unified diff