Upload
-
View
191
Download
14
Embed Size (px)
Citation preview
RYU 学习指南State Key Laboratory of Networking and Switching Technology
Future Networking LaboratoryCheng Li
AgendaWhat is RYU
How RYU workHow to develop
What RYU can do
What is RYU
Ryu is a component-based software defined networking framework.
What is RYU
OSS SDN Framework founded by NTT:•Python library for SDN•Apache v2 license•Supports various protocols for managing network devices: - OpenFlow, Netconf, OF-config, SNMP etc.
Features:•OpenFlow - Version:1.0,1.2,1.3,1.4,1.5•Parsing and building various protocols packets: - IP, UDP,TCP,MPLS…•Ryu can configure Open vSwitch directly without ovs-vsctl, ovsdb-client•Integration with other project - OpenStack - HA with Zookeeper - IDS(Intrusion Detection System) with snort
What RYU can do
• Various SDN Application and library: - simple_switch firewall router… - LACP,STP… - RESTAPI, RPC• Integration with other project: - OpenStack - HA with Zookeeper - IDS(Intrusion Detection System) with snort
• Topology Viewer - Topology discovery - Flow entry management.
Mininet 创建的 host , switch 等实例实际上是运行在不同 namespace 下的某个进程。默认情况下 Host 运行在自己的 namespace 中,交换节点运行在 root namespace 中。
User RYU 在工业界得到了不错的应用,使用 RYU 作为控制器的厂家包括 pica8, centec , broadcom 等。开源软件交换机 OVS,CPQD 等也均支持 RYU 控制器。更多企业的 SDN 解决方案采用 RYU控制器。
RYU 以其轻巧,快速开发,协议支持完整,支持和其他开源软件协同工作的特点,在开源控制器的竞争中获得了一席之地。
Ref: http://www.slideshare.net/apnic/ryu-sdn-framework?qid=b548fb40-1f9d-477c-ad35-2b9c85f47358&v=default&b=&from_search=1
How to develop• Installation
• Getting started
• CLI
• GUI
• RESTAPI
• Simple_switch
Installation• Pip install
~pip install ryu
• Native Installation form Source~git clone https://github.com/osrg/ryu.git~cd ryu~sudo python setup.py install
• Installhelper~git clone https://github.com/sdnds-tw/ryuInstallHelper.git~cd ryuInstallHelper~./ryuInstallHelper.sh
Getting StartedStartup Options
●ryu-manager 启动 ryu, 如果不加任何参数,则默认启动 ofphandler 模块。●ryu run 等同于 ryu-manager●Ryu-manager –h 查看帮助信息●--verbose 打印详细信息●--version●--observe-links 自动下发 LLDP ,用于拓扑发现。●…
●Example: ryu-manager simple_switch.py ofctl_rest.py –observe-links
CLICLI register
●参数注册统一使用 oslo : OpenStack Common Libraries 。
●cfg.py: CONF=oslo.config.cfg.ConfigOpts()
●from ryu import cfg :cfg 模块定义了 CONF 对象
●CONF.register_cli_opts([cfg.StrOpt(“wsapi-port”, default =8080, help = ‘webapp listen port’ )])
GUI● 使用官方 GUI
o 官方提供 GUI 套件o 详细教程:
http://www.muzixing.com/pages/2015/04/21/ryu316-guian-zhuang-yu-topologymo-kuai-fen-xi.html
● 使用第三方 GUIo 第三方 GUI 提供者有很多o http://sdnhub.org/releases/sdn-starter-kit-ryu/o ANT GUI
GUI
GUI
GUI
RESAT APIRYU 提供了 RESTAPI , 用于可以使用 RESTAPI 来开发应用程序。•Ofctl_rest.py 提供 OpenFlow 方面的 REST API 接口:
get the list of all switches GET /stats/switches get the desc stats of the switch GET /stats/desc/<dpid> get flows stats of the switch GET /stats/flow/<dpid> get flows stats of the switch filtered by the fields : POST /stats/flow/<dpid>
•Rest_topology.py 提供获取拓扑相关 API: get all the switches GET /v1.0/topology/switches get the switch GET /v1.0/topology/switches/<dpid> get all the links GET /v1.0/topology/links get the links of a switch GET /v1.0/topology/links/<dpid>
Write your first APPhttp://ryu.readthedocs.org/en/latest/writing_ryu_app.html
Program model
Simple hub
Simple hub
Controller
SwitchHost A Host C
Host B
Packet Packet
Packet
Packet INPacket out
Simple hub
控制器需要做的事情:•创建一个 app 类,用于描述 hub 的行为:
•注册监听 Packet_in 事件的处理函数,用于处理 packet_in 事件
Event
EventOFPMsgBase
Eventbase
OFPEVENT
EventMSG(datapath, version,msg_type, msg_len, xid, buf)
Datapath
ProtocolDesc(ofproto, ofproto_parser)
Others
OFPActionOutput
OFPActionOutput
OFPAction
OFPActionHeader
StringifyMixin
Simple switch
控制器需要做的事情:•创建一个 app 类,用于描述 switch 的行为:
•注册监听 Packet_in 事件的处理函数,用于处理 packet_in 事件:相比 hub ,多了 MAC 地址自学习功能
•链接: http://osrg.github.io/ryu-book/en/html/switching_hub.html
Parsing Packet
Building Packet
Traffic Monitor
控制器需要做的事情:•创建一个 app 类,用于描述流量监控,继承 Simple switch ;
•完成发送获取网络信息报文的函数;
•注册处理统计数据回复报文的 handler 。
•教程:•http://osrg.github.io/ryu-book/en/html/traffic_monitor.html•http://www.muzixing.com/pages/2015/03/04/traffic-monitor-in-ryu.html
Controller
Switch
Stats_reqeust Stats_reply
How RYU work• Architecture
• RYU code
• Call Graph
Architecture
RYU code
Call Graph
Data plane
Main(RYU)
AppManager
Service brick (event router)
OpenVSwitch
OFHandler(RyuAPP)
ofprotoofproto_v1_* ofproto_v1_*_parser
OpenFlowController
Hello handler
Switch features handler
Handlers…
libARP ipv4… icmp
Datapaths
dp1 dp2 dp3 dpn
StreamServer
OpenVSwitch
OpenVSwitchSocket Client
Read&wirte socketSocket server
connect
CONF
APPn APP2 OFPHandlerAPP list
even
t event
event
response
New datapath
Thank youMUZIXING.COM
State Key Laboratory of Networking and Switching TechnologyFuture Networking Laboratory
Cheng Li