blob: b981f00059a6ece759968e623127b945d0efe6b2 [file] [log] [blame]
Andrea Campanella6d2ae8a2018-03-09 08:44:35 -08001#!/usr/bin/python
2
3import sys
4sys.path.append('..')
5from mininet.topo import Topo
6from mininet.net import Mininet
7from mininet.cli import CLI
8from mininet.log import setLogLevel
9from mininet.node import RemoteController, OVSBridge, Host, OVSSwitch
10from mininet.link import TCLink
11from mininet.nodelib import NAT
12from ipaddress import ip_network
13from routinglib import BgpRouter
14from routinglib import RoutedHost, RoutedHost6
15from trellislib import DhcpClient, Dhcp6Client, DhcpRelay, DhcpServer, Dhcp6Server
16from trellislib import DualHomedDhcpClient
17from functools import partial
18
19class Trellis( Topo ):
20 "Trellis basic topology"
21
22 def __init__( self, *args, **kwargs ):
23 Topo.__init__( self, *args, **kwargs )
24
25 # Spines
26 s226 = self.addSwitch('s226', dpid='226')
27 s227 = self.addSwitch('s227', dpid='227')
28
29 # Leaves
30 s203 = self.addSwitch('s203', dpid='203')
31 s204 = self.addSwitch('s204', dpid='204')
32 s205 = self.addSwitch('s205', dpid='205')
33 s206 = self.addSwitch('s206', dpid='206')
34
35 # Leaf-Spine Links
36 self.addLink(s226, s203)
37 self.addLink(s226, s203)
38 self.addLink(s226, s204)
39 self.addLink(s226, s204)
40 self.addLink(s226, s205)
41 self.addLink(s226, s205)
42 self.addLink(s226, s206)
43 self.addLink(s226, s206)
44 self.addLink(s227, s203)
45 self.addLink(s227, s203)
46 self.addLink(s227, s204)
47 self.addLink(s227, s204)
48 self.addLink(s227, s205)
49 self.addLink(s227, s205)
50 self.addLink(s227, s206)
51 self.addLink(s227, s206)
52
53 # Leaf-Leaf Links
54 self.addLink(s203, s204)
55 self.addLink(s205, s206)
56
57 # NOTE avoid using 10.0.1.0/24 which is the default subnet of quaggas
58 # NOTE avoid using 00:00:00:00:00:xx which is the default mac of host behind upstream router
59 # IPv4 Hosts
60 h1 = self.addHost('h1', cls=DhcpClient, mac='00:aa:00:00:00:01')
61 h2 = self.addHost('h2', cls=DhcpClient, mac='00:aa:00:00:00:02')
62 h3 = self.addHost('h3', cls=DhcpClient, mac='00:aa:00:00:00:03')
63 h4 = self.addHost('h4', cls=DhcpClient, mac='00:aa:00:00:00:04')
64 self.addLink(h1, s204)
65 self.addLink(h2, s204)
66 self.addLink(h3, s205)
67 self.addLink(h4, s205)
68
69 # IPv6 Hosts
70 h1v6 = self.addHost('h1v6', cls=Dhcp6Client, mac='00:bb:00:00:00:01')
71 h2v6 = self.addHost('h2v6', cls=Dhcp6Client, mac='00:bb:00:00:00:02')
72 h3v6 = self.addHost('h3v6', cls=Dhcp6Client, mac='00:bb:00:00:00:03')
73 h4v6 = self.addHost('h4v6', cls=Dhcp6Client, mac='00:bb:00:00:00:04')
74 self.addLink(h1v6, s204)
75 self.addLink(h2v6, s204)
76 self.addLink(h3v6, s205)
77 self.addLink(h4v6, s205)
78
79 # Dual-homed IPv4 Host 203-204
80 dh1 = self.addHost('dh1', cls=DualHomedDhcpClient, mac='00:cc:00:00:00:01')
81 self.addLink(dh1, s204)
82 self.addLink(dh1, s203)
83
84 # DHCP server
85 dhcp = self.addHost('dhcp', cls=DhcpServer, mac='00:99:00:00:00:01', ips=['10.0.3.253/24'], gateway='10.0.3.254')
86
87 # DHCPv6 server
88 dhcp6 = self.addHost('dhcp6', cls=Dhcp6Server, mac='00:99:66:00:00:01', ips=['2000::3fd/120'], gateway='2000::3ff')
89
90 # Dataplane L2 plane switch (for DHCP servers)
91 cs1 = self.addSwitch('cs1', cls=OVSBridge)
92 self.addLink(cs1, s205)
93 self.addLink(dhcp, cs1)
94 self.addLink(dhcp6, cs1)
95
96 # Control plane switch (for quagga fpm)
97 cs0 = self.addSwitch('cs0', cls=OVSBridge)
98
99 # Control plane NAT (for quagga fpm)
100 nat = self.addHost('nat', cls=NAT,
101 ip='172.16.0.1/12',
102 subnet=str(ip_network(u'172.16.0.0/12')), inNamespace=False)
103 self.addLink(cs0, nat)
104
105 # Internal Quagga bgp1
106 """
107 intfs = {'bgp1-eth0': [{'ipAddrs': ['10.0.1.2/24', '2000::102/120'], 'mac': '00:88:00:00:00:03', 'vlan': '110'},
108 {'ipAddrs': ['10.0.7.2/24', '2000::702/120'], 'mac': '00:88:00:00:00:03', 'vlan': '170'}],
109 'bgp1-eth1': {'ipAddrs': ['172.16.0.3/12']}}
110 """
111 intfs = {'bgp1-eth0': {'ipAddrs': ['10.0.1.2/24', '2000::102/120'], 'mac': '00:88:00:00:00:03', 'vlan': '110'},
112 'bgp1-eth1': {'ipAddrs': ['172.16.0.3/12']}}
113 bgp1 = self.addHost('bgp1', cls=BgpRouter,
114 interfaces=intfs,
115 quaggaConfFile='./bgpdbgp1.conf',
116 zebraConfFile='./zebradbgp1.conf')
117 self.addLink(bgp1, s205)
118 self.addLink(bgp1, cs0)
119
120 # Internal Quagga bgp2
121 """
122 intfs = {'bgp2-eth0': [{'ipAddrs': ['10.0.5.2/24', '2000::502/120'], 'mac': '00:88:00:00:00:04', 'vlan': '150'},
123 {'ipAddrs': ['10.0.6.2/24', '2000::602/120'], 'mac': '00:88:00:00:00:04', 'vlan': '160'}],
124 'bgp2-eth1': {'ipAddrs': ['172.16.0.4/12']}}
125 """
126 intfs = {'bgp2-eth0': {'ipAddrs': ['10.0.6.2/24', '2000::602/120'], 'mac': '00:88:00:00:00:04', 'vlan': '160'},
127 'bgp2-eth1': {'ipAddrs': ['172.16.0.4/12']}}
128 bgp2 = self.addHost('bgp2', cls=BgpRouter,
129 interfaces=intfs,
130 quaggaConfFile='./bgpdbgp2.conf',
131 zebraConfFile='./zebradbgp2.conf')
132 self.addLink(bgp2, s206)
133 self.addLink(bgp2, cs0)
134
135 # External Quagga r1
136 intfs = {'r1-eth0': {'ipAddrs': ['10.0.1.1/24', '2000::101/120'], 'mac': '00:88:00:00:00:01'},
137 #'r1-eth1': {'ipAddrs': ['10.0.5.1/24', '2000::501/120'], 'mac': '00:88:00:00:00:11'},
138 'r1-eth1': {'ipAddrs': ['10.0.99.1/16']},
139 'r1-eth2': {'ipAddrs': ['2000::9901/120']},
140 'r1-eth3': {'ipAddrs': ['2000::7701/120']}}
141 r1 = self.addHost('r1', cls=BgpRouter,
142 interfaces=intfs,
143 quaggaConfFile='./bgpdr1.conf')
144 self.addLink(r1, s205)
145 #self.addLink(r1, s206)
146
147 # External IPv4 Host behind r1
148 rh1 = self.addHost('rh1', cls=RoutedHost, ips=['10.0.99.2/24'], gateway='10.0.99.1')
149 self.addLink(r1, rh1)
150
151 # External IPv6 Host behind r1
152 rh1v6 = self.addHost('rh1v6', cls=RoutedHost, ips=['2000::9902/120'], gateway='2000::9901')
153 self.addLink(r1, rh1v6)
154
155 # Another external IPv6 Host behind r1
156 rh11v6 = self.addHost('rh11v6', cls=RoutedHost, ips=['2000::7702/120'], gateway='2000::7701')
157 self.addLink(r1, rh11v6)
158
159 # External Quagga r2
160 intfs = {'r2-eth0': {'ipAddrs': ['10.0.6.1/24', '2000::601/120'], 'mac': '00:88:00:00:00:02'},
161 #'r2-eth1': {'ipAddrs': ['10.0.7.1/24', '2000::701/120'], 'mac': '00:88:00:00:00:22'},
162 'r2-eth1': {'ipAddrs': ['10.0.99.1/16']},
163 'r2-eth2': {'ipAddrs': ['2000::9901/120']},
164 'r2-eth3': {'ipAddrs': ['2000::8801/120']}}
165 r2 = self.addHost('r2', cls=BgpRouter,
166 interfaces=intfs,
167 quaggaConfFile='./bgpdr2.conf')
168 self.addLink(r2, s206)
169 #self.addLink(r2, s205)
170
171 # External IPv4 Host behind r2
172 rh2 = self.addHost('rh2', cls=RoutedHost, ips=['10.0.99.2/24'], gateway='10.0.99.1')
173 self.addLink(r2, rh2)
174
175 # External IPv6 Host behind r2
176 rh2v6 = self.addHost('rh126', cls=RoutedHost, ips=['2000::9902/120'], gateway='2000::9901')
177 self.addLink(r2, rh2v6)
178
179 # Another external IPv6 Host behind r1
180 rh22v6 = self.addHost('rh22v6', cls=RoutedHost, ips=['2000::8802/120'], gateway='2000::8801')
181 self.addLink(r2, rh22v6)
182
183 # Dual-homed IPv4 Host for 205-206
184 dh2 = self.addHost('dh2', cls=DualHomedDhcpClient, mac='00:cc:00:00:00:02')
185 self.addLink(dh2, s205)
186 self.addLink(dh2, s206)
187
188 # ----- Secondary fabric -----
189
190 # Spines(HAG)
191 s246 = self.addSwitch('s246', dpid='246')
192 s247 = self.addSwitch('s247', dpid='247')
193
194 # Leaves(DAAS)
195 s207 = self.addSwitch('s207', dpid='207')
196 s208 = self.addSwitch('s208', dpid='208')
197
198 # HAG-DAAS Links
199 self.addLink(s246, s207)
200 self.addLink(s246, s208)
201 self.addLink(s247, s207)
202 self.addLink(s247, s208)
203
204 # HAG - Spine Links
205 self.addLink(s246, s226)
206 self.addLink(s247, s227)
207
208 # IPv4 Hosts - RPDs
209 rpd5 = self.addHost('rpd5', cls=DhcpClient, mac='00:dd:00:00:00:01')
210 rpd6 = self.addHost('rpd6', cls=DhcpClient, mac='00:dd:00:00:00:02')
211 self.addLink(rpd5, s207)
212 self.addLink(rpd6, s208)
213
214 # IPv6 Hosts - RPDs
215 rpd5v6 = self.addHost('rpd5v6', cls=Dhcp6Client, mac='00:ee:00:00:00:01')
216 rpd6v6 = self.addHost('rpd6v6', cls=Dhcp6Client, mac='00:ee:00:00:00:02')
217 self.addLink(rpd5v6, s207)
218 self.addLink(rpd6v6, s208)
219
220
221
222
223
224topos = { 'trellis' : Trellis }
225
226if __name__ == "__main__":
227 setLogLevel('debug')
228 topo = Trellis()
229
230 switch = partial(OVSSwitch, protocols='OpenFlow13')
231 net = Mininet(topo=topo, controller=None, switch=switch)
232 #net.addController(RemoteController('c0', ip='10.192.19.161'))
233 #net.addController(RemoteController('c1', ip='10.192.19.162'))
234 #net.addController(RemoteController('c2', ip='10.192.19.163'))
235
236 net.start()
237 CLI(net)
238 net.stop()