blob: c0dda25e209b5f974b0a9bf1e8f365e2cd3a9fa3 [file] [log] [blame]
Jonathan Hartce97e5b2016-04-19 01:41:31 -07001#!/usr/bin/python
2
3from mininet.topo import Topo
4from mininet.net import Mininet
5from mininet.node import RemoteController
6from mininet.cli import CLI
7from mininet.log import setLogLevel, info
8from mininet.node import OVSBridge
9from routinglib import BgpRouter, RoutedHost
10from onoslib import ONOSHostSdnipCluster
11
12onoses = [ '192.168.56.11', '192.168.56.12' ]
13
14class BgpRouterDeployTopo( Topo ):
15 "Our familiar ONS demo topology"
16
17 def __init__( self, *args, **kwargs ):
18 Topo.__init__( self, *args, **kwargs )
19 sw1 = self.addSwitch('sw1', dpid='00000000000000a1')
20 sw2 = self.addSwitch('sw2', dpid='00000000000000a2')
21 sw3 = self.addSwitch('sw3', dpid='00000000000000a3')
22 sw4 = self.addSwitch('sw4', dpid='00000000000000a4')
23 sw5 = self.addSwitch('sw5', dpid='00000000000000a5')
24 sw6 = self.addSwitch('sw6', dpid='00000000000000a6')
25
26 #Note this switch isn't part of the SDN topology
27 as6sw = self.addSwitch('as6sw', dpid='00000000000000a7', cls=OVSBridge)
28
29 #AS2 host
30 host3eth0 = { 'mac':'00:00:00:00:02:01', 'ipAddrs' : [ '192.168.10.1/24' ] }
31 host3eth1 = { 'mac':'00:00:00:00:02:02', 'ipAddrs' : [ '192.168.20.1/24' ] }
32 host3eth2 = { 'ipAddrs' : [ '172.16.20.254/24' ] }
33 host3Intfs = {'host3-eth0' : host3eth0,
34 'host3-eth1' : host3eth1,
35 'host3-eth2' : host3eth2 }
36 host3neigh = [{'address':'192.168.10.101', 'as':64513},
37 {'address':'192.168.20.101', 'as':64513}]
38 host3routes = ['127.16.10.0/24']
39
40 host3 = self.addHost( 'host3', interfaces=host3Intfs, asNum=65001,
41 neighbors=host3neigh, routes=host3routes,
42 cls=BgpRouter)
43
44 as2host = self.addHost( 'as2host', cls=RoutedHost, ip='172.16.20.1/24',
45 route='172.16.20.254' )
46
47
48 #AS3 host
49 host4eth0 = { 'mac':'00:00:00:00:03:01', 'ipAddrs' : [ '192.168.30.1/24' ] }
50 host4eth1 = { 'ipAddrs' : [ '172.16.30.254/24' ] }
51 host4Intfs = {'host4-eth0' : host4eth0,
52 'host4-eth1' : host4eth1 }
53 host4neigh = [{'address':'192.168.30.101', 'as':64513}]
54 host4routes = ['172.16.30.0/24']
55 host4 = self.addHost( 'host4', interfaces=host4Intfs, asNum=65002,
56 neighbors=host4neigh, routes=host4routes,
57 cls=BgpRouter)
58
59 as3host = self.addHost( 'as3host', cls=RoutedHost, ip='172.16.30.1/24',
60 route='172.16.30.254' )
61
62
63 #AS4 host
64 host5eth0 = { 'mac':'00:00:00:00:04:01', 'ipAddrs' : [ '192.168.40.1/24' ] }
65 host5eth1 = { 'ipAddrs' : [ '172.16.40.254/24' ] }
66 host5Intfs = {'host5-eth0' : host5eth0,
67 'host5-eth1' : host5eth1 }
68 host5neigh = [{'address':'192.168.40.101', 'as':64513}]
69 host5routes = ['172.16.40.0/24']
70 host5 = self.addHost( 'host5', interfaces=host5Intfs, asNum=65003,
71 neighbors=host5neigh, routes=host5routes,
72 cls=BgpRouter)
73
74 as4host = self.addHost( 'as4host', cls=RoutedHost, ip='172.16.40.1/24',
75 route='172.16.40.254' )
76
77 #AS6 host
78 #as6rs = self.addHost( 'as6rs' )
79 #as6rs2 = self.addHost( 'as6rs2' )
80 #as6router = self.addHost( 'as6router' )
81 #as6host = self.addHost( 'as6host' )
82
83 # Create a control network
84 onosCluster = ONOSHostSdnipCluster(controlSubnet='192.168.50.0/24',
85 dataSubnet='1.1.1.0/24', numInstances=2)
86 cs1 = onosCluster.create(self)
87 #cs0 = self.createControlNet((u'192.168.50.0/24'), (u'1.1.1.0/24'), numOnos=2)
88
89 # Set up BGP speakers
90 bgp1eth0 = { 'ipAddrs' : ['1.1.1.11/24'] }
91 bgp1eth1 = { 'mac':'00:00:00:00:00:01',
92 'ipAddrs' : ['192.168.10.101/24',
93 '192.168.20.101/24',
94 '192.168.30.101/24',
95 '192.168.40.101/24',] }
96 bgp1Intfs = { 'BGP1-eth0' : bgp1eth0,
97 'BGP1-eth1' : bgp1eth1 }
98 bgp1neigh = [{'address':'192.168.10.1', 'as':65001},
99 {'address':'192.168.20.1', 'as':65001},
100 {'address':'192.168.30.1', 'as':65002},
101 {'address':'192.168.40.1', 'as':65003},
102 {'address':'1.1.1.1', 'as':64513},
103 {'address':'1.1.1.2', 'as':64513},
104 {'address':'1.1.1.12', 'as':64513}]
105
106 bgp1 = self.addHost( "BGP1", interfaces=bgp1Intfs, asNum=64513,
107 neighbors=bgp1neigh, routes=[], cls=BgpRouter)
108
109 self.addLink( bgp1, cs1 )
110 self.addLink( bgp1, sw1 )
111
112 #bgp2eth0 = { 'ipAddrs' : ['1.1.1.12/24'] }
113 #bgp2eth1 = { 'mac':'00:00:00:00:00:02',
114 # 'ipAddrs' : ['192.168.10.102/24',
115 # '192.168.20.102/24',
116 # '192.168.30.102/24',
117 # '192.168.40.102/24',] }
118 #bgp2Intfs = { 'BGP2-eth0' : bgp2eth0,
119 # 'BGP2-eth1' : bgp2eth1 }
120
121 #bgp2 = self.addHost( "BGP2", cls=BgpRouter,
122 # quaggaConfFile = '../onsdemo/quagga-sdn2.conf',
123 # zebraConfFile = zebraConf,
124 # interfaces=bgp2Intfs )
125
126 #self.addLink( bgp2, cs0 )
127 #self.addLink( bgp2, sw4 )
128
129 #Links to the multihomed AS
130 self.addLink( host3, sw3 )
131 self.addLink( host3, sw5 )
132 self.addLink( as2host, host3 )
133 #Single links to the remaining two ASes
134 self.addLink( host4, sw2 )
135 self.addLink( as3host, host4 )
136 self.addLink( host5, sw6 )
137 self.addLink( as4host, host5 )
138 #AS3-AS4 link
139 #self.addLink( host4, host5)
140 #Add new AS6 to its bridge
141 #self.addLink( as6rs, as6sw )
142 #self.addLink( as6rs2, as6sw )
143 #self.addLink( as6router, as6sw )
144 #self.addLink( as6host, as6router )
145 #for i in range(1, 10):
146 # host = self.addHost('as6host%d' % i)
147 # self.addLink(host, as6router)
148
149 self.addLink( sw1, sw2 )
150 self.addLink( sw1, sw3 )
151 self.addLink( sw2, sw4 )
152 self.addLink( sw3, sw4 )
153 self.addLink( sw3, sw5 )
154 self.addLink( sw4, sw6 )
155 self.addLink( sw5, sw6 )
156 self.addLink( as6sw, sw4 )
157
158if __name__ == "__main__":
159 setLogLevel('debug')
160 topo = BgpRouterDeployTopo()
161
162 net = Mininet(topo=topo, controller=None)
163 for i in range(len(onoses)):
164 net.addController( RemoteController( 'c%s' % (i+1), ip=onoses[i], checkListening=False ) )
165
166 net.start()
167
168 CLI(net)
169
170 net.stop()
171
172 info("done\n")