blob: 2b6f156c668ebdd83c9d8f9d6f4f3523cb91ae50 [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.cli import CLI
6from mininet.log import setLogLevel
Jonathan Hartfc0af772017-01-16 13:15:08 -08007from mininet.node import RemoteController, OVSBridge, UserSwitch
Jonathan Hartce97e5b2016-04-19 01:41:31 -07008from routinglib import BasicAutonomousSystem
9from routinglib import SdnAutonomousSystem, AutonomousSystem
10from routinglib import generateRoutes
11
12
13class VrouterTopo( Topo ):
14 "Single switch topology for testing the vRouter"
15
16 def __init__( self, *args, **kwargs ):
17 Topo.__init__( self, *args, **kwargs )
18 # Router switch
Jonathan Hartfc0af772017-01-16 13:15:08 -080019 s1 = self.addSwitch('s1', dpid='000000000b1')
Jonathan Hartce97e5b2016-04-19 01:41:31 -070020
21 # SDN AS
22 onosIps = ['192.168.56.11']
Jonathan Hartfc0af772017-01-16 13:15:08 -080023 sdnAs = SdnAutonomousSystem(onosIps, numBgpSpeakers=1, asNum=65000, withFpm=True)
Jonathan Hartce97e5b2016-04-19 01:41:31 -070024
25 numRoutesPerAs = 1
26
27 # Normal ASes
28 as1 = BasicAutonomousSystem(1,
29 generateRoutes(u'10.1.0.0/16', numRoutesPerAs))
30 AutonomousSystem.addPeering(as1, sdnAs, useVlans=True)
31 as1.addLink(s1)
32 as1.build(self)
33
34 as2 = BasicAutonomousSystem(2,
35 generateRoutes(u'10.2.0.0/16', numRoutesPerAs))
36 AutonomousSystem.addPeering(as2, sdnAs, useVlans=True)
37 as2.addLink(s1)
38 as2.build(self)
39
40 as3 = BasicAutonomousSystem(3,
41 generateRoutes(u'10.3.0.0/16', numRoutesPerAs))
42 AutonomousSystem.addPeering(as3, sdnAs, useVlans=True)
43 as3.addLink(s1)
44 as3.build(self)
45
46 as4 = BasicAutonomousSystem(4,
47 generateRoutes(u'10.4.0.0/16', numRoutesPerAs))
48 AutonomousSystem.addPeering(as4, sdnAs, useVlans=False)
49 as4.addLink(s1)
50 as4.build(self)
51
52 # SDN AS (internal BGP speaker) connects to control plane switch
53 cs0 = self.addSwitch('cs0', cls=OVSBridge)
54 sdnAs.build(self, s1, cs0)
55
56topos = { 'vrouter' : VrouterTopo }
57
58if __name__ == "__main__":
59 setLogLevel('debug')
60 topo = VrouterTopo()
61
62 net = Mininet(topo=topo, controller=None)
63 net.addController(RemoteController('c0', ip='192.168.56.11'))
Jonathan Hartfc0af772017-01-16 13:15:08 -080064 net.addController(RemoteController('c1', ip='192.168.56.12'))
65 net.addController(RemoteController('c2', ip='192.168.56.13'))
Jonathan Hartce97e5b2016-04-19 01:41:31 -070066
67 net.start()
68
69 CLI(net)
70
71 net.stop()
72