来自 OpenFlow(RYU 控制器)的关于交换机和端口的信息 [英] Information about Switches and Ports from OpenFlow (RYU Controller)

查看:104
本文介绍了来自 OpenFlow(RYU 控制器)的关于交换机和端口的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 OpenFlow 获取一些关于我在 RYU 上的 OpenFlow 应用程序的信息.

I am attempting to get some information from OpenFlow for my OpenFlow Application on RYU.

我想得到的信息如下.

对于每个开关,我想要

        - DPID
        - STATE   (ACTIVE/INACTIVE)

对于每个端口,我想要

         - DPID
         - PORT_NUMBER
         - STATE
         - PORT_STATE

端口状态 - 跟踪来自 OF 的端口状态消息.1 - 主动.0 - INACTIVE.OpenFlow 1.0 有两种来自内存的端口状态,一种是关于端口是否有链接,另一种是关于端口是否在管理上.我相信此端口状态会跟踪第二种类型 - 即,如果端口在管理上处于开启状态,即使它没有链接,端口状态也应为 1.

Port state - Tracks Port Status message from OF. 1 - ACTIVE. 0 - INACTIVE.OpenFlow 1.0 has 2 types of port status from memory, one concerning whether the port has link and the other concerning whether the port is administratively up. I believe this port status tracks the second type - i.e. port status should be 1 if the port is administratively up even if it doesn't have a link.

我应该听哪些消息来获取上述信息.我也尝试获取有关 ofp_event.EventOFPStateChange 的信息.

Which messages should I listen to to get the above information.Also I tried getting information about ofp_event.EventOFPStateChange.

我尝试查看 http://ryu.readthedocs.org/en/latest/genindex.html我找不到与 ofp_event.EventOFPStateChange 相关的信息.

I tried looking at http://ryu.readthedocs.org/en/latest/genindex.html I couldn't find the information related to ofp_event.EventOFPStateChange.

如果能帮助我指明正确的方向,我们将不胜感激.

Any help to point me in the right direction would be highly appreciated.

推荐答案

您可以使用以下代码.我正在使用它来识别连接到它的所有交换机.我只需要 DPID 和输出端口.但是您可以使用ev.link"获取其他信息.希望这可以帮助.`

You can use the following code. I am using it to identify all switches connected to it. I needed only the DPIDs and out ports. But you can use 'ev.link' for other information. Hope this helps. `

class OF13(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]

_CONTEXTS = {
    'dpset': dpset.DPSet,
}

def __init__(self, *args, **kwargs):
    super(OF13, self).__init__(*args, **kwargs)
    self.dpset = kwargs['dpset']     

def _get_hwaddr(self, dpid, port_no):
    return self.dpset.get_port(dpid, port_no).hw_addr

@handler.set_ev_cls(event.EventLinkAdd)
def link_add(self, ev):
    print ev.link.src, ev.link.dst
    print self._get_hwaddr(ev.link.src.dpid, ev.link.src.port_no)        

这篇关于来自 OpenFlow(RYU 控制器)的关于交换机和端口的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆