blob: 2ceeb3635b9504536d51bcc34ec39b4b0a411ed8 [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')
35 self.addLink(h1a, leaf1) # port 1
36 self.addLink(h1b, leaf1) # port 2
37
38
39def main():
40 net = Mininet(topo=TutorialTopo(), controller=None)
41 net.start()
42 CLI(net)
43 net.stop()
44
45
46if __name__ == "__main__":
47 parser = argparse.ArgumentParser(
48 description='Mininet topology script for single leaf having two hosts with stratum_bmv2')
49 args = parser.parse_args()
50 setLogLevel('info')
51
52 main()