blob: bc5c7a6ead081831a524bcb9d94b05ebf0153746 [file] [log] [blame]
Jonathan Hart09608592016-05-19 09:39:22 -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
7from mininet.node import RemoteController, OVSSwitch, UserSwitch
8from mininet.nodelib import NAT
9from routinglib import QuaggaRouter
10from routinglib import BgpProtocol, OspfProtocol
11from routinglib import RoutedNetwork, RoutedHost, Router
12from ipaddress import ip_network
13from routinglib import PimProtocol
14
15#onosIps = ['192.168.56.11']
16
17cordOnos = '192.168.56.12'
18fabricOnos = '192.168.56.11'
19
20c0 = RemoteController( 'c0', ip=fabricOnos )
21c1 = RemoteController( 'c1', ip=cordOnos )
22
23cmap = { 's1': c0, 's2': c1 }
24
25class MultiSwitch( UserSwitch ):
26 "Custom Switch() subclass that connects to different controllers"
27 def start( self, controllers ):
28 return UserSwitch.start( self, [ cmap[ self.name ] ] )
29
30class MulticastTopo( Topo ):
31 """Topology for testing multicast in CORD.
32 Contains two switches:
33 (1) stand-in for the OLT, where the IGMP snooping will happen
34 (2) vRouter/fabric leaf where the PIM to upstream happens"""
35
36 def __init__( self, *args, **kwargs ):
37 Topo.__init__( self, *args, **kwargs )
38
39 QuaggaRouter.binDir='/home/jono/shared/quagga/build/bin'
40
41 # vRouter switch
42 s1 = self.addSwitch('s1', dpid='1')
43 # IGMP switch
44 s2 = self.addSwitch('s2', dpid='2')
45
46 eth0 = { 'ipAddrs' : ['10.0.3.1/24'] }
47 eth1 = { 'ipAddrs' : ['10.0.2.254/24']}
48 intfs = {'r1-eth0' : eth0,
49 'r1-eth1' : eth1}
50
51 pim = PimProtocol(configFile='configs/pim.conf')
52 #bgp = BgpProtocol(asNum=65001, neighbors=[{'address' : '10.0.3.2', 'as' : 65000}], routes=['10.0.2.0/24'])
53 ospf = OspfProtocol()
54 r1 = self.addHost('r1', interfaces=intfs, cls=QuaggaRouter,
55 protocols=[pim, ospf])
56
57 self.addLink(r1, s1)
58
59 RoutedNetwork.build(self, r1, 'h1', [ip_network(u'10.0.2.0/24')])
60
61
62 cpintfs = {'cp1-eth0' : { 'mac' : '00:00:00:00:00:01', 'ipAddrs' : ['10.0.3.2/24', '10.0.1.100/24'] },
63 'cp1-eth1' : { 'ipAddrs' : ['1.1.1.1/24']} }
64 #bgp = BgpProtocol(asNum=65000, neighbors=[{'address' : '10.0.3.1', 'as': 65001}])
65 ospf = OspfProtocol()
66 cp1 = self.addHost('cp1', cls=QuaggaRouter, interfaces=cpintfs, protocols=[ospf],
67 fpm=fabricOnos, defaultRoute='1.1.1.254')
68 #cp1 = self.addHost('cp1', cls=Router, ips=['10.0.3.2/24'], mac='00:00:00:00:00:01')
69
70 nat = self.addHost('nat', cls=NAT,
71 ip='1.1.1.254/24',
72 subnet='1.1.1.0/24', inNamespace=False);
73 self.addLink(cp1, s1)
74 self.addLink(cp1, nat)
75
76 h2 = self.addHost('h2', ip="10.0.1.1/24", defaultRoute="via 10.0.1.254", mac="00:00:00:00:00:02", inNamespace=True)
77 self.addLink(h2, s2)
78 self.addLink(s2, s1)
79
80if __name__ == "__main__":
81 setLogLevel('debug')
82 topo = MulticastTopo()
83
84 net = Mininet(topo=topo, switch=MultiSwitch, controller=None)
85
86 net.addController(c0)
87 net.addController(c1)
88
89 h2 = net.get('h2')
90 h2.cmd('ethtool --offload h2-eth0 tx off')
91 r1 = net.get('r1')
92 r1.cmd('ethtool --offload r1-eth0 tx off')
93 cp1 = net.get('cp1')
94 cp1.cmd('ethtool --offload cp1-eth0 tx off')
95
96 net.start()
97
98 CLI(net)
99
100 net.stop()