資訊人筆記

Work hard, Have fun, Make history!

使用者工具

網站工具


ccis_lab:sdn:ryu:ryu_topology_discovery_code_analysis_class

Ryu Topology Discovery Class

0x00 前言

0x01 LLDP 概述

0x02 原始碼類別

ryu/topology/switches.py 中有幾個主要類別

  • Port : 主要是監聽 EventPortXXX 事件的類別,保存 switches id, MAC address, port name, port number
  • Switch : 主要是監聽 EventSwitchXXX 事件類別,保存 datapath 類別以及其對應的 Port 類別組成的 port list
  • Link : 主要是監聽 EventLinkXXX 事件類別,保存 src port, dst port,因為 port 帶有 dpid 訊息,所以可以對應到 switches
  • Host : 主要是監聽 EventHostXXX 事件類別,保存 mac, port, ipv4, ipv6 等資訊
  • HostState : 這是一個 dictionary 類別,建立了從 mac address → Host class 的映射
  • PortState : 這是一個 dictionary 類別,建立了從 int port_no → OFPPort port 的映射
  • PortData : 這是 Port 的附加類別,保存 port 是否啟用,port lldp data,timestamp,以及 port 發送封包的數量 sent
  • PortDataState : 這也是一個 dictionary 類別,建立了從 Port class → PortData class 的映射
  • LinkState : 這也是一個 dictionary 類別,建立了從 Link class → timestamp 的映射
  • LLDPPacket : 這個類別定義了 RYU 中使用的 LLDP packet 封包格式、型態與內容,以及 parse LLDP 封包的方式
  • Switches : 這是一個繼承 app_manager.RyuApp 的類別,這個類別中實現了 LLDP 拓樸發現的主要邏輯

0x03 Port Class

<html>
<style>
pre { box-shadow: none; }
table, td { border: none; }
</style>

<body>
<script type='text/javascript' src='gistfy-app.herokuapp.com/github/nike1000/ryu/ryu/topology/switches.py?branch=master&slice=59:104&lang=python&style=github'></script>
</body>
</html>

*
is_reserved : 回傳了此 port 是否為保留 port, self._ofproto.OFPP_MAX 的值為 0xffffff00,可在 ryu/ofproto/ofproto_v1_3.py 中找到,其他的保留 port 則都會大於這個值
*
is_down : 回傳了此 port 是否關閉
*
is_live : 則回傳了此 port 是否開啟,與 is_down 為相反值
*
to_dict : 則回傳了這個 port 所屬的 dpid, port_no, hw_addr, name 等 dictionary 資訊

=====0x04 Switch Class=====

<html>
<style>
pre { box-shadow: none; }
table, td { border: none; }
</style>

<body>
<script type='text/javascript' src='
gistfy-app.herokuapp.com/github/nike1000/ryu/ryu/topology/switches.py?branch=master&slice=107:134&lang=python&style=github'></script>
</body>
</html>

  • add_port : 先取得一個 Port 類別,檢測不是保留 port 後就加進 port list 中
  • del_port : 從 port list 中移除 Port
  • to_dict : 將 dpid 與對應的 port list 轉成 dictionary 格式

0x06 Host Class

0x07 HostState Class

0x08 PortState Class

0x09 PortData

0x0A PortDataState

0x0B LinkState

0x0C LLDPPacket

0x0D Switches

ccis_lab/sdn/ryu/ryu_topology_discovery_code_analysis_class.txt · 上一次變更: 127.0.0.1