qq_57142785 2024-03-05 16:29 采纳率: 0%
浏览 16
已结题

floodlight拓扑错误

mininet自带的可视化构建拓扑工具,构建拓扑,连接floodlight之后可以在web ui界面显示连接

img

img


但是保存为.py文件之后,使用python2 命令显示不了完整的拓扑图,但是链路存在

img

img

以下为3.2.py文件内容:

#!/usr/bin/env python

from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf
from subprocess import call

def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/24')

    info( '*** Adding controller\n' )
    c0=net.addController(name='c0',
                      controller=RemoteController,
                      ip='127.0.0.1',
                      protocol='tcp',
                      port=6653)

    info( '*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s12 = net.addSwitch('s12', cls=OVSKernelSwitch)
    s9 = net.addSwitch('s9', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch)
    s14 = net.addSwitch('s14', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s10 = net.addSwitch('s10', cls=OVSKernelSwitch)
    s13 = net.addSwitch('s13', cls=OVSKernelSwitch)
    s7 = net.addSwitch('s7', cls=OVSKernelSwitch)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
    s6 = net.addSwitch('s6', cls=OVSKernelSwitch)
    s11 = net.addSwitch('s11', cls=OVSKernelSwitch)
    s8 = net.addSwitch('s8', cls=OVSKernelSwitch)
    s4 = net.addSwitch('s4', cls=OVSKernelSwitch)

    info( '*** Add hosts\n')
    h19 = net.addHost('h19', cls=Host, ip='10.0.0.19', defaultRoute=None)
    h14 = net.addHost('h14', cls=Host, ip='10.0.0.14', defaultRoute=None)
    h10 = net.addHost('h10', cls=Host, ip='10.0.0.10', defaultRoute=None)
    h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
    h23 = net.addHost('h23', cls=Host, ip='10.0.0.23', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h15 = net.addHost('h15', cls=Host, ip='10.0.0.15', defaultRoute=None)
    h11 = net.addHost('h11', cls=Host, ip='10.0.0.11', defaultRoute=None)
    h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
    h26 = net.addHost('h26', cls=Host, ip='10.0.0.26', defaultRoute=None)
    h24 = net.addHost('h24', cls=Host, ip='10.0.0.24', defaultRoute=None)
    h16 = net.addHost('h16', cls=Host, ip='10.0.0.16', defaultRoute=None)
    h12 = net.addHost('h12', cls=Host, ip='10.0.0.12', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
    h8 = net.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None)
    h20 = net.addHost('h20', cls=Host, ip='10.0.0.20', defaultRoute=None)
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h17 = net.addHost('h17', cls=Host, ip='10.0.0.17', defaultRoute=None)
    h13 = net.addHost('h13', cls=Host, ip='10.0.0.13', defaultRoute=None)
    h21 = net.addHost('h21', cls=Host, ip='10.0.0.21', defaultRoute=None)
    h27 = net.addHost('h27', cls=Host, ip='10.0.0.27', defaultRoute=None)
    h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
    h9 = net.addHost('h9', cls=Host, ip='10.0.0.9', defaultRoute=None)
    h22 = net.addHost('h22', cls=Host, ip='10.0.0.22', defaultRoute=None)
    h18 = net.addHost('h18', cls=Host, ip='10.0.0.18', defaultRoute=None)
    h25 = net.addHost('h25', cls=Host, ip='10.0.0.25', defaultRoute=None)

    info( '*** Add links\n')
    net.addLink(s6, s2)
    net.addLink(s7, s2)
    net.addLink(s8, s2)
    net.addLink(s9, s3)
    net.addLink(s10, s3)
    net.addLink(s11, s3)
    net.addLink(s12, s4)
    net.addLink(s4, s13)
    net.addLink(s14, s4)
    net.addLink(s2, s3)
    net.addLink(s3, s4)
    net.addLink(s4, s5)
    net.addLink(s1, s2)
    net.addLink(h1, s6)
    net.addLink(s6, h2)
    net.addLink(h3, s6)
    net.addLink(s7, h4)
    net.addLink(s7, h5)
    net.addLink(s7, h6)
    net.addLink(s8, h7)
    net.addLink(s8, h8)
    net.addLink(s8, h9)
    net.addLink(s9, h10)
    net.addLink(s9, h11)
    net.addLink(s9, h12)
    net.addLink(s10, h13)
    net.addLink(s10, h14)
    net.addLink(s10, h15)
    net.addLink(s11, h16)
    net.addLink(s11, h17)
    net.addLink(s11, h18)
    net.addLink(s12, h19)
    net.addLink(s12, h20)
    net.addLink(s13, h22)
    net.addLink(s12, h21)
    net.addLink(s13, h23)
    net.addLink(s13, h24)
    net.addLink(s14, h25)
    net.addLink(s14, h26)
    net.addLink(s14, h27)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s1').start([c0])
    net.get('s12').start([c0])
    net.get('s9').start([c0])
    net.get('s5').start([c0])
    net.get('s14').start([c0])
    net.get('s2').start([c0])
    net.get('s10').start([c0])
    net.get('s13').start([c0])
    net.get('s7').start([c0])
    net.get('s3').start([c0])
    net.get('s6').start([c0])
    net.get('s11').start([c0])
    net.get('s8').start([c0])
    net.get('s4').start([c0])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
if __name__ == '__main__':
    setLogLevel('info')
    myNetwork()
> 
> 

  • 写回答

21条回答 默认 最新

  • 码农阿豪@新空间代码工作室 Java领域优质创作者 2024-03-06 15:50
    关注
    获得0.40元问题酬金
    让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言
    问题:保存为.py文件之后,使用python2命令无法显示完整的拓扑图,但是链路存在,如何解决? 回答: 出现这种情况一般是因为拓扑图文件中的部分代码没有被正确执行。可以尝试以下几个步骤来解决问题:
    1. 检查拓扑图文件中代码的正确性。特别注意缩进是否正确,语法是否正确等。
    2. 重新运行一遍代码,确保代码没有出错。
    3. 针对代码中显示不完整的拓扑图部分,尝试手动在终端中使用mn命令进行构建拓扑图,并查看是否存在同样的问题。如果手动构建也无法显示完整的拓扑图,则可能是因为缺少某些依赖。可以使用命令“sudo mn -v debug”来获取详细的错误信息。
    4. 修改代码中的log级别,以便更方便地查找问题。可以在代码的开头添加如下代码:setLogLevel('info'),然后查看代码执行过程中产生的log信息,找到相关的错误信息。 代码示例: 在代码开头添加如下代码,可以查看更多的log信息: from mininet.log import setLogLevel setLogLevel('info')
    评论

报告相同问题?

问题事件

  • 系统已结题 3月13日
  • 创建了问题 3月5日

悬赏问题

  • ¥15 鼠标右键,撤销删除 复制 移动,要怎样删除
  • ¥15 使用MATLAB进行余弦相似度计算加速
  • ¥15 服务器安装php5.6版本
  • ¥15 我想用51单片机和数码管做一个从0开始的计数表 我写了一串代码 但是放到单片机里面数码管只闪烁一下然后熄灭
  • ¥20 系统工程中,状态空间模型中状态方程的应用。请猛男来完整讲一下下面所有问题
  • ¥15 我想在WPF的Model Code中获取ViewModel Code中的一个参数
  • ¥15 arcgis处理土地利用道路 建筑 林地分类
  • ¥20 使用visual studio 工具用C++语音,调用openslsx库读取excel文件的sheet问题
  • ¥100 寻会做云闪付tn转h5支付链接的技术
  • ¥15 DockerSwarm跨节点无法访问问题