SDN
from mininet.topo import Topo
class MyTopo(Topo):
def __init__(self):
# initilaize topology
Topo.__init__(self)
# add hosts and switches
h1 = self.addHost('h1')
h2 = self.addHost('h2')
h3 = self.addHost('h3')
h4 = self.addHost('h4')
sw1 = self.addSwitch('s1')
sw2 = self.addSwitch('s2')
sw3 = self.addSwitch('s3')
sw4 = self.addSwitch('s4')
# add links
self.addLink(sw1,h1, 1, 1)
self.addLink(sw1,sw2, 2, 1)
self.addLink(sw1,sw3, 3, 1)
self.addLink(sw4,sw4, 4, 1)
self.addLink(sw2,sw4, 2, 2)
self.addLink(sw3,sw4, 2, 3)
self.addLink(sw4,h2, 4 ,1)
self.addLink(sw4,h3, 5, 1)
self.addLink(sw4,h4, 6, 1)
topos = {'mytopo': (lambda: MyTopo())}