Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
775 B
3
Indexable
Never
from mininet.topo import Topo

class CustomTopology(Topo):
    def build(self):
        # Create top-level switch
        top_switch = self.addSwitch('s1')

        # Create lower-level switches and connect them to the top-level switch
        lower_switches = []
        for i in range(1, 5):
            lower_switch = self.addSwitch('s{}'.format(i + 1))
            self.addLink(top_switch, lower_switch)
            lower_switches.append(lower_switch)

        # Create hosts and connect them to each lower-level switch
        for switch in lower_switches:
            for j in range(1, 9):
                host = self.addHost('h{}_{}'.format(switch[1:], j))
                self.addLink(switch, host)

topology = CustomTopology()
topology.build()