REST API services in Floodlight (Topology)
Introduction
- Topology這邊則是維護整個網路拓樸的資訊,包含Link、Cluster以及routing path。
- Topology的所有資訊都是建立於LinkDiscovery所發送的LLDP與BDDP,再搭配演算法去得到整個網路拓樸的情況。
- 每個Cluster都會包含一個以上的Switch,同一個Cluster內的Switch可以組成一個Strongly Connected Components (SCC)。
API
- /wm/topology/links/json : 回傳所有Links,盡可能回傳BIDRECTONAL
- Method: GET
- Parameter: 無,
- Code:
- TopologyWebRoutable.java
- LinksResource.java
- Example:
+ curl -s http://127.0.0.1:8080/wm/topology/links/json | python -mjson.tool
[
{
"direction": "bidirectional",
"dst-port": 1,
"dst-switch": "00:00:00:00:00:00:00:04",
"src-port": 3,
"src-switch": "00:00:00:00:00:00:00:01",
"type": "internal"
},
{
"direction": "bidirectional",
"dst-port": 1,
"dst-switch": "00:00:00:00:00:00:00:05",
"src-port": 4,
"src-switch": "00:00:00:00:00:00:00:01",
"type": "internal"
},
{
"direction": "bidirectional",
"dst-port": 1,
"dst-switch": "00:00:00:00:00:00:00:02",
"src-port": 1,
"src-switch": "00:00:00:00:00:00:00:01",
"type": "internal"
},
{
"direction": "bidirectional",
"dst-port": 1,
"dst-switch": "00:00:00:00:00:00:00:03",
"src-port": 2,
"src-switch": "00:00:00:00:00:00:00:01",
"type": "internal"
}
]
- /wm/topology/directed-links/json : 回傳所有Type是 DIRECT_LINK或是TUNNEL的Link,都以UNIDIRECTIONAL的方式呈現
- Method: GET
- Parameter: 沒有參數,就回傳所有符合條件的Links
- Code:
- TopologyWebRoutable.java
- DirectedLinksResource.java
- Example:
+ curl -s http://127.0.0.1:8080/wm/topology/directed-links/json | python -mjson.tool
[
{
"direction": "unidirectional",
"dst-port": 1,
"dst-switch": "00:00:00:00:00:00:00:05",
"src-port": 4,
"src-switch": "00:00:00:00:00:00:00:01",
"type": "internal"
},
{
"direction": "unidirectional",
"dst-port": 3,
"dst-switch": "00:00:00:00:00:00:00:01",
"src-port": 1,
"src-switch": "00:00:00:00:00:00:00:04",
"type": "internal"
},
{
"direction": "unidirectional",
"dst-port": 1,
"dst-switch": "00:00:00:00:00:00:00:01",
"src-port": 1,
"src-switch": "00:00:00:00:00:00:00:02",
"type": "internal"
},
{
"direction": "unidirectional",
"dst-port": 1,
"dst-switch": "00:00:00:00:00:00:00:03",
"src-port": 2,
"src-switch": "00:00:00:00:00:00:00:01",
"type": "internal"
},
{
"direction": "unidirectional",
"dst-port": 2,
"dst-switch": "00:00:00:00:00:00:00:01",
"src-port": 1,
"src-switch": "00:00:00:00:00:00:00:03",
"type": "internal"
},
{
"direction": "unidirectional",
"dst-port": 4,
"dst-switch": "00:00:00:00:00:00:00:01",
"src-port": 1,
"src-switch": "00:00:00:00:00:00:00:05",
"type": "internal"
},
{
"direction": "unidirectional",
"dst-port": 1,
"dst-switch": "00:00:00:00:00:00:00:04",
"src-port": 3,
"src-switch": "00:00:00:00:00:00:00:01",
"type": "internal"
},
{
"direction": "unidirectional",
"dst-port": 1,
"dst-switch": "00:00:00:00:00:00:00:02",
"src-port": 1,
"src-switch": "00:00:00:00:00:00:00:01",
"type": "internal"
}
]
- /wm/topology/external-links/json : 回傳透過BDDP所發現的Links。External-Links可以用來找出在網路環境中,不受controoler控制的switch的links。使用情境請參考這篇
- Method: GET
- Parameter: 沒有參數,就回傳所有符合條件的Links
- Code:
- TopologyWebRoutable.java
- ExternalLinksResource.java
- Example:
+ curl -s http://127.0.0.1:8080/wm/topology/external-links/json | python -mjson.tool
[
{
"src-switch": "00:00:00:00:00:00:00:02",
"src-port": 3,
"dst-switch": "00:00:00:00:00:00:00:03",
"dst-port": 3,
"type": "external",
"direction": "bidirectional"
}
]
- /wm/topology/tunnellinks/json : 回傳所有的tunnelLink,我還沒有嘗試過有tunnel的網路拓墣,所以此API也不是很了解,只能從code去看。
- Method: GET
- Parameter: 沒有參數,就回傳所有tunnelLinks,每條link都會以NodePortTuple的形式呈現,該型態包含了switch的DPID以及對應的Port
- Code:
- TopologyWebRoutable.java
- TunnelLinksResource.java
- Example:
+ curl -s http://127.0.0.1:8080/wm/topology/tunnellinks-links/json | python -mjson.tool
- /wm/topology/switchclusters/json : 回傳Controller底下的所有cluster,每個cluster是由一群switches所組成的SCC。
- Method: GET
- Parameter: 沒有參數,就回傳所有的cluster
- Code:
- SwitchClustersResource.java
- TopologyWebRoutable.java
- Example:
+ curl -s http://127.0.0.1:8080/wm/topology/switchclusters/json | python -mjson.tool
{
"00:00:00:00:00:00:00:01": [
"00:00:00:00:00:00:00:01",
"00:00:00:00:00:00:00:02",
"00:00:00:00:00:00:00:03",
"00:00:00:00:00:00:00:04",
"00:00:00:00:00:00:00:05"
]
}
由此範例可以看到目前網路拓墣中有一個cluster,包含了五個switches。cluster的識別碼就由最小的switch DPID來決定。由於是SCC的關係,這五個switches都有辦法傳送封包到彼此。
- /wm/topology/broadcastdomainports/json : 回傳所有的broadcast domain ports,此port跟externel link有關係。返回值代表某switch上的某port所連接到的是一個不受controller所控制的switch。所以未來若是有收到廣播封包的話,這邊的要收起來。
- Method: GET
- Parameter: 沒有參數,就回傳所有符合條件的NodePortTuple
- Code:
- TopologyWebRoutable.java
- BroadcastDomainPortsResource.java
- Example:
+ curl -s http://127.0.0.1:8080/wm/topology/broadcastdomainports/json | python -mjson.tool
[
{
"port": 1,
"switch": "00:00:00:00:00:00:00:05"
},
{
"port": 1,
"switch": "00:00:00:00:00:00:00:04"
},
{
"port": 1,
"switch": "00:00:00:00:00:00:00:03"
},
{
"port": 1,
"switch": "00:00:00:00:00:00:00:02"
}
]
- /wm/topology/enabledports/json : 回傳所有Switch上面的所有Ports。
- Method: GET
- Parameter: 沒有參數
- Code:
- EnabledPortsResource.java
- TopologyWebRoutable.java
- Example:
+ curl -s http://127.0.0.1:8080/wm/topology/enabledports/json | python -mjson.tool
[
{
"port": 1,
"switch": "00:00:00:00:00:00:00:02"
},
{
"port": 2,
"switch": "00:00:00:00:00:00:00:02"
},
{
"port": 65534,
"switch": "00:00:00:00:00:00:00:02"
},
{
"port": 1,
"switch": "00:00:00:00:00:00:00:03"
},
{
"port": 2,
"switch": "00:00:00:00:00:00:00:03"
},
{
"port": 65534,
"switch": "00:00:00:00:00:00:00:03"
},
{
"port": 1,
"switch": "00:00:00:00:00:00:00:04"
},
{
"port": 2,
"switch": "00:00:00:00:00:00:00:04"
},
{
"port": 65534,
"switch": "00:00:00:00:00:00:00:04"
},
{
"port": 1,
"switch": "00:00:00:00:00:00:00:05"
},
{
"port": 2,
"switch": "00:00:00:00:00:00:00:05"
},
{
"port": 65534,
"switch": "00:00:00:00:00:00:00:05"
}
]
- /wm/topology/blockedports/json : 此API我還沒有測試成功,看CODE也沒有發現情況的port會被加入到blockedports,會再寄信詢問。
- Method: GET
- Parameter: 沒有參數,就回傳所有符合條件的Links
- Code:
- TopologyWebRoutable.java
- BlockedPortsResource.java
- Example:
+ curl -s http://127.0.0.1:8080/wm/topology/blockedports/json | python -mjson.tool
- /mw/topology/route/{src-dpid}/{src-port}/{dst-dpid}/{dst-port/json : 一個用來找出最短路徑的REST API
- Method: GET
- Parameter:
+ src-dpid: source switch dpid
- src-port: source port of the source switch
- dst-dpid: destination switch dpid
- dst-port: destination port of the destination switch
- Code:
- TopologyWebRoutable.java
- RouteResource.java
- Example:
+ curl -s http://127.0.0.1:8080/wm/topology/route/00:00:00:00:00:00:00:04/2/00:00:00:00:00:00:00:07/2/json | python -mjson.tool
[
{
"port": 2,
"switch": "00:00:00:00:00:00:00:04"
},
{
"port": 3,
"switch": "00:00:00:00:00:00:00:04"
},
{
"port": 2,
"switch": "00:00:00:00:00:00:00:02"
},
{
"port": 3,
"switch": "00:00:00:00:00:00:00:02"
},
{
"port": 1,
"switch": "00:00:00:00:00:00:00:01"
},
{
"port": 2,
"switch": "00:00:00:00:00:00:00:01"
},
{
"port": 3,
"switch": "00:00:00:00:00:00:00:05"
},
{
"port": 2,
"switch": "00:00:00:00:00:00:00:05"
},
{
"port": 3,
"switch": "00:00:00:00:00:00:00:07"
},
{
"port": 2,
"switch": "00:00:00:00:00:00:00:07"
}
]
以一個 --topo tree,3的範例來說,若想要從switch4的port2到switch7的port2,可以得到上述結果的走法。