RYU Introduction

Post on 16-Jan-2017

813 views 3 download

Transcript of RYU Introduction

RYU shanyu@sdnds-tw

Outline

❖ Introduction to RYU❖ Environment Setup❖ Basic RYU Operation❖ RYU Application Development❖ RYU Restful API

Outline

❖ Introduction to RYU❖ Environment Setup❖ Basic RYU Operation❖ RYU Application Development❖ RYU Restful API

RYU❖ Ryu is a component-based software defined networking

framework❖ Fully written in Python❖ Ryu supports various protocols for managing network

devices OpenFlow 1.0, 1.2, 1.3, 1.4, Netconf, OF-config, SNMP etc.

Official site:• http://osrg.github.io/ryu/Mailing list:• https://lists.sourceforge.net/lists/listinfo/ryu-develAPI Documentation:• http://ryu.readthedocs.org/en/latest/RyuBook Tutorial (Chinese):• http://osrg.github.io/ryu-book/zh_tw/html/

Controller and Switch OpenFlow Message

CONFIG_DISPATCHER

HANDSHAKE_DISPATCHER

MAIN_DISPATCHER

DEAD_DISPATCHER

RYU four status

RYU OpenFlow MessageType Message Name Ryu OpenFlow Message

Controller-to-Switch

Features OFPFeaturesRequest / OFPSwitchFeatures

Configuration OFPSetConfig

Packet-out OFPPacketOut

Modify-State OFPFlowModRead-State OFPFlowStatsRequest/OFPFlowStatsReply

OFPPortStatsRequest/OFPPortStatsReplyBarrier OFPBarrierRequest/OFPBarrierReply

Asynchronous(switch->controller)

Packet-In OFPPacketInFlow Removed OFPFlowRemoved

Port Status OFPPortStatusError OFPErrorMsg

Symmetric(switch<->controller)

Hello OFPHelloEcho Request / Reply OFPEchoRequest/OFPEchoReply

Vender OFPExperimenter

RYU Application Programming Model

❖ Data path thread 接收所有來自 OpenFlow switch events❖ Asynchronous messages❖ Switch reply messages

❖ Data path thread 收到 event 後即分配給所有有註冊這 event 的 application❖ 每個 Application 維護自己的 Event queue❖ decorator (@) 接收事件

❖ Programmer 定義 Event Handler

(Event Dispatcher)

Outline

❖ Introduction to RYU❖ Environment Setup❖ Basic RYU Operation❖ RYU Application Development❖ RYU Restful API

Environment Setup❖ All-in-one tutorial VM contains:

❖ SDN Controllers: OpenDaylight, ONOS, RYU, Floodlight, Floodlight-OF1.3, POX, and Trema

❖ Open vSwitch 2.3.0 with support for Openflow 1.2, 1.3 and 1.4, and LINC switch

❖ Mininet to create and run example topologies❖ Pyretic❖ Wireshark 1.12.1 with native support for OpenFlow parsing❖ JDK 1.8, Eclipse Luna, and Maven 3.3.3

❖ Update newest RYU version$ cd ~/ryu$ git fetch$ git merge origin$ python ./setup.py install http://sdnhub.org/tutorials/sdn-tutorial-vm/

Outline

❖ Introduction to RYU❖ Environment Setup❖ Basic RYU Operation❖ RYU Application Development❖ RYU Restful API

Basic RYU operation - CLI❖ ryu-manager, ryu run

❖ 啟動 ryu❖ --h

❖ Show help message❖ --verbose

❖ Show debug output❖ --version

❖ Show program’s version❖ --observe-links

❖ 定期發送 LLDP 封包❖ Example:

$ cd ~/ryu/$ ./bin/ryu-manager --observe-links ryu/app/simple_switch.py

ryu.app.simple_switch

Basic RYU operation - GUI

$ ./bin/ryu-manager --observe-links ryu.app.gui_topology.gui_topology ryu.app.simple_switch

$ sudo mn --topo=single,3 --controller=remote --mac

Outline❖ Introduction to RYU❖ Environment Setup❖ Basic RYU Operation❖ RYU Application Development

❖ Simple Switch❖ Traffic Monitor❖ Lab

❖ RYU Restful API

RYU application – Simple Switch

• mac_to_port 目前所學習到連接埠與 host 之 MAC 對應關係• Receive pkt_in dst_mac 存在於 mac_to_port -> 轉送該封包到相對應的連接埠 dst_mac 不存在於 mac_to_port -> Flood

Simple Switch – Example (1/4)❖ Initial status

Simple Switch – Example (2/4)❖ Host A -> Host B

❖ Host A triggers Packet-In message❖ Record Host A MAC

❖ Host B has not been found, the packets are flooded❖ Host B and host C received

Simple Switch – Example (3/4)❖ Host B -> Host A

❖ When the packets are returned from host B to host A❖ Host B triggers Packet-In message

❖ Record Host B MAC ❖ Controller installs an entry to the flow table and also the

packets are transferred to port 1.

Simple Switch – Example (4/4)❖ Host A -> Host B

❖ Controller installs an entry to the flow table

RYU application – Traffic Monitor

Controller

OpenFlowSwitch

Stats_reqeust Stats_reply

https://github.com/osrg/ryu-book/blob/master/en/source/sources/simple_monitor.py

Outline

❖ Introduction to RYU❖ Environment Setup❖ Basic RYU Operation❖ RYU Application Development❖ RYU Restful API

RYU Restful API

OpenFlowSwitch

SDN App SDN App

RYU APP RYU APP

OpenFlowSwitch

NetworkDevice

Event Dispatcher

Libraries

RYU provided restful API:/ryu/app/rest*.py/ryu/app/ofctl_rest.py

Open Protocol(OpenFlow, OF-config, NetConf..)

Control layer

Well-defined API(REST, RPC)

Application layer

Reference❖ SDNDS-TW

❖ http://sdnds.tw/

❖ RYU Contributor

❖ John-Lin

❖ http://linton.tw/

❖ http://www.slideshare.net/ireri339/sdndstw-ryu-developing

❖ Tseng Yi

❖ http://blog.takeshi.tw/about.html

Thank you

補充 – OpenFlow

OpenFlow - Controller-to-Switch (1/6)

❖ Controller sends a Feature request message to the switch to get the capabilities of a switch

❖ Switch must reply with a Feature reply that specifies the capabilities supported by the switch max packets buffered at once capabilities supported by switch

flow statis, table statis, port statis, reassemble IP fragments,... actions supported by the switch

SET_VLAN_VID, SET_DL_SRC, SET_DL_DST, ENQUEUE,... describe all the physical ports (which support OpenFlow)

port no, hw addr, state,...

OpenFlow - Controller-to-Switch (2/6)

❖ SET_CONFIG Controller send a SET_CONFIG message to set configuration parameters in

the switch max bytes of new flow that switch should send to the controller handling of IP fragments (normal, drop, reassemble,...)

❖ GET_CONFIG Controller send a GET_CONFIG Request message to query configuration

parameters in the switch Switch responds to a configuration request with an GET_CONFIG Reply

message

OpenFlow - Controller-to-Switch (3/6)

❖ Controller sends Packet_out of a specified port on the switch buffer_id in_port

port = TABLE actions

OpenFlow - Controller-to-Switch (4/6)

❖ Controller send Flow_mod message to switch to add/delete/modify flows in the flow tables ❖ match fields❖ idle/hard timeout❖ buffer_id❖ actions

OpenFlow - Controller-to-Switch (5/6)

❖ Stats request is used by the controller to collect statistics ❖ Switches flow-tables, ports and the individual flow entries

❖ switch responds with one or more Stats reply messages

OpenFlow - Controller-to-Switch (6/6)

❖ Controller to ensure message dependencies have been met or to receive notifications for completed operations

❖ Switch must finish processing all previously-received messages before executing any messages beyond the Barrier request

❖ switch must send an Barrier reply message when such processing is complete

OpenFlow - Asynchronous

❖ Packet_in❖ Packet_in message (event) is sent to the controller when

❖ a packet do not have a matching flow entry❖ a packet matches an entry with a "send to controller" action

❖ Flow_removed ❖ Switch sends a Flow_removed message to controller when

❖ flow time out❖ delete flow using Flow_removed message by controller

❖ Port_status❖ As physical ports are added, modified, and removed from the switch

OpenFlow - Symmetric

❖ Hello❖ Hello messages are exchanged between the switch and

controller upon connection startup❖ version negotiation

❖ Echo❖ indicate liveness of a controller-switch connection

❖ Vendor❖ Offer additional functionality within the OpenFlow message type space