#!/usr/bin/python3

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.util import dumpNodeConnections
from mininet.cli import CLI


class part1_topo(Topo):
    def build(self):
        pass
        # switch1 = self.addSwitch('switchname')
        s1=self.addSwitch('s1')
        # host1 = self.addHost('hostname')
        h1 = self.addHost('h1')
        h2 = self.addHost('h2')
        h3 = self.addHost('h3')
        h4 = self.addHost('h4')
        # self.addLink(hostname,switchname)
        self.addLink(h1,s1)
        self.addLink(h2,s1)
        self.addLink(h3,s1)
        self.addLink(h4,s1)


topos = {"part1": part1_topo}

if __name__ == "__main__":  # block code is executed when the script is run directly, not through sudo mininet
    t = part1_topo()    # creates a network topology object
    net = Mininet(topo=t) # creates a mininet object, passing topology t 
    net.start()     # starts the Mininet network based on this topology
    CLI(net)    # launches mininet CLI
    net.stop()  # stops the Mininet network, cleaning up all the virtual resources
