blob: e2cd797c9a57e53cb57d5386b766b89bc710b146 [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, OVSBridge
6from mininet.cli import CLI
7from mininet.log import setLogLevel, info
8from routinglib import BasicAutonomousSystem, RouteServerAutonomousSystem
9from routinglib import SdnAutonomousSystem, AutonomousSystem
10from ipaddress import ip_network
11
12onoses = [ '192.168.56.11' ]
13
14class SdnTopo( Topo ):
15 "Topology built using higher-level abstractions (ASes)"
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 # SDN AS
27 sdnAs = SdnAutonomousSystem(onoses, numBgpSpeakers=1, asNum=65000)
28
29 # Normal ASes
30 as1 = BasicAutonomousSystem(1, [ip_network(u'172.16.10.0/24')])
31
32 AutonomousSystem.addPeering(as1, sdnAs)
33 as1.addLink(sw3)
34 as1.build(self)
35
36 as2 = BasicAutonomousSystem(2, [ip_network(u'172.16.20.0/24')])
37
38 AutonomousSystem.addPeering(as2, sdnAs)
39 as2.addLink(sw2)
40 as2.build(self)
41
42 as3 = BasicAutonomousSystem(3, [ip_network(u'172.16.30.0/24')])
43
44 AutonomousSystem.addPeering(as3, sdnAs)
45 as3.addLink(sw6)
46 as3.build(self)
47
48 # AS containing a route server
49 #as4 = RouteServerAutonomousSystem('192.168.60.2/24', 4, '192.168.60.1/24',
50 # [ip_network(u'172.16.60.0/24')])
51 #as4.build(self, sw4);
52
53 cs0 = self.addSwitch('cs0', cls=OVSBridge)
54
55 sdnAs.build(self, sw1, cs0)
56
57 self.addLink( sw1, sw2 )
58 self.addLink( sw1, sw3 )
59 self.addLink( sw2, sw4 )
60 self.addLink( sw3, sw4 )
61 self.addLink( sw3, sw5 )
62 self.addLink( sw4, sw6 )
63 self.addLink( sw5, sw6 )
64
65if __name__ == "__main__":
66 setLogLevel('debug')
67 topo = SdnTopo()
68
69 net = Mininet(topo=topo, controller=None)
70 for i in range(len(onoses)):
71 net.addController( RemoteController( 'c%s' % (i+1), ip=onoses[i], checkListening=False ) )
72
73 net.start()
74
75 CLI(net)
76
77 net.stop()
78
79 info("done\n")