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, info |
| 7 | from mininet.node import RemoteController, OVSSwitch |
| 8 | from routinglib import BgpRouter |
| 9 | |
| 10 | class BgpRouterDeployTopo( Topo ): |
| 11 | "Sets up control plane components for BgpRouter deployment" |
| 12 | |
| 13 | def __init__( self, *args, **kwargs ): |
| 14 | Topo.__init__( self, *args, **kwargs ) |
| 15 | s1 = self.addSwitch('s1', dpid='0000000000000001') |
| 16 | |
| 17 | sdnAs = 65000 |
| 18 | |
| 19 | # Set up BGP speakers |
| 20 | bgp1eth0 = { 'ipAddrs' : ['1.1.1.11/24'] } |
| 21 | |
| 22 | bgp1eth1 = [ |
| 23 | { 'vlan': 1, |
| 24 | 'mac':'00:00:00:00:00:01', |
| 25 | 'ipAddrs' : ['192.168.10.101/24'] }, |
| 26 | { 'vlan': 2, |
| 27 | 'mac':'00:00:00:00:00:02', |
| 28 | 'ipAddrs' : ['192.168.20.101/24'] } |
| 29 | ] |
| 30 | |
| 31 | bgp1Intfs = { 'bgp1-eth0' : bgp1eth0, |
| 32 | 'bgp1-eth1' : bgp1eth1 } |
| 33 | |
| 34 | neighbors = [{'address':'192.168.10.1', 'as':65001}, |
| 35 | {'address':'192.168.20.1', 'as':65001}, |
| 36 | {'address':'192.168.30.1', 'as':65002}, |
| 37 | {'address':'192.168.40.1', 'as':65003}, |
| 38 | {'address':'1.1.1.1', 'as':sdnAs, 'port': 2000}] |
| 39 | |
| 40 | bgp1 = self.addHost( "bgp1", interfaces=bgp1Intfs, asNum=sdnAs, |
| 41 | neighbors=neighbors, routes=[], cls=BgpRouter) |
| 42 | |
| 43 | root = self.addHost('root', ip='1.1.1.1/24', inNamespace=False) |
| 44 | |
| 45 | self.addLink( bgp1, root ) |
| 46 | self.addLink( bgp1, s1 ) |
| 47 | |
| 48 | if __name__ == "__main__": |
| 49 | setLogLevel('debug') |
| 50 | topo = BgpRouterDeployTopo() |
| 51 | |
| 52 | net = Mininet(topo=topo, controller=RemoteController, switch=OVSSwitch) |
| 53 | |
| 54 | net.start() |
| 55 | |
| 56 | CLI(net) |
| 57 | |
| 58 | net.stop() |
| 59 | |
| 60 | info("done\n") |