You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 4 | Copyright 2016 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 5 | |
| 6 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 7 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 8 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 9 | |
| 10 | TestON is free software: you can redistribute it and/or modify |
| 11 | it under the terms of the GNU General Public License as published by |
| 12 | the Free Software Foundation, either version 2 of the License, or |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 13 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 14 | |
| 15 | TestON is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 22 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 23 | """ |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 24 | Custom topology for Mininet |
| 25 | """ |
| 26 | from mininet.topo import Topo |
| 27 | from mininet.net import Mininet |
| 28 | from mininet.node import Host, RemoteController |
| 29 | from mininet.node import Node |
| 30 | from mininet.node import CPULimitedHost |
| 31 | from mininet.link import TCLink |
| 32 | from mininet.cli import CLI |
| 33 | from mininet.log import setLogLevel |
| 34 | from mininet.util import dumpNodeConnections |
| 35 | from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch ) |
| 36 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 37 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 38 | class dualStackHost( Host ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 39 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 40 | def config( self, v6Addr='1000::1/64', **params ): |
| 41 | r = super( Host, self ).config( **params ) |
| 42 | intf = self.defaultIntf() |
| 43 | self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) ) |
| 44 | return r |
| 45 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 46 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 47 | class attTopo( Topo ): |
| 48 | |
| 49 | def __init__( self, **opts ): |
| 50 | "Create a topology." |
| 51 | |
| 52 | # Initialize Topology |
| 53 | Topo.__init__( self, **opts ) |
| 54 | |
| 55 | NY54 = self.addSwitch( 's1' ) |
| 56 | CMBR = self.addSwitch( 's2' ) |
| 57 | CHCG = self.addSwitch( 's3' ) |
| 58 | CLEV = self.addSwitch( 's4' ) |
| 59 | RLGH = self.addSwitch( 's5' ) |
| 60 | ATLN = self.addSwitch( 's6' ) |
| 61 | PHLA = self.addSwitch( 's7' ) |
| 62 | WASH = self.addSwitch( 's8' ) |
| 63 | NSVL = self.addSwitch( 's9' ) |
| 64 | STLS = self.addSwitch( 's10' ) |
| 65 | NWOR = self.addSwitch( 's11' ) |
| 66 | HSTN = self.addSwitch( 's12' ) |
| 67 | SNAN = self.addSwitch( 's13' ) |
| 68 | DLLS = self.addSwitch( 's14' ) |
| 69 | ORLD = self.addSwitch( 's15' ) |
| 70 | DNVR = self.addSwitch( 's16' ) |
| 71 | KSCY = self.addSwitch( 's17' ) |
| 72 | SNFN = self.addSwitch( 's18' ) |
| 73 | SCRM = self.addSwitch( 's19' ) |
| 74 | PTLD = self.addSwitch( 's20' ) |
| 75 | STTL = self.addSwitch( 's21' ) |
| 76 | SLKC = self.addSwitch( 's22' ) |
| 77 | LA03 = self.addSwitch( 's23' ) |
| 78 | SNDG = self.addSwitch( 's24' ) |
| 79 | PHNX = self.addSwitch( 's25' ) |
| 80 | |
| 81 | # ... and now hosts |
| 82 | NY54_host = self.addHost( 'h1', ip='10.1.0.1/24', cls=dualStackHost, v6Addr='1000::1/64' ) |
| 83 | CMBR_host = self.addHost( 'h2', ip='10.1.0.2/24', cls=dualStackHost, v6Addr='1000::2/64' ) |
| 84 | CHCG_host = self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='1000::3/64' ) |
| 85 | CLEV_host = self.addHost( 'h4', ip='10.1.0.4/24', cls=dualStackHost, v6Addr='1000::4/64' ) |
| 86 | RLGH_host = self.addHost( 'h5', ip='10.1.0.5/24', cls=dualStackHost, v6Addr='1000::5/64' ) |
| 87 | ATLN_host = self.addHost( 'h6', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='1000::6/64' ) |
| 88 | PHLA_host = self.addHost( 'h7', ip='10.1.0.7/24', cls=dualStackHost, v6Addr='1000::7/64' ) |
| 89 | WASH_host = self.addHost( 'h8', ip='10.1.0.8/24', cls=dualStackHost, v6Addr='1000::8/64' ) |
| 90 | NSVL_host = self.addHost( 'h9', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='1000::9/64' ) |
| 91 | STLS_host = self.addHost( 'h10', ip='10.1.0.10/24', cls=dualStackHost, v6Addr='1000::10/64' ) |
| 92 | NWOR_host = self.addHost( 'h11', ip='10.1.0.11/24', cls=dualStackHost, v6Addr='1000::11/64' ) |
| 93 | HSTN_host = self.addHost( 'h12', ip='10.1.0.12/24', cls=dualStackHost, v6Addr='1000::12/64' ) |
| 94 | SNAN_host = self.addHost( 'h13', ip='10.1.0.13/24', cls=dualStackHost, v6Addr='1000::13/64' ) |
| 95 | DLLS_host = self.addHost( 'h14', ip='10.1.0.14/24', cls=dualStackHost, v6Addr='1000::14/64' ) |
| 96 | ORLD_host = self.addHost( 'h15', ip='10.1.0.15/24', cls=dualStackHost, v6Addr='1000::15/64' ) |
| 97 | DNVR_host = self.addHost( 'h16', ip='10.1.0.16/24', cls=dualStackHost, v6Addr='1000::16/64' ) |
| 98 | KSCY_host = self.addHost( 'h17', ip='10.1.0.17/24', cls=dualStackHost, v6Addr='1000::17/64' ) |
| 99 | SNFN_host = self.addHost( 'h18', ip='10.1.0.18/24', cls=dualStackHost, v6Addr='1000::18/64' ) |
| 100 | SCRM_host = self.addHost( 'h19', ip='10.1.0.19/24', cls=dualStackHost, v6Addr='1000::19/64' ) |
| 101 | PTLD_host = self.addHost( 'h20', ip='10.1.0.20/24', cls=dualStackHost, v6Addr='1000::20/64' ) |
| 102 | STTL_host = self.addHost( 'h21', ip='10.1.0.21/24', cls=dualStackHost, v6Addr='1000::21/64' ) |
| 103 | SLKC_host = self.addHost( 'h22', ip='10.1.0.22/24', cls=dualStackHost, v6Addr='1000::22/64' ) |
| 104 | LA03_host = self.addHost( 'h23', ip='10.1.0.23/24', cls=dualStackHost, v6Addr='1000::23/64' ) |
| 105 | SNDG_host = self.addHost( 'h24', ip='10.1.0.24/24', cls=dualStackHost, v6Addr='1000::24/64' ) |
| 106 | PHNX_host = self.addHost( 'h25', ip='10.1.0.25/24', cls=dualStackHost, v6Addr='1000::25/64' ) |
| 107 | |
| 108 | # add edges between switch and corresponding host |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 109 | self.addLink( NY54, NY54_host ) |
| 110 | self.addLink( CMBR, CMBR_host ) |
| 111 | self.addLink( CHCG, CHCG_host ) |
| 112 | self.addLink( CLEV, CLEV_host ) |
| 113 | self.addLink( RLGH, RLGH_host ) |
| 114 | self.addLink( ATLN, ATLN_host ) |
| 115 | self.addLink( PHLA, PHLA_host ) |
| 116 | self.addLink( WASH, WASH_host ) |
| 117 | self.addLink( NSVL, NSVL_host ) |
| 118 | self.addLink( STLS, STLS_host ) |
| 119 | self.addLink( NWOR, NWOR_host ) |
| 120 | self.addLink( HSTN, HSTN_host ) |
| 121 | self.addLink( SNAN, SNAN_host ) |
| 122 | self.addLink( DLLS, DLLS_host ) |
| 123 | self.addLink( ORLD, ORLD_host ) |
| 124 | self.addLink( DNVR, DNVR_host ) |
| 125 | self.addLink( KSCY, KSCY_host ) |
| 126 | self.addLink( SNFN, SNFN_host ) |
| 127 | self.addLink( SCRM, SCRM_host ) |
| 128 | self.addLink( PTLD, PTLD_host ) |
| 129 | self.addLink( STTL, STTL_host ) |
| 130 | self.addLink( SLKC, SLKC_host ) |
| 131 | self.addLink( LA03, LA03_host ) |
| 132 | self.addLink( SNDG, SNDG_host ) |
| 133 | self.addLink( PHNX, PHNX_host ) |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 134 | |
| 135 | # add edges between switches |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 136 | self.addLink( NY54, CMBR, bw=10, delay='0.979030824185ms' ) |
| 137 | self.addLink( NY54, CHCG, bw=10, delay='0.806374975652ms' ) |
| 138 | self.addLink( NY54, PHLA, bw=10, delay='0.686192970166ms' ) |
| 139 | self.addLink( NY54, WASH, bw=10, delay='0.605826192092ms' ) |
| 140 | self.addLink( CMBR, PHLA, bw=10, delay='1.4018238197ms' ) |
| 141 | self.addLink( CHCG, CLEV, bw=10, delay='0.232315346482ms' ) |
| 142 | self.addLink( CHCG, PHLA, bw=10, delay='1.07297714274ms' ) |
| 143 | self.addLink( CHCG, STLS, bw=10, delay='1.12827896944ms' ) |
| 144 | self.addLink( CHCG, DNVR, bw=10, delay='1.35964770335ms' ) |
| 145 | self.addLink( CHCG, KSCY, bw=10, delay='1.5199778541ms' ) |
| 146 | self.addLink( CHCG, SNFN, bw=10, delay='0.620743405435ms' ) |
| 147 | self.addLink( CHCG, STTL, bw=10, delay='0.93027212534ms' ) |
| 148 | self.addLink( CHCG, SLKC, bw=10, delay='0.735621751348ms' ) |
| 149 | self.addLink( CLEV, NSVL, bw=10, delay='0.523419372248ms' ) |
| 150 | self.addLink( CLEV, STLS, bw=10, delay='1.00360290845ms' ) |
| 151 | self.addLink( CLEV, PHLA, bw=10, delay='0.882912133249ms' ) |
| 152 | self.addLink( RLGH, ATLN, bw=10, delay='1.1644489729ms' ) |
| 153 | self.addLink( RLGH, WASH, bw=10, delay='1.48176810502ms' ) |
| 154 | self.addLink( ATLN, WASH, bw=10, delay='0.557636936322ms' ) |
| 155 | self.addLink( ATLN, NSVL, bw=10, delay='1.32869749865ms' ) |
| 156 | self.addLink( ATLN, STLS, bw=10, delay='0.767705554748ms' ) |
| 157 | self.addLink( ATLN, DLLS, bw=10, delay='0.544782086448ms' ) |
| 158 | self.addLink( ATLN, ORLD, bw=10, delay='1.46119152532ms' ) |
| 159 | self.addLink( PHLA, WASH, bw=10, delay='0.372209320106ms' ) |
| 160 | self.addLink( NSVL, STLS, bw=10, delay='1.43250491305ms' ) |
| 161 | self.addLink( NSVL, DLLS, bw=10, delay='1.67698215288ms' ) |
| 162 | self.addLink( STLS, DLLS, bw=10, delay='0.256389964194ms' ) |
| 163 | self.addLink( STLS, KSCY, bw=10, delay='0.395511571791ms' ) |
| 164 | self.addLink( STLS, LA03, bw=10, delay='0.257085227363ms' ) |
| 165 | self.addLink( NWOR, HSTN, bw=10, delay='0.0952906633914ms' ) |
| 166 | self.addLink( NWOR, DLLS, bw=10, delay='1.60231329739ms' ) |
| 167 | self.addLink( NWOR, ORLD, bw=10, delay='0.692731063896ms' ) |
| 168 | self.addLink( HSTN, SNAN, bw=10, delay='0.284150653798ms' ) |
| 169 | self.addLink( HSTN, DLLS, bw=10, delay='1.65690128332ms' ) |
| 170 | self.addLink( HSTN, ORLD, bw=10, delay='0.731886304782ms' ) |
| 171 | self.addLink( SNAN, PHNX, bw=10, delay='1.34258627257ms' ) |
| 172 | self.addLink( SNAN, DLLS, bw=10, delay='1.50063532341ms' ) |
| 173 | self.addLink( DLLS, DNVR, bw=10, delay='0.251471593235ms' ) |
| 174 | self.addLink( DLLS, KSCY, bw=10, delay='0.18026026737ms' ) |
| 175 | self.addLink( DLLS, SNFN, bw=10, delay='0.74304274592ms' ) |
| 176 | self.addLink( DLLS, LA03, bw=10, delay='0.506439293357ms' ) |
| 177 | self.addLink( DNVR, KSCY, bw=10, delay='0.223328790403ms' ) |
| 178 | self.addLink( DNVR, SNFN, bw=10, delay='0.889017541903ms' ) |
| 179 | self.addLink( DNVR, SLKC, bw=10, delay='0.631898982721ms' ) |
| 180 | self.addLink( KSCY, SNFN, bw=10, delay='0.922778522233ms' ) |
| 181 | self.addLink( SNFN, SCRM, bw=10, delay='0.630352278097ms' ) |
| 182 | self.addLink( SNFN, PTLD, bw=10, delay='0.828572513655ms' ) |
| 183 | self.addLink( SNFN, STTL, bw=10, delay='1.54076081649ms' ) |
| 184 | self.addLink( SNFN, SLKC, bw=10, delay='0.621507502625ms' ) |
| 185 | self.addLink( SNFN, LA03, bw=10, delay='0.602936230151ms' ) |
| 186 | self.addLink( SCRM, SLKC, bw=10, delay='0.461350343644ms' ) |
| 187 | self.addLink( PTLD, STTL, bw=10, delay='1.17591515181ms' ) |
| 188 | self.addLink( SLKC, LA03, bw=10, delay='0.243225267023ms' ) |
| 189 | self.addLink( LA03, SNDG, bw=10, delay='0.681264950821ms' ) |
| 190 | self.addLink( LA03, PHNX, bw=10, delay='0.343709457969ms' ) |
| 191 | self.addLink( SNDG, PHNX, bw=10, delay='0.345064487693ms' ) |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 192 | |
| 193 | topos = { 'att': ( lambda: attTopo() ) } |
| 194 | |
| 195 | # HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS |
| 196 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 197 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 198 | def setupNetwork(): |
| 199 | "Create network" |
| 200 | topo = attTopo() |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 201 | # if controller_ip == '': |
| 202 | # controller_ip = '10.0.2.2'; |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 203 | # controller_ip = '127.0.0.1'; |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 204 | network = Mininet( topo=topo, link=TCLink, autoSetMacs=True, controller=None ) |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 205 | network.start() |
| 206 | CLI( network ) |
| 207 | network.stop() |
| 208 | |
| 209 | if __name__ == '__main__': |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 210 | setLogLevel( 'info' ) |
| 211 | # setLogLevel( 'debug' ) |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 212 | setupNetwork() |