from mininet.link import TCLink
from mininet.topo import Topo

class MyTopo( Topo ):
    "Simple topology example"

    def __init__( self ):
        "Create custom topo. "
        #Initialize topology
        Topo.__init__( self )
        '''
          Seattle   : 's1'
         Sunnyvale  : 's2'
          Denver    : 's3'
        Los Angeles : 's4'
        Kansas City : 's5'
          Houston   : 's6'
          Chicago   : 's7'
        Indianapolis: 's8'
           Atlanta  : 's9'
          New York  : 's10'
         Washington : 's11'
        '''

        s1 = self.addSwitch('s1', failmode='standalone', stp=True)
        s2 = self.addSwitch('s2', failmode='standalone', stp=True)
        s3 = self.addSwitch('s3', failmode='standalone', stp=True)
        s4 = self.addSwitch('s4', failmode='standalone', stp=True)
        s5 = self.addSwitch('s5', failmode='standalone', stp=True)
        s6 = self.addSwitch('s6', failmode='standalone', stp=True)
        s7 = self.addSwitch('s7', failmode='standalone', stp=True)
        s8 = self.addSwitch('s8', failmode='standalone', stp=True)
        s9 = self.addSwitch('s9', failmode='standalone', stp=True)
        s10 = self.addSwitch('s10', failmode='standalone', stp=True)
        s11 = self.addSwitch('s11', failmode='standalone', stp=True)
        # set link bandwidth to 10MB
        self.addLink(s1, s2, port1=2, port2=1, cls=TCLink, bw=10)
        self.addLink(s1, s3, port1=1, port2=1, cls=TCLink, bw=10)
        self.addLink(s2, s4, port1=3, port2=1, cls=TCLink, bw=10)
        self.addLink(s2, s3, port1=2, port2=3, cls=TCLink, bw=10)
        self.addLink(s3, s5, port1=2, port2=1, cls=TCLink, bw=10)
        self.addLink(s4, s6, port1=2, port2=1, cls=TCLink, bw=10)
        self.addLink(s5, s6, port1=3, port2=2, cls=TCLink, bw=10)
        self.addLink(s5, s8, port1=2, port2=1, cls=TCLink, bw=10)
        self.addLink(s6, s9, port1=3, port2=1, cls=TCLink, bw=10)
        self.addLink(s7, s8, port1=1, port2=2, cls=TCLink, bw=10)
        self.addLink(s7, s10, port1=2, port2=1, cls=TCLink, bw=10)
        self.addLink(s8, s9, port1=3, port2=2, cls=TCLink, bw=10)
        self.addLink(s9, s11, port1=3, port2=1, cls=TCLink, bw=10)
        self.addLink(s10, s11, port1=2, port2=2, cls=TCLink, bw=10)

        # switch s1
        h10 = self.addHost('h10')
        h11 = self.addHost('h11')
        h12 = self.addHost('h12')
        h13 = self.addHost('h13')
        h14 = self.addHost('h14')
        h15 = self.addHost('h15')
        h16 = self.addHost('h16')
        h17 = self.addHost('h17')
        h18 = self.addHost('h18')
        h19 = self.addHost('h19')
        h110 = self.addHost('h110')
        h111 = self.addHost('h111')

        self.addLink(s1, h10, port1=3, port2=0)
        self.addLink(s1, h11, port1=4, port2=0)
        self.addLink(s1, h12, port1=5, port2=0)
        self.addLink(s1, h13, port1=6, port2=0)
        self.addLink(s1, h14, port1=7, port2=0)
        self.addLink(s1, h15, port1=8, port2=0)
        self.addLink(s1, h16, port1=9, port2=0)
        self.addLink(s1, h17, port1=10, port2=0)
        self.addLink(s1, h18, port1=11, port2=0)
        self.addLink(s1, h19, port1=12, port2=0)
        self.addLink(s1, h110, port1=13, port2=0)
        self.addLink(s1, h111, port1=14, port2=0)

        # switch s2
        h20 = self.addHost('h20')
        h21 = self.addHost('h21')
        h22 = self.addHost('h22')
        h23 = self.addHost('h23')
        h24 = self.addHost('h24')
        h25 = self.addHost('h25')
        h26 = self.addHost('h26')
        h27 = self.addHost('h27')
        h28 = self.addHost('h28')
        h29 = self.addHost('h29')
        h210 = self.addHost('h210')
        h211 = self.addHost('h211')

        self.addLink(s2, h20, port1=4, port2=0)
        self.addLink(s2, h21, port1=5, port2=0)
        self.addLink(s2, h22, port1=6, port2=0)
        self.addLink(s2, h23, port1=7, port2=0)
        self.addLink(s2, h24, port1=8, port2=0)
        self.addLink(s2, h25, port1=9, port2=0)
        self.addLink(s2, h26, port1=10, port2=0)
        self.addLink(s2, h27, port1=11, port2=0)
        self.addLink(s2, h28, port1=12, port2=0)
        self.addLink(s2, h29, port1=13, port2=0)
        self.addLink(s2, h210, port1=14, port2=0)
        self.addLink(s2, h211, port1=15, port2=0)

        # switch s3
        h30 = self.addHost('h30')
        h31 = self.addHost('h31')
        h32 = self.addHost('h32')
        h33 = self.addHost('h33')
        h34 = self.addHost('h34')
        h35 = self.addHost('h35')
        h36 = self.addHost('h36')
        h37 = self.addHost('h37')
        h38 = self.addHost('h38')
        h39 = self.addHost('h39')
        h310 = self.addHost('h310')
        h311 = self.addHost('h311')

        self.addLink(s3, h30, port1=4, port2=0)
        self.addLink(s3, h31, port1=5, port2=0)
        self.addLink(s3, h32, port1=6, port2=0)
        self.addLink(s3, h33, port1=7, port2=0)
        self.addLink(s3, h34, port1=8, port2=0)
        self.addLink(s3, h35, port1=9, port2=0)
        self.addLink(s3, h36, port1=10, port2=0)
        self.addLink(s3, h37, port1=11, port2=0)
        self.addLink(s3, h38, port1=12, port2=0)
        self.addLink(s3, h39, port1=13, port2=0)
        self.addLink(s3, h310, port1=14, port2=0)
        self.addLink(s3, h311, port1=15, port2=0)


        # switch s4
        h40 = self.addHost('h40')
        h41 = self.addHost('h41')
        h42 = self.addHost('h42')
        h43 = self.addHost('h43')
        h44 = self.addHost('h44')
        h45 = self.addHost('h45')
        h46 = self.addHost('h46')
        h47 = self.addHost('h47')
        h48 = self.addHost('h48')
        h49 = self.addHost('h49')
        h410 = self.addHost('h410')
        h411 = self.addHost('h411')

        self.addLink(s4, h40, port1=3, port2=0)
        self.addLink(s4, h41, port1=4, port2=0)
        self.addLink(s4, h42, port1=5, port2=0)
        self.addLink(s4, h43, port1=6, port2=0)
        self.addLink(s4, h44, port1=7, port2=0)
        self.addLink(s4, h45, port1=8, port2=0)
        self.addLink(s4, h46, port1=9, port2=0)
        self.addLink(s4, h47, port1=10, port2=0)
        self.addLink(s4, h48, port1=11, port2=0)
        self.addLink(s4, h49, port1=12, port2=0)
        self.addLink(s4, h410, port1=13, port2=0)
        self.addLink(s4, h411, port1=14, port2=0)

        # switch s5
        h50 = self.addHost('h50')
        h51 = self.addHost('h51')
        h52 = self.addHost('h52')
        h53 = self.addHost('h53')
        h54 = self.addHost('h54')
        h55 = self.addHost('h55')
        h56 = self.addHost('h56')
        h57 = self.addHost('h57')
        h58 = self.addHost('h58')
        h59 = self.addHost('h59')
        h510 = self.addHost('h510')
        h511 = self.addHost('h511')

        self.addLink(s5, h50, port1=4, port2=0)
        self.addLink(s5, h51, port1=5, port2=0)
        self.addLink(s5, h52, port1=6, port2=0)
        self.addLink(s5, h53, port1=7, port2=0)
        self.addLink(s5, h54, port1=8, port2=0)
        self.addLink(s5, h55, port1=9, port2=0)
        self.addLink(s5, h56, port1=10, port2=0)
        self.addLink(s5, h57, port1=11, port2=0)
        self.addLink(s5, h58, port1=12, port2=0)
        self.addLink(s5, h59, port1=13, port2=0)
        self.addLink(s5, h510, port1=14, port2=0)
        self.addLink(s5, h511, port1=15, port2=0)

        # switch s6
        h60 = self.addHost('h60')
        h61 = self.addHost('h61')
        h62 = self.addHost('h62')
        h63 = self.addHost('h63')
        h64 = self.addHost('h64')
        h65 = self.addHost('h65')
        h66 = self.addHost('h66')
        h67 = self.addHost('h67')
        h68 = self.addHost('h68')
        h69 = self.addHost('h69')
        h610 = self.addHost('h610')
        h611 = self.addHost('h611')

        self.addLink(s6, h60, port1=4, port2=0)
        self.addLink(s6, h61, port1=5, port2=0)
        self.addLink(s6, h62, port1=6, port2=0)
        self.addLink(s6, h63, port1=7, port2=0)
        self.addLink(s6, h64, port1=8, port2=0)
        self.addLink(s6, h65, port1=9, port2=0)
        self.addLink(s6, h66, port1=10, port2=0)
        self.addLink(s6, h67, port1=11, port2=0)
        self.addLink(s6, h68, port1=12, port2=0)
        self.addLink(s6, h69, port1=13, port2=0)
        self.addLink(s6, h610, port1=14, port2=0)
        self.addLink(s6, h611, port1=15, port2=0)

        # switch s7
        h70 = self.addHost('h70')
        h71 = self.addHost('h71')
        h72 = self.addHost('h72')
        h73 = self.addHost('h73')
        h74 = self.addHost('h74')
        h75 = self.addHost('h75')
        h76 = self.addHost('h76')
        h77 = self.addHost('h77')
        h78 = self.addHost('h78')
        h79 = self.addHost('h79')
        h710 = self.addHost('h710')
        h711 = self.addHost('h711')

        self.addLink(s7, h70, port1=3, port2=0)
        self.addLink(s7, h71, port1=4, port2=0)
        self.addLink(s7, h72, port1=5, port2=0)
        self.addLink(s7, h73, port1=6, port2=0)
        self.addLink(s7, h74, port1=7, port2=0)
        self.addLink(s7, h75, port1=8, port2=0)
        self.addLink(s7, h76, port1=9, port2=0)
        self.addLink(s7, h77, port1=10, port2=0)
        self.addLink(s7, h78, port1=11, port2=0)
        self.addLink(s7, h79, port1=12, port2=0)
        self.addLink(s7, h710, port1=13, port2=0)
        self.addLink(s7, h711, port1=14, port2=0)


        # switch s8
        h80 = self.addHost('h80')
        h81 = self.addHost('h81')
        h82 = self.addHost('h82')
        h83 = self.addHost('h83')
        h84 = self.addHost('h84')
        h85 = self.addHost('h85')
        h86 = self.addHost('h86')
        h87 = self.addHost('h87')
        h88 = self.addHost('h88')
        h89 = self.addHost('h89')
        h810 = self.addHost('h810')
        h811 = self.addHost('h811')

        self.addLink(s8, h80, port1=4, port2=0)
        self.addLink(s8, h81, port1=5, port2=0)
        self.addLink(s8, h82, port1=6, port2=0)
        self.addLink(s8, h83, port1=7, port2=0)
        self.addLink(s8, h84, port1=8, port2=0)
        self.addLink(s8, h85, port1=9, port2=0)
        self.addLink(s8, h86, port1=10, port2=0)
        self.addLink(s8, h87, port1=11, port2=0)
        self.addLink(s8, h88, port1=12, port2=0)
        self.addLink(s8, h89, port1=13, port2=0)
        self.addLink(s8, h810, port1=14, port2=0)
        self.addLink(s8, h811, port1=15, port2=0)


        # switch s9
        h90 = self.addHost('h90')
        h91 = self.addHost('h91')
        h92 = self.addHost('h92')
        h93 = self.addHost('h93')
        h94 = self.addHost('h94')
        h95 = self.addHost('h95')
        h96 = self.addHost('h96')
        h97 = self.addHost('h97')
        h98 = self.addHost('h98')
        h99 = self.addHost('h99')
        h910 = self.addHost('h910')
        h911 = self.addHost('h911')

        self.addLink(s9, h90, port1=4, port2=0)
        self.addLink(s9, h91, port1=5, port2=0)
        self.addLink(s9, h92, port1=6, port2=0)
        self.addLink(s9, h93, port1=7, port2=0)
        self.addLink(s9, h94, port1=8, port2=0)
        self.addLink(s9, h95, port1=9, port2=0)
        self.addLink(s9, h96, port1=10, port2=0)
        self.addLink(s9, h97, port1=11, port2=0)
        self.addLink(s9, h98, port1=12, port2=0)
        self.addLink(s9, h99, port1=13, port2=0)
        self.addLink(s9, h910, port1=14, port2=0)
        self.addLink(s9, h911, port1=15, port2=0)

        # switch s10
        h100 = self.addHost('h100')
        h101 = self.addHost('h101')
        h102 = self.addHost('h102')
        h103 = self.addHost('h103')
        h104 = self.addHost('h104')
        h105 = self.addHost('h105')
        h106 = self.addHost('h106')
        h107 = self.addHost('h107')
        h108 = self.addHost('h108')
        h109 = self.addHost('h109')
        h1010 = self.addHost('h1010')
        h1011 = self.addHost('h1011')

        self.addLink(s10, h100, port1=3, port2=0)
        self.addLink(s10, h101, port1=4, port2=0)
        self.addLink(s10, h102, port1=5, port2=0)
        self.addLink(s10, h103, port1=6, port2=0)
        self.addLink(s10, h104, port1=7, port2=0)
        self.addLink(s10, h105, port1=8, port2=0)
        self.addLink(s10, h106, port1=9, port2=0)
        self.addLink(s10, h107, port1=10, port2=0)
        self.addLink(s10, h108, port1=11, port2=0)
        self.addLink(s10, h109, port1=12, port2=0)
        self.addLink(s10, h1010, port1=13, port2=0)
        self.addLink(s10, h1011, port1=14, port2=0)


        # switch s11 2 case same rename h110 to h11000 , and h11 to h1100
        h11000 = self.addHost('h11000')
        h11100 = self.addHost('h11100')
        h112 = self.addHost('h112')
        h113 = self.addHost('h113')
        h114 = self.addHost('h114')
        h115 = self.addHost('h115')
        h116 = self.addHost('h116')
        h117 = self.addHost('h117')
        h118 = self.addHost('h118')
        h119 = self.addHost('h119')
        h1110 = self.addHost('h1110')
        h1111 = self.addHost('h1111')

        self.addLink(s11, h11000, port1=3, port2=0)
        self.addLink(s11, h11100, port1=4, port2=0)
        self.addLink(s11, h112, port1=5, port2=0)
        self.addLink(s11, h113, port1=6, port2=0)
        self.addLink(s11, h114, port1=7, port2=0)
        self.addLink(s11, h115, port1=8, port2=0)
        self.addLink(s11, h116, port1=9, port2=0)
        self.addLink(s11, h117, port1=10, port2=0)
        self.addLink(s11, h118, port1=11, port2=0)
        self.addLink(s11, h119, port1=12, port2=0)
        self.addLink(s11, h1110, port1=13, port2=0)
        self.addLink(s11, h1111, port1=14, port2=0)


'''   
        h1 = self.addHost('h1', mac='70:00:00:00:00:00')
        h2 = self.addHost('h2', mac='60:00:00:00:00:00')
        self.addLink(s1, h1, port1=1, port2=0)
        self.addLink(s3, h2, port1=2, port2=0)'''



topos = { 'mytopo': (lambda:MyTopo()) }


