Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | """ |
| 4 | """ |
| 5 | from mininet.topo import Topo |
| 6 | from mininet.net import Mininet |
| 7 | from mininet.node import RemoteController |
| 8 | from mininet.node import Node |
| 9 | from mininet.node import CPULimitedHost |
| 10 | from mininet.link import TCLink |
| 11 | from mininet.cli import CLI |
| 12 | from mininet.log import setLogLevel |
| 13 | from mininet.util import dumpNodeConnections |
| 14 | |
| 15 | class GeantMplsTopo( Topo ): |
| 16 | "Internet Topology Zoo Specimen." |
| 17 | |
Thomas Vachuska | b5a7fd6 | 2018-01-17 13:41:22 -0800 | [diff] [blame] | 18 | def addSwitch( self, name, **opts ): |
| 19 | kwargs = { 'protocols' : 'OpenFlow13' } |
| 20 | kwargs.update( opts ) |
| 21 | return super(GeantMplsTopo, self).addSwitch( name, **kwargs ) |
| 22 | |
Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 23 | def __init__( self ): |
| 24 | "Create a topology." |
| 25 | |
| 26 | # Initialize Topology |
| 27 | Topo.__init__( self ) |
| 28 | |
| 29 | # add nodes, switches first... |
| 30 | ATH = self.addSwitch( 's1' ) |
Thomas Vachuska | b5a7fd6 | 2018-01-17 13:41:22 -0800 | [diff] [blame] | 31 | LIS = self.addSwitch( 's2' ) |
Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 32 | LON = self.addSwitch( 's3' ) |
| 33 | BRU = self.addSwitch( 's4' ) |
| 34 | PAR = self.addSwitch( 's5' ) |
| 35 | DUB = self.addSwitch( 's6' ) |
| 36 | MAD = self.addSwitch( 's7' ) |
| 37 | GEN = self.addSwitch( 's8' ) |
Thomas Vachuska | b5a7fd6 | 2018-01-17 13:41:22 -0800 | [diff] [blame] | 38 | MIL = self.addSwitch( 's9' ) |
Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 39 | SOF = self.addSwitch( 's10' ) |
| 40 | BUC = self.addSwitch( 's11' ) |
| 41 | VIE = self.addSwitch( 's12' ) |
| 42 | FRA = self.addSwitch( 's13' ) |
| 43 | COP = self.addSwitch( 's14' ) |
| 44 | TLN = self.addSwitch( 's15' ) |
| 45 | RIG = self.addSwitch( 's16' ) |
| 46 | KAU = self.addSwitch( 's17' ) |
| 47 | POZ = self.addSwitch( 's18' ) |
| 48 | PRA = self.addSwitch( 's19' ) |
| 49 | BRA = self.addSwitch( 's20' ) |
| 50 | ZAG = self.addSwitch( 's21' ) |
Thomas Vachuska | b5a7fd6 | 2018-01-17 13:41:22 -0800 | [diff] [blame] | 51 | LJU = self.addSwitch( 's22' ) |
Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 52 | BUD = self.addSwitch( 's23' ) |
| 53 | MLT = self.addSwitch( 's24' ) |
| 54 | LUX = self.addSwitch( 's25' ) |
| 55 | MAR = self.addSwitch( 's26' ) |
| 56 | HAM = self.addSwitch( 's27' ) |
| 57 | AMS = self.addSwitch( 's28' ) |
Andrea Campanella | ad509f9 | 2016-06-21 15:06:12 +0200 | [diff] [blame] | 58 | STO = self.addSwitch( 's29' ) |
| 59 | OSL = self.addSwitch( 's30' ) |
| 60 | HEL = self.addSwitch( 's31' ) |
Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 61 | |
| 62 | |
| 63 | # ... and now hosts |
| 64 | ATH_host = self.addHost( 'h1' ) |
| 65 | LIS_host = self.addHost( 'h2' ) |
| 66 | LON_host = self.addHost( 'h3' ) |
| 67 | BRU_host = self.addHost( 'h4' ) |
| 68 | PAR_host = self.addHost( 'h5' ) |
| 69 | DUB_host = self.addHost( 'h6' ) |
| 70 | MAD_host = self.addHost( 'h7' ) |
| 71 | GEN_host = self.addHost( 'h8' ) |
| 72 | MIL_host = self.addHost( 'h9' ) |
| 73 | SOF_host = self.addHost( 'h10' ) |
| 74 | BUC_host = self.addHost( 'h11' ) |
| 75 | VIE_host = self.addHost( 'h12' ) |
| 76 | FRA_host = self.addHost( 'h13' ) |
| 77 | COP_host = self.addHost( 'h14' ) |
| 78 | TLN_host = self.addHost( 'h15' ) |
| 79 | RIG_host = self.addHost( 'h16' ) |
| 80 | KAU_host = self.addHost( 'h17' ) |
| 81 | POZ_host = self.addHost( 'h18' ) |
| 82 | PRA_host = self.addHost( 'h19' ) |
| 83 | BRA_host = self.addHost( 'h20' ) |
| 84 | ZAG_host = self.addHost( 'h21' ) |
| 85 | LJU_host = self.addHost( 'h22' ) |
| 86 | BUD_host = self.addHost( 'h23' ) |
| 87 | MLT_host = self.addHost( 'h24' ) |
| 88 | LUX_host = self.addHost( 'h25' ) |
| 89 | MAR_host = self.addHost( 'h26' ) |
| 90 | HAM_host = self.addHost( 'h27' ) |
| 91 | AMS_host = self.addHost( 'h28' ) |
Andrea Campanella | ad509f9 | 2016-06-21 15:06:12 +0200 | [diff] [blame] | 92 | STO_host = self.addHost( 'h29' ) |
| 93 | OSL_host = self.addHost( 'h30' ) |
| 94 | HEL_host = self.addHost( 'h31' ) |
Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 95 | |
| 96 | # add edges between switch and corresponding host |
| 97 | self.addLink( ATH , ATH_host ) |
| 98 | self.addLink( LIS , LIS_host ) |
| 99 | self.addLink( LON , LON_host ) |
| 100 | self.addLink( BRU , BRU_host ) |
| 101 | self.addLink( PAR , PAR_host ) |
| 102 | self.addLink( DUB , DUB_host ) |
| 103 | self.addLink( MAD , MAD_host ) |
| 104 | self.addLink( GEN , GEN_host ) |
| 105 | self.addLink( MIL , MIL_host ) |
| 106 | self.addLink( SOF , SOF_host ) |
| 107 | self.addLink( BUC , BUC_host ) |
| 108 | self.addLink( VIE , VIE_host ) |
| 109 | self.addLink( FRA , FRA_host ) |
| 110 | self.addLink( COP , COP_host ) |
| 111 | self.addLink( TLN , TLN_host ) |
| 112 | self.addLink( RIG , RIG_host ) |
| 113 | self.addLink( KAU , KAU_host ) |
| 114 | self.addLink( POZ , POZ_host ) |
| 115 | self.addLink( PRA , PRA_host ) |
| 116 | self.addLink( BRA , BRA_host ) |
| 117 | self.addLink( ZAG , ZAG_host ) |
| 118 | self.addLink( LJU , LJU_host ) |
| 119 | self.addLink( BUD , BUD_host ) |
| 120 | self.addLink( MLT , MLT_host ) |
| 121 | self.addLink( LUX , LUX_host ) |
| 122 | self.addLink( MAR , MAR_host ) |
| 123 | self.addLink( HAM , HAM_host ) |
| 124 | self.addLink( AMS , AMS_host ) |
Andrea Campanella | ad509f9 | 2016-06-21 15:06:12 +0200 | [diff] [blame] | 125 | self.addLink( STO , STO_host ) |
Andrea Campanella | ad509f9 | 2016-06-21 15:06:12 +0200 | [diff] [blame] | 126 | self.addLink( OSL , OSL_host ) |
Thomas Vachuska | cc0b7d6 | 2016-07-12 14:03:11 -0700 | [diff] [blame] | 127 | self.addLink( HEL , HEL_host ) |
Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 128 | |
| 129 | # add edges between switches |
Thomas Vachuska | b5a7fd6 | 2018-01-17 13:41:22 -0800 | [diff] [blame] | 130 | self.addLink( ATH , MIL ) |
| 131 | self.addLink( MIL , ATH ) |
| 132 | self.addLink( MIL , VIE ) |
| 133 | self.addLink( MIL , MAR ) |
| 134 | self.addLink( MIL , GEN ) |
| 135 | self.addLink( GEN , MIL ) |
| 136 | self.addLink( MIL , MLT ) |
| 137 | self.addLink( GEN , FRA ) |
| 138 | self.addLink( FRA , GEN ) |
| 139 | self.addLink( GEN , PAR ) |
| 140 | self.addLink( PAR , GEN ) |
| 141 | self.addLink( GEN , PAR ) |
| 142 | self.addLink( FRA , POZ ) |
| 143 | self.addLink( GEN , MAR ) |
| 144 | self.addLink( MAR , MAD ) |
| 145 | self.addLink( MAD , PAR ) |
| 146 | self.addLink( MAD , LIS ) |
| 147 | self.addLink( LIS , LON ) |
| 148 | self.addLink( LON , LIS ) |
| 149 | self.addLink( LON , PAR ) |
| 150 | self.addLink( LON , DUB ) |
| 151 | self.addLink( DUB , LON ) |
| 152 | self.addLink( LON , BRU ) |
| 153 | self.addLink( BRU , AMS ) |
| 154 | self.addLink( AMS , LUX ) |
| 155 | self.addLink( LUX , FRA ) |
| 156 | self.addLink( AMS , HAM ) |
| 157 | self.addLink( HAM , FRA ) |
| 158 | self.addLink( HAM , COP ) |
| 159 | self.addLink( COP , AMS ) |
| 160 | self.addLink( FRA , POZ ) |
| 161 | self.addLink( FRA , PRA ) |
| 162 | self.addLink( FRA , BUD ) |
| 163 | self.addLink( FRA , VIE ) |
| 164 | self.addLink( POZ , PRA ) |
| 165 | self.addLink( POZ , KAU ) |
| 166 | self.addLink( KAU , RIG ) |
| 167 | self.addLink( ZAG , VIE ) |
| 168 | self.addLink( ZAG , BUD ) |
| 169 | self.addLink( BUD , PRA ) |
| 170 | self.addLink( BUD , BRA ) |
| 171 | self.addLink( BUD , BUC ) |
| 172 | self.addLink( BUD , SOF ) |
| 173 | self.addLink( BUD , LJU ) |
| 174 | self.addLink( BUC , SOF ) |
| 175 | self.addLink( BUC , VIE ) |
| 176 | self.addLink( VIE , BRA ) |
| 177 | self.addLink( RIG , TLN ) |
| 178 | self.addLink( TLN , HAM ) |
| 179 | self.addLink( OSL , STO ) |
| 180 | self.addLink( STO , HEL ) |
| 181 | self.addLink( STO , COP ) |
| 182 | self.addLink( OSL , COP ) |
| 183 | self.addLink( TLN , HEL ) |
Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 184 | |
Thomas Vachuska | b5a7fd6 | 2018-01-17 13:41:22 -0800 | [diff] [blame] | 185 | topos = { 'geant': ( lambda: GeantMplsTopo() ) } |
Andrea Campanella | 60a5a98 | 2016-06-20 16:17:18 +0200 | [diff] [blame] | 186 | |
| 187 | if __name__ == '__main__': |
| 188 | from onosnet import run |
| 189 | run( GeantMplsTopo() ) |