【问题标题】:Representation of Network topology in pythonpython中网络拓扑的表示
【发布时间】:2014-04-22 02:31:11
【问题描述】:

这是来自https://github.com/osrg/ryu/blob/master/ryu/topology/switches.py#L429的类开关的代码

Switches 类中我特别感兴趣的成员变量如下。

    self.dps = {}                 # datapath_id => Datapath class
    self.port_state = {}          # datapath_id => ports
    self.ports = PortDataState()  # Port class -> PortData class
    self.links = LinkState()      # Link class -> timestamp
    self.is_active = True

这些是 RYU 用来缓存拓扑详细信息的成员变量。我试图弄清楚如何使用以下变量来表示拓扑。

1) dps 是一个将 datapath_id 映射到 datapath 类的字典?

- Can someone explain to me what is a datapath_id and a datapath class?

2) port_state 是将数据路径 id 映射到端口的字典

- As per my understanding on a switch without a VLAN all the ports will belong to the           same datapath id? In case of a switch with VLAN ports on the switch can have multiple datapath id's. Is my understanding correct?

3) ports 又是一个将 Port 类映射到 PortData 类的字典?

- what does this mean?

4) links 又是一个字典,将 Link 类映射到时间戳

- again what does this mean?

我正在尝试了解 RYU 控制器如何使用上述结构存储拓扑信息。任何理解或解释方面的帮助将不胜感激。

【问题讨论】:

    标签: python networking switch-statement ethernet openflow


    【解决方案1】:

    一般来说,每个 OpenFlow 交换机都连接到特定端口上的控制器,交换机和控制器之间的每个此类连接都被视为单独的“数据路径”,通常称为 DPID(数据路径 ID)。

    链接被认为是属于 2 个 DPID 的端口之间的连接,因此 DPID 1 (PORT1) (PORT2)DPID2 是 SW1 P1 和 SW2 P1 之间的链接。

    我使用 POX 控制器,所以不太会使用 Ryu,但我认为您现在可以理解它了。

    【讨论】:

      【解决方案2】:

      以下是我对答案的看法:

      1. 为每个 datapth id 保存一个数据路径类。例如switches.py 的第 475 行: self.dps[dp.id] = dp 这样一来,只要有一个数据路径 id,就可以轻松找到整个类。

      2. PortState 在第 161 行定义为 PortState(dict),这意味着它是一个字典。 dict 的键为int port_no,值为OFPPort port
        所以self.port_state 保存了每个数据路径 ID 的端口。例如,self.port_state[1] 将包含数据路径 ID 为 1 的端口。

      3. PortDataState 在第 206 行定义为 PortDataState(dict),这意味着它是一个字典。就字典而言,它是某种双向链表。 看起来这更像是一个端口列表作为键,然后将它们的状态作为值。

      4. LinkState 跟踪链接。 对于srcdst 之间的链接,它会创建一个链接对象。并保存了dstsrc 之间的映射(这是使用self._map 结构完成的)。此外,对于每个创建的 Link 对象,它都会记录时间(我不知道为什么会这样做)。
        看看switches.py的第317行

      这是topo discovery in Ryu 的好教程。

      【讨论】:

        猜你喜欢
        • 2014-10-14
        • 2011-03-31
        • 2011-05-08
        • 1970-01-01
        • 1970-01-01
        • 2012-07-13
        • 1970-01-01
        • 2012-05-31
        • 2012-03-01
        相关资源
        最近更新 更多