ngsdn-tutorial
ngsdn-tutorial copied to clipboard
Custom Topologies
trafficstars
Hi! I was trying to create a custom topology for my research. This topology consists of an 's1' switch and 4(four) hosts connected to it(h1,h2,h3,h4). In the future, I plan to add 3 more switches and create links between them. I thought I could do it by editing topo.py and netcfg.json. Can I do it? Is it possible to do it by editing topo.py and netcfg.json? Because I did that and I can't ping between hosts, even if I follow exercise 1 instructions. Can someone help me?my netcfg and topo files follows:
{
"devices":{
"device:s1":{
"basic":{
"managementAddress": "grpc://mininet:50001?device_id=1",
"driver": "stratum-bmv2",
"pipeconf": "org.onosproject.ngsdn-tutorial",
"locType": "grid",
"gridX": 200,
"gridY": 600
},
"fabricDeviceConfig":{
"myStationMac": "00:aa:00:00:00:01",
"isSpine": false
}
}
},
"ports":{
"device:s1/3": {
"interfaces": [
{
"name": "s1-3",
"ips": ["2001:1:1::ff/64"]
}
]
},
"device:s1/4": {
"interfaces": [
{
"name": "s1-4",
"ips": ["2001:1:1::ff/64"]
}
]
},
"device:s1/5": {
"interfaces": [
{
"name": "s1-5",
"ips": ["2001:1:1::ff/64"]
}
]
},
"device:s1/6": {
"interfaces": [
{
"name": "s1-6",
"ips": ["2001:1:2::ff/64"]
}
]
}
},
"hosts":{
"00:00:00:00:00:1A/None": {
"basic": {
"name": "h1",
"locType": "grid",
"gridX": 100,
"gridY": 700
}
},
"00:00:00:00:00:1B/None": {
"basic": {
"name": "h2",
"locType": "grid",
"gridX": 100,
"gridY": 750
}
},
"00:00:00:00:00:1C/None": {
"basic": {
"name": "h3",
"locType": "grid",
"gridX": 100,
"gridY": 850
}
},
"00:00:00:00:00:1D/None": {
"basic": {
"name": "h4",
"locType": "grid",
"gridX": 100,
"gridY": 900
}
}
}
}
#!/usr/bin/python
# Copyright 2019-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#this version was modified by ajsalmeida
import argparse
from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.net import Mininet
from mininet.node import Host
from mininet.topo import Topo
from stratum import StratumBmv2Switch
CPU_PORT = 255
class IPv6Host(Host):
def config(self, ipv6, ipv6_gw=None, **params):
super(IPv6Host, self).config(**params)
self.cmd('ip -4 addr flush dev %s' % self.defaultIntf())
self.cmd('ip -6 addr flush dev %s' % self.defaultIntf())
self.cmd('ip -6 addr add %s dev %s' % (ipv6, self.defaultIntf()))
if ipv6_gw:
self.cmd('ip -6 route add default via %s' % ipv6_gw)
# Disable offload
for attr in ["rx", "tx", "sg"]:
cmd = "/sbin/ethtool --offload %s %s off" % (self.defaultIntf(), attr)
self.cmd(cmd)
def updateIP():
return ipv6.split('/')[0]
self.defaultIntf().updateIP = updateIP
def terminate(self):
super(IPv6Host, self).terminate()
class TutorialTopo(Topo):
"""topologia ambar"""
def __init__(self, *args, **kwargs):
Topo.__init__(self, *args, **kwargs)
# Leaves
# gRPC port 50001
#leaf1 = self.addSwitch('leaf1', cls=StratumBmv2Switch, cpuport=CPU_PORT)
# gRPC port 50002
#leaf2 = self.addSwitch('leaf2', cls=StratumBmv2Switch, cpuport=CPU_PORT)
#modificado gRPC porta 50001
s1 = self.addSwitch('s1', cls=StratumBmv2Switch, cpuport=CPU_PORT)
# Spines
# gRPC port 50003
#spine1 = self.addSwitch('spine1', cls=StratumBmv2Switch, cpuport=CPU_PORT)
# gRPC port 50004
#spine2 = self.addSwitch('spine2', cls=StratumBmv2Switch, cpuport=CPU_PORT)
# Switch Links
#self.addLink(spine1, leaf1)
#self.addLink(spine1, leaf2)
#self.addLink(spine2, leaf1)
#self.addLink(spine2, leaf2)
# IPv6 hosts attached to leaf 1
#h1a = self.addHost('h1a', cls=IPv6Host, mac="00:00:00:00:00:1A", ipv6='2001:1:1::a/64', ipv6_gw='2001:1:1::ff')
#h1b = self.addHost('h1b', cls=IPv6Host, mac="00:00:00:00:00:1B", ipv6='2001:1:1::b/64', ipv6_gw='2001:1:1::ff')
#h1c = self.addHost('h1c', cls=IPv6Host, mac="00:00:00:00:00:1C", ipv6='2001:1:1::c/64', ipv6_gw='2001:1:1::ff')
#h2 = self.addHost('h2', cls=IPv6Host, mac="00:00:00:00:00:20", ipv6='2001:1:2::1/64', ipv6_gw='2001:1:2::ff')
#self.addLink(h1a, leaf1) # port 3
#self.addLink(h1b, leaf1) # port 4
#self.addLink(h1c, leaf1) # port 5
#self.addLink(h2, leaf1) # port 6
#hosts
h1 = self.addHost('h1',cls=IPv6Host, mac="00:00:00:00:00:1A", ipv6='2001:1:1::a/64', ipv6_gw='2001:1:1::ff')
h2 = self.addHost('h2',cls=IPv6Host, mac="00:00:00:00:00:1B", ipv6='2001:1:1::b/64', ipv6_gw='2001:1:1::ff')
h3 = self.addHost('h3',cls=IPv6Host, mac="00:00:00:00:00:1C", ipv6='2001:1:1::c/64', ipv6_gw='2001:1:1::ff')
h4 = self.addHost('h4',cls=IPv6Host, mac="00:00:00:00:00:1D", ipv6='2001:1:1::d/64', ipv6_gw='2001:1:1::ff')
#links
self.addLink(h1, s1) #port 3
self.addLink(h2, s1) #port 4
self.addLink(h3, s1) #port 5
self.addLink(h4, s1) #port 6
# IPv6 hosts attached to leaf 2
#h3 = self.addHost('h3', cls=IPv6Host, mac="00:00:00:00:00:30", ipv6='2001:2:3::1/64', ipv6_gw='2001:2:3::ff')
#h4 = self.addHost('h4', cls=IPv6Host, mac="00:00:00:00:00:40", ipv6='2001:2:4::1/64', ipv6_gw='2001:2:4::ff')
#self.addLink(h3, leaf2) # port 3
#self.addLink(h4, leaf2) # port 4
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 2x2 fabric with stratum_bmv2 and IPv6 hosts')
description = 'Ambar Topology')
args = parser.parse_args()
setLogLevel('info')
main()
Thank you very much!
Did you find any solution? Because I am stuck on the same issue.