Jonathan Hart | ce97e5b | 2016-04-19 01:41:31 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | from mininet.topo import Topo |
| 4 | from mininet.net import Mininet |
| 5 | from mininet.cli import CLI |
| 6 | from mininet.log import setLogLevel |
Jonathan Hart | fc0af77 | 2017-01-16 13:15:08 -0800 | [diff] [blame] | 7 | from mininet.node import RemoteController, OVSBridge, UserSwitch |
Jonathan Hart | ce97e5b | 2016-04-19 01:41:31 -0700 | [diff] [blame] | 8 | from routinglib import BasicAutonomousSystem |
| 9 | from routinglib import SdnAutonomousSystem, AutonomousSystem |
| 10 | from routinglib import generateRoutes |
| 11 | |
| 12 | |
| 13 | class 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 Hart | fc0af77 | 2017-01-16 13:15:08 -0800 | [diff] [blame] | 19 | s1 = self.addSwitch('s1', dpid='000000000b1') |
Jonathan Hart | ce97e5b | 2016-04-19 01:41:31 -0700 | [diff] [blame] | 20 | |
| 21 | # SDN AS |
| 22 | onosIps = ['192.168.56.11'] |
Jonathan Hart | fc0af77 | 2017-01-16 13:15:08 -0800 | [diff] [blame] | 23 | sdnAs = SdnAutonomousSystem(onosIps, numBgpSpeakers=1, asNum=65000, withFpm=True) |
Jonathan Hart | ce97e5b | 2016-04-19 01:41:31 -0700 | [diff] [blame] | 24 | |
| 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 | |
| 56 | topos = { 'vrouter' : VrouterTopo } |
| 57 | |
| 58 | if __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 Hart | fc0af77 | 2017-01-16 13:15:08 -0800 | [diff] [blame] | 64 | net.addController(RemoteController('c1', ip='192.168.56.12')) |
| 65 | net.addController(RemoteController('c2', ip='192.168.56.13')) |
Jonathan Hart | ce97e5b | 2016-04-19 01:41:31 -0700 | [diff] [blame] | 66 | |
| 67 | net.start() |
| 68 | |
| 69 | CLI(net) |
| 70 | |
| 71 | net.stop() |
| 72 | |