blob: f135c814cf8267e6cce22d73fd07c8ac322dcc30 [file] [log] [blame]
You Wangdb927a52016-02-26 11:03:28 -08001#!/usr/bin/python
2
3"""
4Custom topology for Mininet
5"""
6from mininet.topo import Topo
7from mininet.net import Mininet
8from mininet.node import Host, RemoteController
9from mininet.node import Node
10from mininet.node import CPULimitedHost
11from mininet.link import TCLink
12from mininet.cli import CLI
13from mininet.log import setLogLevel
14from mininet.util import dumpNodeConnections
15from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
16
17class dualStackHost( Host ):
18 def config( self, v6Addr='1000::1/64', **params ):
19 r = super( Host, self ).config( **params )
20 intf = self.defaultIntf()
21 self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
22 return r
23
24class attTopo( Topo ):
25
26 def __init__( self, **opts ):
27 "Create a topology."
28
29 # Initialize Topology
30 Topo.__init__( self, **opts )
31
32 NY54 = self.addSwitch( 's1' )
33 CMBR = self.addSwitch( 's2' )
34 CHCG = self.addSwitch( 's3' )
35 CLEV = self.addSwitch( 's4' )
36 RLGH = self.addSwitch( 's5' )
37 ATLN = self.addSwitch( 's6' )
38 PHLA = self.addSwitch( 's7' )
39 WASH = self.addSwitch( 's8' )
40 NSVL = self.addSwitch( 's9' )
41 STLS = self.addSwitch( 's10' )
42 NWOR = self.addSwitch( 's11' )
43 HSTN = self.addSwitch( 's12' )
44 SNAN = self.addSwitch( 's13' )
45 DLLS = self.addSwitch( 's14' )
46 ORLD = self.addSwitch( 's15' )
47 DNVR = self.addSwitch( 's16' )
48 KSCY = self.addSwitch( 's17' )
49 SNFN = self.addSwitch( 's18' )
50 SCRM = self.addSwitch( 's19' )
51 PTLD = self.addSwitch( 's20' )
52 STTL = self.addSwitch( 's21' )
53 SLKC = self.addSwitch( 's22' )
54 LA03 = self.addSwitch( 's23' )
55 SNDG = self.addSwitch( 's24' )
56 PHNX = self.addSwitch( 's25' )
57
58 # ... and now hosts
59 NY54_host = self.addHost( 'h1', ip='10.1.0.1/24', cls=dualStackHost, v6Addr='1000::1/64' )
60 CMBR_host = self.addHost( 'h2', ip='10.1.0.2/24', cls=dualStackHost, v6Addr='1000::2/64' )
61 CHCG_host = self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='1000::3/64' )
62 CLEV_host = self.addHost( 'h4', ip='10.1.0.4/24', cls=dualStackHost, v6Addr='1000::4/64' )
63 RLGH_host = self.addHost( 'h5', ip='10.1.0.5/24', cls=dualStackHost, v6Addr='1000::5/64' )
64 ATLN_host = self.addHost( 'h6', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='1000::6/64' )
65 PHLA_host = self.addHost( 'h7', ip='10.1.0.7/24', cls=dualStackHost, v6Addr='1000::7/64' )
66 WASH_host = self.addHost( 'h8', ip='10.1.0.8/24', cls=dualStackHost, v6Addr='1000::8/64' )
67 NSVL_host = self.addHost( 'h9', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='1000::9/64' )
68 STLS_host = self.addHost( 'h10', ip='10.1.0.10/24', cls=dualStackHost, v6Addr='1000::10/64' )
69 NWOR_host = self.addHost( 'h11', ip='10.1.0.11/24', cls=dualStackHost, v6Addr='1000::11/64' )
70 HSTN_host = self.addHost( 'h12', ip='10.1.0.12/24', cls=dualStackHost, v6Addr='1000::12/64' )
71 SNAN_host = self.addHost( 'h13', ip='10.1.0.13/24', cls=dualStackHost, v6Addr='1000::13/64' )
72 DLLS_host = self.addHost( 'h14', ip='10.1.0.14/24', cls=dualStackHost, v6Addr='1000::14/64' )
73 ORLD_host = self.addHost( 'h15', ip='10.1.0.15/24', cls=dualStackHost, v6Addr='1000::15/64' )
74 DNVR_host = self.addHost( 'h16', ip='10.1.0.16/24', cls=dualStackHost, v6Addr='1000::16/64' )
75 KSCY_host = self.addHost( 'h17', ip='10.1.0.17/24', cls=dualStackHost, v6Addr='1000::17/64' )
76 SNFN_host = self.addHost( 'h18', ip='10.1.0.18/24', cls=dualStackHost, v6Addr='1000::18/64' )
77 SCRM_host = self.addHost( 'h19', ip='10.1.0.19/24', cls=dualStackHost, v6Addr='1000::19/64' )
78 PTLD_host = self.addHost( 'h20', ip='10.1.0.20/24', cls=dualStackHost, v6Addr='1000::20/64' )
79 STTL_host = self.addHost( 'h21', ip='10.1.0.21/24', cls=dualStackHost, v6Addr='1000::21/64' )
80 SLKC_host = self.addHost( 'h22', ip='10.1.0.22/24', cls=dualStackHost, v6Addr='1000::22/64' )
81 LA03_host = self.addHost( 'h23', ip='10.1.0.23/24', cls=dualStackHost, v6Addr='1000::23/64' )
82 SNDG_host = self.addHost( 'h24', ip='10.1.0.24/24', cls=dualStackHost, v6Addr='1000::24/64' )
83 PHNX_host = self.addHost( 'h25', ip='10.1.0.25/24', cls=dualStackHost, v6Addr='1000::25/64' )
84
85 # add edges between switch and corresponding host
86 self.addLink( NY54 , NY54_host )
87 self.addLink( CMBR , CMBR_host )
88 self.addLink( CHCG , CHCG_host )
89 self.addLink( CLEV , CLEV_host )
90 self.addLink( RLGH , RLGH_host )
91 self.addLink( ATLN , ATLN_host )
92 self.addLink( PHLA , PHLA_host )
93 self.addLink( WASH , WASH_host )
94 self.addLink( NSVL , NSVL_host )
95 self.addLink( STLS , STLS_host )
96 self.addLink( NWOR , NWOR_host )
97 self.addLink( HSTN , HSTN_host )
98 self.addLink( SNAN , SNAN_host )
99 self.addLink( DLLS , DLLS_host )
100 self.addLink( ORLD , ORLD_host )
101 self.addLink( DNVR , DNVR_host )
102 self.addLink( KSCY , KSCY_host )
103 self.addLink( SNFN , SNFN_host )
104 self.addLink( SCRM , SCRM_host )
105 self.addLink( PTLD , PTLD_host )
106 self.addLink( STTL , STTL_host )
107 self.addLink( SLKC , SLKC_host )
108 self.addLink( LA03 , LA03_host )
109 self.addLink( SNDG , SNDG_host )
110 self.addLink( PHNX , PHNX_host )
111
112 # add edges between switches
113 self.addLink( NY54 , CMBR, bw=10, delay='0.979030824185ms')
114 self.addLink( NY54 , CHCG, bw=10, delay='0.806374975652ms')
115 self.addLink( NY54 , PHLA, bw=10, delay='0.686192970166ms')
116 self.addLink( NY54 , WASH, bw=10, delay='0.605826192092ms')
117 self.addLink( CMBR , PHLA, bw=10, delay='1.4018238197ms')
118 self.addLink( CHCG , CLEV, bw=10, delay='0.232315346482ms')
119 self.addLink( CHCG , PHLA, bw=10, delay='1.07297714274ms')
120 self.addLink( CHCG , STLS, bw=10, delay='1.12827896944ms')
121 self.addLink( CHCG , DNVR, bw=10, delay='1.35964770335ms')
122 self.addLink( CHCG , KSCY, bw=10, delay='1.5199778541ms')
123 self.addLink( CHCG , SNFN, bw=10, delay='0.620743405435ms')
124 self.addLink( CHCG , STTL, bw=10, delay='0.93027212534ms')
125 self.addLink( CHCG , SLKC, bw=10, delay='0.735621751348ms')
126 self.addLink( CLEV , NSVL, bw=10, delay='0.523419372248ms')
127 self.addLink( CLEV , STLS, bw=10, delay='1.00360290845ms')
128 self.addLink( CLEV , PHLA, bw=10, delay='0.882912133249ms')
129 self.addLink( RLGH , ATLN, bw=10, delay='1.1644489729ms')
130 self.addLink( RLGH , WASH, bw=10, delay='1.48176810502ms')
131 self.addLink( ATLN , WASH, bw=10, delay='0.557636936322ms')
132 self.addLink( ATLN , NSVL, bw=10, delay='1.32869749865ms')
133 self.addLink( ATLN , STLS, bw=10, delay='0.767705554748ms')
134 self.addLink( ATLN , DLLS, bw=10, delay='0.544782086448ms')
135 self.addLink( ATLN , ORLD, bw=10, delay='1.46119152532ms')
136 self.addLink( PHLA , WASH, bw=10, delay='0.372209320106ms')
137 self.addLink( NSVL , STLS, bw=10, delay='1.43250491305ms')
138 self.addLink( NSVL , DLLS, bw=10, delay='1.67698215288ms')
139 self.addLink( STLS , DLLS, bw=10, delay='0.256389964194ms')
140 self.addLink( STLS , KSCY, bw=10, delay='0.395511571791ms')
141 self.addLink( STLS , LA03, bw=10, delay='0.257085227363ms')
142 self.addLink( NWOR , HSTN, bw=10, delay='0.0952906633914ms')
143 self.addLink( NWOR , DLLS, bw=10, delay='1.60231329739ms')
144 self.addLink( NWOR , ORLD, bw=10, delay='0.692731063896ms')
145 self.addLink( HSTN , SNAN, bw=10, delay='0.284150653798ms')
146 self.addLink( HSTN , DLLS, bw=10, delay='1.65690128332ms')
147 self.addLink( HSTN , ORLD, bw=10, delay='0.731886304782ms')
148 self.addLink( SNAN , PHNX, bw=10, delay='1.34258627257ms')
149 self.addLink( SNAN , DLLS, bw=10, delay='1.50063532341ms')
150 self.addLink( DLLS , DNVR, bw=10, delay='0.251471593235ms')
151 self.addLink( DLLS , KSCY, bw=10, delay='0.18026026737ms')
152 self.addLink( DLLS , SNFN, bw=10, delay='0.74304274592ms')
153 self.addLink( DLLS , LA03, bw=10, delay='0.506439293357ms')
154 self.addLink( DNVR , KSCY, bw=10, delay='0.223328790403ms')
155 self.addLink( DNVR , SNFN, bw=10, delay='0.889017541903ms')
156 self.addLink( DNVR , SLKC, bw=10, delay='0.631898982721ms')
157 self.addLink( KSCY , SNFN, bw=10, delay='0.922778522233ms')
158 self.addLink( SNFN , SCRM, bw=10, delay='0.630352278097ms')
159 self.addLink( SNFN , PTLD, bw=10, delay='0.828572513655ms')
160 self.addLink( SNFN , STTL, bw=10, delay='1.54076081649ms')
161 self.addLink( SNFN , SLKC, bw=10, delay='0.621507502625ms')
162 self.addLink( SNFN , LA03, bw=10, delay='0.602936230151ms')
163 self.addLink( SCRM , SLKC, bw=10, delay='0.461350343644ms')
164 self.addLink( PTLD , STTL, bw=10, delay='1.17591515181ms')
165 self.addLink( SLKC , LA03, bw=10, delay='0.243225267023ms')
166 self.addLink( LA03 , SNDG, bw=10, delay='0.681264950821ms')
167 self.addLink( LA03 , PHNX, bw=10, delay='0.343709457969ms')
168 self.addLink( SNDG , PHNX, bw=10, delay='0.345064487693ms')
169
170topos = { 'att': ( lambda: attTopo() ) }
171
172# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
173
174def setupNetwork():
175 "Create network"
176 topo = attTopo()
177 #if controller_ip == '':
178 #controller_ip = '10.0.2.2';
179 # controller_ip = '127.0.0.1';
180 network = Mininet(topo=topo, link=TCLink, autoSetMacs=True, controller=None)
181 network.start()
182 CLI( network )
183 network.stop()
184
185if __name__ == '__main__':
186 setLogLevel('info')
187 #setLogLevel('debug')
188 setupNetwork()