| #!/usr/bin/python |
| |
| # SPDX-FileCopyrightText: 2022-present Intel Corporation |
| # SPDX-License-Identifier: Apache-2.0 |
| |
| import argparse |
| |
| from mininet.cli import CLI |
| from mininet.log import setLogLevel |
| from mininet.net import Mininet |
| from mininet.topo import Topo |
| from stratum import StratumBmv2Switch |
| |
| from mn_lib import IPv4Host |
| from mn_lib import TaggedIPv4Host |
| |
| CPU_PORT = 255 |
| |
| |
| class TutorialTopo(Topo): |
| """Single leaf switch with two hosts attached""" |
| |
| def __init__(self, *args, **kwargs): |
| Topo.__init__(self, *args, **kwargs) |
| |
| # Leaves |
| # gRPC port 50001 |
| leaf1 = self.addSwitch('leaf1', cls=StratumBmv2Switch, cpuport=CPU_PORT) |
| |
| # IPv4 hosts attached to leaf 1 |
| h1a = self.addHost('h1a', cls=IPv4Host, mac="00:00:00:00:00:1A", |
| ip='172.16.1.1/24', gw='172.16.1.254') |
| h1b = self.addHost('h1b', cls=IPv4Host, mac="00:00:00:00:00:1B", |
| ip='172.16.1.2/24', gw='172.16.1.254') |
| self.addLink(h1a, leaf1) # port 1 |
| self.addLink(h1b, leaf1) # port 2 |
| |
| |
| def main(): |
| net = Mininet(topo=TutorialTopo(), controller=None) |
| net.start() |
| CLI(net) |
| net.stop() |
| |
| |
| if __name__ == "__main__": |
| parser = argparse.ArgumentParser( |
| description='Mininet topology script for single leaf having two hosts with stratum_bmv2') |
| args = parser.parse_args() |
| setLogLevel('info') |
| |
| main() |