SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Downloaden Sie, um offline zu lesen
Ryu: SDN framework and Python
experience
Isaku Yamahata <yamahata@private.email.ne.jp>
<isaku.yamahata@gmail.com>
Pycon APAC 2013, September 14
Agenda
● Introduction
● Ryu: SDN framework
● Ryu Internals
– Openstack support
● Ryu development
● Python experience through Ryu
This presentation represents my personal view/opinion. Not Ryu project nor any companies.
Who am I?
● My background is OS/virtualization/cloud
– Not network guy
● Programming language
– C/C++/assembler
● Projects I've contributed
– Linux
– Virtualization
● Qemu, KVM, Xen
– OpenStack
● Nova, neutron(formarly quantum) Ryu plugin
– Open vSwitch
● My python experience had begun with OpenStack and Ryu
Introduction
What's SDN? And why?
●
Software Defined Networking
– Making network programmable
– http://www.opennetsummit.org/why-sdn.html
●
SDN is a disruptive technology that is making
networks programmable by ordinary programmers
using ordinary software running on ordinary
operating systems in ordinary servers. With SDN,
the introduction of new features becomes less
manual, less prone to error, and faster to
implement.
– [Paraphrased from the HotSDN ‘13 Solicitaion]
●
Software Defined Networking (SDN) is a refactoring
of the relationship between network devices and the
software that controls them.
● Motivations behind SDN
– Academic research
● Allow researchers to program/modify
switches freely
– Industry technology trends
● Virtualization/cloud technology
● Network is behind those technology
progress
● Networkig virtualization/automation
From http://opennetsummit.org/why.html
Separating data/control plan
From http://www.opennetsummit.org/why-sdn.html
SDN architecture
Openflow
datapath(hardware)
controlpath(software)
datapath(hardware)
controlpath(software) openflow
Openflow controller
Openflow protocol(tcp/ssl)
Ethernet switch Openflow ethernet switch
● protocol to control switches
Flow table and match/action
Openflow controller
Flow table
MAC
src
MAC
dst
IP
src
IP
dst
TCP
src
TCP
dst ... action
Packet in event
When entry miss
* * * * * 80
output
port N
port PacketportPacket
Packet match Action
Ryu, a component-based
software-defined networking
framework
What's Ryu?
流 龍
Flow
Oriental Dragion,
A god of water
Manages flow control to
enable intelligent networking
http://ja.wikipedia.org/wiki/%E8%B5%A4%E7%9B%AE%E5%9B%9B%E5%8D%81%E5%85%AB%E6%BB%9D
What's Ryu?
● a component-based software-defined
networking framework
● License: Apache 2.0
● Fully written in Python
● Supports various protocols for managing
network devices
– OpenFlow, Netconf, OF-config, SNMP etc.
●
Official site http://osrg.github.io/ryu/
●
MLhttps://lists.sourceforge.net/lists/listinfo/ryu-devel
●
Download https://github.com/osrg/ryu
●
Documentation http://ryu.readthedocs.org/en/latest/
● Wiki https://github.com/osrg/ryu/wiki
Supported features/protocols
● Openflow protoocol
– OF-wire: 1.0,1.2, 1.3, Nicira extension
– OF-config 1.1
● Non-openflow protocols
– Netconf, OVSDB, netflow, sflow,
VRRP, SNMP
● Snmp: Enterprise OID: 41786
– Ryu can configure Open vSwitch
directly without ovs-vsctl, ovsdb-client
Some features are under development. The patches can be found on ML archive.
● RyuApp, library
– Packet library
– STP, LACP
– Sample apps, etc...
– Conversion from/to JSON
representation from/to OF
– RPC to communicate/control Ryu
● Integration with other project
– OpenStack
– HA with Zookeeper
– IDS(Intrusion Detection System)
with snort
OF/firewall/router REST API
● OF REST (ofctl_reset)
– Insert/delete openflow rule
● Firewall (rest_firewall)
– Configure firewall
– https://github.com/osrg/ryu/wiki/Third-Party-Tools,-Etc.
● Router(rest_router)
– Configure router
Ryu
REST
OF REST API
add a flow entry
POST http://example.org/stats/flownetry/add
delete flow entries
DELETE http://example.org/stats/flowentry/delete
get flow stats
GET http://example.org/stats/flow/{dpid}
allow
drop
firewall
OF switch
Ryu
REST
OF switch
router
Topology Viewer
● Discover topology
by LLDP and
show
topology/flows
dynamically
HA support
● Centralized controller is single pointer of
failure(SPOF)
● Ryu + Zookeeper can be used to address
SPOF
Ryu Ryu
zookeeper
OF switch
master slave
failover
IDS support
● Snort integration
https://github.com/osrg/ryu/wiki/Snort-Integration
Ryu
OF switch
Sort
Control app IDS(snort)
1. L1-L4 matching
2. send patcket to IDS
3. alert4. take actions
e.g. loggingt
Ryu Internals
Ryu implementation
● Quite normal python program from the point of implementation
view
– It doesn't use any special tricks
● Event driven
– Event source/dispatcher/sink
– Core(= Event dispatcher) is very small
– It is so generic that Ryu can be used without OpenFlow
● Component based
– Event source/sink are created as components
● Even OpenFlow related codes are so
– Message passing via events, not directly communite.
Ryu architecture
● Follows standard SDN architecture
OpenFlow switch OpenFlow switch Network device
SDN apps
Well defined API
(REST, RPC...)
Open protocols
(OpenFlow, OF-config,
NETConfig, OVSDB...)
SDN apps SDN apps
Ryu SDN framework
OpenFlow
Parser/serializer
Event dispatcher
Ryu built-in app
(tenant isolation,
Topology discovery, firewall )
Ryu App
libraries
Protocol support
(OVSDB, VRRP, ...)
Ryu App...
operator openstack User app
Control layer
Application layer
Aio/thread
● Uses eventlet
– Like OpenStack
– gevent was used before
– switched to eventlet for pypy
● twisted was not adopted for simplicity
● eventlet(or gevent) is cooperative threading, so
some cautions are needed
– This is different from preemptive threading like pthread
Event Dispatcher
● class AppManager and class RyuApp
● The guts of Ryu
● Decouples event sources/sinks
– Event sources generate whatever events
– Event sinks register handlers dynamically
● Dispatches events based on class of events
– To event sinks that want class of events
– Class is a first class object in Python
● knows which methods are interested in which event by
methods attributes
– Methods are also first class object in Python
RyuAppRyuApp
queue
BRICKS
Event
Determin which RyuApp to deliver
Based on class of event
dispatch
Events are read only because
It is shared with many RyuApps
Event sink
Event dispatcher
RyuAppRyuApp
queue
RyuAppRyuApp
queueEvent source
EventEvent source
Event source/sink
● source
– Call methods of the event dispatcher to generate events
● sink
– Subclass of class RyuApp
● Event dispatcher knows which methods are interested in which
events
– Event handlers are invoked in its own thread context of each
RyuApp
– To avoid race condition
– Direct queuing is also possible
RyuApp
queue
Event thread
Consuming events
Event
Event request/reply
● request/reply messaging between RyuApps for
easy programming
RyuApp
Event thread
RyuAppevent
queue
RyuApp
Event thread
RyuApp
event
queue
reply
queue
reply
queue
request
event
reply
event
1. queue request event
3. process request
4. queue back result
5. wake up
waiting event thread
If necessary
2. wait for reply if
synchronous
OpenFlow parser and its event
● Only controller part is supported
● OF events are created automatically on startup
– Introspection is used
● “Where EventOFPxxx is defined?” is FAQ
ofproto_v1_N_parser
OFPxxx EventOFPxxx
ofp_event
Connection to OpenFlow switch
● class OpenFlowController, class Datapath
● Receiving loop and sending loop
OpenFlow switch
Receiving thread
Generates OFPEvents
Sending thread
Serialize and send
OF packets
Send queue
EventOFP
message
Ryu
Datapath
RyuAppRyuApp
queue
Event sink
OpenStack support
OpenStack Component
● Composed of Many
component
● Neutron
– Plugin architecture
– Able to support many
network technology
service Openstack project
compute nova
storage swift(object)
glance(image)
cinder(block)
identity keystone
network neutron
... ...
Ryu Plugin for Neutron
● L2 isolation
● Multi tenant w/o or w/ VLAN
– Mac address based
– VLAN
– GRE tunnel
Overview of Ryu plugin
Compute-node
Vif driver
Create
OVS port
Ryu
agent OVS
OVS
initialization
OVS
Ryu
agent
OVS
initialization
L3 agent
Neutron Node
Neutron DB
(Network ID, key)
Ryu server
(Network ID, key)
Neutron API
Ryu node
r
Ryu REST
OpenFlow & OVSDB
Neutron server
Ryu
plugin
Network node
OpenStack L2 isolation: logical view
VM VM VM VM VM VM
Tenant X Tenant Y
OpenStack L2 isolation: physical view
Compute
Node
Compute
Node
Compute
/network
OVS
OVS
Tenant X
VM
Tenant Y
VM
Tenant X
VM
Tenant Y
VM
Tenant X
VM
Tenant Y
VM
Tenant => GRE key
GRE tunnel
OpenFlow
Tenant X
GRE key = M
Tenant Y
GRE key = N
L2 over L3 with GRE tunnel
- Able to span over network
segments
(l2 segment can over multi
data centers)
- can coexists with
Conventional network
technology
Set GRE key
Deliver packets
based on GRE key
En/de-cupsel packet
Into/from GRE packet
Ryu
nw-gw
nw-gw OVS
Table 0 Table 1 Table 2
Src table Tunnel out Local out
VM port
match action
in_port
src mac
set_tunnel
goto table 1
in_port drop
match action
tunnel_id
dst mac
output(tunnel)
goto table 2
match action
tunnel_id
dst mac
output(vm)
tunnel_id goto table 2
tunnel_id drop
Tunnel
port in_port
tunnel_id
goto table 2
in_port drop
OVS
VM1
VM2
GRE tunnel
tunnel
port
VM port
In port
Flow Table Usage
Nicira extension is used for GRE tunnel
GRE tunneling with OpenStack
● Composed of several RyuApps
● Network tenant creation
– Assign GRE key
– Create gateway
● Guest VM instance creation
– Create port
● Tenant ↔ key ↔ port relationship
– Set flow to the VM port
● Tunnel port management
– Create/delete tunnel port
● Track physical compute node
– Set flow to the tunnel port
rest_quantum
gre_tunnel
tunnel_port_updater
quantum_adapter
REST
OVS
ovsdbOpenFlow
Neutron
Ryu
quantum: former name of neutron project
Ryu development
Development process
● Open development
● Linux style
● Discuss on Mailing List openly
● Send/review patches on Mailing List
– git format-patch
– git send-patch
– No pull request on github
● Evolution
– Ryu has evoleved from
very small program
http://dir.gmane.org/gmane.network.ryu.devel
Python experience through Ryu
Python
●
Good things
– Easy/fast to learn/use
– Many useful features
●
Dynamic language, first class everything, decorator, introspection...
– Especially introspection is very useful
– Decorator is handy
– Many useful libraries
● Bad things
– Hard to debug
● debugger(pdb) is unstable
● Debugger isn't compatible with eventlet
– Magic attributes(__xxx___)
– Many similar libraries: which to use?
AIO libraries
● Gevent → Eventlet
● In general, monky-patching is ugly hack and
very fragile
● Monkey patching of gevent/eventlet works
stably
● Hit some issues and patches are proposed.
● epoll is removed by monkey patching
Threading
● eventlet(or gevent) is cooperative threading
– Needs special care for protection
● Starvation
● Thread scheduling
– Different from native threading like pthread
● Synchronization primitives
● Hard to debug
– When debugger(pdb) tries to stop, the thread is switched to other thread
● Need to consider
– Native vs green
– Giant Interpreter Lock
– What context to deliver events?
Performance
● Gevent performs slightly better than eventlet
– But it's very slight.
– Needs other approach for more performance boost
● Pypy
– Needs patch for eventlet
● Mulit process?
Network programming
● For IGMP with VRRP
● Needs to read Cpython code or C-module code
– Much better than unsupported, though
Thank you
Questions?
http://osrg.github.com/ryu/

Weitere ähnliche Inhalte

Was ist angesagt?

SDN & NFV Introduction - Open Source Data Center Networking
SDN & NFV Introduction - Open Source Data Center NetworkingSDN & NFV Introduction - Open Source Data Center Networking
SDN & NFV Introduction - Open Source Data Center Networking
Thomas Graf
 
Introduction to OpenFlow, SDN and NFV
Introduction to OpenFlow, SDN and NFVIntroduction to OpenFlow, SDN and NFV
Introduction to OpenFlow, SDN and NFV
Kingston Smiler
 

Was ist angesagt? (20)

The Basic Introduction of Open vSwitch
The Basic Introduction of Open vSwitchThe Basic Introduction of Open vSwitch
The Basic Introduction of Open vSwitch
 
SDN Architecture & Ecosystem
SDN Architecture & EcosystemSDN Architecture & Ecosystem
SDN Architecture & Ecosystem
 
OpenStack Networking
OpenStack NetworkingOpenStack Networking
OpenStack Networking
 
Openstack Neutron, interconnections with BGP/MPLS VPNs
Openstack Neutron, interconnections with BGP/MPLS VPNsOpenstack Neutron, interconnections with BGP/MPLS VPNs
Openstack Neutron, interconnections with BGP/MPLS VPNs
 
Open vSwitch 패킷 처리 구조
Open vSwitch 패킷 처리 구조Open vSwitch 패킷 처리 구조
Open vSwitch 패킷 처리 구조
 
Implementing SDN Testbed(ONOS & OpenVirteX)
Implementing SDN Testbed(ONOS & OpenVirteX)Implementing SDN Testbed(ONOS & OpenVirteX)
Implementing SDN Testbed(ONOS & OpenVirteX)
 
Sdn and open flow tutorial 4
Sdn and open flow tutorial 4Sdn and open flow tutorial 4
Sdn and open flow tutorial 4
 
OpenvSwitch Deep Dive
OpenvSwitch Deep DiveOpenvSwitch Deep Dive
OpenvSwitch Deep Dive
 
Open vSwitch Introduction
Open vSwitch IntroductionOpen vSwitch Introduction
Open vSwitch Introduction
 
OVN DBs HA with scale test
OVN DBs HA with scale testOVN DBs HA with scale test
OVN DBs HA with scale test
 
SDN, OpenFlow, NFV, and Virtual Network
SDN, OpenFlow, NFV, and Virtual NetworkSDN, OpenFlow, NFV, and Virtual Network
SDN, OpenFlow, NFV, and Virtual Network
 
SDN & NFV Introduction - Open Source Data Center Networking
SDN & NFV Introduction - Open Source Data Center NetworkingSDN & NFV Introduction - Open Source Data Center Networking
SDN & NFV Introduction - Open Source Data Center Networking
 
OVN - Basics and deep dive
OVN - Basics and deep diveOVN - Basics and deep dive
OVN - Basics and deep dive
 
IP Routing Tutorial
IP Routing TutorialIP Routing Tutorial
IP Routing Tutorial
 
Doc6 mpls vpn-ppt
Doc6 mpls vpn-pptDoc6 mpls vpn-ppt
Doc6 mpls vpn-ppt
 
The Open vSwitch and OVN Projects
The Open vSwitch and OVN ProjectsThe Open vSwitch and OVN Projects
The Open vSwitch and OVN Projects
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN Controller
 
OpenStack Neutron Tutorial
OpenStack Neutron TutorialOpenStack Neutron Tutorial
OpenStack Neutron Tutorial
 
Introduction to OpenFlow, SDN and NFV
Introduction to OpenFlow, SDN and NFVIntroduction to OpenFlow, SDN and NFV
Introduction to OpenFlow, SDN and NFV
 
SDN Fundamentals - short presentation
SDN Fundamentals -  short presentationSDN Fundamentals -  short presentation
SDN Fundamentals - short presentation
 

Andere mochten auch

Andere mochten auch (11)

2014年10月江戸前セキュリティ勉強会資料 -セキュリティ技術者になるには-
2014年10月江戸前セキュリティ勉強会資料 -セキュリティ技術者になるには-2014年10月江戸前セキュリティ勉強会資料 -セキュリティ技術者になるには-
2014年10月江戸前セキュリティ勉強会資料 -セキュリティ技術者になるには-
 
Ryu SDN Framework
Ryu SDN FrameworkRyu SDN Framework
Ryu SDN Framework
 
Ryu Learning Guide
Ryu Learning GuideRyu Learning Guide
Ryu Learning Guide
 
Brocade Software Networking (SDN NFV Day ITB 2016)
Brocade Software Networking (SDN NFV Day ITB 2016)Brocade Software Networking (SDN NFV Day ITB 2016)
Brocade Software Networking (SDN NFV Day ITB 2016)
 
Brocade SDN Controller -Sample Code for Brocade vRouter-
Brocade SDN Controller -Sample Code for Brocade vRouter-Brocade SDN Controller -Sample Code for Brocade vRouter-
Brocade SDN Controller -Sample Code for Brocade vRouter-
 
OpenFlow tutorial
OpenFlow tutorialOpenFlow tutorial
OpenFlow tutorial
 
OpenFlow: What is it Good For?
OpenFlow: What is it Good For? OpenFlow: What is it Good For?
OpenFlow: What is it Good For?
 
Implementing MPLS Services using Openflow
Implementing MPLS Services using OpenflowImplementing MPLS Services using Openflow
Implementing MPLS Services using Openflow
 
Brocade Software Networking Presentation at Interface 2016
Brocade Software Networking Presentation at Interface 2016Brocade Software Networking Presentation at Interface 2016
Brocade Software Networking Presentation at Interface 2016
 
OVNC 2015-THE NEW IP - Open Networking Architecture with SDN & NFV
OVNC 2015-THE NEW IP - Open Networking Architecture with SDN & NFVOVNC 2015-THE NEW IP - Open Networking Architecture with SDN & NFV
OVNC 2015-THE NEW IP - Open Networking Architecture with SDN & NFV
 
Cisco SDN/NVF Innovations (SDN NVF Day ITB 2016)
Cisco SDN/NVF Innovations (SDN NVF Day ITB 2016)Cisco SDN/NVF Innovations (SDN NVF Day ITB 2016)
Cisco SDN/NVF Innovations (SDN NVF Day ITB 2016)
 

Ähnlich wie Ryu sdn framework

software defined network, openflow protocol and its controllers
software defined network, openflow protocol and its controllerssoftware defined network, openflow protocol and its controllers
software defined network, openflow protocol and its controllers
Isaku Yamahata
 
Openstack Neutron and SDN
Openstack Neutron and SDNOpenstack Neutron and SDN
Openstack Neutron and SDN
inakipascual
 
[AI Dev World 2022] Build ML Enhanced Event Streaming
[AI Dev World 2022] Build ML Enhanced Event Streaming[AI Dev World 2022] Build ML Enhanced Event Streaming
[AI Dev World 2022] Build ML Enhanced Event Streaming
Timothy Spann
 
NaaS in OpenStack - CloudCamp Moscow
NaaS in OpenStack - CloudCamp MoscowNaaS in OpenStack - CloudCamp Moscow
NaaS in OpenStack - CloudCamp Moscow
Ilya Alekseyev
 

Ähnlich wie Ryu sdn framework (20)

software defined network, openflow protocol and its controllers
software defined network, openflow protocol and its controllerssoftware defined network, openflow protocol and its controllers
software defined network, openflow protocol and its controllers
 
Quantum - Virtual networks for Openstack
Quantum - Virtual networks for OpenstackQuantum - Virtual networks for Openstack
Quantum - Virtual networks for Openstack
 
neutron_icehouse_update
neutron_icehouse_updateneutron_icehouse_update
neutron_icehouse_update
 
2015 COSCUP SDN Workshop -- SDN Quick Start
2015 COSCUP SDN Workshop -- SDN Quick Start2015 COSCUP SDN Workshop -- SDN Quick Start
2015 COSCUP SDN Workshop -- SDN Quick Start
 
Openstack Neutron and SDN
Openstack Neutron and SDNOpenstack Neutron and SDN
Openstack Neutron and SDN
 
BKK16-106 ODP Project Update
BKK16-106 ODP Project UpdateBKK16-106 ODP Project Update
BKK16-106 ODP Project Update
 
NS3 Overview
NS3 OverviewNS3 Overview
NS3 Overview
 
Open stack networking_101_update_2014
Open stack networking_101_update_2014Open stack networking_101_update_2014
Open stack networking_101_update_2014
 
[AI Dev World 2022] Build ML Enhanced Event Streaming
[AI Dev World 2022] Build ML Enhanced Event Streaming[AI Dev World 2022] Build ML Enhanced Event Streaming
[AI Dev World 2022] Build ML Enhanced Event Streaming
 
Big mountain data and dev conference apache pulsar with mqtt for edge compu...
Big mountain data and dev conference   apache pulsar with mqtt for edge compu...Big mountain data and dev conference   apache pulsar with mqtt for edge compu...
Big mountain data and dev conference apache pulsar with mqtt for edge compu...
 
Networking in Openstack - Neutron 101
Networking in Openstack - Neutron 101Networking in Openstack - Neutron 101
Networking in Openstack - Neutron 101
 
OpenStack Neutron Advanced Services by Akanda
OpenStack Neutron Advanced Services by AkandaOpenStack Neutron Advanced Services by Akanda
OpenStack Neutron Advanced Services by Akanda
 
OpenStack Neutron Advanced Services by Akanda
OpenStack Neutron Advanced Services by AkandaOpenStack Neutron Advanced Services by Akanda
OpenStack Neutron Advanced Services by Akanda
 
Network Virtualization & Software-defined Networking
Network Virtualization & Software-defined NetworkingNetwork Virtualization & Software-defined Networking
Network Virtualization & Software-defined Networking
 
OpenStack Astara
OpenStack AstaraOpenStack Astara
OpenStack Astara
 
Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12x
 
NaaS in OpenStack - CloudCamp Moscow
NaaS in OpenStack - CloudCamp MoscowNaaS in OpenStack - CloudCamp Moscow
NaaS in OpenStack - CloudCamp Moscow
 
Machine Intelligence Guild_ Build ML Enhanced Event Streaming Applications wi...
Machine Intelligence Guild_ Build ML Enhanced Event Streaming Applications wi...Machine Intelligence Guild_ Build ML Enhanced Event Streaming Applications wi...
Machine Intelligence Guild_ Build ML Enhanced Event Streaming Applications wi...
 
Data science online camp using the flipn stack for edge ai (flink, nifi, pu...
Data science online camp   using the flipn stack for edge ai (flink, nifi, pu...Data science online camp   using the flipn stack for edge ai (flink, nifi, pu...
Data science online camp using the flipn stack for edge ai (flink, nifi, pu...
 
Apache Pulsar Development 101 with Python
Apache Pulsar Development 101 with PythonApache Pulsar Development 101 with Python
Apache Pulsar Development 101 with Python
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Ryu sdn framework

  • 1. Ryu: SDN framework and Python experience Isaku Yamahata <yamahata@private.email.ne.jp> <isaku.yamahata@gmail.com> Pycon APAC 2013, September 14
  • 2. Agenda ● Introduction ● Ryu: SDN framework ● Ryu Internals – Openstack support ● Ryu development ● Python experience through Ryu This presentation represents my personal view/opinion. Not Ryu project nor any companies.
  • 3. Who am I? ● My background is OS/virtualization/cloud – Not network guy ● Programming language – C/C++/assembler ● Projects I've contributed – Linux – Virtualization ● Qemu, KVM, Xen – OpenStack ● Nova, neutron(formarly quantum) Ryu plugin – Open vSwitch ● My python experience had begun with OpenStack and Ryu
  • 5. What's SDN? And why? ● Software Defined Networking – Making network programmable – http://www.opennetsummit.org/why-sdn.html ● SDN is a disruptive technology that is making networks programmable by ordinary programmers using ordinary software running on ordinary operating systems in ordinary servers. With SDN, the introduction of new features becomes less manual, less prone to error, and faster to implement. – [Paraphrased from the HotSDN ‘13 Solicitaion] ● Software Defined Networking (SDN) is a refactoring of the relationship between network devices and the software that controls them. ● Motivations behind SDN – Academic research ● Allow researchers to program/modify switches freely – Industry technology trends ● Virtualization/cloud technology ● Network is behind those technology progress ● Networkig virtualization/automation
  • 8. Openflow datapath(hardware) controlpath(software) datapath(hardware) controlpath(software) openflow Openflow controller Openflow protocol(tcp/ssl) Ethernet switch Openflow ethernet switch ● protocol to control switches
  • 9. Flow table and match/action Openflow controller Flow table MAC src MAC dst IP src IP dst TCP src TCP dst ... action Packet in event When entry miss * * * * * 80 output port N port PacketportPacket Packet match Action
  • 11. What's Ryu? 流 龍 Flow Oriental Dragion, A god of water Manages flow control to enable intelligent networking http://ja.wikipedia.org/wiki/%E8%B5%A4%E7%9B%AE%E5%9B%9B%E5%8D%81%E5%85%AB%E6%BB%9D
  • 12. What's Ryu? ● a component-based software-defined networking framework ● License: Apache 2.0 ● Fully written in Python ● Supports various protocols for managing network devices – OpenFlow, Netconf, OF-config, SNMP etc. ● Official site http://osrg.github.io/ryu/ ● MLhttps://lists.sourceforge.net/lists/listinfo/ryu-devel ● Download https://github.com/osrg/ryu ● Documentation http://ryu.readthedocs.org/en/latest/ ● Wiki https://github.com/osrg/ryu/wiki
  • 13. Supported features/protocols ● Openflow protoocol – OF-wire: 1.0,1.2, 1.3, Nicira extension – OF-config 1.1 ● Non-openflow protocols – Netconf, OVSDB, netflow, sflow, VRRP, SNMP ● Snmp: Enterprise OID: 41786 – Ryu can configure Open vSwitch directly without ovs-vsctl, ovsdb-client Some features are under development. The patches can be found on ML archive. ● RyuApp, library – Packet library – STP, LACP – Sample apps, etc... – Conversion from/to JSON representation from/to OF – RPC to communicate/control Ryu ● Integration with other project – OpenStack – HA with Zookeeper – IDS(Intrusion Detection System) with snort
  • 14. OF/firewall/router REST API ● OF REST (ofctl_reset) – Insert/delete openflow rule ● Firewall (rest_firewall) – Configure firewall – https://github.com/osrg/ryu/wiki/Third-Party-Tools,-Etc. ● Router(rest_router) – Configure router Ryu REST OF REST API add a flow entry POST http://example.org/stats/flownetry/add delete flow entries DELETE http://example.org/stats/flowentry/delete get flow stats GET http://example.org/stats/flow/{dpid} allow drop firewall OF switch Ryu REST OF switch router
  • 15. Topology Viewer ● Discover topology by LLDP and show topology/flows dynamically
  • 16. HA support ● Centralized controller is single pointer of failure(SPOF) ● Ryu + Zookeeper can be used to address SPOF Ryu Ryu zookeeper OF switch master slave failover
  • 17. IDS support ● Snort integration https://github.com/osrg/ryu/wiki/Snort-Integration Ryu OF switch Sort Control app IDS(snort) 1. L1-L4 matching 2. send patcket to IDS 3. alert4. take actions e.g. loggingt
  • 19. Ryu implementation ● Quite normal python program from the point of implementation view – It doesn't use any special tricks ● Event driven – Event source/dispatcher/sink – Core(= Event dispatcher) is very small – It is so generic that Ryu can be used without OpenFlow ● Component based – Event source/sink are created as components ● Even OpenFlow related codes are so – Message passing via events, not directly communite.
  • 20. Ryu architecture ● Follows standard SDN architecture OpenFlow switch OpenFlow switch Network device SDN apps Well defined API (REST, RPC...) Open protocols (OpenFlow, OF-config, NETConfig, OVSDB...) SDN apps SDN apps Ryu SDN framework OpenFlow Parser/serializer Event dispatcher Ryu built-in app (tenant isolation, Topology discovery, firewall ) Ryu App libraries Protocol support (OVSDB, VRRP, ...) Ryu App... operator openstack User app Control layer Application layer
  • 21. Aio/thread ● Uses eventlet – Like OpenStack – gevent was used before – switched to eventlet for pypy ● twisted was not adopted for simplicity ● eventlet(or gevent) is cooperative threading, so some cautions are needed – This is different from preemptive threading like pthread
  • 22. Event Dispatcher ● class AppManager and class RyuApp ● The guts of Ryu ● Decouples event sources/sinks – Event sources generate whatever events – Event sinks register handlers dynamically ● Dispatches events based on class of events – To event sinks that want class of events – Class is a first class object in Python ● knows which methods are interested in which event by methods attributes – Methods are also first class object in Python RyuAppRyuApp queue BRICKS Event Determin which RyuApp to deliver Based on class of event dispatch Events are read only because It is shared with many RyuApps Event sink Event dispatcher RyuAppRyuApp queue RyuAppRyuApp queueEvent source EventEvent source
  • 23. Event source/sink ● source – Call methods of the event dispatcher to generate events ● sink – Subclass of class RyuApp ● Event dispatcher knows which methods are interested in which events – Event handlers are invoked in its own thread context of each RyuApp – To avoid race condition – Direct queuing is also possible RyuApp queue Event thread Consuming events Event
  • 24. Event request/reply ● request/reply messaging between RyuApps for easy programming RyuApp Event thread RyuAppevent queue RyuApp Event thread RyuApp event queue reply queue reply queue request event reply event 1. queue request event 3. process request 4. queue back result 5. wake up waiting event thread If necessary 2. wait for reply if synchronous
  • 25. OpenFlow parser and its event ● Only controller part is supported ● OF events are created automatically on startup – Introspection is used ● “Where EventOFPxxx is defined?” is FAQ ofproto_v1_N_parser OFPxxx EventOFPxxx ofp_event
  • 26. Connection to OpenFlow switch ● class OpenFlowController, class Datapath ● Receiving loop and sending loop OpenFlow switch Receiving thread Generates OFPEvents Sending thread Serialize and send OF packets Send queue EventOFP message Ryu Datapath RyuAppRyuApp queue Event sink
  • 28. OpenStack Component ● Composed of Many component ● Neutron – Plugin architecture – Able to support many network technology service Openstack project compute nova storage swift(object) glance(image) cinder(block) identity keystone network neutron ... ...
  • 29. Ryu Plugin for Neutron ● L2 isolation ● Multi tenant w/o or w/ VLAN – Mac address based – VLAN – GRE tunnel
  • 30. Overview of Ryu plugin Compute-node Vif driver Create OVS port Ryu agent OVS OVS initialization OVS Ryu agent OVS initialization L3 agent Neutron Node Neutron DB (Network ID, key) Ryu server (Network ID, key) Neutron API Ryu node r Ryu REST OpenFlow & OVSDB Neutron server Ryu plugin Network node
  • 31. OpenStack L2 isolation: logical view VM VM VM VM VM VM Tenant X Tenant Y
  • 32. OpenStack L2 isolation: physical view Compute Node Compute Node Compute /network OVS OVS Tenant X VM Tenant Y VM Tenant X VM Tenant Y VM Tenant X VM Tenant Y VM Tenant => GRE key GRE tunnel OpenFlow Tenant X GRE key = M Tenant Y GRE key = N L2 over L3 with GRE tunnel - Able to span over network segments (l2 segment can over multi data centers) - can coexists with Conventional network technology Set GRE key Deliver packets based on GRE key En/de-cupsel packet Into/from GRE packet Ryu nw-gw nw-gw OVS
  • 33. Table 0 Table 1 Table 2 Src table Tunnel out Local out VM port match action in_port src mac set_tunnel goto table 1 in_port drop match action tunnel_id dst mac output(tunnel) goto table 2 match action tunnel_id dst mac output(vm) tunnel_id goto table 2 tunnel_id drop Tunnel port in_port tunnel_id goto table 2 in_port drop OVS VM1 VM2 GRE tunnel tunnel port VM port In port Flow Table Usage Nicira extension is used for GRE tunnel
  • 34. GRE tunneling with OpenStack ● Composed of several RyuApps ● Network tenant creation – Assign GRE key – Create gateway ● Guest VM instance creation – Create port ● Tenant ↔ key ↔ port relationship – Set flow to the VM port ● Tunnel port management – Create/delete tunnel port ● Track physical compute node – Set flow to the tunnel port rest_quantum gre_tunnel tunnel_port_updater quantum_adapter REST OVS ovsdbOpenFlow Neutron Ryu quantum: former name of neutron project
  • 36. Development process ● Open development ● Linux style ● Discuss on Mailing List openly ● Send/review patches on Mailing List – git format-patch – git send-patch – No pull request on github ● Evolution – Ryu has evoleved from very small program http://dir.gmane.org/gmane.network.ryu.devel
  • 38. Python ● Good things – Easy/fast to learn/use – Many useful features ● Dynamic language, first class everything, decorator, introspection... – Especially introspection is very useful – Decorator is handy – Many useful libraries ● Bad things – Hard to debug ● debugger(pdb) is unstable ● Debugger isn't compatible with eventlet – Magic attributes(__xxx___) – Many similar libraries: which to use?
  • 39. AIO libraries ● Gevent → Eventlet ● In general, monky-patching is ugly hack and very fragile ● Monkey patching of gevent/eventlet works stably ● Hit some issues and patches are proposed. ● epoll is removed by monkey patching
  • 40. Threading ● eventlet(or gevent) is cooperative threading – Needs special care for protection ● Starvation ● Thread scheduling – Different from native threading like pthread ● Synchronization primitives ● Hard to debug – When debugger(pdb) tries to stop, the thread is switched to other thread ● Need to consider – Native vs green – Giant Interpreter Lock – What context to deliver events?
  • 41. Performance ● Gevent performs slightly better than eventlet – But it's very slight. – Needs other approach for more performance boost ● Pypy – Needs patch for eventlet ● Mulit process?
  • 42. Network programming ● For IGMP with VRRP ● Needs to read Cpython code or C-module code – Much better than unsupported, though