搜索

Mininet模拟不同数据中心的网络拓扑

发表于 2025-11-05 15:30:25 来源:全栈开发
Mininet模拟不同数据中心的网络拓扑
复制#FatTree.py   """Customtopology example  Addingthe topos dict with a key/value pair to generate our newly defined  topologyenables one to pass in--topo=mytopofrom the command line.  """  frommininet.topo import Topo  classMyTopo(Topo):      "Simple topology example."       def __init__(self):           "create custom topo."              #initializa topology               Topo.__init__(self)               L1 = 2               L2 = L1 * 2               L3 = L2               cSwitch = []               aSwitch = []               eSwitch = []           #add core ovs           for i in range(L1):                  sw = self.addSwitch(c{}.format(i+1))                      cSwitch.append(sw)               #add aggregation ovs               for i in range(L2):                  sw = self.addSwitch(a{}.format(L1 + i+1))                      aSwitch.append(sw)               #add edge ovs               forin range(L2):                  sw = self.addSwitch(e{}.format(L1 + L2 + i+1))                      eSwitch.append(sw)               #add links between core aggregationovs               for i in range(L1):                  for j in range(L2):                          # self.addLink(sw2,同数拓扑 sw1, bw=10,delay=5ms, loss=10, max_queue_size=1000, use_htb=True)                          link = self.addLink(cSwitch[i],aSwitch[j])               #add links between aggragation andedge ovs               for i in range(L1):                  for j in range(L1):                          self.addLink(aSwitch[i],eSwitch[j])               for i in range(L1):                  for j in range(L1):                          # self.addLink(sw2, sw1, bw=10,delay=5ms, loss=10, max_queue_size=1000, use_htb=True)                          self.addLink(aSwitch[L1 + i],eSwitch[L1 +j])               #add hosts and its links with edgeovs               count = 1               for sw1 in eSwitch:                  for i in range(L1):                          host = self.addHost(h{}.format(count))                             self.addLink(sw1,host)                             count += 1  topos= {mytopo:(lambda:MyTopo())}  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.
随机为您推荐
版权声明:本站资源均来自互联网,如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

Copyright © 2016 Powered by Mininet模拟不同数据中心的网络拓扑,全栈开发  滇ICP备2023006006号-32sitemap

回顶部