【问题标题】:Show all connected Switches in a SDN with pox controller使用 pox 控制器显示 SDN 中所有连接的交换机
【发布时间】:2016-03-09 18:36:23
【问题描述】:

我的环境是 mininet。我试图实现的是,每次开关连接或断开 pox 控制器时,控制器都应打印所有连接的开关(它们的 DPID)。

def _handle_ConnectionUp (self, event):

print "Switch %s has come up." % event.dpid

这是我可以使用的东西吗?在我可以使用 _handle_ConnectionUp 之前我需要实现什么?

提前致谢。

【问题讨论】:

    标签: switch-statement mininet sdn pox


    【解决方案1】:

    最好的方法是在你的控制器类中定义一个集合,并在那里添加所有开关的 DPID。因此,每次您在 _handle_ConnectionUp 中有事件时,您都可以获得交换机的 DPID 并相应地添加它。

    在你的主控制器类初始化函数中

    self.switches = set()
    

    和 _handle_ConnectionUp 函数

    def _handle_ConnectionUp(self, event):
            """
            Fired up openflow connection with the switch
            save the switch dpid
            Args:
                event: openflow ConnectionUp event
            Returns: Nada
            """
            self.switches.add(pox.lib.util.dpid_to_str(event.dpid))
    

    因此,如果需要,您应该捕获 Connection Down 事件以移除开关。要获取 POX 控制器的 Dart 版本中当前可用的所有 openflow 事件 mixin 的列表,请转到 event mixins 处的https://github.com/noxrepo/pox/blob/dart/pox/openflow/init.py line 336

     _eventMixin_events = set([
        ConnectionUp,
        ConnectionDown,
        FeaturesReceived,
        PortStatus,
        FlowRemoved,
        PacketIn,
        BarrierIn,
        ErrorIn,
        RawStatsReply,
        SwitchDescReceived,
        FlowStatsReceived,
        AggregateFlowStatsReceived,
        TableStatsReceived,
        PortStatsReceived,
        QueueStatsReceived,
        FlowRemoved,
      ])
    

    如需进一步帮助,您可以使用 Dart POX 检查功能齐全的 SDN 控制器的代码,我为希腊塞萨洛尼基的 Python Meetup 编写,可以在https://github.com/tsartsaris/pythess-SDN找到。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-12
      相关资源
      最近更新 更多