blob: 3c14dee42df305818ada9978b3d100c31a11c1af [file] [log] [blame]
Girish Gowdra267e25e2022-08-20 20:03:58 -07001#!/usr/bin/python
2
3# SPDX-FileCopyrightText: 2022-present Intel Corporation
4# SPDX-License-Identifier: Apache-2.0
5
6import argparse
7
8from mininet.cli import CLI
9from mininet.log import setLogLevel
10from mininet.net import Mininet
11from mininet.topo import Topo
12from stratum import StratumBmv2Switch
13
14from mn_lib import IPv4Host
15from mn_lib import TaggedIPv4Host
16
17CPU_PORT = 255
18
19
20class TutorialTopo(Topo):
21 """Single leaf switch with two hosts attached"""
22
23 def __init__(self, *args, **kwargs):
24 Topo.__init__(self, *args, **kwargs)
25
26 # Leaves
27 # gRPC port 50001
28 leaf1 = self.addSwitch('leaf1', cls=StratumBmv2Switch, cpuport=CPU_PORT)
29
30 # IPv4 hosts attached to leaf 1
31 h1a = self.addHost('h1a', cls=IPv4Host, mac="00:00:00:00:00:1A",
32 ip='172.16.1.1/24', gw='172.16.1.254')
33 h1b = self.addHost('h1b', cls=IPv4Host, mac="00:00:00:00:00:1B",
34 ip='172.16.1.2/24', gw='172.16.1.254')
Andrea Campanellaa32c9302022-09-01 13:03:13 +020035 hVa = self.addHost('hVa', cls=IPv4Host, mac="AA:BB:CC:DD:EE:FE",
36 ip='172.16.1.101/24', gw='172.16.1.254')
37 hVb = self.addHost('hVb', cls=TaggedIPv4Host, mac="AA:BB:CC:DD:EE:FF",
38 ip='172.16.1.102/24', gw='172.16.1.254', vlan=15)
39 hVc = self.addHost('hVc', cls=IPv4Host, mac="AA:BB:CC:DD:EE:EE",
40 ip='172.16.1.103/24', gw='172.16.1.254')
41 hVd = self.addHost('hVd', cls=TaggedIPv4Host, mac="AA:BB:CC:DD:EE:EF",
42 ip='172.16.1.104/24', gw='172.16.1.254', vlan=15)
Girish Gowdra267e25e2022-08-20 20:03:58 -070043 self.addLink(h1a, leaf1) # port 1
44 self.addLink(h1b, leaf1) # port 2
Andrea Campanellaa32c9302022-09-01 13:03:13 +020045 self.addLink(hVa, leaf1) # port 3
46 self.addLink(hVb, leaf1) # port 4
47 self.addLink(hVc, leaf1) # port 5
48 self.addLink(hVd, leaf1) # port 6
Girish Gowdra267e25e2022-08-20 20:03:58 -070049
50
51def main():
52 net = Mininet(topo=TutorialTopo(), controller=None)
53 net.start()
Andrea Campanellaa32c9302022-09-01 13:03:13 +020054 net.staticArp()
Girish Gowdra267e25e2022-08-20 20:03:58 -070055 CLI(net)
56 net.stop()
57
58
59if __name__ == "__main__":
60 parser = argparse.ArgumentParser(
61 description='Mininet topology script for single leaf having two hosts with stratum_bmv2')
62 args = parser.parse_args()
63 setLogLevel('info')
64
65 main()