OpenDaylight REST APIsde 研究

 

 

RESTAPIs研究

 

 

 

 

作者:冀烨       QQ:35317626

OpenDaylightSDN研究群

@南京-冀烨

 

 

 

 

1 Topology REST APIs

在org.opendaylight.controller.topology.northbound包中。

TopologyNorthbound REST API

Authenticationscheme : HTTP Basic,Authenticationrealm : opendaylight,Transport :HTTP and HTTPS。默认使用HTTPSAuthentication

1.1 Topology REST APIs可提供的服务

客户端请求

服务器响应

GET:检测拓扑

topology

GET:检测用户配置连接

list

PUT:添加一个用户连接

topologyUserLinkConfig

1.2 Topology REST APIs数据模型

其REST数据元素及相应的XML配置细节如表4.2-1所示。

Data Elements

Data Types

XML Elements

名称(类型)

最大/最小 出现

edge

edge

tailNodeConnector(nodeConnector)

0/1

headNodeConnector(nodeConnector)

0/1

edgeProperties

edgeProperties

edge (edge)

0/1

properties/property

0/unbounded

list

topologyUserLinks

userLinks (topologyUserLinkConfig)

0/unbounded

node

node

type (string)

0/1

id (string)

0/1

nodeConnector

nodeConnector

type (string)

0/1

id (string)

0/1

node (node)

0/1

property

property

 

 

topology

topology

edgeProperties (edgeProperties)

0/unbounded

topologyUserLinkConfig

topologyUserLinkConfig

status (string)

0/1

srcNodeConnector (string)

0/1

dstNodeConnector (string)     

0/1

name (string)

0/1

表4.2-1 Topology REST APIs

其中,Topology的基本单元是:节点node,node的标识包括id和类型,头节点和尾节点连接器的连线组成边edge,edge和多个property的组合构成了具有实际属性的edgeProperties即有了一个具有实际特性的连接,若干edgeProperties的组合构成了Topology。

另外该APIs提供了TopologyUserLinkConfig组成的list,存储的是用户连接的配置信息。

UserLinks功能有待考证。

1.3 实验分析

1.3.1 实验拓扑

该拓扑是通过mininet进行创建,即用mininet来模拟SDN网络,拓扑创建命令如下:

mn--topo tree,depth=2,fanout=2 --controller=remote,ip=xxx.xxx.xxx.xxx,port=6633

1.3.2 实验抓包情况

1)获取拓扑

客户端请求topology信息

服务器应答topology信息

拓扑信息由连接组成,该拓扑的连接组成有:

(OF|2@OF|00:00:00:00:00:00:00:01->OF|3@OF|00:00:00:00:00:00:00:03)

(OF|3@OF|00:00:00:00:00:00:00:03->OF|2@OF|00:00:00:00:00:00:00:01)

(OF|3@OF|00:00:00:00:00:00:00:02->OF|1@OF|00:00:00:00:00:00:00:01)

(OF|1@OF|00:00:00:00:00:00:00:01->OF|3@OF|00:00:00:00:00:00:00:02)

其中箭头表示连接方向,@前面的数字表示交换机的端口,后面表示连接类型,后面的64位字符串是交换机的DPID。

2)配置UserLink

客户端配置UserLinks信息

服务器应答配置成功信息201

客户端配置UserLinks信息

服务器应答配置成功信息201

 

3)获取UserLinks信息

客户端请求UserLinks信息

服务器应答UserLinks信息(无Userlink)

配置成功的Userlink将显示如下拓扑:

该UserLink的配置信息为2号交换机的1端口和3号交换机的2端口连接

服务器应答UserLinks信息(存在Userlink)

2 Host Tracker REST APIs

本部分APIs的应用见HostTrackerNorthbound

本部分APIs提供追踪主机在网络中的位置的功能。主机位置通过Hostnode connector表示。Host node connector本质是一个逻辑实体,它表示一个交换机或端口。一个主机被IP地址和MAC地址所标识。

2.1 Host Tracker REST APIs可提供的服务:

请求分类

客户端请求

服务器响应

地址

GET:返回一个同IP地址参数匹配的主机

hostConfig

PUT:增加一个主机(若该主机IP存在,返回失败)

hostConfig

DELETE:删除一个主机

hostConfig

活动主机

GET:返回本网络所有主机的列表(通过PUT API配置,在网络中动态学习)

list

不活动主机

GET:返回本网络中静态配置和NodeConnector掉线的主机

list

2.2 Host Tracker REST APIs数据模型

Data Elements

Data Types

XML Elements

 

 

名称(类型)

最大/最小 出现

hostConfig

hostConfig

dataLayerAddress (string)

0/1

nodeType (string)

0/1

nodeId (string)

0/1

nodeConnectorType (string)

0/1

nodeConnectorId (string)

0/1

vlan (string)

0/1

staticHost (boolean)

0/1

networkAddress (string)

0/1

list

hosts

hostConfig (hostConfig)

0/1

表 4.2-2  Host Tracker REST APIs

2.3 实验分析

2.3.1 抓包分析

Mininet中进行操作:h1 ping h2

1)获取指定主机信息

客户端根据主机ip发出获取主机信息请求。

服务端返回主机信息,主要包括上述特征值。

2)删除指定主机

客户端发出删除指定ip主机的请求。

服务端返回403信息,并指出主机不是static类型。

3)获取活动主机信息

客户端发出获取活动主机请求。

由于操作是:h1 ping h2。所以返回活动的主机是10.0.0.1和10.0.0.2.

4)获取不活动主机信息

客户端发出获取不活动主机请求。

由于主机未活动,故未能看到主机的信息,应当是只有连接到交换机时方能获得信息。

3 Flow Programmer REST APIs

本部分APIs的应用见FlowProgrammerNorthbound

本部分APIs提供对流性能的编程。

3.1 Flow Programmer REST APIs可提供的服务:

请求分类

客户端请求

服务器响应

一般的流

GET:返回指定流的配置列表

list

指定节点上的流

GET:返回在某节点上的流的配置列表

list

指定节点上的静态流

GET:返回与可读的名字、nodeId匹配的流

flowConfig

PUT:增加或修改一个流的配置。若流存在则替换最近的流。

flowConfig

DELETE:删除流配置

(custom)

POST:切换流配置

(custom)

注:POST给服务器添加信息(例如,注释)

3.2 Flow Programmer REST APIs数据模型

Data Elements

Data Types

XML Elements

 

 

名称(类型)

最大/最小 出现

flowConfig

 

vlanPriority (string)

0/1

nwDst (string)

0/1

idleTimeout (string)

0/1

tosBits (string)

0/1

name (string)

0/1

dlSrc (string)

0/1

hardTimeout (string)

0/1

protocol (string)

0/1

node (node)

0/1

cookie (string)

0/1

installInHw (string)

0/1

tpDst (string)

0/1

nwSrc (string)

0/1

vlanId (string)

0/1

tpSrc (string)

0/1

ingressPort (string)

0/1

etherType (string)

0/1

dlDst (string)

0/1

priority (string)

0/1

actions (string)

0/unbounded

list

flowConfigs

flowConfig (flowConfig)

0/unbounded

Node

node

type (string)

0/1

id (string)

0/1

表4.2-3 Flow Programmer REST APIs

3.3 实验分析

3.3.1 实验拓扑

mininet输入如下命令:

mn --topo tree,depth=2,fanout=2--controller=remote,p=192.168.5.113,port=6633

将产生如下拓扑:

B.在交换机S2中写入流表项,发往h3主机的数据报都进行丢弃。

C.在mininet中输入命令:h1 ping h2

3.3.2 实验抓包分析

1)下发流表即FlowMod

客户端响应

服务器应答

图中的信息Success表示创建成功,返回201。

2)获取流表信息

客户端请求

服务端响应流表信息

3)获取指定交换机流表

客户端请求

由于该网络中的交换机只有一个流表,所以服务端的返回信息同(2)。

4)删除流表

客户端删除流表请求

服务器响应删除流表请求

删除成功,返回204。

4 Static Routing REST APIs

本部分APIs的应用见StaticRoutingNorthbound

本部分APIs涉及到静态路由的管理。

4.1  Static RoutingREST APIs 可提供服务:

请求分类

客户端请求

服务器响应

routes

GET:返回静态路由现状的列表

list

Route

GET:返回所提供配置名称的静态路由

staticRoute

PUT:增加新的静态路由(如果该路由存在,返回错误)

staticRoute

DELETE:删除静态路由

(custom)

4.2 Static Routing REST APIs数据模型

Data Elements

Data Types

XML Elements

 

 

名称(类型)

最大/最小 出现

list

staticRoutes

staticRoute (staticRoute)       

0/unbounded

staticRoute

staticRoute

name (string)

注:The name of the static route.

0/1

prefix (string)

注:The prefix for the route. Format: A.B.C.D/MM Where A.B.C.D is the Default Gateway IP (L3) or ARP Querier IP (L2)

0/1

nextHop (string)

注:NextHop IP-Address (or) datapath ID/port list: xx:xx:xx:xx:xx:xx:xx:xx/a,b,c-m,r-t,y

0/1

表4.2-4 Static Routing REST APIs

4.3 实验分析

4.3.1 抓包情况分析

1)设置静态路由

客户端向服务端设置静态路由请求。

服务端响应,返回201,创建成功

2)获取静态路由信息

客户端请求静态路由信息

请求成功,响应200,并返回静态路由信息。

----------StaticRoute-----------

StaticRoute:name = StaticRoute

StaticRoute:nexthop = 170.0.0.1

StaticRoute:prefix = 192.168.100.0/23

包括路由名称、网络号、下一跳地址

3)删除静态路由

客户端删除流表请求

删除成功,返回204.

5 Statistics REST APIs

本部分APIs的应用见StatisticsNorthbound

本部分APIs返回被南向的协议插件(如OpenFlow)公开的多种统计信息。

5.1 Statistics REST APIs可提供的服务:

请求分类

客户端请求

服务器响应

flow

GET:返回所有节点的所有流的统计信息的列表

list

port

GET:返回所有经过节点上的NodeConnector的端口统计信息

list

table

GET:返回在所有节点上的链表信息

list

Flow on a node

GET:返回指定节点上的流的统计信息的列表

nodeFlowStatistics

Port on a node

GET:返回所有经过指定节点上的NodeConnector的端口统计信息

nodePortStatistics

table on a node

GET:返回在指定节点上的链表信息

nodeTableStatistics

 

5.2 Statistics REST APIs数据模型

Data Elements

Data Types

XML Elements

 

 

名称(类型)

最大/最小 出现

action

action

type (actionType)    

0/1

flow

flow

actions (action)

0/unbounded

hardTimeout (short)

1/1

idleTimeout (short)

1/1

match (match)

0/1

priority (short)

1/1

id (long)

1/1

FlowStat

flowOnNode

flow (flow)

0/1

tableId (byte)

1/1

byteCount (long)

1/1

durationSeconds (int)

1/1

packetCount (long)

1/1

durationNanoseconds (int)

1/1

list

allTableStatistics

tableStatistics (tableStatistics)

0/unbounded

match

match

matchField (matchField)

0/unbounded

matchField

matchField

 

 

node

node

type (string)

0/1

id (string)

0/1

nodeConnector

nodeConnector

type (string)

0/1

id (string)

0/1

node (node)

0/1

nodeConnectorStatistics

nodeConnectorStatistics

receivePackets (long)

1/1

receiveBytes (long)

1/1

transmitErrors (long)

1/1

transmitPackets (long)

1/1

receiveDrops (long)

1/1

receiveOverRunError (long)

1/1

receiveErrors (long)

1/1

nodeConnector (nodeConnector)

0/1

transmitDrops (long)

1/1

transmitBytes (long)

1/1

collisionCount (long)

1/1

receiveCrcError (long)

1/1

receiveFrameError (long)

1/1

nodeFlowStatistics

flowStatistics

node (node)

0/1

flowStatistic (flowOnNode)

0/unbounded

nodePortStatistics

portStatistics

node (node)

0/1

portStatistic (nodeConnectorStatistics)

0/unbounded

nodeTable

nodeTable

id (string)

0/1

node (node)

0/1

nodeTableStatistics

tableStatistics

node (node)

0/1

tableStatistic (nodeTableStatistics)        

0/unbounded

 

nodeTableStatistics

maximumEntries (int)

1/1

name (string)

0/1

matchedCount (long)

1/1

activeCount (int)

1/1

lookupCount (long)

1/1

nodeTable (nodeTable)

0/1

表4.2-5 Statistics REST APIs

5.3 实验分析

5.3.1 实验拓扑

mn --topotree,depth=2,fanout=2 --controller=remote,ip=192.168.5.15,port=6633

即产生如下拓扑:

5.3.2 抓包情况分析

统计模块分别统计了三个交换机上的流的状况。除了一些交换机的基本信息外还会返回一些南向接口向上公开的统计信息,故可以调用SAL上的reader包中的类获取更详细的数据。

Flow信息包括:

getByteCount()

getDurationNanoseconds()

getDurationSeconds()

getPacketCount()

getTableId()

getFlow()

         Port信息包括:

getReceivePacketCount

getTransmitPacketCount

getReceiveByteCount

getTransmitByteCount

getReceiveDropCount

getTransmitDropCount

getReceiveErrorCount

getTransmitErrorCount

getReceiveFrameErrorCount

getReceiveOverRunErrorCount

getReceiveCRCErrorCount

getCollisionCount

Table信息包括:

getName()

getActiveCount()

getLookupCount()

getLookupCount()

getMaximumEntries():默认10000000

1)获取流统计信息

因之前在mininet中做过一次平all操作,所以这里面的流表略显多。

客户端发出获取流统计的请求。

 

2)获取端口统计信息

3)获取流表信息

客户端发出获取流表信息的请求。

交换机2的流表

交换机3的流表

交换机1的流表

服务端返回流表信息,由于每个交换机中的流表项默认有255项,服务端会把便利后的结果全数返回,所以数据量会很大,但真正有用的数据却不多,故取其中一个交换机的一项进行解析。

6 Subnets REST APIs

本部分APIs的应用见SubnetsNorthbound

本部分APIs用来管理子网。

6.1 Subnets RESTAPIs 可提供的服务:

请求分类

客户端请求

服务器响应

subnets

GET:列出给定范围的所有子网

list

subnet

GET:列出给定区域一个子网的配置

subnetConfig

PUT:增加一个子网到指定的区域,节点连接器可选

subnetConfig

DELETE:从指定区域删除子网

(custom)

POST:修改一个子网。用新的代替旧的。只有端口的列表可以修改。若不存在则新建子网。

subnetConfig

6.2 Subnets REST APIs 数据模型

Data Elements

Data Types

XML Elements

 

 

名称(类型)

最大/最小 出现

list

subnetConfigs

subnetConfig (subnetConfig)

0/unbounded

subnetConfig

subnetConfig

 

subnet (string)

0/1

name (string)

0/1

nodeConnectors (string)

0/unbounded

6.3 实验分析

6.3.1抓包情况分析

1)添加新的子网

创建子网11.1.1.254/16,其包括的交换机有1号交换机的1端口、2号交换机的2端口、3号交换机的3端口。

创建成功,返回201。

2)获取子网信息

客户端向服务端发出子网信息请求。

服务端返回子网信息,总共返回三个子网信息。

A.子网1

子网名:eng1

地址:11.1.1.254/16

包含内容:交换机1:端口1,交换机2:端口2,交换机3:端口3。

B.子网2

子网名:jiye2

地址:192.168.5.0/18

包含内容:无

C.子网3

子网名:jiye

地址:192.168.5.128/19

包含内容:交换机2:端口3

3)获取指定子网信息

客户端发出获取指定子网信息的请求。

获取成功,返回200。

子网信息:

子网名:jiye2

地址:192.168.5.0/18

包含内容:无

4)修改指定子网信息

发出修改请求,求改子网的地址为11.1.1.254/16。

请求成功,返回200。

5)删除指定子网

发出删除子网eng1的请求。

删除成功,返回204.

7 Switch Manager REST APIs

本部分APIs的应用见SwitchNorthbound

本部分APIs用来批准node、node connector、property的接入。

7.1 Switch Manager REST APIs 可提供的服务:

请求分类

客户端请求

服务器响应

nodes

GET:在网络上检索所有的节点和他们的属性

list

save

POST:保存最近的交换机设置

(custom)

node

GET:在网络上检索指定节点的节点连接器和他们的属性

list

node property

DELETE:删除指定节点的属性

(custom)

Node property value

PUT:增加一个转发层模式属性的描述给节点

(custom)

nodeConnector property

DELETE:删除节点连接器的属性

(custom)

7.2 Switch Manager REST APIs 数据模型

Data Elements

Data Types

XML Elements

 

 

名称(类型)

最大/最小 出现

list

nodes

nodeProperties (nodeProperties)

0/unbounded

node

node

type (string)

0/1

 

id (string)

0/1

nodeConnector

nodeConnector

type (string)

0/1

id (string)

0/1

node (node)

0/1

nodeConnectorProperties

nodeConnectorProperties

nodeconnector (nodeConnector)   

0/1

properties/property

0/unbounded

nodeProperties

nodeProperties

node (node)

0/1

properties/property

0/unbounded

7.3 实验分析

7.3.1 实验拓扑

7.3.2 抓包情况分析

1)获取全部交换机信息

客户端请求交换机信息

 

 

 

 

服务端响应。

2)存储交换机配置信息

客户端发起post请求。

保存成功,返回200。

3)获取单个交换机信息

客户端发出请求。

8 User Manager REST APIs

本部分APIs的应用见UserManagerNorthbound

本部分APIs用来管理用户,并且只能用于HTTPs协议。

8.1 User Manager REST APIs 可提供的服务:

请求分类

客户端请求

服务器响应

users

POST:增加一位新用户

userConfig

users

DELETE:删除一个用户

(custom)

8.2 User Manager REST APIs数据模型

Data Elements

Data Types

XML Elements

 

 

名称(类型)

最大/最小 出现

userConfig

userConfig

roles (string)

0/unbounded

password (string)

0/1

user (string)

0/1

 

configurationObject

 

 

8.3 实验分析

8.3.1 抓包分析

1)添加新用户

用户名:test、密码:testPass、角色(roles):Network-Admin

这里要特别注意url的写法

客户端向服务端发出post请求。(这里有一个疑问:POST和PUT的区别究竟是什么)。

创建成功,返回200。

2)删除用户

客户端发出删除用户请求

删除成功,返回200。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值