ryu控制器与mininet连接的简单使用(2021.6.16)

进入ryu/ryu/app目录,然后启动相应模块:

ryu-manager --verbose simple_switch_13.py ofctl_rest.py rest_topology.py

simple_switch_13.py模块是一个简单的交换机,是openflow1.3的交换机。后面的两个文件是为了进行restapi的调用加载的,方便直接用浏览器查看。

ryu控制器与mininet连接的简单使用(2021.6.16)

 

 

 再启动mininet,远程连接ryu控制器(ip地址:192.168.231.131,如果是在一台虚拟机里,则为本地ip:127.0.0.1):

sudo mn --controller=remote,ip=192.168.231.131,port=6653 --switch=ovsk,protocols=OpenFlow13

ryu控制器与mininet连接的简单使用(2021.6.16)

 

 

 相应的,ryu控制器打开的终端输出信息:

ryu控制器与mininet连接的简单使用(2021.6.16)

 

 

 下面参考https://blog.csdn.net/qq_34415266/article/details/92795959

在浏览器中调用ryu的api

①得到某台交换机的状态信息:http://192.168.231.131(这里是控制器ip地址):8080/stats/desc/1

ryu控制器与mininet连接的简单使用(2021.6.16)

 

 

 ②查看交换机当前的流表:http://192.168.231.131(这里是控制器ip地址):8080/stats/flow/1

ryu控制器与mininet连接的简单使用(2021.6.16)

 

 ryu控制器与mininet连接的简单使用(2021.6.16)

 

 查询指定交换机上所有流表的统计信息:http://192.168.231.131(这里是控制器ip地址):8080/stats/table/1

ryu控制器与mininet连接的简单使用(2021.6.16)

 

 得到端口的统计信息:http://192.168.231.131(这里是控制器ip地址):8080/stats/port/1

ryu控制器与mininet连接的简单使用(2021.6.16)

 

 得到端口配置信息:http://192.168.231.131(这里是控制器ip地址):8080/stats/portdesc/1

ryu控制器与mininet连接的简单使用(2021.6.16)

 

 在浏览器中除了可以查询流表信息外,还可以对流表进行操作,但需要支持构造post、delete等请求的浏览器插件,如httprequester、restclient等。

我这里使用的是火狐的restclient。

安装restclient:附件组件-扩展-restclient-安装

点击ryu控制器与mininet连接的简单使用(2021.6.16)该插件进行使用。

 

 

例如,查看交换机1的状态信息:

ryu控制器与mininet连接的简单使用(2021.6.16)

 

 

其他例如:获取交换机流表

# 获取交换机列表
GET /stats/switches

# 获取某台交换机的设备信息
GET /stats/desc/<dpid>

# get flows desc stats of the switch
GET /stats/flowdesc/<dpid>

# get flows desc stats of the switch filtered by the fields
POST /stats/flowdesc/<dpid>

# 得到指定交换机的所有flow的状态信息
GET /stats/flow/<dpid>

# 有条件地查询某台交换机的流表
POST /stats/flow/<dpid>

# 查询指定交换机的全局统计流表的字段
GET /stats/aggregateflow/<dpid>

# 有条件的查询指定交换机的全局统计流表的字段
POST /stats/aggregateflow/<dpid>

# 查询指定交换机上所有流表的统计信息
GET /stats/table/<dpid>

# get table features stats of the switch
GET /stats/tablefeatures/<dpid>

# 得到端口的统计信息
GET /stats/port/<dpid>[/<port>]
# Note: Specification of port number is optional

# get queues stats of the switch
GET /stats/queue/<dpid>[/<port>[/<queue_id>]]
# Note: Specification of port number and queue id are optional
# If you want to omitting the port number and setting the queue id,
# please specify the keyword "ALL" to the port number
# e.g. GET /stats/queue/1/ALL/1

# get queues config stats of the switch
GET /stats/queueconfig/<dpid>[/<port>]
# Note: Specification of port number is optional

# get queues desc stats of the switch
GET /stats/queuedesc/<dpid>[/<port>[/<queue_id>]]
# Note: Specification of port number and queue id are optional
# If you want to omitting the port number and setting the queue id,
# please specify the keyword "ALL" to the port number
# e.g. GET /stats/queuedesc/1/ALL/1

# get meter features stats of the switch
GET /stats/meterfeatures/<dpid>

# get meter config stats of the switch
GET /stats/meterconfig/<dpid>[/<meter_id>]
# Note: Specification of meter id is optional

# get meter desc stats of the switch
GET /stats/meterdesc/<dpid>[/<meter_id>]
# Note: Specification of meter id is optional

# get meters stats of the switch
GET /stats/meter/<dpid>[/<meter_id>]
# Note: Specification of meter id is optional

# get group features stats of the switch
GET /stats/groupfeatures/<dpid>

# get groups desc stats of the switch
GET /stats/groupdesc/<dpid>[/<group_id>]
# Note: Specification of group id is optional (OpenFlow 1.5 or later)

# get groups stats of the switch
GET /stats/group/<dpid>[/<group_id>]
# Note: Specification of group id is optional

# get ports description of the switch
GET /stats/portdesc/<dpid>[/<port_no>]
# Note: Specification of port number is optional (OpenFlow 1.5 or later)

 

再比如更新交换机流表项

# 添加流表项
POST /stats/flowentry/add

# 修改所有匹配的流表项
POST /stats/flowentry/modify

# modify flow entry strictly matching wildcards and priority
POST /stats/flowentry/modify_strict

# delete all matching flow entries
POST /stats/flowentry/delete

# delete flow entry strictly matching wildcards and priority
POST /stats/flowentry/delete_strict

# delete all flow entries of the switch
DELETE /stats/flowentry/clear/<dpid>

# add a meter entry
POST /stats/meterentry/add

# modify a meter entry
POST /stats/meterentry/modify

# delete a meter entry
POST /stats/meterentry/delete

# add a group entry
POST /stats/groupentry/add

# modify a group entry
POST /stats/groupentry/modify

# delete a group entry
POST /stats/groupentry/delete

# modify behavior of the physical port
POST /stats/portdesc/modify

# modify role of controller
POST /stats/role

# send a experimeter message
POST /stats/experimenter/<dpid>

上一篇:BLE理论基础:协议栈、角色分类


下一篇:openTSDB详解之Stats