advertisement
ryu Documentation
Release 3.21
ryu development team
March 14, 2016
Contents
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
3
3
3
3
2 Writing Your Ryu Application
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
OpenFlow protocol API Reference
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
61
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
6
9
5
5
259
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
263
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Testing OF-config support with LINC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
5 Using Ryu Network Operating System with OpenStack as OpenFlow controller
271
273
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
305
307
i
ii
Contents:
ryu Documentation, Release 3.21
Contents 1
ryu Documentation, Release 3.21
2 Contents
CHAPTER
1
Getting Started
1.1 What’s Ryu
Ryu is a component-based software defined networking framework.
Ryu provides software components with well defined API that make it easy for developers to create new network management and control applications. Ryu supports various protocols for managing network devices, such as OpenFlow,
Netconf, OF-config, etc. About OpenFlow, Ryu supports fully 1.0, 1.2, 1.3, 1.4 and Nicira Extensions.
All of the code is freely available under the Apache 2.0 license. Ryu is fully written in Python.
1.2 Quick Start
Installing Ryu is quite easy:
% pip install ryu
If you prefer to install Ryu from the source code:
% git clone git://github.com/osrg/ryu.git
% cd ryu; python ./setup.py install
If you want to use Ryu with OpenStack , please refer networking-ofagent project .
If you want to write your Ryu application, have a look at Writing ryu application document. After writing your application, just type:
% ryu-manager yourapp.py
1.3 Optional Requirements
Some functionalities of ryu requires extra packages:
• OF-Config requires lxml
• NETCONF requires paramiko
• BGP speaker (ssh console) requires paramiko
If you want to use the functionalities, please install requirements:
3
ryu Documentation, Release 3.21
% pip install lxml
% pip install paramiko
1.4 Support
Ryu Official site is http://osrg.github.io/ryu/ .
If you have any questions, suggestions, and patches, the mailing list is available at ryu-devel ML .
The ML archive at
Gmane is also available.
4 Chapter 1. Getting Started
CHAPTER
2
Writing Your Ryu Application
2.1 The First Application
2.1.1 Whetting Your Appetite
If you want to manage the network gears (switches, routers, etc) at your way, you need to write your Ryu application.
Your application tells Ryu how you want to manage the gears. Then Ryu configures the gears by using OpenFlow protocol, etc.
Writing Ryu application is easy. It’s just Python scripts.
2.1.2 Start Writing
We show a Ryu application that make OpenFlow switches work as a dumb layer 2 switch.
Open a text editor creating a new file with the following content:
from ryu.base
import
app_manager
class L2Switch
(app_manager .
RyuApp):
def
__init__ ( self ,
* args,
** kwargs): super (L2Switch, self ) .
__init__(
* args,
** kwargs)
Ryu application is just a Python script so you can save the file with any name, extensions, and any place you want.
Let’s name the file ‘l2.py’ at your home directory.
This application does nothing useful yet, however it’s a complete Ryu application. In fact, you can run this Ryu application:
% ryu-manager ~/l2.py
loading app /Users/fujita/l2.py
instantiating app /Users/fujita/l2.py
All you have to do is defining needs a new subclass of RyuApp to run your Python script as a Ryu application.
Next let’s add the functionality of sending a received packet to all the ports.
from ryu.base
import
app_manager
from ryu.controller
import
ofp_event
from ryu.controller.handler
import
MAIN_DISPATCHER
from ryu.controller.handler
import
set_ev_cls
class L2Switch
(app_manager .
RyuApp):
5
ryu Documentation, Release 3.21
def
__init__ ( self ,
* args,
** kwargs): super (L2Switch, self ) .
__init__(
* args,
** kwargs)
@set_ev_cls
(ofp_event .
EventOFPPacketIn, MAIN_DISPATCHER)
def
packet_in_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto ofp_parser = dp .
ofproto_parser actions = [ofp_parser .
OFPActionOutput(ofp .
OFPP_FLOOD)] out = ofp_parser .
OFPPacketOut( datapath = dp, buffer_id = msg .
buffer_id, in_port = msg .
in_port, actions = actions) dp .
send_msg(out)
A new method ‘packet_in_handler’ is added to L2Switch class. This is called when Ryu receives an OpenFlow packet_in message. The trick is ‘set_ev_cls’ decorator. This decorator tells Ryu when the decorated function should be called.
The first argument of the decorator indicates an event that makes function called. As you expect easily, every time
Ryu gets a packet_in message, this function is called.
The second argument indicates the state of the switch. Probably, you want to ignore packet_in messages before the negotiation between Ryu and the switch finishes. Using ‘MAIN_DISPATCHER’ as the second argument means this function is called only after the negotiation completes.
Next let’s look at the first half of the ‘packet_in_handler’ function.
• ev.msg is an object that represents a packet_in data structure.
• msg.dp is an object that represents a datapath (switch).
• dp.ofproto and dp.ofproto_parser are objects that represent the OpenFlow protocol that Ryu and the switch negotiated.
Ready for the second half.
• OFPActionOutput class is used with a packet_out message to specify a switch port that you want to send the packet out of. This application need a switch to send out of all the ports so OFPP_FLOOD constant is used.
• OFPPacketOut class is used to build a packet_out message.
• If you call Datapath class’s send_msg method with a OpenFlow message class object, Ryu builds and send the on-wire data format to the switch.
Here, you finished implementing your first Ryu application. You are ready to run this Ryu application that does something useful.
A dumb l2 switch is too dumb? You want to implement a learning l2 switch? Move to the next step . You can learn from the existing Ryu applications at ryu/app directory and integrated tests directory.
2.2 Components of Ryu
2.2.1 Executables bin/ryu-manager
The main executable.
6 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
2.2.2 Base components ryu.base.app_manager
2.2.3 OpenFlow controller ryu.controller.controller
ryu.controller.dpset
ryu.controller.ofp_event
OpenFlow event definitions.
ryu.controller.ofp_handler
2.2.4 OpenFlow wire protocol encoder and decoder ryu.ofproto.ofproto_v1_0
OpenFlow 1.0 definitions.
ryu.ofproto.ofproto_v1_0_parser
Decoder/Encoder implementations of OpenFlow 1.0.
ryu.ofproto.ofproto_v1_2
OpenFlow 1.2 definitions.
ryu.ofproto.ofproto_v1_2_parser
Decoder/Encoder implementations of OpenFlow 1.2.
ryu.ofproto.ofproto_v1_3
OpenFlow 1.3 definitions.
ryu.ofproto.ofproto_v1_3_parser
This module implements OpenFlow 1.3.x.
This module also implements some of extensions shown in “OpenFlow Extensions for 1.3.X Pack 1”. Namely, the following extensions are implemented.
• EXT-236 Bad flow entry priority error Extension
• EXT-237 Set async config error Extension
• EXT-256 PBB UCA header field Extension
2.2. Components of Ryu 7
ryu Documentation, Release 3.21
• EXT-260 Duplicate instruction error Extension
• EXT-264 Multipart timeout errors Extension
The following extensions are partially implemented.
• EXT-187 Flow entry notifications Extension (ONFMP_FLOW_MONITOR only)
• EXT-230 Bundle Extension (Error codes only)
• EXT-232 Table synchronisation Extension (Error codes only)
The following extensions are not implemented yet.
• EXT-191 Role Status Extension
• EXT-192-e Flow entry eviction Extension
• EXT-192-v Vacancy events Extension
ryu.ofproto.ofproto_v1_4
OpenFlow 1.4 definitions.
ryu.ofproto.ofproto_v1_4_parser
Decoder/Encoder implementations of OpenFlow 1.4.
2.2.5 Ryu applications ryu.app.cbench
ryu.app.simple_switch
ryu.app.simple_isolation
ryu.app.simple_vlan
ryu.app.gre_tunnel
ryu.app.tunnel_port_updater
ryu.app.quantum_adapter
ryu.app.rest
ryu.app.rest_conf_switch
ryu.app.rest_quantum
ryu.app.rest_tunnel
ryu.topology
Switch and link discovery module. Planned to replace ryu/controller/dpset.
8 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
2.2.6 Libraries ryu.lib.packet
Ryu packet library. Decoder/Encoder implementations of popular protocols like TCP/IP.
ryu.lib.ovs
ovsdb interaction library.
ryu.lib.of_config
OF-Config implementation.
ryu.lib.netconf
NETCONF definitions used by ryu/lib/of_config.
ryu.lib.xflow
An implementation of sFlow and NetFlow.
2.2.7 Third party libraries ryu.contrib.ovs
Open vSwitch python binding. Used by ryu.lib.ovs.
ryu.contrib.oslo.config
Oslo configuration library. Used for ryu-manager’s command-line options and configuration files.
ryu.contrib.ncclient
Python library for NETCONF client. Used by ryu.lib.of_config.
2.3 Ryu application API
2.3.1 Ryu application programming model
Threads, events, and event queues
Ryu applications are single-threaded entities which implement various functionalities in Ryu. Events are messages between them.
Ryu applications send asynchronous events each other. Besides that, there are some Ryu-internal event sources which are not Ryu applications. One of examples of such event sources is OpenFlow controller. While an event can currently
2.3. Ryu application API 9
ryu Documentation, Release 3.21
contain arbitrary python objects, it’s discouraged to pass complex objects (eg. unpickleable objects) between Ryu applications.
Each Ryu application has a receive queue for events. The queue is FIFO and preserves the order of events. Each Ryu application has a thread for event processing. The thread keep draining the receive queue by dequeueing an event and calling the appropritate event handler for the event type. Because the event handler is called in the context of the event processing thread, it should be careful for blocking. I.e. while an event handler is blocked, no further events for the
Ryu application will be processed.
There are kinds of events which are used to implement synchronous inter-application calls between Ryu applications.
While such requests uses the same machinary as ordinary events, their replies are put on a queue dedicated to the transaction to avoid deadlock.
While threads and queues is currently implemented with eventlet/greenlet, a direct use of them in a Ryu application is strongly discouraged.
Contexts
Contexts are ordinary python objects shared among Ryu applications. The use of contexts are discouraged for new code.
2.3.2 Create a Ryu application
A Ryu application is a python module which defines a subclass of ryu.base.app_manager.RyuApp. If two or more such classes are defined in a module, the first one (by name order) will be picked by app_manager. Ryu application is singleton: only single instance of a given Ryu application is supported.
2.3.3 Observe events
A Ryu application can register itself to listen for specific events using ryu.controller.handler.set_ev_cls decorator.
2.3.4 Generate events
A Ryu application can raise events by calling appropriate ryu.base.app_manager.RyuApp’s methods like send_event or send_event_to_observers.
2.3.5 Event classes
An event class describes a Ryu event generated in the system. By convention, event class names are prefixed by
“Event”. Events are generated either by the core part of Ryu or Ryu applications. A Ryu application can register its interest for a specific type of event by providing a handler method using ryu.controller.handler.set_ev_cls decorator.
OpenFlow event classes
ryu.controller.ofp_event module exports event classes which describe receptions of OpenFlow messages from connected switches. By convention, they are named as ryu.controller.ofp_event.EventOFPxxxx where xxxx is the name of the corresponding OpenFlow message. For example, EventOFPPacketIn for packet-in message. The OpenFlow controller part of Ryu automatically decodes OpenFlow messages received from switches and send these events to
Ryu applications which expressed an interest using ryu.controller.handler.set_ev_cls. OpenFlow event classes have at least the following attributes.
10 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute msg
Description
An object which describes the corresponding OpenFlow message.
msg.datapath
A ryu.controller.controller.Datapath instance which describes an OpenFlow switch from which we received this OpenFlow message.
The msg object has some more additional members whose values are extracted from the original OpenFlow message.
See
OpenFlow protocol API Reference
for more info about OpenFlow messages.
2.3.6 ryu.base.app_manager.RyuApp
See
2.3.7 ryu.controller.handler.set_ev_cls(ev_cls, dispatchers=None)
A decorator for Ryu application to declare an event handler. Decorated method will become an event handler. ev_cls is an event class whose instances this RyuApp wants to receive. dispatchers argument specifies one of the following negotiation phases (or a list of them) for which events should be generated for this handler. Note that, in case an event changes the phase, the phase before the change is used to check the interest.
Negotiation phase Description ryu.controller.handler.HANDSHAKE_DISPATCHER
Sending and waiting for hello message ryu.controller.handler.CONFIG_DISPATCHER
ryu.controller.handler.MAIN_DISPATCHER
Version negotiated and sent features-request message
Switch-features message received and sent set-config message ryu.controller.handler.DEAD_DISPATCHER
Disconnect from the peer. Or disconnecting due to some unrecoverable errors.
2.3.8 ryu.controller.controller.Datapath
A class to describe an OpenFlow switch connected to this controller. An instance has the following attributes.
2.3. Ryu application API 11
ryu Documentation, Release 3.21
Attribute id ofproto ofproto_parser
Description
64-bit OpenFlow Datapath ID. Only available for ryu.controller.handler.MAIN_DISPATCHER phase.
A module which exports OpenFlow definitions, mainly constants appeared in the specification, for the negotiated OpenFlow version. For example, ryu.ofproto.ofproto_v1_0 for OpenFlow 1.0.
A module which exports OpenFlow wire message encoder and decoder for the negotiated OpenFlow version. For example, ryu.ofproto.ofproto_v1_0_parser for OpenFlow 1.0.
ofproto_parser.OFPxxxx(datapath, ....) A callable to prepare an OpenFlow message for the given switch. It can be sent with Datapath.send_msg later. xxxx is a name of the message.
set_xid(self, msg)
For example OFPFlowMod for flow-mod message. Arguemnts depend on the message.
Generate an OpenFlow XID and put it in msg.xid.
send_msg(self, msg) Queue an OpenFlow message to send to the corresponding switch. If msg.xid is None, set_xid is automatically called on the message before queueing.
deprecated send_packet_out send_flow_mod send_flow_del send_delete_all_flows send_barrier send_nxt_set_flow_format is_reserved_port deprecated deprecated deprecated
Queue an OpenFlow barrier message to send to the switch.
deprecated deprecated
2.3.9 ryu.controller.event.EventBase
The base of all event classes. A Ryu application can define its own event type by creating a subclass.
2.3.10 ryu.controller.event.EventRequestBase
The base class for synchronous request for RyuApp.send_request.
2.3.11 ryu.controller.event.EventReplyBase
The base class for synchronous request reply for RyuApp.send_reply.
2.3.12 ryu.controller.ofp_event.EventOFPStateChange
An event class for negotiation phase change notification. An instance of this class is sent to observer after changing the negotiation phase. An instance has at least the following attributes.
Attribute Description datapath ryu.controller.controller.Datapath instance of the switch
2.3.13 ryu.controller.dpset.EventDP
An event class to notify connect/disconnect of a switch. For OpenFlow switches, one can get the same notification by observing ryu.controller.ofp_event.EventOFPStateChange. An instance has at least the following attributes.
12 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute Description dp A ryu.controller.controller.Datapath instance of the switch enter True when the switch connected to our controller. False for disconnect.
2.3.14 ryu.controller.dpset.EventPortAdd
An event class for switch port status notification. This event is generated when a new port is added to a switch. For
OpenFlow switches, one can get the same notification by observing ryu.controller.ofp_event.EventOFPPortStatus. An instance has at least the following attributes.
Attribute Description dp A ryu.controller.controller.Datapath instance of the switch port port number
2.3.15 ryu.controller.dpset.EventPortDelete
An event class for switch port status notification. This event is generated when a port is removed from a switch. For
OpenFlow switches, one can get the same notification by observing ryu.controller.ofp_event.EventOFPPortStatus. An instance has at least the following attributes.
Attribute Description dp A ryu.controller.controller.Datapath instance of the switch port port number
2.3.16 ryu.controller.dpset.EventPortModify
An event class for switch port status notification. This event is generated when some attribute of a port is changed. For
OpenFlow switches, one can get the same notification by observing ryu.controller.ofp_event.EventOFPPortStatus. An instance has at least the following attributes.
Attribute Description dp A ryu.controller.controller.Datapath instance of the switch port port number
2.3.17 ryu.controller.network.EventNetworkPort
An event class for notification of port arrival and deperture. This event is generated when a port is introduced to or removed from a network by the REST API. An instance has at least the following attributes.
Attribute Description network_id Network ID dpid port_no add_del
OpenFlow Datapath ID of the switch to which the port belongs.
OpenFlow port number of the port
True for adding a port. False for removing a port.
2.3.18 ryu.controller.network.EventNetworkDel
An event class for network deletion. This event is generated when a network is deleted by the REST API. An instance has at least the following attributes.
Attribute Description network_id Network ID
2.3. Ryu application API 13
ryu Documentation, Release 3.21
2.3.19 ryu.controller.network.EventMacAddress
An event class for end-point MAC address registration. This event is generated when a end-point MAC address is updated by the REST API. An instance has at least the following attributes.
Attribute network_id dpid
Description
Network ID
OpenFlow Datapath ID of the switch to which the port belongs.
port_no OpenFlow port number of the port mac_address The old MAC address of the port if add_del is False. Otherwise the new MAC address.
add_del False if this event is a result of a port removal. Otherwise True.
2.3.20 ryu.controller.tunnels.EventTunnelKeyAdd
An event class for tunnel key registration. This event is generated when a tunnel key is registered or updated by the
REST API. An instance has at least the following attributes.
Attribute Description network_id Network ID tunnel_key Tunnel Key
2.3.21 ryu.controller.tunnels.EventTunnelKeyDel
An event class for tunnel key registration. This event is generated when a tunnel key is removed by the REST API. An instance has at least the following attributes.
Attribute Description network_id Network ID tunnel_key Tunnel Key
2.3.22 ryu.controller.tunnels.EventTunnelPort
An event class for tunnel port registration. This event is generated when a tunnel port is added or removed by the
REST API. An instance has at least the following attributes.
Attribute dpid
Description
OpenFlow Datapath ID port_no OpenFlow port number remote_dpid OpenFlow port number of the tunnel peer add_del True for adding a tunnel. False for removal.
2.4 Library
Ryu provides some useful library for your network applications.
14 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
2.4.1 Packet library
Introduction
Ryu packet library helps you to parse and build various protocol packets. dpkt is the popular library for the same purpose, however it is not designed to handle protocols that are interleaved; vlan, mpls, gre, etc. So we implemented our own packet library.
Network Addresses
Unless otherwise specified, MAC/IPv4/IPv6 addresses are specified using human readable strings for this library. For example, ‘08:60:6e:7f:74:e7’, ‘192.0.2.1’, ‘fe80::a60:6eff:fe7f:74e7’.
Parsing Packet
First, let’s look at how we can use the library to parse the received packets in a handler for OFPPacketIn messages.
from ryu.lib.packet
import
packet
@handler.set_ev_cls
(ofp_event .
EventOFPPacketIn, handler .
MAIN_DISPATCHER)
def
packet_in_handler ( self , ev): pkt = packet .
Packet(array .
array( 'B' , ev .
msg .
data))
for
p
in
pkt .
protocols:
p
You can create a Packet class instance with the received raw data. Then the packet library parses the data and creates protocol class instances included the data. The packet class ‘protocols’ has the protocol class instances.
If a TCP packet is received, something like the following is printed:
<ryu.lib.packet.ethernet.ethernet object at 0x107a5d790>
<ryu.lib.packet.vlan.vlan object at 0x107a5d7d0>
<ryu.lib.packet.ipv4.ipv4 object at 0x107a5d810>
<ryu.lib.packet.tcp.tcp object at 0x107a5d850>
If vlan is not used, you see something like:
<ryu.lib.packet.ethernet.ethernet object at 0x107a5d790>
<ryu.lib.packet.ipv4.ipv4 object at 0x107a5d810>
<ryu.lib.packet.tcp.tcp object at 0x107a5d850>
You can access to a specific protocol class instance by using the packet class iterator. Let’s try to check VLAN id if
VLAN is used:
from ryu.lib.packet
import
packet
@handler.set_ev_cls
(ofp_event .
EventOFPPacketIn, handler .
MAIN_DISPATCHER)
def
packet_in_handler ( self , ev): pkt = packet .
Packet(array .
array( 'B' , ev .
msg .
data))
for
p
in
pkt:
p .
protocol_name, p
if
p .
protocol_name == 'vlan' :
'vid = ' , p .
vid
You see something like:
2.4. Library 15
ryu Documentation, Release 3.21
ethernet <ryu.lib.packet.ethernet.ethernet object at 0x107a5d790> vlan <ryu.lib.packet.vlan.vlan object at 0x107a5d7d0> vid = 10 ipv4 <ryu.lib.packet.ipv4.ipv4 object at 0x107a5d810> tcp <ryu.lib.packet.tcp.tcp object at 0x107a5d850>
Building Packet
You need to create protocol class instances that you want to send, add them to a packet class instance via add_protocol method, and then call serialize method. You have the raw data to send. The following example is building an arp packet.
from ryu.ofproto
import
ether
from ryu.lib.packet
import
ethernet, arp, packet e = ethernet .
ethernet(dst = 'ff:ff:ff:ff:ff:ff' , src = '08:60:6e:7f:74:e7' , ethertype = ether .
ETH_TYPE_ARP) a = arp .
arp(hwtype = 1 , proto = 0x0800 , hlen = 6 , plen = 4 , opcode = 2 , src_mac = '08:60:6e:7f:74:e7' , src_ip = '192.0.2.1' , dst_mac = '00:00:00:00:00:00' , dst_ip = '192.0.2.2' ) p = packet .
Packet() p .
add_protocol(e) p .
add_protocol(a) p .
serialize()
repr (p .
data) # the on-wire packet
2.4.2 Packet library API Reference
Packet class
class ryu.lib.packet.packet.Packet(data=None, protocols=None
‘ryu.lib.packet.ethernet.ethernet’>)
,
A packet decoder/encoder class.
An instance is used to either decode or encode a single packet.
parse_cls=<class data is a bytearray to describe a raw datagram to decode. When decoding, a Packet object is iteratable. Iterated values are protocol (ethernet, ipv4, ...) headers and the payload. Protocol headers are instances of subclass of packet_base.PacketBase. The payload is a bytearray. They are iterated in on-wire order.
data should be omitted when encoding a packet.
add_protocol
( proto)
Register a protocol proto for this packet.
This method is legal only when encoding a packet.
When encoding a packet, register a protocol (ethernet, ipv4, ...) header to add to this packet. Protocol headers should be registered in on-wire order before calling self.serialize.
get_protocol
( protocol)
Returns the firstly found protocol that matches to the specified protocol.
get_protocols
( protocol)
Returns a list of protocols that matches to the specified protocol.
16 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
serialize
()
Encode a packet and store the resulted bytearray in self.data.
This method is legal only when encoding a packet.
Stream Parser class
class ryu.lib.packet.stream_parser.StreamParser
Streaming parser base class.
An instance of a subclass of this class is used to extract messages from a raw byte stream.
It’s designed to be used for data read from a transport which doesn’t preserve message boundaries. A typical example of such a transport is TCP.
parse
( data)
Tries to extract messages from a raw byte stream.
The data argument would be python bytes newly read from the input stream.
Returns an ordered list of extracted messages. It can be an empty list.
The rest of data which doesn’t produce a complete message is kept internally and will be used when more data is come. I.e. next time this method is called again.
try_parse
( q)
Try to extract a message from the given bytes.
This is an override point for subclasses.
This method tries to extract a message from bytes given by the argument.
Raises TooSmallException if the given data is not enough to extract a complete message but there’s still a chance to extract a message if more data is come later.
class ryu.lib.packet.bgp.StreamParser
Streaming parser for BGP-4 messages.
This is a subclass of ryu.lib.packet.stream_parser.StreamParser. Its parse method returns a list of BGPMessage subclass instances.
Protocol Header classes
class ryu.lib.packet.packet_base.PacketBase
A base class for a protocol (ethernet, ipv4, ...) header.
classmethod get_packet_type(type_)
Per-protocol dict-like get method.
Provided for convenience of protocol implementers. Internal use only.
classmethod parser(buf )
Decode a protocol header.
This method is used only when decoding a packet.
Decode a protocol header at offset 0 in bytearray buf. Returns the following three objects.
•An object to describe the decoded header.
•A packet_base.PacketBase subclass appropriate for the rest of the packet. None when the rest of the packet should be considered as raw payload.
2.4. Library 17
ryu Documentation, Release 3.21
•The rest of packet.
classmethod register_packet_type(cls_, type_)
Per-protocol dict-like set method.
Provided for convenience of protocol implementers. Internal use only.
serialize
( payload
, prev)
Encode a protocol header.
This method is used only when encoding a packet.
Encode a protocol header. Returns a bytearray which contains the header.
payload is the rest of the packet which will immediately follow this header.
prev is a packet_base.PacketBase subclass for the outer protocol header. prev is None if the current header is the outer-most. For example, prev is ipv4 or ipv6 for tcp.serialize.
class ryu.lib.packet.ethernet.ethernet(dst=’ff:ff:ff:ff:ff:ff ’, src=‘00:00:00:00:00:00’ , ethertype=2048)
Ethernet header encoder/decoder class.
An instance has the following attributes at least.
MAC addresses are represented as a string like
‘08:60:6e:7f:74:e7’. __init__ takes the corresponding args in this order.
Attribute Description dst destination address
Example
‘ff:ff:ff:ff:ff:ff’ src source address ‘08:60:6e:7f:74:e7’ ethertype ether type 0x0800 classmethod get_packet_type(type_)
Override method for the ethernet IEEE802.3 Length/Type field (self.ethertype).
If the value of Length/Type field is less than or equal to 1500 decimal(05DC hexadecimal), it means Length interpretation and be passed to the LLC sublayer.
class ryu.lib.packet.vlan.svlan(pcp=0, cfi=0, vid=0, ethertype=33024)
S-VLAN (IEEE 802.1ad) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description pcp Priority Code Point cfi vid
Canonical Format Indicator. In a case to be used as B-TAG, this field means DEI(Drop
Eligible Indication).
VLAN Identifier ethertype EtherType class ryu.lib.packet.vlan.vlan(pcp=0, cfi=0, vid=0, ethertype=2048)
VLAN (IEEE 802.1Q) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description pcp Priority Code Point cfi Canonical Format Indicator vid VLAN Identifier ethertype EtherType
18 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
classmethod get_packet_type(type_)
Override method for the Length/Type field (self.ethertype). The Length/Type field means Length or Type interpretation, same as ethernet IEEE802.3. If the value of Length/Type field is less than or equal to 1500 decimal(05DC hexadecimal), it means Length interpretation and be passed to the LLC sublayer.
class ryu.lib.packet.pbb.itag(pcp=0, dei=0, uca=0, sid=0)
I-TAG (IEEE 802.1ah-2008) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description pcp Priority Code Point dei Drop Eligible Indication uca sid
Use Customer Address
Service Instance ID class ryu.lib.packet.mpls.mpls(label=0, exp=0, bsb=1, ttl=255)
MPLS (RFC 3032) header encoder/decoder class.
NOTE: When decoding, this implementation assumes that the inner protocol is IPv4.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description label Label Value exp bsb ttl
Experimental Use
Bottom of Stack
Time To Live class ryu.lib.packet.arp.arp(hwtype=1, proto=2048 , hlen=6 , plen=4 , opcode=1 src_mac=’ff:ff:ff:ff:ff:ff ’ , src_ip=‘0.0.0.0’, dst_mac=’ff:ff:ff:ff:ff:ff ’,
, dst_ip=‘0.0.0.0’)
ARP (RFC 826) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. IPv4 addresses are represented as a string like ‘192.0.2.1’. MAC addresses are represented as a string like ‘08:60:6e:7f:74:e7’. __init__ takes the corresponding args in this order.
Attribute Description Example hwtype ar$hrd proto hlen ar$pro ar$hln plen opcode src_mac src_ip dst_mac dst_ip ar$pln ar$op ar$sha ar$spa ar$tha ar$tpa
‘08:60:6e:7f:74:e7’
‘192.0.2.1’
‘00:00:00:00:00:00’
‘192.0.2.2’ ryu.lib.packet.arp.arp_ip( opcode , src_mac, src_ip, dst_mac, dst_ip)
A convenient wrapper for IPv4 ARP for Ethernet.
This is an equivalent of the following code.
arp(ARP_HW_TYPE_ETHERNET, ether.ETH_TYPE_IP, 6, 4, opcode, src_mac, src_ip, dst_mac, dst_ip)
2.4. Library 19
ryu Documentation, Release 3.21
class ryu.lib.packet.ipv4.ipv4(version=4, header_length=5 , tos=0 , total_length=0 , identification=0 , flags=0 , offset=0 , ttl=255 , proto=0 , csum=0 , src=‘10.0.0.1’ , dst=‘10.0.0.2’, option=None)
IPv4 (RFC 791) header encoder/decoder class.
NOTE: When decoding, this implementation tries to decode the upper layer protocol even for a fragmented datagram. It isn’t likely what a user would want.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. IPv4 addresses are represented as a string like ‘192.0.2.1’. __init__ takes the corresponding args in this order.
Example Attribute version
Description
Version header_length IHL tos Type of Service total_length Total Length (0 means automatically-calculate when encoding) identification Identification flags offset
Flags
Fragment Offset ttl proto csum src dst option
Time to Live
Protocol
Header Checksum (Ignored and automatically-calculated when encoding)
Source Address
Destination Address
A bytearray which contains the entire Options, or None for no Options
‘192.0.2.1’
‘192.0.2.2’ class ryu.lib.packet.icmp.TimeExceeded(data_len=0, data=None)
ICMP sub encoder/decoder class for Time Exceeded Message.
This is used with ryu.lib.packet.icmp.icmp for ICMP Time Exceeded Message.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
[RFC4884] introduced 8-bit data length attribute.
Attribute Description data_len data length data Internet Header + leading octets of original datagram class ryu.lib.packet.icmp.dest_unreach(data_len=0, mtu=0, data=None)
ICMP sub encoder/decoder class for Destination Unreachable Message.
This is used with ryu.lib.packet.icmp.icmp for ICMP Destination Unreachable Message.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
[RFC1191] reserves bits for the “Next-Hop MTU” field. [RFC4884] introduced 8-bit data length attribute.
Attribute Description data_len data length mtu data
Next-Hop MTU
NOTE: This field is required when icmp code is 4 code 4 = fragmentation needed and DF set
Internet Header + leading octets of original datagram class ryu.lib.packet.icmp.echo(id_=0, seq=0, data=None)
ICMP sub encoder/decoder class for Echo and Echo Reply messages.
20 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
This is used with ryu.lib.packet.icmp.icmp for ICMP Echo and Echo Reply messages.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description id Identifier seq data
Sequence Number
Internet Header + 64 bits of Original Data Datagram class ryu.lib.packet.icmp.icmp(type_=8, code=0, csum=0, data=None)
ICMP (RFC 792) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description type Type code Code csum data
CheckSum (0 means automatically-calculate when encoding)
Payload. Either a bytearray, or ryu.lib.packet.icmp.echo or ryu.lib.packet.icmp.dest_unreach or ryu.lib.packet.icmp.TimeExceeded object NOTE for icmp.echo: This includes “unused” 16 bits and the following “Internet Header + 64 bits of Original Data Datagram” of the ICMP header. NOTE for icmp.dest_unreach and icmp.TimeExceeded: This includes “unused” 8 or
24 bits and the following “Internet Header + leading octets of original datagram” of the original packet.
class ryu.lib.packet.ipv6.auth(nxt=6, size=2, spi=0, seq=0, data=’x00x00x00x00’)
IP Authentication header (RFC 2402) encoder/decoder class.
This is used with ryu.lib.packet.ipv6.ipv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description nxt Next Header size spi the length of the Authentication Header in 64-bit words, subtracting 1.
security parameters index.
seq data sequence number.
authentication data.
class ryu.lib.packet.ipv6.dst_opts(nxt=6, size=0, data=None)
IPv6 (RFC 2460) destination header encoder/decoder class.
This is used with ryu.lib.packet.ipv6.ipv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description nxt Next Header size the length of the destination header, not include the first 8 octet.
data IPv6 options.
class ryu.lib.packet.ipv6.fragment(nxt=6, offset=0, more=0, id_=0)
IPv6 (RFC 2460) fragment header encoder/decoder class.
This is used with ryu.lib.packet.ipv6.ipv6.
2.4. Library 21
ryu Documentation, Release 3.21
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description nxt Next Header offset more id_ offset, in 8-octet units, relative to the start of the fragmentable part of the original packet.
1 means more fragments follow; 0 means last fragment.
packet identification value.
class ryu.lib.packet.ipv6.header(nxt) extension header abstract class.
class ryu.lib.packet.ipv6.hop_opts(nxt=6, size=0, data=None)
IPv6 (RFC 2460) Hop-by-Hop Options header encoder/decoder class.
This is used with ryu.lib.packet.ipv6.ipv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description nxt Next Header size data the length of the Hop-by-Hop Options header, not include the first 8 octet.
IPv6 options.
class ryu.lib.packet.ipv6.ipv6(version=6, traffic_class=0 , flow_label=0 , payload_length=0 , nxt=6 , hop_limit=255 , src=‘10::10’ , dst=‘20::20’ , ext_hdrs=None)
IPv6 (RFC 2460) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. IPv6 addresses are represented as a string like ‘ff02::1’. __init__ takes the corresponding args in this order.
Example Attribute version traffic_class
Description
Version
Traffic Class flow_label When decoding, Flow Label. When encoding, the most significant 8 bits of
Flow Label.
payload_length Payload Length nxt hop_limit src dst ext_hdrs
Next Header
Hop Limit
Source Address
Destination Address
Extension Headers
‘ff02::1’
‘::’ class ryu.lib.packet.ipv6.opt_header(nxt, size, data) an abstract class for Hop-by-Hop Options header and destination header.
class ryu.lib.packet.ipv6.option(type_=0, len_=-1, data=None)
IPv6 (RFC 2460) Options header encoder/decoder class.
This is used with ryu.lib.packet.ipv6.hop_opts or ryu.lib.packet.ipv6.dst_opts.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description type_ option type.
len_ data the length of data. -1 if type_ is 0.
an option value. None if len_ is 0 or -1.
22 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.lib.packet.ipv6.routing(nxt)
An IPv6 Routing Header decoder class. This class has only the parser method.
IPv6 Routing Header types.
http://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml
Value
0
1
2 Type 2 Routing Header
3 RPL Source Route Header
4 - 252 Unassigned
253
254
255
Description
Source Route (DEPRECATED)
Nimrod (DEPRECATED 2009-05-06)
RFC3692-style Experiment 1 [2]
RFC3692-style Experiment 2 [2]
Reserved
Reference
[[IPV6]][RFC5095]
[RFC6275]
[RFC6554]
[RFC4727]
[RFC4727] class ryu.lib.packet.ipv6.routing_type3(nxt=6, size=0, type_=3, seg=0, cmpi=0, cmpe=0, adrs=None)
An IPv6 Routing Header for Source Routes with the RPL (RFC 6554) encoder/decoder class.
This is used with ryu.lib.packet.ipv6.ipv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description nxt Next Header size The length of the Routing header, not include the first 8 octet. (0 means automatically-calculate when encoding) type seg cmpi cmpe pad adrs
Identifies the particular Routing header variant.
Number of route segments remaining.
Number of prefix octets from segments 1 through n-1.
Number of prefix octets from segment n.
Number of octets that are used for padding after Address[n] at the end of the SRH.
Vector of addresses, numbered 1 to n.
class ryu.lib.packet.icmpv6.echo(id_=0, seq=0, data=None)
ICMPv6 sub encoder/decoder class for Echo Request and Echo Reply messages.
This is used with ryu.lib.packet.icmpv6.icmpv6 for ICMPv6 Echo Request and Echo Reply messages.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description id Identifier seq data
Sequence Number
Data class ryu.lib.packet.icmpv6.icmpv6(type_=0, code=0, csum=0, data=None)
ICMPv6 (RFC 2463) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
2.4. Library 23
ryu Documentation, Release 3.21
Attribute Description type_ Type code Code csum data
CheckSum (0 means automatically-calculate when encoding)
Payload.
ryu.lib.packet.icmpv6.echo
object, ryu.lib.packet.icmpv6.nd_neighbor
object, ryu.lib.packet.icmpv6.nd_router_solicit object, ryu.lib.packet.icmpv6.nd_router_advert
object, ryu.lib.packet.icmpv6.mld object, or a bytearray.
class ryu.lib.packet.icmpv6.mld(maxresp=0, address=’::’)
ICMPv6 sub encoder/decoder class for MLD Lister Query, MLD Listener Report, and MLD Listener Done messages. (RFC 2710) http://www.ietf.org/rfc/rfc2710.txt
This is used with ryu.lib.packet.icmpv6.icmpv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description maxresp max response time in millisecond. it is meaningful only in Query Message.
address a group address value.
class ryu.lib.packet.icmpv6.mldv2_query(maxresp=0, address=’::’, s_flg=0, qrv=2, qqic=0, num=0 , srcs=None)
ICMPv6 sub encoder/decoder class for MLD v2 Lister Query messages. (RFC 3810) http://www.ietf.org/rfc/rfc3810.txt
This is used with ryu.lib.packet.icmpv6.icmpv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description maxresp address max response time in millisecond. it is meaningful only in Query Message.
a group address value.
s_flg qrv qqic num srcs when set to 1, routers suppress the timer process.
robustness variable for a querier.
an interval time for a querier in unit of seconds.
a number of the multicast servers.
a list of IPv6 addresses of the multicast servers.
class ryu.lib.packet.icmpv6.mldv2_report(record_num=0, records=None)
ICMPv6 sub encoder/decoder class for MLD v2 Lister Report messages. (RFC 3810) http://www.ietf.org/rfc/rfc3810.txt
This is used with ryu.lib.packet.icmpv6.icmpv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description record_num a number of the group records.
records a list of ryu.lib.packet.icmpv6.mldv2_report_group. None if no records.
class ryu.lib.packet.icmpv6.mldv2_report_group(type_=0, aux_len=0, num=0, address=’::’, srcs=None , aux=None)
ICMPv6 sub encoder/decoder class for MLD v2 Lister Report Group Record messages. (RFC 3810)
24 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
This is used with ryu.lib.packet.icmpv6.mldv2_report.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description type_ a group record type for v3.
aux_len num the length of the auxiliary data in 32-bit words.
a number of the multicast servers.
address srcs aux a group address value.
a list of IPv6 addresses of the multicast servers.
the auxiliary data.
class ryu.lib.packet.icmpv6.nd_neighbor(res=0, dst=’::’, option=None)
ICMPv6 sub encoder/decoder class for Neighbor Solicitation and Neighbor Advertisement messages. (RFC
4861)
This is used with ryu.lib.packet.icmpv6.icmpv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description res R,S,O Flags for Neighbor Advertisement. The 3 MSBs of “Reserved” field for Neighbor
Solicitation.
dst option
Target Address a derived object of ryu.lib.packet.icmpv6.nd_option or a bytearray. None if no options.
class ryu.lib.packet.icmpv6.nd_option_pi(length=0, pl=0, res1=0, val_l=0, pre_l=0, res2=0, prefix=’::’)
ICMPv6 sub encoder/decoder class for Neighbor discovery Prefix Information Option. (RFC 4861)
This is used with ryu.lib.packet.icmpv6.nd_router_advert.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description length length of the option. (0 means automatically-calculate when encoding) pl Prefix Length.
res1 val_l pre_l res2 prefix
L,A,R* Flags for Prefix Information.
Valid Lifetime.
Preferred Lifetime.
This field is unused. It MUST be initialized to zero.
An IP address or a prefix of an IP address.
*R flag is defined in (RFC 3775) class ryu.lib.packet.icmpv6.nd_option_sla(length=0, hw_src=‘00:00:00:00:00:00’
, data=None)
ICMPv6 sub encoder/decoder class for Neighbor discovery Source Link-Layer Address Option. (RFC 4861)
This is used with ryu.lib.packet.icmpv6.nd_neighbor, ryu.lib.packet.icmpv6.nd_router_solicit
or ryu.lib.packet.icmpv6.nd_router_advert.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
2.4. Library 25
ryu Documentation, Release 3.21
Attribute Description length length of the option. (0 means automatically-calculate when encoding) hw_src Link-Layer Address. NOTE: If the address is longer than 6 octets this contains the first
6 octets in the address. This implementation assumes the address has at least 6 octets.
data A bytearray which contains the rest of Link-Layer Address and padding. When encoding a packet, it’s user’s responsibility to provide necessary padding for 8-octets alignment required by the protocol.
class ryu.lib.packet.icmpv6.nd_option_tla(length=0, hw_src=‘00:00:00:00:00:00’ , data=None)
ICMPv6 sub encoder/decoder class for Neighbor discovery Target Link-Layer Address Option. (RFC 4861)
This is used with ryu.lib.packet.icmpv6.nd_neighbor.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description length length of the option. (0 means automatically-calculate when encoding) hw_src data
Link-Layer Address. NOTE: If the address is longer than 6 octets this contains the first
6 octets in the address. This implementation assumes the address has at least 6 octets.
A bytearray which contains the rest of Link-Layer Address and padding. When encoding a packet, it’s user’s responsibility to provide necessary padding for 8-octets alignment required by the protocol.
class ryu.lib.packet.icmpv6.nd_router_advert(ch_l=0, res=0, rou_l=0, rea_t=0, ret_t=0, options=None)
ICMPv6 sub encoder/decoder class for Router Advertisement messages. (RFC 4861)
This is used with ryu.lib.packet.icmpv6.icmpv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description ch_l Cur Hop Limit.
res rou_l
M,O Flags for Router Advertisement.
Router Lifetime.
rea_t ret_t options
Reachable Time.
Retrans Timer.
List of a derived object of ryu.lib.packet.icmpv6.nd_option or a bytearray. None if no options.
class ryu.lib.packet.icmpv6.nd_router_solicit(res=0, option=None)
ICMPv6 sub encoder/decoder class for Router Solicitation messages. (RFC 4861)
This is used with ryu.lib.packet.icmpv6.icmpv6.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description res This field is unused. It MUST be initialized to zero.
option a derived object of ryu.lib.packet.icmpv6.nd_option or a bytearray. None if no options.
class ryu.lib.packet.cfm.cc_message(md_lv=0, version=0 , rdi=0 , interval=4 , seq_num=0 , mep_id=1 , md_name_format=4 , md_name_length=0 , md_name=‘0’ , short_ma_name_length=0 , short_ma_name_format=2 short_ma_name=‘1’ tlvs=None)
CFM (IEEE Std 802.1ag-2007) Continuity Check Message (CCM) encoder/decoder class.
,
,
26 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute md_lv version rdi
Description
Maintenance Domain Level.
The protocol version number.
RDI bit.
interval seq_num mep_id md_name_format md_name_length
CCM Interval.The default is 4 (1 frame/s)
Sequence Number.
Maintenance association End Point Identifier.
Maintenance Domain Name Format. The default is 4 (Character string) md_name
Maintenance Domain Name Length. (0 means automatically-calculate when encoding.)
Maintenance Domain Name.
short_ma_name_format Short MA Name Format. The default is 2 (Character string) short_ma_name_length Short MA Name Format Length. (0 means automatically-calculate when encoding.) short_ma_name tlvs
Short MA Name.
TLVs.
class ryu.lib.packet.cfm.cfm(op=None)
CFM (Connectivity Fault Management) Protocol header class.
http://standards.ieee.org/getieee802/download/802.1ag-2007.pdf
OpCode Field range assignments
1
2
OpCode range CFM PDU or organization
0 Reserved for IEEE 802.1
Continuity Check Message (CCM)
Loopback Reply (LBR)
3
4
5
06 - 31
32 - 63
64 - 255
Loopback Message (LBM)
Linktrace Reply (LTR)
Linktrace Message (LTM)
Reserved for IEEE 802.1
Defined by ITU-T Y.1731
Reserved for IEEE 802.1.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description op CFM PDU class ryu.lib.packet.cfm.data_tlv(length=0, data_value=’‘)
CFM (IEEE Std 802.1ag-2007) Data TLV encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute length
Description
Length of Value field. (0 means automatically-calculate when encoding) data_value Bit pattern of any of n octets.(n = length) class ryu.lib.packet.cfm.interface_status_tlv(length=0, interface_status=1)
CFM (IEEE Std 802.1ag-2007) Interface Status TLV encoder/decoder class.
2.4. Library 27
ryu Documentation, Release 3.21
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute length
Description
Length of Value field. (0 means automatically-calculate when encoding.) interface_status Interface Status.The default is 1 (isUp) class ryu.lib.packet.cfm.link_trace_message(md_lv=0, version=0 transaction_id=0 ,
, ltm_orig_addr=‘00:00:00:00:00:00’ , ltm_targ_addr=‘00:00:00:00:00:00’ , tlvs=None)
CFM (IEEE Std 802.1ag-2007) Linktrace Message (LTM) encoder/decoder class.
use_fdb_only=1 , ttl=64 ,
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute md_lv
Description
Maintenance Domain Level.
version The protocol version number.
use_fdb_only UseFDBonly bit.
transaction_id LTM Transaction Identifier.
ttl LTM TTL.
ltm_orig_addr Original MAC Address.
ltm_targ_addr Target MAC Address.
tlvs TLVs.
class ryu.lib.packet.cfm.link_trace_reply(md_lv=0, version=0, use_fdb_only=1, fwd_yes=0, terminal_mep=1 , transaction_id=0, ttl=64, relay_action=1 , tlvs=None)
CFM (IEEE Std 802.1ag-2007) Linktrace Reply (LTR) encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description version The protocol version number.
use_fdb_only UseFDBonly bit.
fwd_yes FwdYes bit.
terminal_mep TerminalMep bit.
transaction_id LTR Transaction Identifier.
ttl Reply TTL.
relay_action tlvs
Relay Action.The default is 1 (RlyHit)
TLVs.
transaction_id=0 , class ryu.lib.packet.cfm.loopback_message(md_lv=0, version=0 , tlvs=None)
CFM (IEEE Std 802.1ag-2007) Loopback Message (LBM) encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
28 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute md_lv version
Description
Maintenance Domain Level.
The protocol version number.
transaction_id Loopback Transaction Identifier.
tlvs TLVs.
class ryu.lib.packet.cfm.loopback_reply(md_lv=0, version=0, transaction_id=0, tlvs=None)
CFM (IEEE Std 802.1ag-2007) Loopback Reply (LBR) encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute md_lv version
Description
Maintenance Domain Level.
The protocol version number.
transaction_id Loopback Transaction Identifier.
tlvs TLVs.
class ryu.lib.packet.cfm.ltm_egress_identifier_tlv(length=0, egress_id_ui=0 , egress_id_mac=‘00:00:00:00:00:00’)
CFM (IEEE Std 802.1ag-2007) LTM EGRESS TLV encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute length egress_id_ui
Description
Length of Value field. (0 means automatically-calculate when encoding.)
Egress Identifier of Unique ID.
egress_id_mac Egress Identifier of MAC address.
class ryu.lib.packet.cfm.ltr_egress_identifier_tlv(length=0, last_egress_id_ui=0 , last_egress_id_mac=‘00:00:00:00:00:00’ , next_egress_id_ui=0 , next_egress_id_mac=‘00:00:00:00:00:00’)
CFM (IEEE Std 802.1ag-2007) LTR EGRESS TLV encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute length
Description
Length of Value field. (0 means automatically-calculate when encoding.) last_egress_id_ui Last Egress Identifier of Unique ID.
last_egress_id_mac Last Egress Identifier of MAC address.
next_egress_id_ui Next Egress Identifier of Unique ID.
next_egress_id_mac Next Egress Identifier of MAC address.
class ryu.lib.packet.cfm.organization_specific_tlv(length=0, oui=’x00x00x00’ , subtype=0 , value=’‘)
CFM (IEEE Std 802.1ag-2007) Organization Specific TLV encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
2.4. Library 29
ryu Documentation, Release 3.21
Attribute Description length Length of Value field. (0 means automatically-calculate when encoding.) oui Organizationally Unique Identifier.
subtype value
Subtype.
Value.(optional) class ryu.lib.packet.cfm.port_status_tlv(length=0, port_status=2)
CFM (IEEE Std 802.1ag-2007) Port Status TLV encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute length
Description
Length of Value field. (0 means automatically-calculate when encoding.) port_status Port Status.The default is 1 (psUp) class ryu.lib.packet.cfm.reply_egress_tlv(length=0, mac_address=‘00:00:00:00:00:00’ , action=1 port_id_length=0 , port_id_subtype=0, port_id=’‘)
CFM (IEEE Std 802.1ag-2007) Reply Egress TLV encoder/decoder class.
,
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute length action
Description
Length of Value field. (0 means automatically-calculate when encoding.)
Egress Action.The default is 1 (EgrOK) mac_address port_id_length
Egress MAC Address.
Egress PortID Length. (0 means automatically-calculate when encoding.) port_id_subtype Egress PortID Subtype.
port_id Egress PortID.
class ryu.lib.packet.cfm.reply_ingress_tlv(length=0, mac_address=‘00:00:00:00:00:00’ , action=1 port_id_subtype=0 ,
, port_id_length=0 , port_id=’‘)
CFM (IEEE Std 802.1ag-2007) Reply Ingress TLV encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute length action
Description
Length of Value field. (0 means automatically-calculate when encoding.)
Ingress Action.The default is 1 (IngOK) mac_address port_id_length
Ingress MAC Address.
Ingress PortID Length. (0 means automatically-calculate when encoding.) port_id_subtype Ingress PortID Subtype.
port_id Ingress PortID.
class ryu.lib.packet.cfm.sender_id_tlv(length=0, chassis_id_length=0, chassis_id_subtype=4, chassis_id=’‘ , ma_domain_length=0, ma_domain=’‘, ma_length=0 , ma=’‘)
CFM (IEEE Std 802.1ag-2007) Sender ID TLV encoder/decoder class.
This is used with ryu.lib.packet.cfm.cfm.
30 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute length
Description
Length of Value field. (0 means automatically-calculate when encoding.) chassis_id_length Chassis ID Length. (0 means automatically-calculate when encoding.) chassis_id_subtype Chassis ID Subtype. The default is 4 (Mac Address) chassis_id Chassis ID.
ma_domain_length Management Address Domain Length. (0 means automatically-calculate when encoding.) ma_domain ma_length ma
Management Address Domain.
Management Address Length. (0 means automatically-calculate when encoding.)
Management Address.
class ryu.lib.packet.tcp.tcp(src_port=1, dst_port=1, seq=0, ack=0, offset=0, bits=0, window_size=0
, csum=0, urgent=0, option=None)
TCP (RFC 793) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute src_port dst_port seq ack offset bits
Description
Source Port
Destination Port
Sequence Number
Acknowledgement Number
Data Offset (0 means automatically-calculate when encoding)
Control Bits window_size Window csum Checksum (0 means automatically-calculate when encoding) urgent option
Urgent Pointer
An bytearray containing Options and following Padding. None if no options.
class ryu.lib.packet.udp.udp(src_port=1, dst_port=1, total_length=0, csum=0)
UDP (RFC 768) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute src_port
Description
Source Port dst_port Destination Port total_length Length (0 means automatically-calculate when encoding) csum Checksum (0 means automatically-calculate when encoding) class ryu.lib.packet.dhcp.dhcp(op, chaddr, options, htype=1, hlen=0, hops=0, xid=None, secs=0, flags=0 , ciaddr=‘0.0.0.0’, yiaddr=‘0.0.0.0’, siaddr=‘0.0.0.0’, giaddr=‘0.0.0.0’ , sname=’‘, boot_file=’‘)
DHCP (RFC 2131) header encoder/decoder class.
The serialized packet would looks like the ones described in the following sections.
•RFC 2131 DHCP packet format
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
2.4. Library 31
ryu Documentation, Release 3.21
Attribute Description op Message op code / message type. 1 = BOOTREQUEST, 2 = BOOTREPLY htype Hardware address type (e.g. ‘1’ = 10mb ethernet).
hlen hops xid
Hardware address length (e.g. ‘6’ = 10mb ethernet).
Client sets to zero, optionally used by relay agent when booting via a relay agent.
Transaction ID, a random number chosen by the client, used by the client and serverto associate messages and responses between a client and a server.
Filled in by client, seconds elapsed since client began address acquisition or renewal process.
secs flags ciaddr
Flags.
Client IP address; only filled in if client is in BOUND, RENEW or REBINDING state and can respond to ARP requests.
yiaddr siaddr giaddr chaddr
‘your’ (client) IP address.
IP address of next server to use in bootstrap; returned in DHCPOFFER, DHCPACK by server.
Relay agent IP address, used in booting via a relay agent.
Client hardware address.
sname Optional server host name, null terminated string.
boot_file Boot file name, null terminated string; “generic” name or null in DHCPDISCOVER, fully qualified directory-path name in DHCPOFFER.
options Optional parameters field (‘DHCP message type’ option must be included in every DHCP message).
class ryu.lib.packet.dhcp.options(option_list=None, magic_cookie=‘99.130.83.99’)
DHCP (RFC 2132) options encoder/decoder class.
options_len=0
,
This is used with ryu.lib.packet.dhcp.dhcp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute option_list
Description
‘end option’ and ‘pad option’ are added automatically after the option class is stored in array.
options_len Option’s byte length. (‘magic cookie’, ‘end option’ and ‘pad option’ length including.) magic_cookie The first four octets contain the decimal values 99, 130, 83 and 99.
class ryu.lib.packet.dhcp.option(tag, value, length=0)
DHCP (RFC 2132) options encoder/decoder class.
This is used with ryu.lib.packet.dhcp.dhcp.options.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description tag Option type. (except for the ‘magic cookie’, ‘pad option’ and ‘end option’.) value Option’s value. (set the value that has been converted to hexadecimal.) length Option’s value length. (calculated automatically from the length of value.) class ryu.lib.packet.vrrp.vrrp(version, type_, vrid, priority, count_ip, max_adver_int, checksum, ip_addresses , auth_type=None, auth_data=None)
The base class for VRRPv2 (RFC 3768) and VRRPv3 (RFC 5798) header encoder/decoder classes.
Unlike other ryu.lib.packet.packet_base.PacketBase derived classes, This class should not be directly instantiated by user.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order.
32 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute version type
Description
Version
Type vrid priority
Virtual Rtr ID (VRID)
Priority count_ip Count IPvX Addr. Calculated automatically when encoding.
max_adver_int Maximum Advertisement Interval (Max Adver Int) checksum ip_addresses auth_type auth_data
Checksum. Calculated automatically when encoding.
IPvX Address(es). A python list of IP addresses.
Authentication Type (only for VRRPv2)
Authentication Data (only for VRRPv2)
create_packet
( primary_ip_address , vlan_id=None)
Prepare a VRRP packet.
Returns a newly created ryu.lib.packet.packet.Packet object with appropriate protocol header objects added by add_protocol(). It’s caller’s responsibility to serialize(). The serialized packet would looks like the ones described in the following sections.
•RFC 3768 5.1. VRRP Packet Format
•RFC 5798 5.1. VRRP Packet Format
Argument Description primary_ip_address Source IP address vlan_id VLAN ID. None for no VLAN.
class ryu.lib.packet.vrrp.vrrpv2(version, type_, vrid, priority, count_ip, max_adver_int, checksum , ip_addresses, auth_type=None, auth_data=None)
VRRPv2 (RFC 3768) header encoder/decoder class.
Unlike other ryu.lib.packet.packet_base.PacketBase derived classes, create method should be used to instantiate an object of this class.
static create(type_, vrid, priority, max_adver_int, ip_addresses)
Unlike other ryu.lib.packet.packet_base.PacketBase derived classes, this method should be used to instantiate an object of this class.
This method’s arguments are same as ryu.lib.packet.vrrp.vrrp object’s attributes of the same name. (except that type_ corresponds to type attribute.) class ryu.lib.packet.vrrp.vrrpv3(version, type_, vrid, priority, count_ip, max_adver_int, checksum , ip_addresses, auth_type=None, auth_data=None)
VRRPv3 (RFC 5798) header encoder/decoder class.
Unlike other ryu.lib.packet.packet_base.PacketBase derived classes, create method should be used to instantiate an object of this class.
static create(type_, vrid, priority, max_adver_int, ip_addresses)
Unlike other ryu.lib.packet.packet_base.PacketBase derived classes, this method should be used to instantiate an object of this class.
This method’s arguments are same as ryu.lib.packet.vrrp.vrrp object’s attributes of the same name. (except that type_ corresponds to type attribute.) class ryu.lib.packet.slow.slow
Slow Protocol header decoder class. This class has only the parser method.
http://standards.ieee.org/getieee802/download/802.3-2012_section5.pdf
Slow Protocols Subtypes
2.4. Library 33
ryu Documentation, Release 3.21
Subtype Value Protocol Name
0 Unused - Illegal Value
1 Link Aggregation Control Protocol(LACP)
2
3
4 - 9
10
11 - 255
Link Aggregation - Marker Protocol
Operations, Administration, and Maintenance(OAM)
Reserved for future use
Organization Specific Slow Protocol(OSSP)
Unused - Illegal values class ryu.lib.packet.slow.lacp(version=1, tor_system=‘00:00:00:00:00:00’
, tor_port_priority=0 , actor_system_priority=0
, actor_port=0 , actor_key=0
, acacactor_state_activity=0 , actor_state_timeout=0 , tor_state_synchronization=0 , actor_state_aggregation=0 , acactor_state_collecting=0 , actor_state_distributing=0 , tor_state_expired=0 , actor_state_defaulted=0 partner_system_priority=0 ,
, acpartner_system=‘00:00:00:00:00:00’ , partner_key=0 , partner_port_priority=0 , partner_port=0 , partner_state_activity=0 , partner_state_timeout=0 , partner_state_aggregation=0 , partner_state_synchronization=0 , partner_state_collecting=0 , partner_state_distributing=0 , partner_state_defaulted=0 , partner_state_expired=0 , collector_max_delay=0)
Link Aggregation Control Protocol(LACP, IEEE 802.1AX) header encoder/decoder class.
http://standards.ieee.org/getieee802/download/802.1AX-2008.pdf
LACPDU format
34 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
LACPDU structure
Subtype = LACP
Version Number
TLV Actor TLV_type = Actor Information
Actor_Information_Length = 20
Actor_System_Priority
Actor_System
TLV Partner
Actor_Key
Actor_Port_Priority
Actor_Port
Actor_State
Reserved
TLV_type = Partner Information
Partner_Information_Length = 20
Partner_System_Priority
Partner_System
TLV Collector
Partner_Key
Partner_Port_Priority
Partner_Port
Partner_State
Reserved 3
TLV_type = Collector Information 1
Collector_Information_Length = 16 1
Collector_Max_Delay 2
2
1
2
2
Reserved
TLV Terminator TLV_type = Terminator
Terminator_Length = 0
Reserved
12
1
1
50
1
2
3
1
6
2
1
2
2
2
6
1
1
Octets
1
1
Terminator information uses a length value of 0 (0x00).
NOTE–The use of a Terminator_Length of 0 is intentional. In TLV encoding schemes it is common practice for the terminator encoding to be 0 both for the type and the length.
Actor_State and Partner_State encoded as individual bits within a single octet as follows:
7 6 5 4 3 2 1 0
EXPR DFLT DIST CLCT SYNC AGGR TMO ACT
ACT bit 0. about the activity control value with regard to this link.
TMO bit 1. about the timeout control value with regard to this link.
AGGR bit 2. about how the system regards this link from the point of view of the aggregation.
SYNC bit 3. about how the system regards this link from the point of view of the synchronization.
CLCT bit 4. about collecting of incoming frames.
DIST bit 5. about distributing of outgoing frames.
DFLT bit 6. about the opposite system information which the system use.
EXPR bit 7. about the expire state of the system.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
2.4. Library 35
ryu Documentation, Release 3.21
Attribute version actor_system_priority actor_system actor_key actor_port_priority actor_port actor_state_activity
Description
LACP version. This parameter must be set to
LACP_VERSION_NUMBER(i.e. 1).
The priority assigned to this System.
The Actor’s System ID, encoded as a MAC address.
The operational Key value assigned to the port by the Actor.
The priority assigned to this port.
The port number assigned to the port by the Actor.
about the activity control value with regard to this link.
LACP_STATE_ACTIVE(1)
LACP_STATE_PASSIVE(0) actor_state_timeout about the timeout control value with regard to this link.
LACP_STATE_SHORT_TIMEOUT(1)
LACP_STATE_LONG_TIMEOUT(0) actor_state_aggregation about how the system regards this link from the point of view of the aggregation.
LACP_STATE_AGGREGATEABLE(1)
LACP_STATE_INDIVIDUAL(0) actor_state_synchronization about how the system regards this link from the point of view of the synchronization.
LACP_STATE_IN_SYNC(1)
LACP_STATE_OUT_OF_SYNC(0) actor_state_collecting about collecting of incoming frames.
LACP_STATE_COLLECTING_ENABLED(1)
LACP_STATE_COLLECTING_DISABLED(0) actor_state_distributing about distributing of outgoing frames.
LACP_STATE_DISTRIBUTING_ENABLED(1)
LACP_STATE_DISTRIBUTING_DISABLED(0) actor_state_defaulted about the Partner information which the the Actor use.
LACP_STATE_DEFAULTED_PARTNER(1)
LACP_STATE_OPERATIONAL_PARTNER(0) actor_state_expired about the state of the Actor.
LACP_STATE_EXPIRED(1)
LACP_STATE_NOT_EXPIRED(0) partner_system_priority partner_system partner_key partner_port_priority
The priority assigned to the Partner System.
The Partner’s System ID, encoded as a MAC address.
The operational Key value assigned to the port by the Partner.
The priority assigned to this port by the Partner.
partner_port partner_state_activity partner_state_timeout partner_state_aggregation
The port number assigned to the port by the Partner.
See
See
See
partner_state_synchronization See
partner_state_collecting partner_state_distributing partner_state_defaulted partner_state_expired collector_max_delay
See
See
See
See
the maximum time that the Frame Collector may delay.
36 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.lib.packet.llc.llc(dsap_addr, ssap_addr, control)
LLC(IEEE 802.2) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description dsap_addr Destination service access point address field includes I/G bit at least significant bit.
ssap_addr Source service access point address field includes C/R bit at least significant bit.
control Control field [16 bits for formats that include sequence numbering, and 8 bits for formats that do not]. Either ryu.lib.packet.llc.ControlFormatI or ryu.lib.packet.llc.ControlFormatS or ryu.lib.packet.llc.ControlFormatU object.
class ryu.lib.packet.llc.ControlFormatI(send_sequence_number=0, ceive_sequence_number=0)
LLC sub encoder/decoder class for control I-format field.
pf_bit=0 , re-
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute send_sequence_number
Description sender send sequence number pf_bit poll/final bit receive_sequence_number sender receive sequence number class ryu.lib.packet.llc.ControlFormatS(supervisory_function=0, ceive_sequence_number=0)
LLC sub encoder/decoder class for control S-format field.
pf_bit=0 , re-
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute supervisory_function
Description supervisory function bit pf_bit poll/final bit receive_sequence_number sender receive sequence number class ryu.lib.packet.llc.ControlFormatU(modifier_function1=0, fier_function2=0)
LLC sub encoder/decoder class for control U-format field.
pf_bit=0 , modi-
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description modifier_function1 modifier function bit pf_bit poll/final bit modifier_function2 modifier function bit class ryu.lib.packet.bpdu.bpdu
Bridge Protocol Data Unit(BPDU) header encoder/decoder base class.
class ryu.lib.packet.bpdu.ConfigurationBPDUs(flags=0, root_priority=32768 root_system_id_extension=0 ,
, root_mac_address=‘00:00:00:00:00:00’ , root_path_cost=0 , bridge_priority=32768 , bridge_system_id_extension=0 , bridge_mac_address=‘00:00:00:00:00:00’ , port_priority=128 , port_number=0 , message_age=0 , max_age=20 , hello_time=2 , forward_delay=15)
2.4. Library 37
ryu Documentation, Release 3.21
Configuration BPDUs(IEEE 802.1D) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute flags
Description
Bit 1: Topology Change flag
Bits 2 through 7: unused and take the value 0
Bit 8: Topology Change Acknowledgment flag root_priority root_system_id_extension root_mac_address root_path_cost bridge_priority bridge_system_id_extension bridge_mac_address port_priority port_number message_age max_age hello_time forward_delay
Root Identifier priority set 0-61440 in steps of 4096
Root Identifier system ID extension
Root Identifier MAC address
Root Path Cost
Bridge Identifier priority set 0-61440 in steps of 4096
Bridge Identifier system ID extension
Bridge Identifier MAC address
Port Identifier priority set 0-240 in steps of 16
Port Identifier number
Message Age timer value
Max Age timer value
Hello Time timer value
Forward Delay timer value class ryu.lib.packet.bpdu.TopologyChangeNotificationBPDUs
Topology Change Notification BPDUs(IEEE 802.1D) header encoder/decoder class.
class ryu.lib.packet.bpdu.RstBPDUs(flags=0, root_priority=32768, root_system_id_extension=0, root_mac_address=‘00:00:00:00:00:00’ , root_path_cost=0, bridge_priority=32768 , bridge_system_id_extension=0 , bridge_mac_address=‘00:00:00:00:00:00’ , port_priority=128
, port_number=0
, message_age=0
, max_age=20
, hello_time=2, forward_delay=15)
Rapid Spanning Tree BPDUs(RST BPDUs, IEEE 802.1D) header encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
38 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute flags
Description
Bit 1: Topology Change flag
Bit 2: Proposal flag
Bits 3 and 4: Port Role
Bit 5: Learning flag
Bit 6: Forwarding flag
Bit 7: Agreement flag
Bit 8: Topology Change Acknowledgment flag root_priority root_system_id_extension root_mac_address root_path_cost bridge_priority bridge_system_id_extension bridge_mac_address port_priority port_number message_age max_age hello_time forward_delay
Root Identifier priority set 0-61440 in steps of 4096
Root Identifier system ID extension
Root Identifier MAC address
Root Path Cost
Bridge Identifier priority set 0-61440 in steps of 4096
Bridge Identifier system ID extension
Bridge Identifier MAC address
Port Identifier priority set 0-240 in steps of 16
Port Identifier number
Message Age timer value
Max Age timer value
Hello Time timer value
Forward Delay timer value class ryu.lib.packet.igmp.igmp(msgtype=17, maxresp=0, csum=0, address=‘0.0.0.0’)
Internet Group Management Protocol(IGMP, RFC 1112, RFC 2236) header encoder/decoder class.
http://www.ietf.org/rfc/rfc1112.txt
http://www.ietf.org/rfc/rfc2236.txt
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description msgtype a message type for v2, or a combination of version and a message type for v1.
maxresp max response time in unit of 1/10 second. it is meaningful only in Query Message.
csum address a check sum value. 0 means automatically-calculate when encoding.
a group address value.
class ryu.lib.packet.igmp.igmpv3_query(msgtype=17, maxresp=100 , csum=0 , address=‘0.0.0.0’ , s_flg=0 , qrv=2 , qqic=0 , num=0 , srcs=None)
Internet Group Management Protocol(IGMP, RFC 3376) Membership Query message encoder/decoder class.
http://www.ietf.org/rfc/rfc3376.txt
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
2.4. Library 39
ryu Documentation, Release 3.21
Attribute Description msgtype a message type for v3.
maxresp max response time in unit of 1/10 second.
csum address s_flg qrv a check sum value. 0 means automatically-calculate when encoding.
a group address value.
when set to 1, routers suppress the timer process.
robustness variable for a querier.
qqic num srcs an interval time for a querier in unit of seconds.
a number of the multicast servers.
a list of IPv4 addresses of the multicast servers.
class ryu.lib.packet.igmp.igmpv3_report(msgtype=34, csum=0 , record_num=0 , records=None)
Internet Group Management Protocol(IGMP, RFC 3376) Membership Report message encoder/decoder class.
http://www.ietf.org/rfc/rfc3376.txt
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute msgtype csum
Description a message type for v3.
a check sum value. 0 means automatically-calculate when encoding.
record_num a number of the group records.
records a list of ryu.lib.packet.igmp.igmpv3_report_group. None if no records.
class ryu.lib.packet.igmp.igmpv3_report_group(type_=0, aux_len=0 , num=0 , address=‘0.0.0.0’ , srcs=None, aux=None)
Internet Group Management Protocol(IGMP, RFC 3376) Membership Report Group Record message encoder/decoder class.
http://www.ietf.org/rfc/rfc3376.txt
This is used with ryu.lib.packet.igmp.igmpv3_report.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description type_ a group record type for v3.
aux_len the length of the auxiliary data.
num address srcs aux a number of the multicast servers.
a group address value.
a list of IPv4 addresses of the multicast servers.
the auxiliary data.
class ryu.lib.packet.bgp.BGPMessage(type_, len_=None, marker=None)
Base class for BGP-4 messages.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description marker Marker field. Ignored when encoding.
len type
Length field. Ignored when encoding.
Type field. one of BGP_MSG_ constants.
class ryu.lib.packet.bgp.BGPOpen(my_as, bgp_identifier , opt_param=[] , version=4 , marker=None)
BGP-4 OPEN Message encoder/decoder class.
type_=1 , opt_param_len=0 , hold_time=0 , len_=None ,
40 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute marker len type
Description
Marker field. Ignored when encoding.
Length field. Ignored when encoding.
Type field. The default is BGP_MSG_OPEN.
version my_as
Version field. The default is 4.
My Autonomous System field. 2 octet unsigned integer.
hold_time Hold Time field. 2 octet unsigned integer. The default is 0.
bgp_identifier BGP Identifier field. An IPv4 address. For example, ‘192.0.2.1’ opt_param_len Optional Parameters Length field. Ignored when encoding.
opt_param Optional Parameters field. A list of BGPOptParam instances. The default is [].
class ryu.lib.packet.bgp.BGPUpdate(type_=2, drawn_routes=[] , withdrawn_routes_len=None , withtotal_path_attribute_len=None , path_attributes=[] , nlri=[], len_=None, marker=None)
BGP-4 UPDATE Message encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute marker len type withdrawn_routes_len
Description
Marker field. Ignored when encoding.
Length field. Ignored when encoding.
Type field. The default is BGP_MSG_UPDATE.
Withdrawn Routes Length field. Ignored when encoding.
withdrawn_routes Withdrawn Routes field. A list of BGPWithdrawnRoute instances. The default is
[].
total_path_attribute_len Total Path Attribute Length field. Ignored when encoding.
path_attributes nlri
Path Attributes field. A list of BGPPathAttribute instances. The default is [].
Network Layer Reachability Information field. A list of BGPNLRI instances.
The default is [].
class ryu.lib.packet.bgp.BGPKeepAlive(type_=4, len_=None, marker=None)
BGP-4 KEEPALIVE Message encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description marker Marker field. Ignored when encoding.
len type
Length field. Ignored when encoding.
Type field. The default is BGP_MSG_KEEPALIVE.
class ryu.lib.packet.bgp.BGPNotification(error_code, error_subcode , data=’‘ , type_=3 , len_=None , marker=None)
BGP-4 NOTIFICATION Message encoder/decoder class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute marker len type
Description
Marker field. Ignored when encoding.
Length field. Ignored when encoding.
Type field. The default is BGP_MSG_NOTIFICATION.
error_code Error code field.
error_subcode Error subcode field.
data Data field. The default is ‘’.
2.4. Library 41
ryu Documentation, Release 3.21
class ryu.lib.packet.sctp.cause_cookie_while_shutdown(length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Cookie Received While Shutting
Down (RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_invalid_param(length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Invalid Mandatory Parameter
(RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_invalid_stream_id(value=0, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Invalid Stream Identifier (RFC
4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value stream id.
length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_missing_param(types=None, num=0, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Missing Mandatory Parameter
(RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description types a list of missing params.
num length
Number of missing params. (0 means automatically-calculate when encoding) length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_no_userdata(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for No User Data (RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value the TSN of the DATA chunk received with no user data field.
length length of this cause containing this header. (0 means automatically-calculate when encoding)
42 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.lib.packet.sctp.cause_out_of_resource(length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Out of Resource (RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_protocol_violation(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Protocol Violation (RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value Additional Information.
length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_restart_with_new_addr(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Restart of an Association with
New Addresses (RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value New Address TLVs.
length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_stale_cookie(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Stale Cookie Error (RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value Measure of Staleness.
length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_unrecognized_chunk(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Unrecognized Chunk Type (RFC
4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value Unrecognized Chunk.
length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_unrecognized_param(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Unrecognized Parameters (RFC
4960).
2.4. Library 43
ryu Documentation, Release 3.21
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value Unrecognized Parameter.
length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_unresolvable_addr(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Unresolvable Address (RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value Unresolvable Address. one of follows: ryu.lib.packet.sctp.param_host_addr, ryu.lib.packet.sctp.param_ipv4, or ryu.lib.packet.sctp.param_ipv6.
length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.cause_user_initiated_abort(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for User-Initiated Abort (RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_abort and ryu.lib.packet.sctp.chunk_error.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value Upper Layer Abort Reason.
length length of this cause containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.chunk_abort(tflag=0, length=0, causes=None)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Abort Association (ABORT) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description tflag ‘0’ means the Verification tag is normal. ‘1’ means the Verification tag is copy of the sender.
length length of this chunk containing this header. (0 means automatically-calculate when encoding) causes a list of derived classes of ryu.lib.packet.sctp.causes.
class ryu.lib.packet.sctp.chunk_cookie_ack(flags=0, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Cookie Acknowledgement
(COOKIE ACK) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description flags set to ‘0’. this field will be ignored.
length length of this chunk containing this header. (0 means automatically-calculate when encoding)
44 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.lib.packet.sctp.chunk_cookie_echo(flags=0, length=0, cookie=None)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Cookie Echo (COOKIE ECHO) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description flags set to ‘0’. this field will be ignored.
length length of this chunk containing this header. (0 means automatically-calculate when encoding) cookie cookie data.
class ryu.lib.packet.sctp.chunk_cwr(flags=0, length=0, low_tsn=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for CWR chunk (RFC 4960 Appendix
A.).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description flags set to ‘0’. this field will be ignored.
length length of this chunk containing this header. (0 means automatically-calculate when encoding) low_tsn the lowest TSN.
class ryu.lib.packet.sctp.chunk_data(unordered=0, begin=0, end=0, length=0, tsn=0, sid=0, seq=0 , payload_id=0, payload_data=None)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Payload Data (DATA) chunk (RFC
4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute unordered begin end length
Description if set to ‘1’, the receiver ignores the sequence number.
if set to ‘1’, this chunk is the first fragment.
if set to ‘1’, this chunk is the last fragment.
length of this chunk containing this header. (0 means automatically-calculate when encoding)
Transmission Sequence Number.
tsn sid seq stream id.
the sequence number.
payload_id application specified protocol id. ‘0’ means that no application id is identified.
payload_data user data.
class ryu.lib.packet.sctp.chunk_ecn_echo(flags=0, length=0, low_tsn=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for ECN-Echo chunk (RFC 4960
Appendix A.).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
2.4. Library 45
ryu Documentation, Release 3.21
Attribute Description flags set to ‘0’. this field will be ignored.
length length of this chunk containing this header. (0 means automatically-calculate when encoding) low_tsn the lowest TSN.
class ryu.lib.packet.sctp.chunk_error(flags=0, length=0, causes=None)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Operation Error (ERROR) chunk
(RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description flags set to ‘0’. this field will be ignored.
length causes length of this chunk containing this header. (0 means automatically-calculate when encoding) a list of derived classes of ryu.lib.packet.sctp.causes.
class ryu.lib.packet.sctp.chunk_heartbeat(flags=0, length=0, info=None)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Heartbeat Request (HEARTBEAT) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description flags set to ‘0’. this field will be ignored.
length info length of this chunk containing this header. (0 means automatically-calculate when encoding) ryu.lib.packet.sctp.param_heartbeat.
class ryu.lib.packet.sctp.chunk_heartbeat_ack(flags=0, length=0, info=None)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Heartbeat Acknowledgement
(HEARTBEAT ACK) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description flags set to ‘0’. this field will be ignored.
length length of this chunk containing this header. (0 means automatically-calculate when encoding) info ryu.lib.packet.sctp.param_heartbeat.
class ryu.lib.packet.sctp.chunk_init(flags=0, length=0, init_tag=0, a_rwnd=0, os=0, mis=0, i_tsn=0 , params=None)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Initiation (INIT) chunk (RFC
4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
46 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute Description flags set to ‘0’. this field will be ignored.
length length of this chunk containing this header. (0 means automatically-calculate when encoding) init_tag a_rwnd os mis i_tsn params the tag that be used as Verification Tag.
Advertised Receiver Window Credit.
number of outbound streams.
number of inbound streams.
Transmission Sequence Number that the sender will use.
Optional/Variable-Length Parameters.
a list of derived classes of ryu.lib.packet.sctp.param.
class ryu.lib.packet.sctp.chunk_init_ack(flags=0, length=0, init_tag=0, a_rwnd=0, os=0, mis=0 , i_tsn=0, params=None)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Initiation Acknowledgement (INIT
ACK) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description flags set to ‘0’. this field will be ignored.
length length of this chunk containing this header. (0 means automatically-calculate when encoding) init_tag a_rwnd os mis i_tsn params the tag that be used as Verification Tag.
Advertised Receiver Window Credit.
number of outbound streams.
number of inbound streams.
Transmission Sequence Number that the sender will use.
Optional/Variable-Length Parameters.
a list of derived classes of ryu.lib.packet.sctp.param.
class ryu.lib.packet.sctp.chunk_sack(flags=0, length=0, tsn_ack=0, a_rwnd=0, gapack_num=0, duptsn_num=0 , gapacks=None, duptsns=None)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Selective Acknowledgement
(SACK) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute flags length
Description set to ‘0’. this field will be ignored.
length of this chunk containing this header. (0 means automatically-calculate when encoding) tsn_ack a_rwnd gapack_num number of Gap Ack blocks.
duptsn_num number of duplicate TSNs.
gapacks
TSN of the last DATA chunk received in sequence before a gap.
Advertised Receiver Window Credit.
duptsns a list of Gap Ack blocks. one block is made of a list with the start offset and the end offset from tsn_ack. e.g.) gapacks = [[2, 3], [10, 12], [19, 21]] a list of duplicate TSN.
class ryu.lib.packet.sctp.chunk_shutdown(flags=0, length=0, tsn_ack=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Shutdown Association (SHUT-
DOWN) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
2.4. Library 47
ryu Documentation, Release 3.21
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description flags set to ‘0’. this field will be ignored.
length tsn_ack length of this chunk containing this header. (0 means automatically-calculate when encoding)
TSN of the last DATA chunk received in sequence before a gap.
class ryu.lib.packet.sctp.chunk_shutdown_ack(flags=0, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Shutdown Acknowledgement
(SHUTDOWN ACK) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description flags set to ‘0’. this field will be ignored.
length length of this chunk containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.chunk_shutdown_complete(tflag=0, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Shutdown Complete (SHUT-
DOWN COMPLETE) chunk (RFC 4960).
This is used with ryu.lib.packet.sctp.sctp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description tflag ‘0’ means the Verification tag is normal. ‘1’ means the Verification tag is copy of the sender.
length length of this chunk containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.param_cookie_preserve(value=0, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Cookie Preservative Parameter
(RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_init.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value Suggested Cookie Life-Span Increment (msec).
length length of this param containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.param_ecn(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for ECN Parameter (RFC 4960 Appendix A.).
This is used with ryu.lib.packet.sctp.chunk_init and ryu.lib.packet.sctp.chunk_init_ack.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value set to None.
length length of this param containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.param_heartbeat(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Heartbeat Info Parameter (RFC
4960).
48 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
This is used with ryu.lib.packet.sctp.chunk_heartbeat and ryu.lib.packet.sctp.chunk_heartbeat_ack.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value the sender-specific heartbeat information.
length length of this param containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.param_host_addr(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Host Name Address Parameter
(RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_init and ryu.lib.packet.sctp.chunk_init_ack.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value a host name that ends with null terminator.
length length of this param containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.param_ipv4(value=‘127.0.0.1’, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for IPv4 Address Parameter (RFC
4960).
This is used with ryu.lib.packet.sctp.chunk_init and ryu.lib.packet.sctp.chunk_init_ack.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value IPv4 address of the sending endpoint.
length length of this param containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.param_ipv6(value=’::1’, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for IPv6 Address Parameter (RFC
4960).
This is used with ryu.lib.packet.sctp.chunk_init and ryu.lib.packet.sctp.chunk_init_ack.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value IPv6 address of the sending endpoint.
length length of this param containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.param_state_cookie(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for State Cookie Parameter (RFC
4960).
This is used with ryu.lib.packet.sctp.chunk_init_ack.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value the state cookie. see Section 5.1.3 in RFC 4960.
length length of this param containing this header. (0 means automatically-calculate when encoding)
2.4. Library 49
ryu Documentation, Release 3.21
class ryu.lib.packet.sctp.param_supported_addr(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Supported Address Types Parameter (RFC 4960).
This is used with ryu.lib.packet.sctp.chunk_init.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value a list of parameter types. odd cases pad with 0x0000.
length length of this param containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.param_unrecognized_param(value=None, length=0)
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Unrecognized Parameter (RFC
4960).
This is used with ryu.lib.packet.sctp.chunk_init_ack.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description value the unrecognized parameter in the INIT chunk.
length length of this param containing this header. (0 means automatically-calculate when encoding) class ryu.lib.packet.sctp.sctp(src_port=1, dst_port=1, vtag=0, csum=0, chunks=None)
Stream Control Transmission Protocol (SCTP) header encoder/decoder class (RFC 4960).
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description src_port Source Port dst_port vtag
Destination Port
Verification Tag csum chunks
Checksum (0 means automatically-calculate when encoding) a list of derived classes of ryu.lib.packet.sctp.chunk.
class ryu.lib.packet.bfd.bfd(ver=1, diag=0 , state=0 , flags=0 , detect_mult=0 my_discr=0 , your_discr=0 , desired_min_tx_interval=0 , re-
, required_min_echo_rx_interval=0 , quired_min_rx_interval=0 , auth_cls=None , length=None)
BFD (RFC 5880) Control packet encoder/decoder class.
The serialized packet would looks like the ones described in the following sections.
•RFC 5880 Generic BFD Control Packet Format
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order.
__init__ takes the corresponding args in this order.
50 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute ver diag state flags
Description
The version number of the protocol. This class implements protocol version 1.
A diagnostic code specifying the local system’s reason for the last change in session state.
The current BFD session state as seen by the transmitting system.
Bitmap of the following flags.
BFD_FLAG_POLL
BFD_FLAG_FINAL
BFD_FLAG_CTRL_PLANE_INDEP
BFD_FLAG_AUTH_PRESENT
BFD_FLAG_DEMAND
BFD_FLAG_MULTIPOINT detect_mult my_discr
Detection time multiplier.
My Discriminator.
your_discr desired_min_tx_interval required_min_rx_interval Required Min RX Interval. (in microseconds) required_min_echo_rx_interval Required Min Echo RX Interval. (in microseconds) auth_cls
Your Discriminator.
Desired Min TX Interval. (in microseconds)
(Optional) Authentication Section instance. It’s defined only when the
Authentication Present (A) bit is set in flags. Assign an instance of the following classes: SimplePassword, KeyedMD5,
MeticulousKeyedMD5
, KeyedSHA1, and
MeticulousKeyedSHA1
.
length (Optional) Length of the BFD Control packet, in bytes.
authenticate
( *args
, **kwargs)
Authenticate this packet.
Returns a boolean indicates whether the packet can be authenticated or not.
Returns False if the Authentication Present (A) is not set in the flag of this packet.
Returns False if the Authentication Section for this packet is not present.
For the description of the arguemnts of this method, refer to the authentication method of the Authentication Section classes.
pack
()
Encode a BFD Control packet without authentication section.
class ryu.lib.packet.bfd.SimplePassword(auth_key_id, password, auth_len=None)
BFD (RFC 5880) Simple Password Authentication Section class
An instance has the following attributes. Most of them are same to the on-wire counterparts but in host byte order.
Attribute auth_type
Description
(Fixed) The authentication type in use.
auth_key_id The authentication Key ID in use.
password auth_len
The simple password in use on this session. The password is a binary string, and MUST be from 1 to 16 bytes in length.
The length, in bytes, of the authentication section, including the auth_type and auth_len fields.
2.4. Library 51
ryu Documentation, Release 3.21
authenticate
( prev=None , auth_keys={})
Authenticate the password for this packet.
This method can be invoked only when self.password is defined.
Returns a boolean indicates whether the password can be authenticated or not.
prev is a bfd instance for the BFD Control header. It’s not necessary for authenticating the Simple
Password.
auth_keys is a dictionary of authentication key chain which key is an integer of Auth Key ID and value is a string of Password.
serialize
( payload , prev)
Encode a Simple Password Authentication Section.
payload is the rest of the packet which will immediately follow this section.
prev is a bfd instance for the BFD Control header. It’s not necessary for encoding only the Simple
Password section.
class ryu.lib.packet.bfd.KeyedMD5(auth_key_id, auth_len=None)
BFD (RFC 5880) Keyed MD5 Authentication Section class seq , auth_key=None , digest=None ,
An instance has the following attributes. Most of them are same to the on-wire counterparts but in host byte order.
Attribute auth_type
Description
(Fixed) The authentication type in use.
auth_key_id The authentication Key ID in use.
seq The sequence number for this packet. This value is incremented occasionally.
auth_key digest auth_len
The shared MD5 key for this packet.
(Optional) The 16-byte MD5 digest for the packet.
(Fixed) The length of the authentication section is 24 bytes.
authenticate
( prev , auth_keys={})
Authenticate the MD5 digest for this packet.
This method can be invoked only when self.digest is defined.
Returns a boolean indicates whether the digest can be authenticated by the correspondent Auth Key or not.
prev is a bfd instance for the BFD Control header which this authentication section belongs to. It’s necessary to be assigned because an MD5 digest must be calculated over the entire BFD Control packet.
auth_keys is a dictionary of authentication key chain which key is an integer of Auth Key ID and value is a string of Auth Key.
serialize
( payload , prev)
Encode a Keyed MD5 Authentication Section.
This method is used only when encoding an BFD Control packet.
payload is the rest of the packet which will immediately follow this section.
prev is a bfd instance for the BFD Control header which this authentication section belongs to. It’s necessary to be assigned because an MD5 digest must be calculated over the entire BFD Control packet.
class ryu.lib.packet.bfd.MeticulousKeyedMD5(auth_key_id, seq, auth_key=None, digest=None, auth_len=None)
BFD (RFC 5880) Meticulous Keyed MD5 Authentication Section class
All methods of this class are inherited from KeyedMD5.
52 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
An instance has the following attributes. Most of them are same to the on-wire counterparts but in host byte order.
Attribute auth_type
Description
(Fixed) The authentication type in use.
auth_key_id The authentication Key ID in use.
seq The sequence number for this packet. This value is incremented for each successive packet transmitted for a session.
auth_key digest auth_len
The shared MD5 key for this packet.
(Optional) The 16-byte MD5 digest for the packet.
(Fixed) The length of the authentication section is 24 bytes.
class ryu.lib.packet.bfd.KeyedSHA1(auth_key_id, seq , auth_key=None , auth_hash=None , auth_len=None)
BFD (RFC 5880) Keyed SHA1 Authentication Section class
An instance has the following attributes. Most of them are same to the on-wire counterparts but in host byte order.
Attribute auth_type
Description
(Fixed) The authentication type in use.
auth_key_id The authentication Key ID in use.
seq The sequence number for this packet. This value is incremented occasionally.
auth_key auth_hash auth_len
The shared SHA1 key for this packet.
(Optional) The 20-byte SHA1 hash for the packet.
(Fixed) The length of the authentication section is 28 bytes.
authenticate
( prev , auth_keys={})
Authenticate the SHA1 hash for this packet.
This method can be invoked only when self.auth_hash is defined.
Returns a boolean indicates whether the hash can be authenticated by the correspondent Auth Key or not.
prev is a bfd instance for the BFD Control header which this authentication section belongs to. It’s necessary to be assigned because an SHA1 hash must be calculated over the entire BFD Control packet.
auth_keys is a dictionary of authentication key chain which key is an integer of Auth Key ID and value is a string of Auth Key.
serialize
( payload
, prev)
Encode a Keyed SHA1 Authentication Section.
This method is used only when encoding an BFD Control packet.
payload is the rest of the packet which will immediately follow this section.
prev is a bfd instance for the BFD Control header which this authentication section belongs to. It’s necessary to be assigned because an SHA1 hash must be calculated over the entire BFD Control packet.
class ryu.lib.packet.bfd.MeticulousKeyedSHA1(auth_key_id, seq , auth_key=None auth_hash=None , auth_len=None)
BFD (RFC 5880) Meticulous Keyed SHA1 Authentication Section class
,
All methods of this class are inherited from KeyedSHA1.
An instance has the following attributes. Most of them are same to the on-wire counterparts but in host byte order.
2.4. Library 53
ryu Documentation, Release 3.21
Attribute auth_type
Description
(Fixed) The authentication type in use.
auth_key_id The authentication Key ID in use.
seq The sequence number for this packet. This value is incremented for each successive packet transmitted for a session.
The shared SHA1 key for this packet.
auth_key auth_hash auth_len
(Optional) The 20-byte SHA1 hash for the packet.
(Fixed) The length of the authentication section is 28 bytes.
2.4.3 OF-Config support
Ryu has a library for OF-Config support.
XML schema files for NETCONFIG and OFConfig
XML schema files for NETCONF and OFConfig are stolen from LINC whose licence is Apache 2.0. It supports only part of OFConfig so that its schema files are (intentionally) limited such that operation attributes are allowed only in several limited places. Once our library is tested with other OFConfig switches, the schema files should be updated to allow operation attribute in more places.
References
• NETCONF ietf ,
• NETCONF ietf wiki ,
• OF-Config spec ,
• ncclient ,
• ncclient repo ,
• LINC git repo
2.4.4 BGP speaker library
Introduction
Ryu BGP speaker library helps you to enable your code to speak BGP protocol. The library supports ipv4, ipv4 vpn, and ipv6 vpn address families.
Example
The following simple code creates a BGP instance with AS number 64512 and Router ID 10.0.0.1. It tries to establish a bgp session with a peer (its IP is 192.168.177.32 and the AS number is 64513). The instance advertizes some prefixes.
import eventlet
# BGPSpeaker needs sockets patched eventlet .
monkey_patch()
# initialize a log handler
# this is not strictly necessary but useful if you get messages like:
54 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
# No handlers could be found for logger "ryu.lib.hub"
import logging import sys
log = logging .
getLogger() log .
addHandler(logging .
StreamHandler(sys .
stderr))
from ryu.services.protocols.bgp.bgpspeaker
import
BGPSpeaker
def
dump_remote_best_path_change (event):
'the best path changed:' , event .
remote_as, event .
prefix,\ event .
nexthop, event .
is_withdraw
def
detect_peer_down (remote_ip, remote_as):
'Peer down:' , remote_ip, remote_as
if
__name__ == "__main__" : speaker = BGPSpeaker(as_number = 64512 , router_id = '10.0.0.1' , best_path_change_handler = dump_remote_best_path_change, peer_down_handler = detect_peer_down) speaker .
neighbor_add( '192.168.177.32' , 64513 )
# uncomment the below line if the speaker needs to talk with a bmp server.
# speaker.bmp_server_add('192.168.177.2', 11019) count = 1
while
True : eventlet .
sleep( 30 ) prefix = '10.20.' + str (count) + '.0/24'
"add a new prefix" , prefix speaker .
prefix_add(prefix) count += 1
if
count == 4 : speaker .
shutdown()
break
2.4.5 BGP speaker library API Reference
BGPSpeaker class
class ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker(as_number, bgp_server_port=179 , router_id , refresh_stalepath_time=0 , refresh_max_eor_time=0 , best_path_change_handler=None , peer_down_handler=None , peer_up_handler=None , ssh_console=False , bel_range=(100 , 100000)) la-
attribute_map_get
( address , route_dist=None, route_family=’ipv4’)
This method gets in-bound filters of the specified neighbor.
address specifies the IP address of the neighbor.
route_dist specifies route distinguisher that has attribute_maps.
route_family specifies route family of the VRF. This parameter must be RF_VPN_V4 or
RF_VPN_V6.
2.4. Library 55
ryu Documentation, Release 3.21
56
Returns a list object containing an instance of AttributeMap
attribute_map_set
( address , attribute_maps, route_dist=None, route_family=’ipv4’)
This method sets attribute mapping to a neighbor. attribute mapping can be used when you want to apply attribute to BGPUpdate under specific conditions.
address specifies the IP address of the neighbor attribute_maps specifies attribute_map list that are used before paths are advertised. All the items in the list must be an instance of AttributeMap class route_dist specifies route dist in which attribute_maps are added.
route_family specifies route family of the VRF. This parameter must be RF_VPN_V4 or
RF_VPN_V6.
We can set AttributeMap to a neighbor as follows; pref_filter = PrefixFilter(‘192.168.103.0/30’, PrefixFilter.POLICY_PERMIT) attribute_map = AttributeMap([pref_filter], AttributeMap.ATTR_LOCAL_PREF, 250) speaker.attribute_map_set(‘192.168.50.102’, [attribute_map])
bmp_server_add
( address , port)
This method registers a new BMP (BGP monitoring Protocol) server. The BGP speaker starts to send BMP messages to the server. Currently, only one BMP server can be registered.
address specifies the IP address of a BMP server.
port specifies the listen port number of a BMP server.
bmp_server_del
( address , port)
This method unregister the registered BMP server.
address specifies the IP address of a BMP server.
port specifies the listen port number of a BMP server.
in_filter_get
( address)
This method gets in-bound filters of the specified neighbor.
address specifies the IP address of the neighbor.
Returns a list object containing an instance of Filter sub-class
in_filter_set
( address , filters)
This method sets in-bound filters to a neighbor.
address specifies the IP address of the neighbor filters specifies filter list applied before advertised paths are imported to the global rib. All the items in the list must be an instance of Filter sub-class.
neighbor_add
( address , remote_as, enable_ipv4=True, enable_vpnv4=False, enable_vpnv6=False, next_hop=None , password=None , multi_exit_disc=None , site_of_origins=None , is_route_server_client=False , is_next_hop_self=False , local_address=None , local_port=None , connect_mode=’both’)
This method registers a new neighbor. The BGP speaker tries to establish a bgp session with the peer
(accepts a connection from the peer and also tries to connect to it).
address specifies the IP address of the peer. It must be the string representation of an IP address. Only
IP v4 is supported now.
remote_as specifies the AS number of the peer. It must be an integer between 1 and 65535.
enable_ipv4 enables IPv4 address family for this neighbor. The default is True.
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
enable_vpnv4 enables VPNv4 address family for this neighbor. The default is False.
enable_vpnv6 enables VPNv6 address family for this neighbor. The default is False.
next_hop specifies the next hop IP address. If not specified, host’s ip address to access to a peer is used.
password is used for the MD5 authentication if it’s specified. By default, the MD5 authenticaiton is disabled.
multi_exit_disc specifies multi exit discriminator (MED) value. The default is None and if not specified, MED value is not sent to the neighbor. It must be an integer.
site_of_origins specifies site_of_origin values. This parameter must be a list of string.
is_route_server_client specifies whether this neighbor is a router server’s client or not.
is_next_hop_self specifies whether the BGP speaker announces its own ip address to iBGP neighbor or not as path’s next_hop address.
connect_mode specifies how to connect to this neighbor.
CONNECT_MODE_ACTIVE tries to connect from us.
CONNECT_MODE_PASSIVE just listens and wait for the connection.
CON-
NECT_MODE_BOTH use both methods. The default is CONNECT_MODE_BOTH local_address specifies Loopback interface address for iBGP peering.
local_port specifies source TCP port for iBGP peering.
neighbor_del
( address)
This method unregister the registered neighbor. If a session with the peer exists, the session will be closed.
address specifies the IP address of the peer. It must be the string representation of an IP address.
neighbor_get
( routetype , address, format=’json’)
This method returns the BGP adj-RIB-in information in a json format.
routetype
This parameter is necessary for only received-routes and sent-routes.
received-routes : paths received and not withdrawn by given peer sent-routes : paths sent and not withdrawn to given peer address specifies the IP address of the peer. It must be the string representation of an IP address.
neighbor_reset
( address)
This method reset the registered neighbor.
address specifies the IP address of the peer. It must be the string representation of an IP address.
neighbor_update
( address , conf_type, conf_value)
This method changes the neighbor configuration.
conf_type specifies configuration type which you want to change.
ryu.services.protocols.bgp.bgpspeaker.NEIGHBOR_CONF_MED can be specified.
conf_value specifies value for the configuration type.
out_filter_get
( address)
This method gets out-filter setting from the specified neighbor.
address specifies the IP address of the peer.
Returns a list object containing an instance of Filter sub-class
out_filter_set
( address
, filters)
This method sets out-filter to neighbor.
address specifies the IP address of the peer.
Currently
2.4. Library 57
ryu Documentation, Release 3.21
filters specifies a filter list to filter the path advertisement. The contents must be an instance of Filter sub-class
If you want to define out-filter that send only a particular prefix to neighbor, filters can be created as follows; p = PrefixFilter(‘10.5.111.0/24’, policy=PrefixFilter.POLICY_PERMIT) all = PrefixFilter(‘0.0.0.0/0’, policy=PrefixFilter.POLICY_DENY) pList = [p, all] self.bgpspeaker.out_filter_set(neighbor_address, pList)
NOTE: out-filter evaluates paths in the order of Filter in the pList.
prefix_add
( prefix , next_hop=None, route_dist=None)
This method adds a new prefix to be advertized.
prefix must be the string representation of an IP network (e.g., 10.1.1.0/24).
next_hop specifies the next hop address for this prefix. This parameter is necessary for only VPNv4 and
VPNv6 address families.
route_dist specifies a route distinguisher value. This parameter is necessary for only VPNv4 and
VPNv6 address families.
prefix_del
( prefix
, route_dist=None)
This method deletes a advertized prefix.
prefix must be the string representation of an IP network (e.g., 10.1.1.0/24).
route_dist specifies a route distinguisher value. This parameter is necessary for only VPNv4 and
VPNv6 address families.
rib_get
( family=’ipv4’ , format=’json’)
This method returns the BGP routing information in a json format. This will be improved soon.
family specifies the address family of the RIB.
shutdown
()
Shutdown BGP speaker
vrf_add
( route_dist
, import_rts
, export_rts
, site_of_origins=None
, route_family=’ipv4’
, multi_exit_disc=None)
This method adds a new vrf used for VPN.
route_dist specifies a route distinguisher value.
import_rts specifies route targets to be imported.
export_rts specifies route targets to be exported.
site_of_origins specifies site_of_origin values. This parameter must be a list of string.
route_family specifies route family of the VRF. This parameter must be RF_VPN_V4 or
RF_VPN_V6.
vrf_del
( route_dist)
This method deletes the existing vrf.
route_dist specifies a route distinguisher value.
class ryu.services.protocols.bgp.bgpspeaker.EventPrefix(remote_as, route_dist, prefix, nexthop , label, is_withdraw)
Used to pass an update on any best remote path to best_path_change_handler.
58 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute remote_as route_dist
Description
The AS number of a peer that caused this change
None in the case of ipv4 or ipv6 family prefix nexthop
A prefix was changed
The nexthop of the changed prefix label mpls label for vpnv4 prefix is_withdraw True if this prefix has gone otherwise False class ryu.services.protocols.bgp.info_base.base.PrefixFilter(prefix, policy ge=None , le=None)
, used to specify a prefix for filter.
We can create PrefixFilter object as follows.
prefix_filter = PrefixFilter(‘10.5.111.0/24’, policy=PrefixFilter.POLICY_PERMIT)
Attribute Description prefix A prefix used for this filter policy PrefixFilter.POLICY.PERMIT or PrefixFilter.POLICY_DENY
ge le
Prefix length that will be applied to this filter. ge means greater than or equal.
Prefix length that will be applied to this filter. le means less than or equal.
For example, when PrefixFilter object is created as follows:
•p = PrefixFilter(‘10.5.111.0/24’, policy=PrefixFilter.POLICY_DENY, ge=26, le=28) prefixes which match 10.5.111.0/24 and its length matches from 26 to 28 will be filtered. When this filter is used as an out-filter, it will stop sending the path to neighbor because of POLICY_DENY. When this filter is used as in-filter, it will stop importing the path to the global rib because of POLICY_DENY. If you specify
POLICY_PERMIT, the path is sent to neighbor or imported to the global rib.
If you don’t want to send prefixes 10.5.111.64/26 and 10.5.111.32/27 and 10.5.111.16/28, and allow to send other 10.5.111.0’s prefixes, you can do it by specifying as follows;
•p = PrefixFilter(‘10.5.111.0/24’, policy=PrefixFilter.POLICY_DENY, ge=26, le=28).
clone
()
This method clones PrefixFilter object.
Returns PrefixFilter object that has the same values with the original one.
evaluate
( path)
This method evaluates the prefix.
Returns this object’s policy and the result of matching. If the specified prefix matches this object’s prefix and ge and le condition, this method returns True as the matching result.
path specifies the path that has prefix.
class ryu.services.protocols.bgp.info_base.base.ASPathFilter(as_number, policy) used to specify a prefix for AS_PATH attribute.
We can create ASPathFilter object as follows;
•as_path_filter = ASPathFilter(65000,policy=ASPathFilter.TOP)
Attribute
Description as_numberA AS number used for this filter policy ASPathFilter.POLICY_TOP and ASPathFilter.POLICY_END,
ASPathFilter.POLICY_INCLUDE and ASPathFilter.POLICY_NOT_INCLUDE are available.
Meaning of each policy is as follows;
2.4. Library 59
ryu Documentation, Release 3.21
•POLICY_TOP : Filter checks if the specified AS number is at the top of AS_PATH attribute.
•POLICY_END : Filter checks is the specified AS number is at the last of AS_PATH attribute.
•POLICY_INCLUDE : Filter checks if specified AS number exists in AS_PATH attribute
•POLICY_NOT_INCLUDE : opposite to POLICY_INCLUDE
clone
()
This method clones ASPathFilter object.
Returns ASPathFilter object that has the same values with the original one.
evaluate
( path)
This method evaluates as_path list.
Returns this object’s policy and the result of matching. If the specified AS number matches this object’s
AS number according to the policy, this method returns True as the matching result.
path specifies the path.
class ryu.services.protocols.bgp.info_base.base.AttributeMap(filters, attr_type , attr_value)
This class is used to specify an attribute to add if the path matches filters. We can create AttributeMap object as follows; pref_filter = PrefixFilter(‘192.168.103.0/30’, PrefixFilter.POLICY_PERMIT) attribute_map = AttributeMap([pref_filter], AttributeMap.ATTR_LOCAL_PREF, 250) speaker.attribute_map_set(‘192.168.50.102’, [attribute_map])
AttributeMap.ATTR_LOCAL_PREF means that 250 is set as a local preference value if nlri in the path matches pref_filter.
ASPathFilter is also available as a filter. ASPathFilter checks if AS_PATH attribute in the path matches AS number in the filter.
Attribute Description filters A list of filter. Each object should be a Filter class or its sub-class attr_type A type of attribute to map on filters. Currently AttributeMap.ATTR_LOCAL_PREF is available.
attr_value A attribute value
clone
()
This method clones AttributeMap object.
Returns AttributeMap object that has the same values with the original one.
evaluate
( path)
This method evaluates attributes of the path.
Returns the cause and result of matching. Both cause and result are returned from filters that this object contains.
path specifies the path.
60 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
2.5 OpenFlow protocol API Reference
2.5.1 OpenFlow version independent classes and functions
Base class for OpenFlow messages
class ryu.ofproto.ofproto_parser.MsgBase(*args, **kwargs)
This is a base class for OpenFlow message classes.
An instance of this class has at least the following attributes.
Attribute Description datapath A ryu.controller.controller.Datapath instance for this message version OpenFlow protocol version msg_type Type of OpenFlow message msg_len xid buf
Length of the message
Transaction id
Raw data
_TYPE
_TYPE class attribute is used to annotate types of attributes.
This type information is used to find an appropriate conversion for a JSON style dictionary.
Currently the following types are implemented.
Type Descrption ascii US-ASCII utf-8 UTF-8
Example:
_TYPE = {
'ascii' : [
'hw_addr' ,
],
'utf-8' : [
'name' ,
]
}
from_jsondict
( dict_ , decode_string=<function b64decode>, **additional_args)
Create an instance from a JSON style dict.
Instantiate this class with parameters specified by the dict.
This method takes the following arguments.
Argument dict_
Descrpition
A dictionary which describes the parameters. For example, {“Param1”: 100,
“Param2”: 200} decode_string (Optional) specify how to decode strings. The default is base64. This argument is used only for attributes which don’t have explicit type annotations in _TYPE class attribute.
additional_args (Optional) Additional kwargs for constructor.
to_jsondict
( encode_string=<function b64encode>)
This method returns a JSON style dict to describe this object.
The returned dict is compatible with json.dumps() and json.loads().
2.5. OpenFlow protocol API Reference 61
ryu Documentation, Release 3.21
Suppose ClassName object inherits StringifyMixin. For an object like the following:
ClassName(Param1 = 100 , Param2 = 200 ) this method would produce:
{ "ClassName" : { "Param1" : 100 , "Param2" : 200 } }
This method takes the following arguments.
Argument Description encode_string (Optional) specify how to encode attributes which has python ‘str’ type. The default is base64. This argument is used only for attributes which don’t have explicit type annotations in _TYPE class attribute.
Functions
ryu.ofproto.ofproto_parser.ofp_msg_from_jsondict( dp , jsondict)
This function instanticates an appropriate OpenFlow message class from the given JSON style dictionary. The objects created by following two code fragments are equivalent.
Code A: jsonstr = '{ "OFPSetConfig": { "flags": 0, "miss_send_len": 128 } }' jsondict = json .
loads(jsonstr) o = ofp_msg_from_jsondict(dp, jsondict)
Code B: o = dp .
ofproto_parser .
OFPSetConfig(flags = 0 , miss_send_len = 128 )
This function takes the following arguments.
Argument Description dp An instance of ryu.controller.Datapath.
jsondict A JSON style dict.
2.5.2 OpenFlow v1.2 Messages and Structures
Controller-to-Switch Messages
Handshake
class ryu.ofproto.ofproto_v1_2_parser.OFPFeaturesRequest(datapath)
Features request message
The controller sends a feature request to the switch upon session establishment.
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Example:
def
send_features_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPFeaturesRequest(datapath) datapath .
send_msg(req)
62 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
JSON Example:
{
"OFPFeaturesRequest" : {}
} class ryu.ofproto.ofproto_v1_2_parser.OFPSwitchFeatures(datapath, datapath_id=None, n_buffers=None , n_tables=None , capabilities=None , ports=None)
Features reply message
The switch responds with a features reply message to a features request.
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Example:
@set_ev_cls
(ofp_event .
EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def
switch_features_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPSwitchFeatures received: '
'datapath_id=0x %016x n_buffers= %d '
'n_tables= %d capabilities=0x %08x ports= %s ' , msg .
datapath_id, msg .
n_buffers, msg .
n_tables, msg .
capabilities, msg .
ports)
JSON Example:
{
"OFPSwitchFeatures" : {
"capabilities" : 79 ,
"datapath_id" : 9210263729383 ,
"n_buffers" : 0 ,
"n_tables" : 255 ,
"ports" : {
"6" : {
"OFPPort" : {
"advertised" : 10240 ,
"config" : 0 ,
"curr" : 10248 ,
"curr_speed" : 5000 ,
"hw_addr" : "f2:0b:a4:7d:f8:ea" ,
"max_speed" : 5000 ,
"name" : "Port6" ,
"peer" : 10248 ,
"port_no" : 6 ,
"state" : 4 ,
"supported" : 10248
}
},
"7" : {
"OFPPort" : {
"advertised" : 10240 ,
"config" : 0 ,
"curr" : 10248 ,
"curr_speed" : 5000 ,
"hw_addr" : "f2:0b:a4:d0:3f:70" ,
"max_speed" : 5000 ,
2.5. OpenFlow protocol API Reference 63
ryu Documentation, Release 3.21
}
}
}
}
}
"name" : "Port7" ,
"peer" : 10248 ,
"port_no" : 7 ,
"state" : 4 ,
"supported" : 10248
Switch Configuration
class ryu.ofproto.ofproto_v1_2_parser.OFPSetConfig(datapath, flags=0, miss_send_len=0)
Set config request message
The controller sends a set config request message to set configuraion parameters.
Attribute flags
Description
One of the following configuration flags.
OFPC_FRAG_NORMAL
OFPC_FRAG_DROP
OFPC_FRAG_REASM
OFPC_FRAG_MASK
OFPC_INVALID_TTL_TO_CONTROLLER miss_send_len Max bytes of new flow that datapath should send to the controller
Example:
def
send_set_config ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPSetConfig(datapath, ofp .
OFPC_FRAG_NORMAL, 256 ) datapath .
send_msg(req)
JSON Example:
{
"OFPSetConfig" : {
"flags" : 0 ,
"miss_send_len" : 128
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPGetConfigRequest(datapath)
Get config request message
The controller sends a get config request to query configuration parameters in the switch.
Example:
def
send_get_config_request ( self , datapath): ofp_parser = datapath .
ofproto_parser
64 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
req = ofp_parser .
OFPGetConfigRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPGetConfigRequest" : {}
} class ryu.ofproto.ofproto_v1_2_parser.OFPGetConfigReply(datapath, flags=None miss_send_len=None)
,
Get config reply message
The switch responds to a configuration request with a get config reply message.
Attribute flags
Description
One of the following configuration flags.
OFPC_FRAG_NORMAL
OFPC_FRAG_DROP
OFPC_FRAG_REASM
OFPC_FRAG_MASK
OFPC_INVALID_TTL_TO_CONTROLLER miss_send_len Max bytes of new flow that datapath should send to the controller
Example:
@set_ev_cls
(ofp_event .
EventOFPGetConfigReply, MAIN_DISPATCHER)
def
get_config_reply_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto
if
msg .
flags == ofp .
OFPC_FRAG_NORMAL: flags = 'NORMAL'
elif
msg .
flags == ofp .
OFPC_FRAG_DROP: flags = 'DROP'
elif
msg .
flags == ofp .
OFPC_FRAG_REASM: flags = 'REASM'
elif
msg .
flags == ofp .
OFPC_FRAG_MASK: flags = 'MASK'
elif
msg .
flags == ofp .
OFPC_INVALID_TTL_TO_CONTROLLER: flags = 'INVALID TTL TO CONTROLLER'
else
: flags = 'unknown' self .
logger .
debug( 'OFPGetConfigReply received: '
'flags= %s miss_send_len= %d ' , flags, msg .
miss_send_len)
JSON Example:
{
"OFPGetConfigReply" : {
"flags" : 0 ,
"miss_send_len" : 128
2.5. OpenFlow protocol API Reference 65
ryu Documentation, Release 3.21
}
}
Flow Table Configuration
class ryu.ofproto.ofproto_v1_2_parser.OFPTableMod(datapath, table_id, config)
Flow table configuration message
The controller sends this message to configure table state.
Attribute table_id config
Description
ID of the table (OFPTT_ALL indicates all tables)
Bitmap of the following flags.
OFPTC_TABLE_MISS_CONTROLLER
OFPTC_TABLE_MISS_CONTINUE
OFPTC_TABLE_MISS_DROP
OFPTC_TABLE_MISS_MASK
Example:
def
send_table_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPTableMod(datapath, ofp .
OFPTT_ALL, ofp .
OFPTC_TABLE_MISS_DROP) datapath .
send_msg(req)
JSON Example:
{
"OFPTableMod" : {
"config" : 0 ,
"table_id" : 255
}
}
Modify State Messages
class ryu.ofproto.ofproto_v1_2_parser.OFPFlowMod(datapath, cookie=0, cookie_mask=0, table_id=0
, command=0, idle_timeout=0, hard_timeout=0 , priority=0 , buffer_id=4294967295 , out_port=0 , out_group=0 , flags=0 , match=None , instructions=[])
Modify Flow entry message
The controller sends this message to modify the flow table.
66 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute cookie cookie_mask table_id command
Description
Opaque controller-issued identifier
Mask used to restrict the cookie bits that must match when the command is OPFFC_MODIFY* or
OFPFC_DELETE*
ID of the table to put the flow in
One of the following values.
OFPFC_ADD
OFPFC_MODIFY
OFPFC_MODIFY_STRICT
OFPFC_DELETE
OFPFC_DELETE_STRICT idle_timeout hard_timeout priority buffer_id out_port out_group flags
Idle time before discarding (seconds)
Max time before discarding (seconds)
Priority level of flow entry
Buffered packet to apply to (or OFP_NO_BUFFER)
For OFPFC_DELETE* commands, require matching entries to include this as an output port
For OFPFC_DELETE* commands, require matching entries to include this as an output group
One of the following values.
OFPFF_SEND_FLOW_REM
OFPFF_CHECK_OVERLAP
OFPFF_RESET_COUNTS match instructions
Example:
def
send_flow_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
Instance of OFPMatch list of OFPInstruction* instance cookie = cookie_mask = 0 table_id = 0 idle_timeout = hard_timeout = 0 priority = 32768 buffer_id = ofp .
OFP_NO_BUFFER match = ofp_parser .
OFPMatch(in_port = 1 , eth_dst = 'ff:ff:ff:ff:ff:ff' ) actions = [ofp_parser .
OFPActionOutput(ofp .
OFPP_NORMAL, 0 )] inst = [ofp_parser .
OFPInstructionActions(ofp .
OFPIT_APPLY_ACTIONS, actions)] req = ofp_parser .
OFPFlowMod(datapath, cookie, cookie_mask, table_id, ofp .
OFPFC_ADD, idle_timeout, hard_timeout, priority, buffer_id, ofp .
OFPP_ANY, ofp .
OFPG_ANY, ofp .
OFPFF_SEND_FLOW_REM, match, inst) datapath .
send_msg(req)
2.5. OpenFlow protocol API Reference 67
ryu Documentation, Release 3.21
68
JSON Example:
{
"OFPFlowMod" : {
"buffer_id" : 65535 ,
"command" : 0 ,
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "vlan_vid" ,
"mask" : null,
"value" : 258
}
}
}
},
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 6 ,
"type" : 0
}
}
],
"len" : 40 ,
"type" : 3
}
},
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "01:02:03:04:05:06"
}
}
}
}
],
"len" : 24 ,
"type" : 4
}
}
],
Chapter 2. Writing Your Ryu Application
}
}
"match" : {
"OFPMatch" : {
"length" : 14 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"priority" : 123 ,
"table_id" : 1
{
"OFPFlowMod" : {
"buffer_id" : 65535 ,
"command" : 0 ,
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionGotoTable" : {
"len" : 8 ,
"table_id" : 1 ,
"type" : 1
}
}
],
"match" : {
"OFPMatch" : {
"length" : 22 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 6
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
69
ryu Documentation, Release 3.21
],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"priority" : 123 ,
"table_id" : 0
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPGroupMod(datapath, command=0 , type_=0 , group_id=0 , buckets=[])
Modify group entry message
The controller sends this message to modify the group table.
Attribute command
Description
One of the following values.
type
OFPGC_ADD
OFPGC_MODIFY
OFPGC_DELETE
One of the following values.
OFPGT_ALL
OFPGT_SELECT
OFPGT_INDIRECT
OFPGT_FF group_id buckets
Group identifier list of OFPBucket type attribute corresponds to type_ parameter of __init__.
Example:
def
send_group_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser port = 1 max_len = 2000 actions = [ofp_parser .
OFPActionOutput(port, max_len)] weight = 100 watch_port = 0 watch_group = 0 buckets = [ofp_parser .
OFPBucket(weight, watch_port, watch_group, actions)] group_id = 1 req = ofp_parser .
OFPGroupMod(datapath, ofp .
OFPGC_ADD, ofp .
OFPGT_SELECT, group_id, buckets) datapath .
send_msg(req)
JSON Example:
70 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
{
"OFPGroupMod" : {
"buckets" : [
{
"OFPBucket" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 2 ,
"type" : 0
}
}
],
"len" : 32 ,
"watch_group" : 1 ,
"watch_port" : 1 ,
"weight" : 1
}
}
],
"command" : 0 ,
"group_id" : 1 ,
"type" : 0
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPPortMod(datapath, port_no=0
, hw_addr=‘00:00:00:00:00:00’ , config=0 , mask=0, advertise=0)
Port modification message
The controller sneds this message to modify the behavior of the port.
2.5. OpenFlow protocol API Reference 71
ryu Documentation, Release 3.21
Attribute port_no hw_addr config mask advertise
Description
Port number to modify
The hardware address that must be the same as hw_addr of OFPPort of OFPSwitchFeatures
Bitmap of configuration flags.
OFPPC_PORT_DOWN
OFPPC_NO_RECV
OFPPC_NO_FWD
OFPPC_NO_PACKET_IN
Bitmap of configuration flags above to be changed
Bitmap of the following flags.
OFPPF_10MB_HD
OFPPF_10MB_FD
OFPPF_100MB_HD
OFPPF_100MB_FD
OFPPF_1GB_HD
OFPPF_1GB_FD
OFPPF_10GB_FD
OFPPF_40GB_FD
OFPPF_100GB_FD
OFPPF_1TB_FD
OFPPF_OTHER
OFPPF_COPPER
OFPPF_FIBER
OFPPF_AUTONEG
OFPPF_PAUSE
OFPPF_PAUSE_ASYM
Example:
def
send_port_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser port_no = 3 hw_addr = 'fa:c8:e8:76:1d:7e' config = 0 mask = (ofp .
OFPPC_PORT_DOWN | ofp .
OFPPC_NO_RECV | ofp .
OFPPC_NO_FWD | ofp .
OFPPC_NO_PACKET_IN) advertise = (ofp .
OFPPF_10MB_HD | ofp .
OFPPF_100MB_FD | ofp .
OFPPF_1GB_FD | ofp .
OFPPF_COPPER | ofp .
OFPPF_AUTONEG | ofp .
OFPPF_PAUSE | ofp .
OFPPF_PAUSE_ASYM) req = ofp_parser .
OFPPortMod(datapath, port_no, hw_addr, config, mask, advertise) datapath .
send_msg(req)
JSON Example:
72 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
{
}
"OFPPortMod" : {
"advertise" : 4096 ,
"config" : 0 ,
"hw_addr" : "00-11-00-00-11-11" ,
"mask" : 0 ,
"port_no" : 1
}
Read State Messages
class ryu.ofproto.ofproto_v1_2_parser.OFPDescStatsRequest(datapath, flags=0)
Description statistics request message
The controller uses this message to query description of the switch.
Attribute Description flags Zero (none yet defined in the spec)
Example:
def
send_desc_stats_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPDescStatsRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPDescStatsRequest" : {
"flags" : 0
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPDescStats
Description statistics reply message
The switch responds with a stats reply that include this message to a description statistics request.
Attribute mfr_desc hw_desc sw_desc
Description
Manufacturer description
Hardware description
Software description serial_num Serial number dp_desc Human readable description of datapath
Example:
@set_ev_cls
(ofp_event .
EventOFPStatsReply, MAIN_DISPATCHER)
def
stats_reply_handler ( self , ev): msg = ev .
msg ofp = msg .
datapath .
ofproto body = ev .
msg .
body
if
msg .
type == ofp .
OFPST_DESC: self .
desc_stats_reply_handler(body)
2.5. OpenFlow protocol API Reference 73
ryu Documentation, Release 3.21
def
desc_stats_reply_handler ( self , body): self .
logger .
debug( 'DescStats: mfr_desc= %s hw_desc= %s sw_desc= %s '
'serial_num= %s dp_desc= %s ' , body .
mfr_desc, body .
hw_desc, body .
sw_desc, body .
serial_num, body .
dp_desc)
JSON Example:
{
"OFPStatsReply" : {
"body" : {
"OFPDescStats" : {
"dp_desc" : "dp" ,
"hw_desc" : "hw" ,
"mfr_desc" : "mfr" ,
"serial_num" : "serial" ,
"sw_desc" : "sw"
}
},
"flags" : 0 ,
"type" : 0
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPFlowStatsRequest(datapath, table_id=255 , out_port=4294967295 , out_group=4294967295 , cookie=0 , cookie_mask=0, match=None , flags=0)
Individual flow statistics request message
The controller uses this message to query individual flow statistics.
Attribute table_id out_port
Description
ID of table to read
Require matching entries to include this as an output port out_group cookie
Require matching entries to include this as an output group
Require matching entries to contain this cookie value cookie_mask Mask used to restrict the cookie bits that must match match Instance of OFPMatch flags Zero (none yet defined in the spec)
Example:
def
send_flow_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser cookie = cookie_mask = 0 match = ofp_parser .
OFPMatch(in_port = 1 ) req = ofp_parser .
OFPFlowStatsRequest(datapath, ofp .
OFPTT_ALL, ofp .
OFPP_ANY, ofp .
OFPG_ANY, cookie, cookie_mask, match) datapath .
send_msg(req)
JSON Example:
74 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
{
"OFPFlowStatsRequest" : {
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"table_id" : 0
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPFlowStats(table_id, duration_sec , duration_nsec , priority , idle_timeout , hard_timeout , cookie, packet_count, byte_count , match , instructions=None , length=None)
Individual flow statistics reply message
The switch responds with a stats reply that include this message to an individual flow statistics request.
Attribute table_id duration_sec
Description
ID of table flow came from
Time flow has been alive in seconds duration_nsec Time flow has been alive in nanoseconds beyond duration_sec priority Priority of the entry idle_timeout Number of seconds idle before expiration hard_timeout Number of seconds before expiration cookie Opaque controller-issued identifier packet_count Number of packets in flow byte_count match instructions
Number of bytes in flow
Instance of OFPMatch list of OFPInstruction* instance
Example:
@set_ev_cls
(ofp_event .
EventOFPStatsReply, MAIN_DISPATCHER)
def
stats_reply_handler ( self , ev): msg = ev .
msg ofp = msg .
datapath .
ofproto body = ev .
msg .
body
if
msg .
type == ofp .
OFPST_FLOW: self .
flow_stats_reply_handler(body)
def
flow_stats_reply_handler ( self , body): flows = []
for
stat
in
body: flows .
append( 'table_id= %s '
'duration_sec= %d duration_nsec= %d '
'priority= %d '
'idle_timeout= %d hard_timeout= %d '
2.5. OpenFlow protocol API Reference 75
ryu Documentation, Release 3.21
'cookie= %d packet_count= %d byte_count= %d '
'match= %s instructions= %s ' %
(stat .
table_id, stat .
duration_sec, stat .
duration_nsec, stat .
priority, stat .
idle_timeout, stat .
hard_timeout, stat .
cookie, stat .
packet_count, stat .
byte_count, stat .
match, stat .
instructions)) self .
logger .
debug( 'FlowStats: %s ' , flows)
JSON Example:
{
"OFPStatsReply" : {
"body" : [
{
"OFPFlowStats" : {
"byte_count" : 0 ,
"cookie" : 0 ,
"duration_nsec" : 115277000 ,
"duration_sec" : 358 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [],
"length" : 56 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
},
"packet_count" : 0 ,
"priority" : 65535 ,
"table_id" : 0
}
},
{
"OFPFlowStats" : {
"byte_count" : 0 ,
"cookie" : 0 ,
"duration_nsec" : 115055000 ,
"duration_sec" : 358 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 0 ,
"port" : 4294967290 ,
"type" : 0
}
}
],
76 Chapter 2. Writing Your Ryu Application
"len" : 24 ,
"type" : 4
}
}
],
"length" : 88 ,
"match" : {
"OFPMatch" : {
"length" : 10 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "eth_type" ,
"mask" : null,
"value" : 2054
}
}
],
"type" : 1
}
},
"packet_count" : 0 ,
"priority" : 65534 ,
"table_id" : 0
},
{
}
"OFPFlowStats" : {
"byte_count" : 238 ,
"cookie" : 0 ,
"duration_nsec" : 511582000 ,
"duration_sec" : 316220 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionGotoTable" : {
"len" : 8 ,
"table_id" : 1 ,
"type" : 1
}
}
],
"length" : 80 ,
"match" : {
"OFPMatch" : {
"length" : 22 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 6
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
77
ryu Documentation, Release 3.21
}
}
}
}
],
"type" : 1
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
"packet_count" : 3 ,
"priority" : 123 ,
"table_id" : 0
}
},
{
"OFPFlowStats" : {
"byte_count" : 98 ,
"cookie" : 0 ,
"duration_nsec" : 980901000 ,
"duration_sec" : 313499 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 4294967293 ,
"type" : 0
}
}
],
"len" : 24 ,
"type" : 3
}
}
],
"length" : 80 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
},
"packet_count" : 1 ,
"priority" : 0 ,
"table_id" : 0
}
}
],
"flags" : 0 ,
"type" : 1
78 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_2_parser.OFPAggregateStatsRequest(datapath, ble_id=255 , taout_port=4294967295 , out_group=4294967295 , cookie=0 , cookie_mask=0
, match=None
, flags=0)
Aggregate flow statistics request message
The controller uses this message to query aggregate flow statictics.
Attribute table_id out_port out_group
Description
ID of table to read
Require matching entries to include this as an output port
Require matching entries to include this as an output group cookie Require matching entries to contain this cookie value cookie_mask Mask used to restrict the cookie bits that must match match flags
Instance of OFPMatch
Zero (none yet defined in the spec)
Example:
def
send_aggregate_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser cookie = cookie_mask = 0 match = ofp_parser .
OFPMatch(in_port = 1 ) req = ofp_parser .
OFPAggregateStatsRequest(datapath, 0 , ofp .
OFPTT_ALL, ofp .
OFPP_ANY, ofp .
OFPG_ANY, cookie, cookie_mask, match) datapath .
send_msg(req)
JSON Example:
{
"OFPAggregateStatsRequest" : {
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"table_id" : 255
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPAggregateStatsReply
Aggregate flow statistics reply message
2.5. OpenFlow protocol API Reference 79
ryu Documentation, Release 3.21
The switch responds with a stats reply that include this message to an aggregate flow statistics request.
Attribute Description packet_count Number of packets in flows byte_count flow_count
Number of bytes in flows
Number of flows
Example:
@set_ev_cls
(ofp_event .
EventOFPStatsReply, MAIN_DISPATCHER)
def
stats_reply_handler ( self , ev): msg = ev .
msg ofp = msg .
datapath .
ofproto body = ev .
msg .
body
if
msg .
type == ofp .
OFPST_AGGREGATE: self .
aggregate_stats_reply_handler(body)
def
aggregate_stats_reply_handler ( self , body): self .
logger .
debug( 'AggregateStats: packet_count= %d byte_count= %d '
'flow_count= %d ' , body .
packet_count, body .
byte_count, body .
flow_count)
JSON Example:
{
"OFPStatsReply" : {
"body" : {
"OFPAggregateStatsReply" : {
"byte_count" : 574 ,
"flow_count" : 6 ,
"packet_count" : 7
}
},
"flags" : 0 ,
"type" : 2
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPTableStatsRequest(datapath, flags=0)
Table statistics request message
The controller uses this message to query flow table statictics.
Attribute Description flags Zero (none yet defined in the spec)
Example:
def
send_table_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPTableStatsRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPTableStatsRequest" : {
80 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"flags" : 0
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPTableStats
Table statistics reply message
The switch responds with a stats reply that include this message to a table statistics request.
Attribute table_id name match
Description
ID of table table name
Bitmap of (1 << OFPXMT_*) that indicate the fields the table can match on wildcards write_actions
Bitmap of (1 << OFPXMT_*) wildcards that are supported by the table
Bitmap of OFPAT_* that are supported by the table with OFPIT_WRITE_ACTIONS apply_actions Bitmap of OFPAT_* that are supported by the table with OFPIT_APPLY_ACTIONS write_setfields Bitmap of (1 << OFPXMT_*) header fields that can be set with
OFPIT_WRITE_ACTIONS apply_setfields Bitmap of (1 << OFPXMT_*) header fields that can be set with
OFPIT_APPLY_ACTIONS metadata_match
Bits of metadata table can match metadata_write Bits of metadata table can write instructions Bitmap of OFPIT_* values supported config max_entries
Bitmap of OFPTC_* values
Max number of entries supported active_count lookup_count
Number of active entries
Number of packets looked up in table matched_count Number of packets that hit table
Example:
@set_ev_cls
(ofp_event .
EventOFPStatsReply, MAIN_DISPATCHER)
def
stats_reply_handler ( self , ev): msg = ev .
msg ofp = msg .
datapath .
ofproto body = ev .
msg .
body
if
msg .
type == ofp .
OFPST_TABLE: self .
table_stats_reply_handler(body)
def
table_stats_reply_handler ( self , body): tables = []
for
stat
in
body: tables .
append( 'table_id= %d active_count= %d lookup_count= %d '
' matched_count= %d ' %
(stat .
table_id, stat .
active_count, stat .
lookup_count, stat .
matched_count)) self .
logger .
debug( 'TableStats: %s ' , tables) class ryu.ofproto.ofproto_v1_2_parser.OFPPortStatsRequest(datapath, port_no=4294967295 , flags=0)
Port statistics request message
The controller uses this message to query information about ports statistics.
2.5. OpenFlow protocol API Reference 81
ryu Documentation, Release 3.21
Attribute Description port_no Port number to read (OFPP_ANY to all ports) flags Zero (none yet defined in the spec)
Example:
def
send_port_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPPortStatsRequest(datapath, ofp .
OFPP_ANY) datapath .
send_msg(req)
JSON Example:
{
"OFPPortStatsRequest" : {
"flags" : 0 ,
"port_no" : 4294967295
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPPortStats
Port statistics reply message
The switch responds with a stats reply that include this message to a port statistics request.
Attribute port_no rx_packets tx_packets rx_bytes tx_bytes rx_dropped tx_dropped
Description
Port number
Number of received packets
Number of transmitted packets
Number of received bytes
Number of transmitted bytes
Number of packets dropped by RX
Number of packets dropped by TX rx_errors tx_errors
Number of receive errors
Number of transmit errors rx_frame_err Number of frame alignment errors rx_over_err Number of packet with RX overrun rx_crc_err collisions
Number of CRC errors
Number of collisions
Example:
@set_ev_cls
(ofp_event .
EventOFPStatsReply, MAIN_DISPATCHER)
def
stats_reply_handler ( self , ev): msg = ev .
msg ofp = msg .
datapath .
ofproto body = ev .
msg .
body
if
msg .
type == ofp .
OFPST_PORT: self .
port_stats_reply_handler(body)
def
port_stats_reply_handler ( self , body): ports = []
for
stat
in
body: ports .
append( 'port_no= %d '
'rx_packets= %d tx_packets= %d '
'rx_bytes= %d tx_bytes= %d '
82 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
'rx_dropped= %d tx_dropped= %d '
'rx_errors= %d tx_errors= %d '
'rx_frame_err= %d rx_over_err= %d rx_crc_err= %d '
'collisions= %d ' %
(stat .
port_no, stat .
rx_packets, stat .
tx_packets, stat .
rx_bytes, stat .
tx_bytes, stat .
rx_dropped, stat .
tx_dropped, stat .
rx_errors, stat .
tx_errors, stat .
rx_frame_err, stat .
rx_over_err, stat .
rx_crc_err, stat .
collisions)) self .
logger .
debug( 'PortStats: %s ' , ports)
JSON Example:
{
"OFPStatsReply" : {
"body" : [
{
"OFPPortStats" : {
"collisions" : 0 ,
"port_no" : 7 ,
"rx_bytes" : 0 ,
"rx_crc_err" : 0 ,
"rx_dropped" : 0 ,
"rx_errors" : 0 ,
"rx_frame_err" : 0 ,
"rx_over_err" : 0 ,
"rx_packets" : 0 ,
"tx_bytes" : 336 ,
"tx_dropped" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 4
}
},
{
"OFPPortStats" : {
"collisions" : 0 ,
"port_no" : 6 ,
"rx_bytes" : 336 ,
"rx_crc_err" : 0 ,
"rx_dropped" : 0 ,
"rx_errors" : 0 ,
"rx_frame_err" : 0 ,
"rx_over_err" : 0 ,
"rx_packets" : 4 ,
}
}
],
"flags" : 0 ,
"type" : 4
"tx_bytes" : 336 ,
"tx_dropped" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 4
}
}
2.5. OpenFlow protocol API Reference 83
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_2_parser.OFPQueueStatsRequest(datapath, port_no=4294967295 , queue_id=4294967295 , flags=0)
Queue statistics request message
The controller uses this message to query queue statictics.
Attribute Description port_no Port number to read queue_id ID of queue to read flags Zero (none yet defined in the spec)
Example:
def
send_queue_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPQueueStatsRequest(datapath, ofp .
OFPP_ANY, ofp .
OFPQ_ALL) datapath .
send_msg(req)
JSON Example:
{
"OFPQueueStatsRequest" : {
"flags" : 0 ,
"port_no" : 4294967295 ,
"queue_id" : 4294967295
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPQueueStats
Queue statistics reply message
The switch responds with a stats reply that include this message to an aggregate flow statistics request.
Attribute port_no queue_id
Description
Port number
ID of queue tx_bytes Number of transmitted bytes tx_packets Number of transmitted packets tx_errors Number of packets dropped due to overrun
Example:
@set_ev_cls
(ofp_event .
EventOFPStatsReply, MAIN_DISPATCHER)
def
stats_reply_handler ( self , ev): msg = ev .
msg ofp = msg .
datapath .
ofproto body = ev .
msg .
body
if
msg .
type == ofp .
OFPST_QUEUE: self .
queue_stats_reply_handler(body)
def
queue_stats_reply_handler ( self , body): queues = []
for
stat
in
body: queues .
append( 'port_no= %d queue_id= %d '
84 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
'tx_bytes= %d tx_packets= %d tx_errors= %d ' %
(stat .
port_no, stat .
queue_id, stat .
tx_bytes, stat .
tx_packets, stat .
tx_errors)) self .
logger .
debug( 'QueueStats: %s ' , queues)
JSON Example:
{
"OFPStatsReply" : {
"body" : [
{
"OFPQueueStats" : {
"port_no" : 7 ,
"queue_id" : 1 ,
"tx_bytes" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 0
}
},
{
"OFPQueueStats" : {
"port_no" : 6 ,
"queue_id" : 1 ,
"tx_bytes" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 0
}
},
{
"OFPQueueStats" : {
"port_no" : 7 ,
"queue_id" : 2 ,
"tx_bytes" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 0
}
}
],
"flags" : 0 ,
"type" : 5
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPGroupStatsRequest(datapath, group_id=4294967292 , flags=0)
Group statistics request message
The controller uses this message to query statistics of one or more groups.
Attribute Description group_id ID of group to read (OFPG_ALL to all groups) flags Zero (none yet defined in the spec)
Example:
def
send_group_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
2.5. OpenFlow protocol API Reference 85
ryu Documentation, Release 3.21
req = ofp_parser .
OFPGroupStatsRequest(datapath, ofp .
OFPG_ALL) datapath .
send_msg(req) class ryu.ofproto.ofproto_v1_2_parser.OFPGroupStats(group_id, ref_count, packet_count, byte_count , bucket_counters)
Group statistics reply message
The switch responds with a stats reply that include this message to a group statistics request.
Attribute group_id ref_count
Description
Group identifier
Number of flows or groups that directly forward to this group packet_count Number of packets processed by group byte_count Number of bytes processed by group bucket_counters List of OFPBucketCounter instance
Example:
@set_ev_cls
(ofp_event .
EventOFPStatsReply, MAIN_DISPATCHER)
def
stats_reply_handler ( self , ev): msg = ev .
msg ofp = msg .
datapath .
ofproto body = ev .
msg .
body
if
msg .
type == ofp .
OFPST_GROUP: self .
group_stats_reply_handler(body)
def
group_stats_reply_handler ( self , body): groups = []
for
stat
in
body: groups .
append( 'group_id= %d ref_count= %d packet_count= %d '
'byte_count= %d bucket_counters= %s ' %
(stat .
group_id, stat .
ref_count, stat .
packet_count, stat .
byte_count, stat .
bucket_counters)) self .
logger .
debug( 'GroupStats: %s ' , groups) class ryu.ofproto.ofproto_v1_2_parser.OFPGroupDescStatsRequest(datapath, flags=0)
Group description request message
The controller uses this message to list the set of groups on a switch.
Attribute Description flags Zero (none yet defined in the spec)
Example:
def
send_group_desc_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGroupDescStatsRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPGroupDescStatsRequest" : {
"flags" : 0
}
}
86 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_2_parser.OFPGroupDescStats(type_, group_id , buckets , length=None)
Group description reply message
The switch responds with a stats reply that include this message to a group description request.
Attribute Description type One of OFPGT_* group_id Group identifier buckets List of OFPBucket instance type attribute corresponds to type_ parameter of __init__.
Example:
@set_ev_cls
(ofp_event .
EventOFPStatsReply, MAIN_DISPATCHER)
def
stats_reply_handler ( self , ev): msg = ev .
msg ofp = msg .
datapath .
ofproto body = ev .
msg .
body
if
msg .
type == ofp .
OFPST_GROUP_DESC: self .
group_desc_stats_reply_handler(body)
def
group_desc_stats_reply_handler ( self , body): descs = []
for
stat
in
body: descs .
append( 'type= %d group_id= %d buckets= %s ' %
(stat .
type, stat .
group_id, stat .
buckets)) self .
logger .
debug( 'GroupDescStats: %s ' , descs)
JSON Example:
{
"OFPStatsReply" : {
"body" : [
{
"OFPGroupDescStats" : {
"buckets" : [
{
"OFPBucket" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 2 ,
"type" : 0
}
}
],
"len" : 32 ,
"watch_group" : 1 ,
"watch_port" : 1 ,
"weight" : 1
}
}
],
2.5. OpenFlow protocol API Reference 87
ryu Documentation, Release 3.21
"group_id" : 1 ,
"length" : 40 ,
"type" : 0
}
}
],
"flags" : 0 ,
"type" : 7
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPGroupFeaturesStatsRequest(datapath, flags=0)
Group features request message
The controller uses this message to list the capabilities of groups on a switch.
Attribute Description flags Zero (none yet defined in the spec)
Example:
def
send_group_features_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGroupFeaturesStatsRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPGroupFeaturesStatsRequest" : {
"flags" : 0
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPGroupFeaturesStats(types, capabilities max_groups , actions ,
, length=None)
Group features reply message
The switch responds with a stats reply that include this message to a group features request.
Attribute types
Description
Bitmap of OFPGT_* values supported capabilities Bitmap of OFPGFC_* capability supported max_groups Maximum number of groups for each type actions Bitmaps of OFPAT_* that are supported
Example:
@set_ev_cls
(ofp_event .
EventOFPStatsReply, MAIN_DISPATCHER)
def
stats_reply_handler ( self , ev): msg = ev .
msg ofp = msg .
datapath .
ofproto body = ev .
msg .
body
if
msg .
type == ofp .
OFPST_GROUP_FEATURES: self .
group_features_stats_reply_handler(body)
88 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
def
group_features_stats_reply_handler ( self , body): self .
logger .
debug( 'GroupFeaturesStats: types= %d '
'capabilities=0x %08x max_groups= %s '
'actions= %s ' , body .
types, body .
capabilities, body .
max_groups, body .
actions)
JSON Example:
{
"OFPStatsReply" : {
"body" : {
"OFPGroupFeaturesStats" : {
"actions" : [
67082241 ,
67082241 ,
67082241 ,
67082241
],
"capabilities" : 5 ,
"length" : 40 ,
"max_groups" : [
16777216 ,
16777216 ,
16777216 ,
16777216
],
"types" : 15
}
},
"flags" : 0 ,
"type" : 8
}
}
Queue Configuration Messages
class ryu.ofproto.ofproto_v1_2_parser.OFPQueueGetConfigRequest(datapath, port)
Queue configuration request message
Attribute Description port Port to be queried (OFPP_ANY to all configured queues)
Example:
def
send_queue_get_config_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPQueueGetConfigRequest(datapath, ofp .
OFPP_ANY) datapath .
send_msg(req)
JSON Example:
{
"OFPQueueGetConfigRequest" : {
"port" : 4294967295
2.5. OpenFlow protocol API Reference 89
ryu Documentation, Release 3.21
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPQueueGetConfigReply(datapath, port=None, queues=None)
Queue configuration reply message
The switch responds with this message to a queue configuration request.
Attribute Description port Port which was queried queues list of OFPPacketQueue instance
Example:
@set_ev_cls
(ofp_event .
EventOFPQueueGetConfigReply, MAIN_DISPATCHER)
def
queue_get_config_reply_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPQueueGetConfigReply received: '
'port= %s queues= %s ' , msg .
port, msg .
queues)
JSON Example:
{
"OFPQueueGetConfigReply" : {
"port" : 4294967295 ,
"queues" : [
{
"OFPPacketQueue" : {
"len" : 48 ,
"port" : 77 ,
"properties" : [
{
"OFPQueuePropMinRate" : {
"len" : 16 ,
"property" : 1 ,
"rate" : 10
}
},
{
"OFPQueuePropMaxRate" : {
"len" : 16 ,
"property" : 2 ,
"rate" : 900
}
}
],
"queue_id" : 99
}
},
{
"OFPPacketQueue" : {
"len" : 48 ,
"port" : 77 ,
"properties" : [
{
"OFPQueuePropMinRate" : {
"len" : 16 ,
90 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
]
}
}
"property" : 1 ,
"rate" : 100
}
},
{
"OFPQueuePropMaxRate" : {
"len" : 16 ,
"property" : 2 ,
"rate" : 200
}
}
],
"queue_id" : 88
Packet-Out Message
class ryu.ofproto.ofproto_v1_2_parser.OFPPacketOut(datapath, buffer_id=None , in_port=None , actions=None , data=None
, actions_len=None)
Packet-Out message
The controller uses this message to send a packet out throught the switch.
Attribute Description buffer_id ID assigned by datapath (OFP_NO_BUFFER if none) in_port Packet’s input port or OFPP_CONTROLLER actions data list of OpenFlow action class
Packet data
Example:
def
send_packet_out ( self , datapath, buffer_id, in_port): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser actions = [ofp_parser .
OFPActionOutput(ofp .
OFPP_FLOOD, 0 )] req = ofp_parser .
OFPPacketOut(datapath, buffer_id, in_port, actions) datapath .
send_msg(req)
JSON Example:
{
"OFPPacketOut" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 4294967292 ,
"type" : 0
}
}
2.5. OpenFlow protocol API Reference 91
ryu Documentation, Release 3.21
}
}
],
"actions_len" : 16 ,
"buffer_id" : 4294967295 ,
"data" : "8guk0D9w8gukffjqCABFAABU+BoAAP8Br4sKAAABCgAAAggAAgj3YAAAMdYCAAAAAACrjS0xAAAAABAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vAAAAAAAAAAA=" ,
"in_port" : 4294967293
Barrier Message
class ryu.ofproto.ofproto_v1_2_parser.OFPBarrierRequest(datapath)
Barrier request message
The controller sends this message to ensure message dependencies have been met or receive notifications for completed operations.
Example:
def
send_barrier_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPBarrierRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPBarrierRequest" : {}
} class ryu.ofproto.ofproto_v1_2_parser.OFPBarrierReply(datapath)
Barrier reply message
The switch responds with this message to a barrier request.
Example:
@set_ev_cls
(ofp_event .
EventOFPBarrierReply, MAIN_DISPATCHER)
def
barrier_reply_handler ( self , ev): self .
logger .
debug( 'OFPBarrierReply received' )
JSON Example:
{
"OFPBarrierReply" : {}
}
Role Request Message
class ryu.ofproto.ofproto_v1_2_parser.OFPRoleRequest(datapath, role, generation_id)
Role request message
The controller uses this message to change its role.
92 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute role
Description
One of the following values.
OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
OFPCR_ROLE_SLAVE generation_id
Example:
def
send_role_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
Master Election Generation ID req = ofp_parser .
OFPRoleRequest(datapath, ofp .
OFPCR_ROLE_EQUAL, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPRoleRequest" : {
"generation_id" : 17294086455919964160 ,
"role" : 2
}
} class ryu.ofproto.ofproto_v1_2_parser.OFPRoleReply(datapath, role=None tion_id=None)
,
Role reply message
The switch responds with this message to a role request.
Attribute role
Description
One of the following values.
genera-
OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
OFPCR_ROLE_SLAVE generation_id
Example:
Master Election Generation ID
@set_ev_cls
(ofp_event .
EventOFPRoleReply, MAIN_DISPATCHER)
def
role_reply_handler ( self , ev): msg = ev .
msg ofp = dp .
ofproto
if
msg .
role == ofp .
OFPCR_ROLE_NOCHANGE: role = 'NOCHANGE'
elif
msg .
role == ofp .
OFPCR_ROLE_EQUAL: role = 'EQUAL'
elif
msg .
role == ofp .
OFPCR_ROLE_MASTER: role = 'MASTER'
elif
msg .
role == ofp .
OFPCR_ROLE_SLAVE: role = 'SLAVE'
2.5. OpenFlow protocol API Reference 93
ryu Documentation, Release 3.21
else
: role = 'unknown' self .
logger .
debug( 'OFPRoleReply received: '
'role= %s generation_id= %d ' , role, msg .
generation_id)
JSON Example:
{
"OFPRoleReply" : {
"generation_id" : 17294086455919964160 ,
"role" : 3
}
}
Asynchronous Messages
Packet-In Message
class ryu.ofproto.ofproto_v1_2_parser.OFPPacketIn(datapath, tal_len=None , buffer_id=None , toreason=None , table_id=None data=None)
, match=None ,
Packet-In message
The switch sends the packet that received to the controller by this message.
Attribute buffer_id total_len reason
Description
ID assigned by datapath
Full length of frame
Reason packet is being sent.
OFPR_NO_MATCH
OFPR_ACTION
OFPR_INVALID_TTL table_id match data
Example:
ID of the table that was looked up
Instance of OFPMatch
Ethernet frame
@set_ev_cls
(ofp_event .
EventOFPPacketIn, MAIN_DISPATCHER)
def
packet_in_handler ( self , ev): msg = ev .
msg ofp = dp .
ofproto
if
msg .
reason == ofp .
OFPR_NO_MATCH: reason = 'NO MATCH'
elif
msg .
reason == ofp .
OFPR_ACTION: reason = 'ACTION'
elif
msg .
reason == ofp .
OFPR_INVALID_TTL: reason = 'INVALID TTL'
else
: reason = 'unknown'
94 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
self .
logger .
debug( 'OFPPacketIn received: '
'buffer_id= %x total_len= %d reason= %s '
'table_id= %d match= %s data= %s ' , msg .
buffer_id, msg .
total_len, reason, msg .
table_id, msg .
match, utils .
hex_array(msg .
data))
JSON Example:
{
"OFPPacketIn" : {
"buffer_id" : 2 ,
"data" : "////////8gukffjqCAYAAQgABgQAAfILpH346goAAAEAAAAAAAAKAAAD" ,
"match" : {
"OFPMatch" : {
"length" : 80 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 6
}
},
{
"OXMTlv" : {
"field" : "eth_type" ,
"mask" : null,
"value" : 2054
}
},
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "ff:ff:ff:ff:ff:ff"
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
"OXMTlv" : {
"field" : "arp_op" ,
"mask" : null,
"value" : 1
}
},
{
"OXMTlv" : {
"field" : "arp_spa" ,
"mask" : null,
"value" : "10.0.0.1"
}
2.5. OpenFlow protocol API Reference 95
ryu Documentation, Release 3.21
}
}
},
{
"OXMTlv" : {
"field" : "arp_tpa" ,
"mask" : null,
"value" : "10.0.0.3"
}
},
{
"OXMTlv" : {
"field" : "arp_sha" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
"OXMTlv" : {
"field" : "arp_tha" ,
"mask" : null,
"value" : "00:00:00:00:00:00"
}
}
],
"type" : 1
}
},
"reason" : 1 ,
"table_id" : 1 ,
"total_len" : 42
Flow Removed Message
class ryu.ofproto.ofproto_v1_2_parser.OFPFlowRemoved(datapath, cookie=None
, priority=None , reason=None , table_id=None , duration_sec=None, duration_nsec=None , idle_timeout=None , hard_timeout=None , packet_count=None , byte_count=None , match=None)
Flow removed message
When flow entries time out or are deleted, the switch notifies controller with this message.
96 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute cookie priority reason
Description
Opaque controller-issued identifier
Priority level of flow entry
One of the following values.
OFPRR_IDLE_TIMEOUT
OFPRR_HARD_TIMEOUT
OFPRR_DELETE
OFPRR_GROUP_DELETE table_id duration_sec duration_nsec idle_timeout hard_timeout packet_count byte_count match
Example:
ID of the table
Time flow was alive in seconds
Time flow was alive in nanoseconds beyond duration_sec
Idle timeout from original flow mod
Hard timeout from original flow mod
Number of packets that was associated with the flow
Number of bytes that was associated with the flow
Instance of OFPMatch
@set_ev_cls
(ofp_event .
EventOFPFlowRemoved, MAIN_DISPATCHER)
def
flow_removed_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto
if
msg .
reason == ofp .
OFPRR_IDLE_TIMEOUT: reason = 'IDLE TIMEOUT'
elif
msg .
reason == ofp .
OFPRR_HARD_TIMEOUT: reason = 'HARD TIMEOUT'
elif
msg .
reason == ofp .
OFPRR_DELETE: reason = 'DELETE'
elif
msg .
reason == ofp .
OFPRR_GROUP_DELETE: reason = 'GROUP DELETE'
else
: reason = 'unknown' self .
logger .
debug( 'OFPFlowRemoved received: '
'cookie= %d priority= %d reason= %s table_id= %d '
'duration_sec= %d duration_nsec= %d '
'idle_timeout= %d hard_timeout= %d '
'packet_count= %d byte_count= %d match.fields= %s ' , msg .
cookie, msg .
priority, reason, msg .
table_id, msg .
duration_sec, msg .
duration_nsec, msg .
idle_timeout, msg .
hard_timeout, msg .
packet_count, msg .
byte_count, msg .
match)
JSON Example:
{
"OFPFlowRemoved" : {
"byte_count" : 86 ,
"cookie" : 0 ,
"duration_nsec" : 48825000 ,
"duration_sec" : 3 ,
2.5. OpenFlow protocol API Reference 97
ryu Documentation, Release 3.21
}
}
"hard_timeout" : 0 ,
"idle_timeout" : 3 ,
"match" : {
"OFPMatch" : {
"length" : 14 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
"packet_count" : 1 ,
"priority" : 65535 ,
"reason" : 0 ,
"table_id" : 0
Port Status Message
class ryu.ofproto.ofproto_v1_2_parser.OFPPortStatus(datapath, desc=None)
Port status message
The switch notifies controller of change of ports.
Attribute reason
Description
One of the following values.
OFPPR_ADD
OFPPR_DELETE
OFPPR_MODIFY desc
Example: instance of OFPPort
@set_ev_cls
(ofp_event .
EventOFPPortStatus, MAIN_DISPATCHER)
def
port_status_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto
if
msg .
reason == ofp .
OFPPR_ADD: reason = 'ADD'
elif
msg .
reason == ofp .
OFPPR_DELETE: reason = 'DELETE'
elif
msg .
reason == ofp .
OFPPR_MODIFY: reason = 'MODIFY'
else
: reason = 'unknown' reason=None ,
98 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
self .
logger .
debug( 'OFPPortStatus received: reason= %s desc= %s ' , reason, msg .
desc)
JSON Example:
{
"OFPPortStatus" : {
"desc" : {
"OFPPort" : {
"advertised" : 10240 ,
"config" : 0 ,
"curr" : 10248 ,
"curr_speed" : 5000 ,
"hw_addr" : "f2:0b:a4:d0:3f:70" ,
"max_speed" : 5000 ,
"name" : "\u79c1\u306e\u30dd\u30fc\u30c8" ,
"peer" : 10248 ,
"port_no" : 7 ,
"state" : 4 ,
"supported" : 10248
}
},
"reason" : 0
}
}
Error Message
class ryu.ofproto.ofproto_v1_2_parser.OFPErrorMsg(datapath, type_=None , code=None , data=None)
Error message
The switch notifies controller of problems by this message.
Attribute Description type High level type of error code data
Details depending on the type
Variable length data depending on the type and code type attribute corresponds to type_ parameter of __init__.
Types and codes are defined in ryu.ofproto.ofproto.
Type
OFPET_HELLO_FAILED
OFPET_BAD_REQUEST
OFPET_BAD_ACTION
OFPET_BAD_INSTRUCTION
OFPET_BAD_MATCH
OFPET_FLOW_MOD_FAILED
OFPET_GROUP_MOD_FAILED
Code
OFPHFC_*
OFPBRC_*
OFPBAC_*
OFPBIC_*
OFPBMC_*
OFPFMFC_*
OFPGMFC_*
OFPET_PORT_MOD_FAILED
OFPET_TABLE_MOD_FAILED
OFPPMFC_*
OFPTMFC_*
OFPET_QUEUE_OP_FAILED OFPQOFC_*
OFPET_SWITCH_CONFIG_FAILED OFPSCFC_*
OFPET_ROLE_REQUEST_FAILED OFPRRFC_*
OFPET_EXPERIMENTER N/A
2.5. OpenFlow protocol API Reference 99
ryu Documentation, Release 3.21
Example:
@set_ev_cls
(ofp_event .
EventOFPErrorMsg,
[HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def
error_msg_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPErrorMsg received: type=0x %02x code=0x %02x '
'message= %s ' , msg .
type, msg .
code, utils .
hex_array(msg .
data))
JSON Example:
{
"OFPErrorMsg" : {
"code" : 11 ,
"data" : "ZnVnYWZ1Z2E=" ,
"type" : 2
}
}
{
}
"OFPErrorExperimenterMsg" : {
"data" : "amlra2VuIGRhdGE=" ,
"exp_type" : 60000 ,
"experimenter" : 999999 ,
"type" : 65535
}
Symmetric Messages
Hello
class ryu.ofproto.ofproto_v1_2_parser.OFPHello(datapath)
Hello message
When connection is started, the hello message is exchanged between a switch and a controller.
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
JSON Example:
{
"OFPHello" : {}
}
Echo Request
class ryu.ofproto.ofproto_v1_2_parser.OFPEchoRequest(datapath, data=None)
Echo request message
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Attribute Description data An arbitrary length data
Example:
100 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
def
send_echo_request ( self , datapath, data): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPEchoRequest(datapath, data) datapath .
send_msg(req)
@set_ev_cls
(ofp_event .
EventOFPEchoRequest,
[HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def
echo_request_handler ( self , ev): self .
logger .
debug( 'OFPEchoRequest received: data= %s ' , utils .
hex_array(ev .
msg .
data))
JSON Example:
{
"OFPEchoRequest" : {
"data" : "aG9nZQ=="
}
}
Echo Reply
class ryu.ofproto.ofproto_v1_2_parser.OFPEchoReply(datapath, data=None)
Echo reply message
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Attribute Description data An arbitrary length data
Example:
def
send_echo_reply ( self , datapath, data): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser reply = ofp_parser .
OFPEchoReply(datapath, data) datapath .
send_msg(reply)
@set_ev_cls
(ofp_event .
EventOFPEchoReply,
[HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def
echo_reply_handler ( self , ev): self .
logger .
debug( 'OFPEchoReply received: data= %s ' , utils .
hex_array(ev .
msg .
data))
JSON Example:
{
"OFPEchoReply" : {
"data" : "aG9nZQ=="
}
}
2.5. OpenFlow protocol API Reference 101
ryu Documentation, Release 3.21
Experimenter
class ryu.ofproto.ofproto_v1_2_parser.OFPExperimenter(datapath, experimenter=None , exp_type=None , data=None)
Experimenter extension message
Attribute Description experimenter Experimenter ID exp_type Experimenter defined data Experimenter defined arbitrary additional data
JSON Example:
{
"OFPExperimenter" : {
"data" : "bmF6bw==" ,
"exp_type" : 123456789 ,
"experimenter" : 98765432
}
}
Flow Match Structure
class ryu.ofproto.ofproto_v1_2_parser.OFPMatch(type_=None, length=None dered_fields=None , **kwargs)
,
Flow Match Structure
_or-
This class is implementation of the flow match structure having compose/query API. There are new API and old
API for compatibility. the old API is supposed to be removed later.
You can define the flow match by the keyword arguments. The following arguments are available.
Argument in_port in_phy_port metadata eth_dst eth_src eth_type vlan_vid vlan_pcp ip_dscp ip_ecn ip_proto ipv4_src ipv4_dst tcp_src tcp_dst udp_src udp_dst sctp_src sctp_dst icmpv4_type icmpv4_code
Value Description
Integer 32bit Switch input port
Integer 32bit Switch physical input port
Integer 64bit Metadata passed between tables
MAC address Ethernet destination address
MAC address Ethernet source address
Integer 16bit Ethernet frame type
Integer 16bit VLAN id
Integer 8bit
Integer 8bit
Integer 8bit
Integer 8bit
VLAN priority
IP DSCP (6 bits in ToS field)
IP ECN (2 bits in ToS field)
IP protocol
IPv4 address IPv4 source address
IPv4 address IPv4 destination address
Integer 16bit TCP source port
Integer 16bit TCP destination port
Integer 16bit UDP source port
Integer 16bit UDP destination port
Integer 16bit SCTP source port
Integer 16bit SCTP destination port
Integer 8bit ICMP type
Integer 8bit ICMP code
Continued on next page
102 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Argument
Table 2.1 – continued from previous page
Value Description arp_op Integer 16bit ARP opcode arp_spa arp_tpa arp_sha
IPv4 address ARP source IPv4 address
IPv4 address ARP target IPv4 address
MAC address ARP source hardware address arp_tha ipv6_src ipv6_dst ipv6_flabel
MAC address ARP target hardware address
IPv6 address IPv6 source address
IPv6 address IPv6 destination address
Integer 32bit IPv6 Flow Label icmpv6_type icmpv6_code
Integer 8bit
Integer 8bit
ICMPv6 type
ICMPv6 code ipv6_nd_target IPv6 address Target address for ND ipv6_nd_sll MAC address Source link-layer for ND ipv6_nd_tll mpls_label mpls_tc
MAC address Target link-layer for ND
Integer 32bit MPLS label
Integer 8bit MPLS TC
Example:
>>>
# compose
>>>
match = parser .
OFPMatch(
...
in_port = 1 ,
...
...
...
...
eth_type ipv6_src ipv6_dst
=
=
=
0x86dd
(
,
'2001:db8:bd05:1d2:288a:1fc0:1:10ee'
'ffff:ffff:ffff:ffff::' ),
'2001:db8:bd05:1d2:288a:1fc0:1:10ee' )
,
>>>
# query
>>> if
'ipv6_src'
in
match:
...
...
match[ 'ipv6_src' ]
('2001:db8:bd05:1d2:288a:1fc0:1:10ee', 'ffff:ffff:ffff:ffff::')
Note: For VLAN id match field, special values are defined in OpenFlow Spec.
1.Packets with and without a VLAN tag
•Example: match = parser .
OFPMatch()
•Packet Matching non-VLAN-tagged MATCH
VLAN-tagged(vlan_id=3) MATCH
VLAN-tagged(vlan_id=5) MATCH
2.Only packets without a VLAN tag
•Example: match = parser .
OFPMatch(vlan_vid = 0x0000 )
•Packet Matching
2.5. OpenFlow protocol API Reference 103
ryu Documentation, Release 3.21
non-VLAN-tagged MATCH
VLAN-tagged(vlan_id=3) x
VLAN-tagged(vlan_id=5) x
3.Only packets with a VLAN tag regardless of its value
•Example: match = parser .
OFPMatch(vlan_vid = ( 0x1000 , 0x1000 ))
•Packet Matching non-VLAN-tagged x
VLAN-tagged(vlan_id=3) MATCH
VLAN-tagged(vlan_id=5) MATCH
4.Only packets with VLAN tag and VID equal
•Example: match = parser .
OFPMatch(vlan_vid = ( 0x1000 | 3 ))
•Packet Matching non-VLAN-tagged x
VLAN-tagged(vlan_id=3) MATCH
VLAN-tagged(vlan_id=5) x
Flow Instruction Structures
class ryu.ofproto.ofproto_v1_2_parser.OFPInstructionGotoTable(table_id, type_=None , len_=None)
Goto table instruction
This instruction indicates the next table in the processing pipeline.
Attribute Description table_id Next table class ryu.ofproto.ofproto_v1_2_parser.OFPInstructionWriteMetadata(metadata, metadata_mask , type_=None , len_=None)
Write metadata instruction
This instruction writes the masked metadata value into the metadata field.
Attribute metadata
Description
Metadata value to write metadata_mask Metadata write bitmask class ryu.ofproto.ofproto_v1_2_parser.OFPInstructionActions(type_, actions=None , len_=None)
Actions instruction
This instruction writes/applies/clears the actions.
104 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute type
Description
One of following values.
OFPIT_WRITE_ACTIONS
OFPIT_APPLY_ACTIONS
OFPIT_CLEAR_ACTIONS actions list of OpenFlow action class type attribute corresponds to type_ parameter of __init__.
Action Structures
class ryu.ofproto.ofproto_v1_2_parser.OFPActionOutput(port, max_len=65509 type_=None , len_=None)
,
Output action
This action indicates output a packet to the switch port.
Attribute Description port Output port max_len Max length to send to controller class ryu.ofproto.ofproto_v1_2_parser.OFPActionGroup(group_id=0, len_=None)
Group action
This action indicates the group used to process the packet.
Attribute Description group_id Group identifier class ryu.ofproto.ofproto_v1_2_parser.OFPActionSetQueue(queue_id, len_=None)
Set queue action type_=None type_=None
This action sets the queue id that will be used to map a flow to an already-configured queue on a port.
Attribute Description queue_id Queue ID for the packets class ryu.ofproto.ofproto_v1_2_parser.OFPActionSetMplsTtl(mpls_ttl, len_=None)
Set MPLS TTL action type_=None ,
,
,
This action sets the MPLS TTL.
Attribute Description mpls_ttl MPLS TTL class ryu.ofproto.ofproto_v1_2_parser.OFPActionDecMplsTtl(type_=None, len_=None)
Decrement MPLS TTL action
This action decrements the MPLS TTL.
type_=None
, class ryu.ofproto.ofproto_v1_2_parser.OFPActionSetNwTtl(nw_ttl, len_=None)
Set IP TTL action
This action sets the IP TTL.
Attribute Description nw_ttl IP TTL
2.5. OpenFlow protocol API Reference 105
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_2_parser.OFPActionDecNwTtl(type_=None, len_=None)
Decrement IP TTL action
This action decrements the IP TTL.
class ryu.ofproto.ofproto_v1_2_parser.OFPActionCopyTtlOut(type_=None, len_=None)
Copy TTL Out action
This action copies the TTL from the next-to-outermost header with TTL to the outermost header with TTL.
class ryu.ofproto.ofproto_v1_2_parser.OFPActionCopyTtlIn(type_=None, len_=None)
Copy TTL In action
This action copies the TTL from the outermost header with TTL to the next-to-outermost header with TTL.
class ryu.ofproto.ofproto_v1_2_parser.OFPActionPushVlan(ethertype=33024, type_=None , len_=None)
Push VLAN action
This action pushes a new VLAN tag to the packet.
Attribute Description ethertype Ether type. The default is 802.1Q. (0x8100) class ryu.ofproto.ofproto_v1_2_parser.OFPActionPushMpls(ethertype=34887, type_=None , len_=None)
Push MPLS action
This action pushes a new MPLS header to the packet.
Attribute Description ethertype Ether type class ryu.ofproto.ofproto_v1_2_parser.OFPActionPopVlan(type_=None, len_=None)
Pop VLAN action
This action pops the outermost VLAN tag from the packet.
class ryu.ofproto.ofproto_v1_2_parser.OFPActionPopMpls(ethertype=2048, type_=None , len_=None)
Pop MPLS action
This action pops the MPLS header from the packet.
class ryu.ofproto.ofproto_v1_2_parser.OFPActionSetField(field=None, **kwargs)
Set field action
This action modifies a header field in the packet.
The set of keywords available for this is same as OFPMatch.
Example: set_field = OFPActionSetField(eth_src = "00:00:00:00:00" ) class ryu.ofproto.ofproto_v1_2_parser.OFPActionExperimenter(experimenter, type_=None , len_=None)
Experimenter action
This action is an extensible action for the experimenter.
Attribute Description experimenter Experimenter ID
106 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
2.5.3 OpenFlow v1.3 Messages and Structures
Controller-to-Switch Messages
Handshake
class ryu.ofproto.ofproto_v1_3_parser.OFPFeaturesRequest(datapath)
Features request message
The controller sends a feature request to the switch upon session establishment.
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Example:
def
send_features_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPFeaturesRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPFeaturesRequest" : {}
} class ryu.ofproto.ofproto_v1_3_parser.OFPSwitchFeatures(datapath, datapath_id=None, n_buffers=None , n_tables=None
, iary_id=None
, ties=None) auxilcapabili-
Features reply message
The switch responds with a features reply message to a features request.
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Example:
@set_ev_cls
(ofp_event .
EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def
switch_features_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPSwitchFeatures received: '
'datapath_id=0x %016x n_buffers= %d '
'n_tables= %d auxiliary_id= %d '
'capabilities=0x %08x ' , msg .
datapath_id, msg .
n_buffers, msg .
n_tables, msg .
auxiliary_id, msg .
capabilities)
JSON Example:
{
"OFPSwitchFeatures" : {
"auxiliary_id" : 99 ,
"capabilities" : 79 ,
"datapath_id" : 9210263729383 ,
"n_buffers" : 0 ,
"n_tables" : 255
2.5. OpenFlow protocol API Reference 107
ryu Documentation, Release 3.21
}
}
Switch Configuration
class ryu.ofproto.ofproto_v1_3_parser.OFPSetConfig(datapath, flags=0, miss_send_len=0)
Set config request message
The controller sends a set config request message to set configuraion parameters.
Attribute flags
Description
Bitmap of the following flags.
miss_send_len
OFPC_FRAG_NORMAL
OFPC_FRAG_DROP
OFPC_FRAG_REASM
Max bytes of new flow that datapath should send to the controller
Example:
def
send_set_config ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPSetConfig(datapath, ofp .
OFPC_FRAG_NORMAL, 256 ) datapath .
send_msg(req)
JSON Example:
{
"OFPSetConfig" : {
"flags" : 0 ,
"miss_send_len" : 128
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPGetConfigRequest(datapath)
Get config request message
The controller sends a get config request to query configuration parameters in the switch.
Example:
def
send_get_config_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGetConfigRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPGetConfigRequest" : {}
}
108 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_3_parser.OFPGetConfigReply(datapath, flags=None miss_send_len=None)
,
Get config reply message
The switch responds to a configuration request with a get config reply message.
Attribute flags
Description
Bitmap of the following flags.
OFPC_FRAG_NORMAL
OFPC_FRAG_DROP
OFPC_FRAG_REASM
OFPC_FRAG_MASK miss_send_len Max bytes of new flow that datapath should send to the controller
Example:
@set_ev_cls
(ofp_event .
EventOFPGetConfigReply, MAIN_DISPATCHER)
def
get_config_reply_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto flags = []
if
msg .
flags & ofp .
OFPC_FRAG_NORMAL: flags .
append( 'NORMAL' )
if
msg .
flags & ofp .
OFPC_FRAG_DROP: flags .
append( 'DROP' )
if
msg .
flags & ofp .
OFPC_FRAG_REASM: flags .
append( 'REASM' ) self .
logger .
debug( 'OFPGetConfigReply received: '
'flags= %s miss_send_len= %d ' ,
',' .
join(flags), msg .
miss_send_len)
JSON Example:
{
"OFPGetConfigReply" : {
"flags" : 0 ,
"miss_send_len" : 128
}
}
Flow Table Configuration
class ryu.ofproto.ofproto_v1_3_parser.OFPTableMod(datapath, table_id, config)
Flow table configuration message
The controller sends this message to configure table state.
Attribute Description table_id ID of the table (OFPTT_ALL indicates all tables) config Bitmap of the following flags. OFPTC_DEPRECATED_MASK (3)
Example:
2.5. OpenFlow protocol API Reference 109
ryu Documentation, Release 3.21
def
send_table_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPTableMod(datapath, 1 , 3 ) datapath .
send_msg(req)
JSON Example:
{
"OFPTableMod" : {
"config" : 0 ,
"table_id" : 255
}
}
Modify State Messages
class ryu.ofproto.ofproto_v1_3_parser.OFPFlowMod(datapath, cookie=0, cookie_mask=0, table_id=0 , command=0, idle_timeout=0, hard_timeout=0 , buffer_id=4294967295 , priority=32768 out_port=0
,
, out_group=0 , flags=0 , match=None , instructions=[])
Modify Flow entry message
The controller sends this message to modify the flow table.
110 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute cookie cookie_mask table_id command idle_timeout hard_timeout priority buffer_id out_port out_group flags
Description
Opaque controller-issued identifier
Mask used to restrict the cookie bits that must match when the command is OPFFC_MODIFY* or
OFPFC_DELETE*
ID of the table to put the flow in
One of the following values.
OFPFC_ADD
OFPFC_MODIFY
OFPFC_MODIFY_STRICT
OFPFC_DELETE
OFPFC_DELETE_STRICT
Idle time before discarding (seconds)
Max time before discarding (seconds)
Priority level of flow entry
Buffered packet to apply to (or OFP_NO_BUFFER)
For OFPFC_DELETE* commands, require matching entries to include this as an output port
For OFPFC_DELETE* commands, require matching entries to include this as an output group
Bitmap of the following flags.
OFPFF_SEND_FLOW_REM
OFPFF_CHECK_OVERLAP
OFPFF_RESET_COUNTS
OFPFF_NO_PKT_COUNTS
OFPFF_NO_BYT_COUNTS match instructions
Example:
def
send_flow_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
Instance of OFPMatch list of OFPInstruction* instance cookie = cookie_mask = 0 table_id = 0 idle_timeout = hard_timeout = 0 priority = 32768 buffer_id = ofp .
OFP_NO_BUFFER match = ofp_parser .
OFPMatch(in_port = 1 , eth_dst = 'ff:ff:ff:ff:ff:ff' ) actions = [ofp_parser .
OFPActionOutput(ofp .
OFPP_NORMAL, 0 )] inst = [ofp_parser .
OFPInstructionActions(ofp .
OFPIT_APPLY_ACTIONS, actions)] req = ofp_parser .
OFPFlowMod(datapath, cookie, cookie_mask, table_id, ofp .
OFPFC_ADD, idle_timeout, hard_timeout, priority, buffer_id, ofp .
OFPP_ANY, ofp .
OFPG_ANY, ofp .
OFPFF_SEND_FLOW_REM, match, inst)
2.5. OpenFlow protocol API Reference 111
ryu Documentation, Release 3.21
datapath .
send_msg(req)
JSON Example:
{
"OFPFlowMod" : {
"buffer_id" : 65535 ,
"command" : 0 ,
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "vlan_vid" ,
"mask" : null,
"value" : 258
}
}
}
},
{
"OFPActionCopyTtlOut" : {
"len" : 8 ,
"type" : 11
}
},
{
"OFPActionCopyTtlIn" : {
"len" : 8 ,
"type" : 12
}
},
{
"OFPActionCopyTtlIn" : {
"len" : 8 ,
"type" : 12
}
},
{
"OFPActionPopPbb" : {
"len" : 8 ,
"type" : 27
}
},
{
"OFPActionPushPbb" : {
"ethertype" : 4660 ,
"len" : 8 ,
"type" : 26
}
112 Chapter 2. Writing Your Ryu Application
},
{
"OFPActionPopMpls" : {
"ethertype" : 39030 ,
"len" : 8 ,
"type" : 20
}
},
{
},
{
"OFPActionPushMpls" : {
"ethertype" : 34887 ,
"len" : 8 ,
"type" : 19
}
"OFPActionPopVlan" : {
"len" : 8 ,
"type" : 18
}
},
{
"OFPActionPushVlan" : {
"ethertype" : 33024 ,
"len" : 8 ,
"type" : 17
}
},
{
"OFPActionDecMplsTtl" : {
"len" : 8 ,
"type" : 16
}
},
{
"OFPActionSetMplsTtl" : {
"len" : 8 ,
"mpls_ttl" : 10 ,
"type" : 15
}
},
{
"OFPActionDecNwTtl" : {
"len" : 8 ,
"type" : 24
}
},
{
"OFPActionSetNwTtl" : {
"len" : 8 ,
"nw_ttl" : 10 ,
"type" : 23
}
},
{
"OFPActionSetQueue" : {
"len" : 8 ,
"queue_id" : 3 ,
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
113
ryu Documentation, Release 3.21
114
"type" : 21
}
},
{
"OFPActionGroup" : {
"group_id" : 99 ,
"len" : 8 ,
"type" : 22
}
},
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 6 ,
"type" : 0
}
}
],
"len" : 160 ,
"type" : 3
}
},
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "01:02:03:04:05:06"
}
}
}
},
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "pbb_uca" ,
"mask" : null,
"value" : 1
}
}
}
}
],
"len" : 40 ,
"type" : 4
}
}
],
"match" : {
"OFPMatch" : {
"length" : 14 ,
"oxm_fields" : [
Chapter 2. Writing Your Ryu Application
}
}
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"priority" : 123 ,
"table_id" : 1
{
"OFPFlowMod" : {
"buffer_id" : 65535 ,
"command" : 0 ,
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionGotoTable" : {
"len" : 8 ,
"table_id" : 1 ,
"type" : 1
}
}
],
"match" : {
"OFPMatch" : {
"length" : 22 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 6
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
115
ryu Documentation, Release 3.21
116
}
}
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"priority" : 123 ,
"table_id" : 0
{
"OFPFlowMod" : {
"buffer_id" : 65535 ,
"command" : 0 ,
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionMeter" : {
"len" : 8 ,
"meter_id" : 1 ,
"type" : 6
}
},
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 6 ,
"type" : 0
}
}
],
"len" : 24 ,
"type" : 3
}
}
],
"match" : {
"OFPMatch" : {
"length" : 14 ,
"oxm_fields" : [
{
"OXMTlv" : {
}
}
],
"type" : 1
"field" : "eth_dst" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"priority" : 123 ,
"table_id" : 1
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPGroupMod(datapath, command=0 , type_=0 , group_id=0 , buckets=[])
Modify group entry message
The controller sends this message to modify the group table.
Attribute command
Description
One of the following values.
OFPGC_ADD
OFPGC_MODIFY
OFPGC_DELETE type One of the following values.
OFPGT_ALL
OFPGT_SELECT
OFPGT_INDIRECT
OFPGT_FF group_id buckets
Group identifier list of OFPBucket type attribute corresponds to type_ parameter of __init__.
Example:
def
send_group_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser port = 1 max_len = 2000 actions = [ofp_parser .
OFPActionOutput(port, max_len)] weight = 100 watch_port = 0 watch_group = 0 buckets = [ofp_parser .
OFPBucket(weight, watch_port, watch_group, actions)] group_id = 1 req = ofp_parser .
OFPGroupMod(datapath, ofp .
OFPGC_ADD, ofp .
OFPGT_SELECT, group_id, buckets) datapath .
send_msg(req)
JSON Example:
{
"OFPGroupMod" : {
"buckets" : [
{
"OFPBucket" : {
2.5. OpenFlow protocol API Reference 117
ryu Documentation, Release 3.21
}
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 2 ,
"type" : 0
}
}
],
"len" : 32 ,
"watch_group" : 1 ,
"watch_port" : 1 ,
"weight" : 1
}
}
],
"command" : 0 ,
"group_id" : 1 ,
"type" : 0
} class ryu.ofproto.ofproto_v1_3_parser.OFPPortMod(datapath, port_no=0 hw_addr=‘00:00:00:00:00:00’ , con-
, fig=0 , mask=0, advertise=0)
Port modification message
The controller sneds this message to modify the behavior of the port.
118 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute port_no hw_addr config mask advertise
Description
Port number to modify
The hardware address that must be the same as hw_addr of OFPPort of OFPSwitchFeatures
Bitmap of configuration flags.
OFPPC_PORT_DOWN
OFPPC_NO_RECV
OFPPC_NO_FWD
OFPPC_NO_PACKET_IN
Bitmap of configuration flags above to be changed
Bitmap of the following flags.
OFPPF_10MB_HD
OFPPF_10MB_FD
OFPPF_100MB_HD
OFPPF_100MB_FD
OFPPF_1GB_HD
OFPPF_1GB_FD
OFPPF_10GB_FD
OFPPF_40GB_FD
OFPPF_100GB_FD
OFPPF_1TB_FD
OFPPF_OTHER
OFPPF_COPPER
OFPPF_FIBER
OFPPF_AUTONEG
OFPPF_PAUSE
OFPPF_PAUSE_ASYM
Example:
def
send_port_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser port_no = 3 hw_addr = 'fa:c8:e8:76:1d:7e' config = 0 mask = (ofp .
OFPPC_PORT_DOWN | ofp .
OFPPC_NO_RECV | ofp .
OFPPC_NO_FWD | ofp .
OFPPC_NO_PACKET_IN) advertise = (ofp .
OFPPF_10MB_HD | ofp .
OFPPF_100MB_FD | ofp .
OFPPF_1GB_FD | ofp .
OFPPF_COPPER | ofp .
OFPPF_AUTONEG | ofp .
OFPPF_PAUSE | ofp .
OFPPF_PAUSE_ASYM) req = ofp_parser .
OFPPortMod(datapath, port_no, hw_addr, config, mask, advertise) datapath .
send_msg(req)
JSON Example:
2.5. OpenFlow protocol API Reference 119
ryu Documentation, Release 3.21
{
"OFPPortMod" : {
"advertise" : 4096 ,
"config" : 0 ,
"hw_addr" : "00:11:00:00:11:11" ,
"mask" : 0 ,
"port_no" : 1
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPMeterMod(datapath, command=0, flags=1, meter_id=1
, bands=[])
Meter modification message
The controller sends this message to modify the meter.
Attribute command
Description
One of the following values.
flags
OFPMC_ADD
OFPMC_MODIFY
OFPMC_DELETE
Bitmap of the following flags.
meter_id bands
OFPMF_KBPS
OFPMF_PKTPS
OFPMF_BURST
OFPMF_STATS
Meter instance list of the following class instance.
OFPMeterBandDrop
OFPMeterBandDscpRemark
OFPMeterBandExperimenter
JSON Example:
{
"OFPMeterMod" : {
"bands" : [
{
"OFPMeterBandDrop" : {
"burst_size" : 10 ,
"len" : 16 ,
"rate" : 1000 ,
"type" : 1
}
},
{
"OFPMeterBandDscpRemark" : {
"burst_size" : 10 ,
"len" : 16 ,
"prec_level" : 1 ,
"rate" : 1000 ,
120 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
"type" : 2
}
},
{
"OFPMeterBandExperimenter" : {
"burst_size" : 10 ,
"experimenter" : 999 ,
"len" : 16 ,
"rate" : 1000 ,
"type" : 65535
}
}
],
"command" : 0 ,
"flags" : 14 ,
"meter_id" : 100
Multipart Messages
class ryu.ofproto.ofproto_v1_3_parser.OFPDescStatsRequest(datapath, type_=None)
Description statistics request message
The controller uses this message to query description of the switch.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_desc_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPDescStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPDescStatsRequest" : {
"flags" : 0 ,
"type" : 0
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPDescStatsReply(datapath,
**kwargs)
Description statistics reply message
The switch responds with this message to a description statistics request.
Attribute Description body Instance of OFPDescStats
Example: flags=0 type_=None ,
,
2.5. OpenFlow protocol API Reference 121
ryu Documentation, Release 3.21
@set_ev_cls
(ofp_event .
EventOFPDescStatsReply, MAIN_DISPATCHER)
def
desc_stats_reply_handler ( self , ev): body = ev .
msg .
body self .
logger .
debug( 'DescStats: mfr_desc= %s hw_desc= %s sw_desc= %s '
'serial_num= %s dp_desc= %s ' , body .
mfr_desc, body .
hw_desc, body .
sw_desc, body .
serial_num, body .
dp_desc)
JSON Example:
{
"OFPDescStatsReply" : {
"body" : {
"OFPDescStats" : {
"dp_desc" : "dp" ,
"hw_desc" : "hw" ,
"mfr_desc" : "mfr" ,
"serial_num" : "serial" ,
"sw_desc" : "sw"
}
},
"flags" : 0 ,
"type" : 0
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPFlowStatsRequest(datapath, table_id=255
, flags=0 out_port=4294967295
, out_group=4294967295 ,
, cookie=0 , cookie_mask=0, match=None , type_=None)
Individual flow statistics request message
The controller uses this message to query individual flow statistics.
Attribute flags table_id out_port
Description
Zero or OFPMPF_REQ_MORE
ID of table to read
Require matching entries to include this as an output port out_group cookie
Require matching entries to include this as an output group
Require matching entries to contain this cookie value cookie_mask Mask used to restrict the cookie bits that must match match Instance of OFPMatch
Example:
def
send_flow_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser cookie = cookie_mask = 0 match = ofp_parser .
OFPMatch(in_port = 1 ) req = ofp_parser .
OFPFlowStatsRequest(datapath, 0 , ofp .
OFPTT_ALL, ofp .
OFPP_ANY, ofp .
OFPG_ANY, cookie, cookie_mask,
122 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
match) datapath .
send_msg(req)
JSON Example:
{
"OFPFlowStatsRequest" : {
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"table_id" : 0 ,
"type" : 1
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPFlowStatsReply(datapath,
**kwargs)
Individual flow statistics reply message
The switch responds with this message to an individual flow statistics request.
Attribute Description body List of OFPFlowStats instance
Example: type_=None
@set_ev_cls
(ofp_event .
EventOFPFlowStatsReply, MAIN_DISPATCHER)
def
flow_stats_reply_handler ( self , ev): flows = []
for
stat
in
ev .
msg .
body: flows .
append( 'table_id= %s '
'duration_sec= %d duration_nsec= %d '
'priority= %d '
'idle_timeout= %d hard_timeout= %d flags=0x %04x '
'cookie= %d packet_count= %d byte_count= %d '
'match= %s instructions= %s ' %
(stat .
table_id, stat .
duration_sec, stat .
duration_nsec, stat .
priority, stat .
idle_timeout, stat .
hard_timeout, stat .
flags, stat .
cookie, stat .
packet_count, stat .
byte_count, stat .
match, stat .
instructions)) self .
logger .
debug( 'FlowStats: %s ' , flows)
,
JSON Example:
{
"OFPFlowStatsReply" : {
"body" : [
{
"OFPFlowStats" : {
2.5. OpenFlow protocol API Reference 123
ryu Documentation, Release 3.21
124
"byte_count" : 0 ,
"cookie" : 0 ,
"duration_nsec" : 115277000 ,
"duration_sec" : 358 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [],
"length" : 56 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
},
"packet_count" : 0 ,
"priority" : 65535 ,
"table_id" : 0
},
{
}
"OFPFlowStats" : {
"byte_count" : 0 ,
"cookie" : 0 ,
"duration_nsec" : 115055000 ,
"duration_sec" : 358 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 0 ,
"port" : 4294967290 ,
"type" : 0
}
}
],
"len" : 24 ,
"type" : 4
}
}
],
"length" : 88 ,
"match" : {
"OFPMatch" : {
"length" : 10 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "eth_type" ,
"mask" : null,
"value" : 2054
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
],
"type" : 1
}
},
"packet_count" : 0 ,
"priority" : 65534 ,
"table_id" : 0
},
{
}
"OFPFlowStats" : {
"byte_count" : 238 ,
"cookie" : 0 ,
"duration_nsec" : 511582000 ,
"duration_sec" : 316220 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionGotoTable" : {
"len" : 8 ,
"table_id" : 1 ,
"type" : 1
}
}
],
"length" : 80 ,
"match" : {
"OFPMatch" : {
"length" : 22 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 6
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
"packet_count" : 3 ,
"priority" : 123 ,
"table_id" : 0
}
},
{
2.5. OpenFlow protocol API Reference 125
ryu Documentation, Release 3.21
126
"OFPFlowStats" : {
"byte_count" : 98 ,
"cookie" : 0 ,
"duration_nsec" : 980901000 ,
"duration_sec" : 313499 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"instructions" : [
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "vlan_vid" ,
"mask" : null,
"value" : 258
}
}
}
},
{
"OFPActionCopyTtlOut" : {
"len" : 8 ,
"type" : 11
}
},
{
"OFPActionCopyTtlIn" : {
"len" : 8 ,
"type" : 12
}
},
{
"OFPActionCopyTtlIn" : {
"len" : 8 ,
"type" : 12
}
},
{
"OFPActionPopPbb" : {
"len" : 8 ,
"type" : 27
}
},
{
"OFPActionPushPbb" : {
"ethertype" : 4660 ,
"len" : 8 ,
"type" : 26
}
},
{
"OFPActionPopMpls" : {
"ethertype" : 39030 ,
"len" : 8 ,
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"type" : 20
},
{
}
"OFPActionPushMpls" : {
"ethertype" : 34887 ,
"len" : 8 ,
"type" : 19
}
},
{
"OFPActionPopVlan" : {
"len" : 8 ,
"type" : 18
}
},
{
"OFPActionPushVlan" : {
"ethertype" : 33024 ,
"len" : 8 ,
"type" : 17
}
},
{
"OFPActionDecMplsTtl" : {
"len" : 8 ,
"type" : 16
}
},
{
"OFPActionSetMplsTtl" : {
"len" : 8 ,
"mpls_ttl" : 10 ,
"type" : 15
}
},
{
"OFPActionDecNwTtl" : {
"len" : 8 ,
"type" : 24
}
},
{
"OFPActionSetNwTtl" : {
"len" : 8 ,
"nw_ttl" : 10 ,
"type" : 23
}
},
{
"OFPActionSetQueue" : {
"len" : 8 ,
"queue_id" : 3 ,
"type" : 21
}
},
{
"OFPActionGroup" : {
2.5. OpenFlow protocol API Reference 127
ryu Documentation, Release 3.21
128
"group_id" : 99 ,
"len" : 8 ,
"type" : 22
}
},
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 6 ,
"type" : 0
}
}
],
"len" : 160 ,
"type" : 3
},
{
}
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "01:02:03:04:05:06"
}
}
}
},
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "pbb_uca" ,
"mask" : null,
"value" : 1
}
}
}
}
],
"len" : 40 ,
"type" : 4
}
},
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 4294967293 ,
"type" : 0
}
Chapter 2. Writing Your Ryu Application
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
}
],
"len" : 24 ,
"type" : 3
}
}
],
"length" : 280 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
},
"packet_count" : 1 ,
"priority" : 0 ,
"table_id" : 0
}
}
],
"flags" : 0 ,
"type" : 1
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPAggregateStatsRequest(datapath, flags , table_id
, out_port, out_group
, cookie, cookie_mask , match , type_=None)
Aggregate flow statistics request message
The controller uses this message to query aggregate flow statictics.
Attribute flags table_id out_port
Description
Zero or OFPMPF_REQ_MORE
ID of table to read
Require matching entries to include this as an output port out_group cookie
Require matching entries to include this as an output group
Require matching entries to contain this cookie value cookie_mask Mask used to restrict the cookie bits that must match match Instance of OFPMatch
Example:
def
send_aggregate_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser cookie = cookie_mask = 0 match = ofp_parser .
OFPMatch(in_port = 1 ) req = ofp_parser .
OFPAggregateStatsRequest(datapath, 0 , ofp .
OFPTT_ALL, ofp .
OFPP_ANY, ofp .
OFPG_ANY, cookie, cookie_mask,
129
ryu Documentation, Release 3.21
match) datapath .
send_msg(req)
JSON Example:
{
"OFPAggregateStatsRequest" : {
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"table_id" : 255 ,
"type" : 2
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPAggregateStatsReply(datapath, type_=None,
**kwargs)
Aggregate flow statistics reply message
The switch responds with this message to an aggregate flow statistics request.
Attribute Description body Instance of OFPAggregateStats
Example:
@set_ev_cls
(ofp_event .
EventOFPAggregateStatsReply, MAIN_DISPATCHER)
def
aggregate_stats_reply_handler ( self , ev): body = ev .
msg .
body self .
logger .
debug( 'AggregateStats: packet_count= %d byte_count= %d '
'flow_count= %d ' , body .
packet_count, body .
byte_count, body .
flow_count)
JSON Example:
{
"OFPAggregateStatsReply" : {
"body" : {
"OFPAggregateStats" : {
"byte_count" : 574 ,
"flow_count" : 6 ,
"packet_count" : 7
}
},
"flags" : 0 ,
"type" : 2
}
}
130 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_3_parser.OFPTableStatsRequest(datapath, type_=None)
Table statistics request message
The controller uses this message to query flow table statictics.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_table_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPTableStatsRequest(datapath, 0 ) datapath .
send_msg(req) flags=0 ,
JSON Example:
{
"OFPTableStatsRequest" : {
"flags" : 0 ,
"type" : 3
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPTableStatsReply(datapath,
**kwargs)
Table statistics reply message
The switch responds with this message to a table statistics request.
Attribute Description body List of OFPTableStats instance
Example:
@set_ev_cls(ofp_event.EventOFPTableStatsReply, MAIN_DISPATCHER) def table_stats_reply_handler(self, ev): tables = [] for stat in ev.msg.body: tables.append('table_id=%d active_count=%d lookup_count=%d '
' matched_count=%d' %
(stat.table_id, stat.active_count, stat.lookup_count, stat.matched_count)) self.logger.debug('TableStats: %s', tables) type_=None
,
JSON Example:
{
"OFPTableStatsReply" : {
"body" : [
{
"OFPTableStats" : {
"active_count" : 4 ,
"lookup_count" : 4 ,
"matched_count" : 4 ,
"table_id" : 0
}
},
{
2.5. OpenFlow protocol API Reference 131
ryu Documentation, Release 3.21
"OFPTableStats" : {
"active_count" : 4 ,
"lookup_count" : 4 ,
"matched_count" : 4 ,
"table_id" : 1
}
}
],
"flags" : 0 ,
"type" : 3
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPPortStatsRequest(datapath, flags=0 port_no=4294967295 ,
, type_=None)
Port statistics request message
The controller uses this message to query information about ports statistics.
Attribute Description flags Zero or OFPMPF_REQ_MORE port_no Port number to read (OFPP_ANY to all ports)
Example:
def
send_port_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPPortStatsRequest(datapath, 0 , ofp .
OFPP_ANY) datapath .
send_msg(req)
JSON Example:
{
"OFPPortStatsRequest" : {
"flags" : 0 ,
"port_no" : 4294967295 ,
"type" : 4
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPPortStatsReply(datapath,
**kwargs)
Port statistics reply message
The switch responds with this message to a port statistics request.
Attribute Description body List of OFPPortStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPPortStatsReply, MAIN_DISPATCHER)
def
port_stats_reply_handler ( self , ev): ports = []
for
stat
in
ev .
msg .
body: ports .
append( 'port_no= %d '
'rx_packets= %d tx_packets= %d '
'rx_bytes= %d tx_bytes= %d ' type_=None ,
132 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
'rx_dropped= %d tx_dropped= %d '
'rx_errors= %d tx_errors= %d '
'rx_frame_err= %d rx_over_err= %d rx_crc_err= %d '
'collisions= %d duration_sec= %d duration_nsec= %d ' %
(stat .
port_no, stat .
rx_packets, stat .
tx_packets, stat .
rx_bytes, stat .
tx_bytes, stat .
rx_dropped, stat .
tx_dropped, stat .
rx_errors, stat .
tx_errors, stat .
rx_frame_err, stat .
rx_over_err, stat .
rx_crc_err, stat .
collisions, stat .
duration_sec, stat .
duration_nsec)) self .
logger .
debug( 'PortStats: %s ' , ports)
JSON Example:
{
"OFPPortStatsReply" : {
"body" : [
{
"OFPPortStats" : {
"collisions" : 0 ,
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
"port_no" : 7 ,
"rx_bytes" : 0 ,
"rx_crc_err" : 0 ,
"rx_dropped" : 0 ,
"rx_errors" : 0 ,
"rx_frame_err" : 0 ,
"rx_over_err" : 0 ,
"rx_packets" : 0 ,
"tx_bytes" : 336 ,
"tx_dropped" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 4
}
},
{
"OFPPortStats" : {
"collisions" : 0 ,
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
"port_no" : 6 ,
"rx_bytes" : 336 ,
"rx_crc_err" : 0 ,
"rx_dropped" : 0 ,
"rx_errors" : 0 ,
"rx_frame_err" : 0 ,
"rx_over_err" : 0 ,
"rx_packets" : 4 ,
"tx_bytes" : 336 ,
"tx_dropped" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 4
}
}
],
2.5. OpenFlow protocol API Reference 133
ryu Documentation, Release 3.21
"flags" : 0 ,
"type" : 4
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPPortDescStatsRequest(datapath, flags=0 , type_=None)
Port description request message
The controller uses this message to query description of all the ports.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_port_desc_stats_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPPortDescStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPPortDescStatsRequest" : {
"flags" : 0 ,
"type" : 13
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPPortDescStatsReply(datapath, type_=None,
**kwargs)
Port description reply message
The switch responds with this message to a port description request.
Attribute Description body List of OFPPortDescStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPPortDescStatsReply, MAIN_DISPATCHER)
def
port_desc_stats_reply_handler ( self , ev): ports = []
for
p
in
ev .
msg .
body: ports .
append( 'port_no= %d hw_addr= %s name= %s config=0x %08x '
'state=0x %08x curr=0x %08x advertised=0x %08x '
'supported=0x %08x peer=0x %08x curr_speed= %d '
'max_speed= %d ' %
(p .
port_no, p .
hw_addr, p .
name, p .
config, p .
state, p .
curr, p .
advertised, p .
supported, p .
peer, p .
curr_speed, p .
max_speed)) self .
logger .
debug( 'OFPPortDescStatsReply received: %s ' , ports)
JSON Example:
{
"OFPPortDescStatsReply" : {
134 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"body" : [
{
"OFPPort" : {
"advertised" : 10240 ,
"config" : 0 ,
"curr" : 10248 ,
"curr_speed" : 5000 ,
"hw_addr" : "f2:0b:a4:d0:3f:70" ,
"max_speed" : 5000 ,
"name" : "Port7" ,
"peer" : 10248 ,
"port_no" : 7 ,
"state" : 4 ,
"supported" : 10248
}
},
{
"OFPPort" : {
"advertised" : 10240 ,
"config" : 0 ,
"curr" : 10248 ,
"curr_speed" : 5000 ,
"hw_addr" : "f2:0b:a4:7d:f8:ea" ,
"max_speed" : 5000 ,
"name" : "Port6" ,
"peer" : 10248 ,
"port_no" : 6 ,
"state" : 4 ,
"supported" : 10248
}
}
],
"flags" : 0 ,
"type" : 13
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPQueueStatsRequest(datapath, flags=0 port_no=4294967295 ,
, queue_id=4294967295 , type_=None)
Queue statistics request message
The controller uses this message to query queue statictics.
Attribute Description flags Zero or OFPMPF_REQ_MORE port_no Port number to read queue_id ID of queue to read
Example:
def
send_queue_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPQueueStatsRequest(datapath, 0 , ofp .
OFPP_ANY, ofp .
OFPQ_ALL) datapath .
send_msg(req)
2.5. OpenFlow protocol API Reference 135
ryu Documentation, Release 3.21
JSON Example:
{
"OFPQueueStatsRequest" : {
"flags" : 0 ,
"port_no" : 4294967295 ,
"queue_id" : 4294967295 ,
"type" : 5
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPQueueStatsReply(datapath,
**kwargs)
Queue statistics reply message
The switch responds with this message to an aggregate flow statistics request.
Attribute Description body List of OFPQueueStats instance type_=None
Example:
@set_ev_cls
(ofp_event .
EventOFPQueueStatsReply, MAIN_DISPATCHER)
def
queue_stats_reply_handler ( self , ev): queues = []
for
stat
in
ev .
msg .
body: queues .
append( 'port_no= %d queue_id= %d '
'tx_bytes= %d tx_packets= %d tx_errors= %d '
'duration_sec= %d duration_nsec= %d ' %
(stat .
port_no, stat .
queue_id, stat .
tx_bytes, stat .
tx_packets, stat .
tx_errors, stat .
duration_sec, stat .
duration_nsec)) self .
logger .
debug( 'QueueStats: %s ' , queues)
,
JSON Example:
{
"OFPQueueStatsReply" : {
"body" : [
{
"OFPQueueStats" : {
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
"port_no" : 7 ,
"queue_id" : 1 ,
"tx_bytes" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 0
}
},
{
"OFPQueueStats" : {
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
"port_no" : 6 ,
"queue_id" : 1 ,
"tx_bytes" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 0
}
},
136 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
{
"OFPQueueStats" : {
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
"port_no" : 7 ,
"queue_id" : 2 ,
"tx_bytes" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 0
}
}
],
"flags" : 0 ,
"type" : 5
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPGroupStatsRequest(datapath, flags=0 , group_id=4294967292
, type_=None)
Group statistics request message
The controller uses this message to query statistics of one or more groups.
Attribute Description flags Zero or OFPMPF_REQ_MORE group_id ID of group to read (OFPG_ALL to all groups)
Example:
def
send_group_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGroupStatsRequest(datapath, 0 , ofp .
OFPG_ALL) datapath .
send_msg(req) class ryu.ofproto.ofproto_v1_3_parser.OFPGroupStatsReply(datapath,
**kwargs)
Group statistics reply message
The switch responds with this message to a group statistics request.
Attribute Description body List of OFPGroupStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPGroupStatsReply, MAIN_DISPATCHER)
def
group_stats_reply_handler ( self , ev): groups = []
for
stat
in
ev .
msg .
body: groups .
append( 'length= %d group_id= %d '
'ref_count= %d packet_count= %d byte_count= %d '
'duration_sec= %d duration_nsec= %d ' %
(stat .
length, stat .
group_id, stat .
ref_count, stat .
packet_count, stat .
byte_count, stat .
duration_sec, stat .
duration_nsec)) self .
logger .
debug( 'GroupStats: %s ' , groups) type_=None ,
2.5. OpenFlow protocol API Reference 137
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_3_parser.OFPGroupDescStatsRequest(datapath, flags=0 , type_=None)
Group description request message
The controller uses this message to list the set of groups on a switch.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_group_desc_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGroupDescStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPGroupDescStatsRequest" : {
"flags" : 0 ,
"type" : 7
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPGroupDescStatsReply(datapath, type_=None,
**kwargs)
Group description reply message
The switch responds with this message to a group description request.
Attribute Description body List of OFPGroupDescStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPGroupDescStatsReply, MAIN_DISPATCHER)
def
group_desc_stats_reply_handler ( self , ev): descs = []
for
stat
in
ev .
msg .
body: descs .
append( 'length= %d type= %d group_id= %d '
'buckets= %s ' %
(stat .
length, stat .
type, stat .
group_id, stat .
bucket)) self .
logger .
debug( 'GroupDescStats: %s ' , groups)
JSON Example:
{
"OFPGroupDescStatsReply" : {
"body" : [
{
"OFPGroupDescStats" : {
"buckets" : [
{
"OFPBucket" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
138 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
],
"flags" : 0 ,
"type" : 7
}
}
],
"group_id" : 1 ,
"length" : 40 ,
"type" : 0
"max_len" : 65535 ,
"port" : 2 ,
"type" : 0
}
}
],
"len" : 32 ,
"watch_group" : 1 ,
"watch_port" : 1 ,
"weight" : 1
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPGroupFeaturesStatsRequest(datapath, flags=0 , type_=None)
Group features request message
The controller uses this message to list the capabilities of groups on a switch.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_group_features_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGroupFeaturesStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPGroupFeaturesStatsRequest" : {
"flags" : 0 ,
"type" : 8
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPGroupFeaturesStatsReply(datapath, type_=None ,
**kwargs)
Group features reply message
The switch responds with this message to a group features request.
Attribute Description body Instance of OFPGroupFeaturesStats
2.5. OpenFlow protocol API Reference 139
ryu Documentation, Release 3.21
Example:
@set_ev_cls
(ofp_event .
EventOFPGroupFeaturesStatsReply, MAIN_DISPATCHER)
def
group_features_stats_reply_handler ( self , ev): body = ev .
msg .
body self .
logger .
debug( 'GroupFeaturesStats: types= %d '
'capabilities=0x %08x max_groups= %s '
'actions= %s ' , body .
types, body .
capabilities, body .
max_groups, body .
actions)
JSON Example:
{
"OFPGroupFeaturesStatsReply" : {
"body" : {
"OFPGroupFeaturesStats" : {
"actions" : [
67082241 ,
67082241 ,
67082241 ,
67082241
],
"capabilities" : 5 ,
"max_groups" : [
16777216 ,
16777216 ,
16777216 ,
16777216
],
"types" : 15
}
},
"flags" : 0 ,
"type" : 8
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPMeterStatsRequest(datapath, flags=0 , meter_id=4294967295 , type_=None)
Meter statistics request message
The controller uses this message to query statistics for one or more meters.
Attribute Description flags Zero or OFPMPF_REQ_MORE meter_id ID of meter to read (OFPM_ALL to all meters)
Example:
def
send_meter_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPMeterStatsRequest(datapath, 0 , ofp .
OFPM_ALL) datapath .
send_msg(req)
JSON Example:
140 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
{
"OFPMeterStatsRequest" : {
"flags" : 0 ,
"meter_id" : 4294967295 ,
"type" : 9
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPMeterStatsReply(datapath,
**kwargs)
Meter statistics reply message
The switch responds with this message to a meter statistics request.
Attribute Description body List of OFPMeterStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPMeterStatsReply, MAIN_DISPATCHER)
def
meter_stats_reply_handler ( self , ev): meters = []
for
stat
in
ev .
msg .
body: meters .
append( 'meter_id=0x %08x len= %d flow_count= %d '
'packet_in_count= %d byte_in_count= %d '
'duration_sec= %d duration_nsec= %d '
'band_stats= %s ' %
(stat .
meter_id, stat .
len, stat .
flow_count, stat .
packet_in_count, stat .
byte_in_count, stat .
duration_sec, stat .
duration_nsec, stat .
band_stats)) self .
logger .
debug( 'MeterStats: %s ' , meters)
JSON Example:
{
"OFPMeterStatsReply" : {
"body" : [
{
"OFPMeterStats" : {
"band_stats" : [
{
"OFPMeterBandStats" : {
"byte_band_count" : 0 ,
"packet_band_count" : 0
}
}
],
"byte_in_count" : 0 ,
"duration_nsec" : 480000 ,
"duration_sec" : 0 ,
"flow_count" : 0 ,
"len" : 56 ,
"meter_id" : 100 ,
"packet_in_count" : 0
}
}
],
"flags" : 0 ,
"type" : 9 type_=None ,
2.5. OpenFlow protocol API Reference 141
ryu Documentation, Release 3.21
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPMeterConfigStatsRequest(datapath, flags=0 , meter_id=4294967295 , type_=None)
Meter configuration statistics request message
The controller uses this message to query configuration for one or more meters.
Attribute Description flags Zero or OFPMPF_REQ_MORE meter_id ID of meter to read (OFPM_ALL to all meters)
Example:
def
send_meter_config_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPMeterConfigStatsRequest(datapath, 0 , ofp .
OFPM_ALL) datapath .
send_msg(req)
JSON Example:
{
"OFPMeterConfigStatsRequest" : {
"flags" : 0 ,
"meter_id" : 4294967295 ,
"type" : 10
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPMeterConfigStatsReply(datapath, type_=None ,
**kwargs)
Meter configuration statistics reply message
The switch responds with this message to a meter configuration statistics request.
Attribute Description body List of OFPMeterConfigStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPMeterConfigStatsReply, MAIN_DISPATCHER)
def
meter_config_stats_reply_handler ( self , ev): configs = []
for
stat
in
ev .
msg .
body: configs .
append( 'length= %d flags=0x %04x meter_id=0x %08x '
'bands= %s ' %
(stat .
length, stat .
flags, stat .
meter_id, stat .
bands)) self .
logger .
debug( 'MeterConfigStats: %s ' , configs)
JSON Example:
{
"OFPMeterConfigStatsReply" : {
142 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"body" : [
{
"OFPMeterConfigStats" : {
"bands" : [
{
"OFPMeterBandDrop" : {
"burst_size" : 10 ,
"len" : 16 ,
"rate" : 1000 ,
"type" : 1
}
}
],
"flags" : 0 ,
"type" : 10
}
}
],
"flags" : 14 ,
"length" : 24 ,
"meter_id" : 100
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPMeterFeaturesStatsRequest(datapath, flags=0 , type_=None)
Meter features statistics request message
The controller uses this message to query the set of features of the metering subsystem.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_meter_features_stats_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPMeterFeaturesStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPMeterFeaturesStatsRequest" : {
"flags" : 0 ,
"type" : 11
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPMeterFeaturesStatsReply(datapath, type_=None ,
**kwargs)
Meter features statistics reply message
The switch responds with this message to a meter features statistics request.
Attribute Description body List of OFPMeterFeaturesStats instance
2.5. OpenFlow protocol API Reference 143
ryu Documentation, Release 3.21
Example:
@set_ev_cls
(ofp_event .
EventOFPMeterFeaturesStatsReply, MAIN_DISPATCHER)
def
meter_features_stats_reply_handler ( self , ev): features = []
for
stat
in
ev .
msg .
body: features .
append( 'max_meter= %d band_types=0x %08x '
'capabilities=0x %08x max_bands= %d '
'max_color= %d ' %
(stat .
max_meter, stat .
band_types, stat .
capabilities, stat .
max_bands, stat .
max_color)) self .
logger .
debug( 'MeterFeaturesStats: %s ' , configs)
JSON Example:
{
"OFPMeterFeaturesStatsReply" : {
"body" : [
{
"OFPMeterFeaturesStats" : {
"band_types" : 2147483654 ,
"capabilities" : 15 ,
"max_bands" : 255 ,
"max_color" : 0 ,
"max_meter" : 16777216
}
}
],
"flags" : 0 ,
"type" : 11
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPTableFeaturesStatsRequest(datapath, flags=0 , body=[] , type_=None)
Table features statistics request message
The controller uses this message to query table features.
Attribute Description body List of OFPTableFeaturesStats instances. The default is [].
class ryu.ofproto.ofproto_v1_3_parser.OFPTableFeaturesStatsReply(datapath, type_=None
,
**kwargs)
Table features statistics reply message
The switch responds with this message to a table features statistics request.
Attribute Description body List of OFPTableFeaturesStats instance
JSON Example:
See an example in: ryu/tests/unit/ofproto/json/of13/4-56-ofp_table_features_reply.packet.json
144 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Queue Configuration Messages
class ryu.ofproto.ofproto_v1_3_parser.OFPQueueGetConfigRequest(datapath, port)
Queue configuration request message
Attribute Description port Port to be queried (OFPP_ANY to all configured queues)
Example:
def
send_queue_get_config_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPQueueGetConfigRequest(datapath, ofp .
OFPP_ANY) datapath .
send_msg(req)
JSON Example:
{
"OFPQueueGetConfigRequest" : {
"port" : 4294967295
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPQueueGetConfigReply(datapath, queues=None , port=None)
Queue configuration reply message
The switch responds with this message to a queue configuration request.
Attribute Description queues list of OFPPacketQueue instance port Port which was queried
Example:
@set_ev_cls
(ofp_event .
EventOFPQueueGetConfigReply, MAIN_DISPATCHER)
def
queue_get_config_reply_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPQueueGetConfigReply received: '
'port= %s queues= %s ' , msg .
port, msg .
queues)
JSON Example:
{
"OFPQueueGetConfigReply" : {
"port" : 4294967295 ,
"queues" : [
{
"OFPPacketQueue" : {
"len" : 48 ,
"port" : 77 ,
"properties" : [
{
"OFPQueuePropMinRate" : {
"len" : 16 ,
"property" : 1 ,
2.5. OpenFlow protocol API Reference 145
ryu Documentation, Release 3.21
}
}
]
"rate" : 10
}
},
{
"OFPQueuePropMaxRate" : {
"len" : 16 ,
"property" : 2 ,
"rate" : 900
}
}
],
"queue_id" : 99
},
{
}
"OFPPacketQueue" : {
"len" : 48 ,
"port" : 77 ,
"properties" : [
{
"OFPQueuePropMinRate" : {
"len" : 16 ,
"property" : 1 ,
"rate" : 100
}
},
{
"OFPQueuePropMaxRate" : {
"len" : 16 ,
"property" : 2 ,
"rate" : 200
}
}
],
"queue_id" : 88
}
}
Packet-Out Message
class ryu.ofproto.ofproto_v1_3_parser.OFPPacketOut(datapath, in_port=None , buffer_id=None actions=None data=None , actions_len=None)
,
,
Packet-Out message
The controller uses this message to send a packet out throught the switch.
Attribute Description buffer_id ID assigned by datapath (OFP_NO_BUFFER if none) in_port actions data
Packet’s input port or OFPP_CONTROLLER list of OpenFlow action class
Packet data
Example:
146 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
def
send_packet_out ( self , datapath, buffer_id, in_port): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser actions = [ofp_parser .
OFPActionOutput(ofp .
OFPP_FLOOD, 0 )] req = ofp_parser .
OFPPacketOut(datapath, buffer_id, in_port, actions) datapath .
send_msg(req)
JSON Example:
{
"OFPPacketOut" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 4294967292 ,
"type" : 0
}
}
],
"actions_len" : 16 ,
"buffer_id" : 4294967295 ,
"data" : "8guk0D9w8gukffjqCABFAABU+BoAAP8Br4sKAAABCgAAAggAAgj3YAAAMdYCAAAAAACrjS0xAAAAABAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vAAAAAAAAAAA=" ,
"in_port" : 4294967293
}
}
Barrier Message
class ryu.ofproto.ofproto_v1_3_parser.OFPBarrierRequest(datapath)
Barrier request message
The controller sends this message to ensure message dependencies have been met or receive notifications for completed operations.
Example:
def
send_barrier_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPBarrierRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPBarrierRequest" : {}
} class ryu.ofproto.ofproto_v1_3_parser.OFPBarrierReply(datapath)
Barrier reply message
The switch responds with this message to a barrier request.
Example:
2.5. OpenFlow protocol API Reference 147
ryu Documentation, Release 3.21
@set_ev_cls
(ofp_event .
EventOFPBarrierReply, MAIN_DISPATCHER)
def
barrier_reply_handler ( self , ev): self .
logger .
debug( 'OFPBarrierReply received' )
JSON Example:
{
"OFPBarrierReply" : {}
}
Role Request Message
class ryu.ofproto.ofproto_v1_3_parser.OFPRoleRequest(datapath, role=None , generation_id=None)
Role request message
The controller uses this message to change its role.
Attribute role
Description
One of the following values.
OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
OFPCR_ROLE_SLAVE generation_id
Example:
def
send_role_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
Master Election Generation ID req = ofp_parser .
OFPRoleRequest(datapath, ofp .
OFPCR_ROLE_EQUAL, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPRoleRequest" : {
"generation_id" : 17294086455919964160 ,
"role" : 2
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPRoleReply(datapath, role=None tion_id=None)
,
Role reply message
The switch responds with this message to a role request.
genera-
148 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute role
Description
One of the following values.
OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
OFPCR_ROLE_SLAVE generation_id
Example:
Master Election Generation ID
@set_ev_cls
(ofp_event .
EventOFPRoleReply, MAIN_DISPATCHER)
def
role_reply_handler ( self , ev): msg = ev .
msg ofp = dp .
ofproto
if
msg .
role == ofp .
OFPCR_ROLE_NOCHANGE: role = 'NOCHANGE'
elif
msg .
role == ofp .
OFPCR_ROLE_EQUAL: role = 'EQUAL'
elif
msg .
role == ofp .
OFPCR_ROLE_MASTER: role = 'MASTER'
elif
msg .
role == ofp .
OFPCR_ROLE_SLAVE: role = 'SLAVE'
else
: role = 'unknown' self .
logger .
debug( 'OFPRoleReply received: '
'role= %s generation_id= %d ' , role, msg .
generation_id)
JSON Example:
{
"OFPRoleReply" : {
"generation_id" : 17294086455919964160 ,
"role" : 3
}
}
Set Asynchronous Configuration Message
class ryu.ofproto.ofproto_v1_3_parser.OFPSetAsync(datapath, port_status_mask , flow_removed_mask)
Set asynchronous configuration message packet_in_mask
,
The controller sends this message to set the asynchronous messages that it wants to receive on a given OpneFlow channel.
2.5. OpenFlow protocol API Reference 149
ryu Documentation, Release 3.21
Attribute packet_in_mask port_status_mask flow_removed_mask
Description
2-element array: element 0, when the controller has a OFPCR_ROLE_EQUAL or OF-
PCR_ROLE_MASTER role.
element 1, OF-
PCR_ROLE_SLAVE role controller.
Bitmasks of following values.
OFPR_NO_MATCH
OFPR_ACTION
OFPR_INVALID_TTL
2-element array. Bitmasks of following values.
OFPPR_ADD
OFPPR_DELETE
OFPPR_MODIFY
2-element array. Bitmasks of following values.
OFPRR_IDLE_TIMEOUT
OFPRR_HARD_TIMEOUT
OFPRR_DELETE
OFPRR_GROUP_DELETE
Example:
def
send_set_async ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser packet_in_mask = ofp .
OFPR_ACTION | ofp .
OFPR_INVALID_TTL port_status_mask = (ofp .
OFPPR_ADD | ofp .
OFPPR_DELETE | ofp .
OFPPR_MODIFY) flow_removed_mask = (ofp .
OFPRR_IDLE_TIMEOUT | ofp .
OFPRR_HARD_TIMEOUT | ofp .
OFPRR_DELETE) req = ofp_parser .
OFPSetAsync(datapath,
[packet_in_mask, 0 ],
[port_status_mask, 0 ],
[flow_removed_mask, 0 ]) datapath .
send_msg(req)
JSON Example:
{
"OFPSetAsync" : {
"flow_removed_mask" : [
15 ,
3
],
"packet_in_mask" : [
5 ,
1
],
"port_status_mask" : [
150 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
7 ,
3
}
]
} class ryu.ofproto.ofproto_v1_3_parser.OFPGetAsyncRequest(datapath)
Get asynchronous configuration request message
The controller uses this message to query the asynchronous message.
Example:
def
send_get_async_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGetAsyncRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPGetAsyncRequest" : {}
} class ryu.ofproto.ofproto_v1_3_parser.OFPGetAsyncReply(datapath, packet_in_mask=None , port_status_mask=None , flow_removed_mask=None)
Get asynchronous configuration reply message
The switch responds with this message to a get asynchronous configuration request.
Attribute packet_in_mask
Description
2-element array: element 0, when the controller has a OFPCR_ROLE_EQUAL or OF-
PCR_ROLE_MASTER role.
element 1, OF-
PCR_ROLE_SLAVE role controller.
Bitmasks of following values.
port_status_mask
OFPR_NO_MATCH
OFPR_ACTION
OFPR_INVALID_TTL
2-element array. Bitmasks of following values.
OFPPR_ADD
OFPPR_DELETE
OFPPR_MODIFY flow_removed_mask 2-element array. Bitmasks of following values.
OFPRR_IDLE_TIMEOUT
OFPRR_HARD_TIMEOUT
OFPRR_DELETE
OFPRR_GROUP_DELETE
2.5. OpenFlow protocol API Reference 151
ryu Documentation, Release 3.21
Example:
@set_ev_cls
(ofp_event .
EventOFPGetAsyncReply, MAIN_DISPATCHER)
def
get_async_reply_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPGetAsyncReply received: '
'packet_in_mask=0x %08x :0x %08x '
'port_status_mask=0x %08x :0x %08x '
'flow_removed_mask=0x %08x :0x %08x ' , msg .
packet_in_mask[ 0 ], msg .
packet_in_mask[ 1 ], msg .
port_status_mask[ 0 ], msg .
port_status_mask[ 1 ], msg .
flow_removed_mask[ 0 ], msg .
flow_removed_mask[ 1 ])
JSON Example:
{
"OFPGetAsyncReply" : {
"flow_removed_mask" : [
15 ,
3
],
"packet_in_mask" : [
5 ,
1
],
"port_status_mask" : [
7 ,
3
]
}
}
Asynchronous Messages
Packet-In Message
class ryu.ofproto.ofproto_v1_3_parser.OFPPacketIn(datapath, buffer_id=None , total_len=None , table_id=None
, reason=None cookie=None match=None
, data=None)
,
,
Packet-In message
The switch sends the packet that received to the controller by this message.
152 Chapter 2. Writing Your Ryu Application
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
Attribute buffer_id total_len reason
Description
ID assigned by datapath
Full length of frame
Reason packet is being sent.
OFPR_NO_MATCH
OFPR_ACTION
OFPR_INVALID_TTL table_id cookie match data
Example:
ID of the table that was looked up
Cookie of the flow entry that was looked up
Instance of OFPMatch
Ethernet frame
@set_ev_cls
(ofp_event .
EventOFPPacketIn, MAIN_DISPATCHER)
def
packet_in_handler ( self , ev): msg = ev .
msg ofp = dp .
ofproto
if
msg .
reason == ofp .
OFPR_NO_MATCH: reason = 'NO MATCH'
elif
msg .
reason == ofp .
OFPR_ACTION: reason = 'ACTION'
elif
msg .
reason == ofp .
OFPR_INVALID_TTL: reason = 'INVALID TTL'
else
: reason = 'unknown' self .
logger .
debug( 'OFPPacketIn received: '
'buffer_id= %x total_len= %d reason= %s '
'table_id= %d cookie= %d match= %s data= %s ' , msg .
buffer_id, msg .
total_len, reason, msg .
table_id, msg .
cookie, msg .
match, utils .
hex_array(msg .
data))
JSON Example:
{
"OFPPacketIn" : {
"buffer_id" : 2 ,
"cookie" : 283686884868096 ,
"data" : "////////8gukffjqCAYAAQgABgQAAfILpH346goAAAEAAAAAAAAKAAAD" ,
"match" : {
"OFPMatch" : {
"length" : 80 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 6
}
},
{
"OXMTlv" : {
"field" : "eth_type" ,
153
ryu Documentation, Release 3.21
154
"mask" : null,
"value" : 2054
}
},
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "ff:ff:ff:ff:ff:ff"
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
"OXMTlv" : {
"field" : "arp_op" ,
"mask" : null,
"value" : 1
}
},
{
"OXMTlv" : {
"field" : "arp_spa" ,
"mask" : null,
"value" : "10.0.0.1"
}
},
{
"OXMTlv" : {
"field" : "arp_tpa" ,
"mask" : null,
"value" : "10.0.0.3"
}
},
{
"OXMTlv" : {
"field" : "arp_sha" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
"OXMTlv" : {
"field" : "arp_tha" ,
"mask" : null,
"value" : "00:00:00:00:00:00"
}
}
],
"type" : 1
}
},
"reason" : 1 ,
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
"table_id" : 1 ,
"total_len" : 42
Flow Removed Message
class ryu.ofproto.ofproto_v1_3_parser.OFPFlowRemoved(datapath, cookie=None , priority=None
, reason=None
, table_id=None
, duration_sec=None, duration_nsec=None , idle_timeout=None , hard_timeout=None , packet_count=None , byte_count=None , match=None)
Flow removed message
When flow entries time out or are deleted, the switch notifies controller with this message.
Attribute cookie priority reason
Description
Opaque controller-issued identifier
Priority level of flow entry
One of the following values.
OFPRR_IDLE_TIMEOUT
OFPRR_HARD_TIMEOUT
OFPRR_DELETE
OFPRR_GROUP_DELETE table_id duration_sec duration_nsec idle_timeout hard_timeout packet_count byte_count match
Example:
ID of the table
Time flow was alive in seconds
Time flow was alive in nanoseconds beyond duration_sec
Idle timeout from original flow mod
Hard timeout from original flow mod
Number of packets that was associated with the flow
Number of bytes that was associated with the flow
Instance of OFPMatch
@set_ev_cls
(ofp_event .
EventOFPFlowRemoved, MAIN_DISPATCHER)
def
flow_removed_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto
if
msg .
reason == ofp .
OFPRR_IDLE_TIMEOUT: reason = 'IDLE TIMEOUT'
elif
msg .
reason == ofp .
OFPRR_HARD_TIMEOUT: reason = 'HARD TIMEOUT'
elif
msg .
reason == ofp .
OFPRR_DELETE: reason = 'DELETE'
elif
msg .
reason == ofp .
OFPRR_GROUP_DELETE: reason = 'GROUP DELETE'
2.5. OpenFlow protocol API Reference 155
ryu Documentation, Release 3.21
else
: reason = 'unknown' self .
logger .
debug( 'OFPFlowRemoved received: '
'cookie= %d priority= %d reason= %s table_id= %d '
'duration_sec= %d duration_nsec= %d '
'idle_timeout= %d hard_timeout= %d '
'packet_count= %d byte_count= %d match.fields= %s ' , msg .
cookie, msg .
priority, reason, msg .
table_id, msg .
duration_sec, msg .
duration_nsec, msg .
idle_timeout, msg .
hard_timeout, msg .
packet_count, msg .
byte_count, msg .
match)
JSON Example:
{
"OFPFlowRemoved" : {
"byte_count" : 86 ,
"cookie" : 0 ,
"duration_nsec" : 48825000 ,
"duration_sec" : 3 ,
"hard_timeout" : 0 ,
"idle_timeout" : 3 ,
"match" : {
"OFPMatch" : {
"length" : 14 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
"packet_count" : 1 ,
"priority" : 65535 ,
"reason" : 0 ,
"table_id" : 0
}
}
Port Status Message
class ryu.ofproto.ofproto_v1_3_parser.OFPPortStatus(datapath, desc=None)
Port status message
The switch notifies controller of change of ports.
reason=None
,
156 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute reason
Description
One of the following values.
OFPPR_ADD
OFPPR_DELETE
OFPPR_MODIFY desc
Example: instance of OFPPort
@set_ev_cls
(ofp_event .
EventOFPPortStatus, MAIN_DISPATCHER)
def
port_status_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto
if
msg .
reason == ofp .
OFPPR_ADD: reason = 'ADD'
elif
msg .
reason == ofp .
OFPPR_DELETE: reason = 'DELETE'
elif
msg .
reason == ofp .
OFPPR_MODIFY: reason = 'MODIFY'
else
: reason = 'unknown' self .
logger .
debug( 'OFPPortStatus received: reason= %s desc= %s ' , reason, msg .
desc)
JSON Example:
{
"OFPPortStatus" : {
"desc" : {
"OFPPort" : {
"advertised" : 10240 ,
"config" : 0 ,
"curr" : 10248 ,
"curr_speed" : 5000 ,
"hw_addr" : "f2:0b:a4:d0:3f:70" ,
"max_speed" : 5000 ,
"name" : "\u79c1\u306e\u30dd\u30fc\u30c8" ,
"peer" : 10248 ,
"port_no" : 7 ,
"state" : 4 ,
"supported" : 10248
}
},
"reason" : 0
}
}
Error Message
class ryu.ofproto.ofproto_v1_3_parser.OFPErrorMsg(datapath, type_=None , code=None , data=None)
Error message
2.5. OpenFlow protocol API Reference 157
ryu Documentation, Release 3.21
The switch notifies controller of problems by this message.
Attribute Description type High level type of error code data
Details depending on the type
Variable length data depending on the type and code type attribute corresponds to type_ parameter of __init__.
Types and codes are defined in ryu.ofproto.ofproto.
Type
OFPET_HELLO_FAILED
OFPET_BAD_REQUEST
OFPET_BAD_ACTION
OFPET_BAD_INSTRUCTION
OFPET_BAD_MATCH
OFPET_FLOW_MOD_FAILED
OFPET_GROUP_MOD_FAILED
Code
OFPHFC_*
OFPBRC_*
OFPBAC_*
OFPBIC_*
OFPBMC_*
OFPFMFC_*
OFPGMFC_*
OFPET_PORT_MOD_FAILED
OFPET_TABLE_MOD_FAILED
OFPET_QUEUE_OP_FAILED
OFPET_SWITCH_CONFIG_FAILED
OFPPMFC_*
OFPTMFC_*
OFPQOFC_*
OFPSCFC_*
OFPET_ROLE_REQUEST_FAILED
OFPET_METER_MOD_FAILED
OFPRRFC_*
OFPMMFC_*
OFPET_TABLE_FEATURES_FAILED OFPTFFC_*
OFPET_EXPERIMENTER N/A
Example:
@set_ev_cls
(ofp_event .
EventOFPErrorMsg,
[HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def
error_msg_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPErrorMsg received: type=0x %02x code=0x %02x '
'message= %s ' , msg .
type, msg .
code, utils .
hex_array(msg .
data))
JSON Example:
{
"OFPErrorMsg" : {
"code" : 11 ,
"data" : "ZnVnYWZ1Z2E=" ,
"type" : 2
}
}
Symmetric Messages
Hello
class ryu.ofproto.ofproto_v1_3_parser.OFPHello(datapath, elements=[])
Hello message
When connection is started, the hello message is exchanged between a switch and a controller.
158 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Attribute Description elements list of OFPHelloElemVersionBitmap instance
JSON Example:
{
"OFPHello" : {
"elements" : [
{
"OFPHelloElemVersionBitmap" : {
"length" : 8 ,
"type" : 1 ,
"versions" : [
1 ,
2 ,
3 ,
9 ,
10 ,
30
]
}
}
]
}
} class ryu.ofproto.ofproto_v1_3_parser.OFPHelloElemVersionBitmap(versions, type_=None , length=None)
Version bitmap Hello Element
Attribute Description versions list of versions of OpenFlow protocol a device supports
Echo Request
class ryu.ofproto.ofproto_v1_3_parser.OFPEchoRequest(datapath, data=None)
Echo request message
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Attribute Description data An arbitrary length data
Example:
def
send_echo_request ( self , datapath, data): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPEchoRequest(datapath, data) datapath .
send_msg(req)
@set_ev_cls
(ofp_event .
EventOFPEchoRequest,
[HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def
echo_request_handler ( self , ev):
2.5. OpenFlow protocol API Reference 159
ryu Documentation, Release 3.21
self .
logger .
debug( 'OFPEchoRequest received: data= %s ' , utils .
hex_array(ev .
msg .
data))
JSON Example:
{
"OFPEchoRequest" : {
"data" : "aG9nZQ=="
}
}
Echo Reply
class ryu.ofproto.ofproto_v1_3_parser.OFPEchoReply(datapath, data=None)
Echo reply message
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Attribute Description data An arbitrary length data
Example:
def
send_echo_reply ( self , datapath, data): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser reply = ofp_parser .
OFPEchoReply(datapath, data) datapath .
send_msg(reply)
@set_ev_cls
(ofp_event .
EventOFPEchoReply,
[HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def
echo_reply_handler ( self , ev): self .
logger .
debug( 'OFPEchoReply received: data= %s ' , utils .
hex_array(ev .
msg .
data))
JSON Example:
{
"OFPEchoReply" : {
"data" : "aG9nZQ=="
}
}
Experimenter
class ryu.ofproto.ofproto_v1_3_parser.OFPExperimenter(datapath, experimenter=None , exp_type=None , data=None)
Experimenter extension message
Attribute Description experimenter Experimenter ID exp_type data
Experimenter defined
Experimenter defined arbitrary additional data
JSON Example:
160 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
{
}
"OFPExperimenter" : {
"data" : "bmF6bw==" ,
"exp_type" : 123456789 ,
"experimenter" : 98765432
}
Flow Match Structure
class ryu.ofproto.ofproto_v1_3_parser.OFPMatch(type_=None, length=None dered_fields=None , **kwargs)
,
Flow Match Structure
_or-
This class is implementation of the flow match structure having compose/query API. There are new API and old
API for compatibility. the old API is supposed to be removed later.
You can define the flow match by the keyword arguments. The following arguments are available.
Argument in_port in_phy_port metadata eth_dst eth_src eth_type vlan_vid vlan_pcp ip_dscp ip_ecn ip_proto ipv4_src ipv4_dst tcp_src tcp_dst udp_src
Value Description
Integer 32bit Switch input port
Integer 32bit Switch physical input port
Integer 64bit Metadata passed between tables
MAC address Ethernet destination address
MAC address Ethernet source address
Integer 16bit Ethernet frame type
Integer 16bit VLAN id
Integer 8bit VLAN priority
Integer 8bit
Integer 8bit
IP DSCP (6 bits in ToS field)
IP ECN (2 bits in ToS field)
Integer 8bit IP protocol
IPv4 address IPv4 source address
IPv4 address IPv4 destination address
Integer 16bit TCP source port
Integer 16bit TCP destination port
Integer 16bit UDP source port udp_dst sctp_src sctp_dst icmpv4_type icmpv4_code arp_op arp_spa arp_tpa arp_sha
Integer 16bit UDP destination port
Integer 16bit SCTP source port
Integer 16bit SCTP destination port
Integer 8bit ICMP type
Integer 8bit ICMP code
Integer 16bit ARP opcode
IPv4 address ARP source IPv4 address
IPv4 address ARP target IPv4 address
MAC address ARP source hardware address arp_tha ipv6_src ipv6_dst ipv6_flabel
MAC address ARP target hardware address
IPv6 address IPv6 source address
IPv6 address IPv6 destination address
Integer 32bit IPv6 Flow Label icmpv6_type icmpv6_code
Integer 8bit
Integer 8bit
ICMPv6 type
ICMPv6 code ipv6_nd_target IPv6 address Target address for ND
Continued on next page
2.5. OpenFlow protocol API Reference 161
ryu Documentation, Release 3.21
Argument ipv6_nd_sll
Table 2.2 – continued from previous page
Value Description
MAC address Source link-layer for ND ipv6_nd_tll MAC address Target link-layer for ND mpls_label mpls_tc mpls_bos pbb_isid tunnel_id ipv6_exthdr
Integer 32bit
Integer 8bit
Integer 8bit
MPLS label
MPLS TC
MPLS BoS bit
Integer 24bit PBB I-SID
Integer 64bit
Integer 16bit
Logical Port Metadata
IPv6 Extension Header pseudo-field
Example:
>>>
# compose
>>>
match = parser .
OFPMatch(
...
...
in_port = eth_type
1
=
,
0x86dd ,
...
...
ipv6_src = ( '2001:db8:bd05:1d2:288a:1fc0:1:10ee' ,
'ffff:ffff:ffff:ffff::' ),
...
ipv6_dst
>>>
# query
= '2001:db8:bd05:1d2:288a:1fc0:1:10ee' )
>>> if
'ipv6_src'
in
match:
...
...
match[ 'ipv6_src' ]
('2001:db8:bd05:1d2:288a:1fc0:1:10ee', 'ffff:ffff:ffff:ffff::')
Note: For VLAN id match field, special values are defined in OpenFlow Spec.
1.Packets with and without a VLAN tag
•Example: match = parser .
OFPMatch()
•Packet Matching non-VLAN-tagged MATCH
VLAN-tagged(vlan_id=3) MATCH
VLAN-tagged(vlan_id=5) MATCH
2.Only packets without a VLAN tag
•Example: match = parser .
OFPMatch(vlan_vid = 0x0000 )
•Packet Matching non-VLAN-tagged MATCH
VLAN-tagged(vlan_id=3) x
VLAN-tagged(vlan_id=5) x
3.Only packets with a VLAN tag regardless of its value
•Example: match = parser .
OFPMatch(vlan_vid = ( 0x1000 , 0x1000 ))
162 Chapter 2. Writing Your Ryu Application
•Packet Matching non-VLAN-tagged x
VLAN-tagged(vlan_id=3) MATCH
VLAN-tagged(vlan_id=5) MATCH
4.Only packets with VLAN tag and VID equal
•Example: match = parser .
OFPMatch(vlan_vid = ( 0x1000 | 3 ))
•Packet Matching non-VLAN-tagged x
VLAN-tagged(vlan_id=3) MATCH
VLAN-tagged(vlan_id=5) x
ryu Documentation, Release 3.21
Flow Instruction Structures
class ryu.ofproto.ofproto_v1_3_parser.OFPInstructionGotoTable(table_id, type_=None
, len_=None)
Goto table instruction
This instruction indicates the next table in the processing pipeline.
Attribute Description table_id Next table class ryu.ofproto.ofproto_v1_3_parser.OFPInstructionWriteMetadata(metadata, metadata_mask , type_=None , len_=None)
Write metadata instruction
This instruction writes the masked metadata value into the metadata field.
Attribute metadata
Description
Metadata value to write metadata_mask Metadata write bitmask class ryu.ofproto.ofproto_v1_3_parser.OFPInstructionActions(type_, actions=None , len_=None)
Actions instruction
This instruction writes/applies/clears the actions.
Attribute type
Description
One of following values.
OFPIT_WRITE_ACTIONS
OFPIT_APPLY_ACTIONS
OFPIT_CLEAR_ACTIONS actions list of OpenFlow action class type attribute corresponds to type_ parameter of __init__.
2.5. OpenFlow protocol API Reference 163
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_3_parser.OFPInstructionMeter(meter_id=1, type_=None, len_=None)
Meter instruction
This instruction applies the meter.
Attribute Description meter_id Meter instance
Action Structures
class ryu.ofproto.ofproto_v1_3_parser.OFPActionOutput(port, max_len=65509 type_=None , len_=None)
,
Output action
This action indicates output a packet to the switch port.
Attribute Description port Output port max_len Max length to send to controller class ryu.ofproto.ofproto_v1_3_parser.OFPActionGroup(group_id=0, len_=None)
Group action
This action indicates the group used to process the packet.
Attribute Description group_id Group identifier class ryu.ofproto.ofproto_v1_3_parser.OFPActionSetQueue(queue_id, len_=None)
Set queue action type_=None type_=None
This action sets the queue id that will be used to map a flow to an already-configured queue on a port.
Attribute Description queue_id Queue ID for the packets class ryu.ofproto.ofproto_v1_3_parser.OFPActionSetMplsTtl(mpls_ttl, len_=None)
Set MPLS TTL action type_=None ,
,
,
This action sets the MPLS TTL.
Attribute Description mpls_ttl MPLS TTL class ryu.ofproto.ofproto_v1_3_parser.OFPActionDecMplsTtl(type_=None, len_=None)
Decrement MPLS TTL action
This action decrements the MPLS TTL.
type_=None
, class ryu.ofproto.ofproto_v1_3_parser.OFPActionSetNwTtl(nw_ttl, len_=None)
Set IP TTL action
This action sets the IP TTL.
Attribute Description nw_ttl IP TTL
164 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_3_parser.OFPActionDecNwTtl(type_=None, len_=None)
Decrement IP TTL action
This action decrements the IP TTL.
class ryu.ofproto.ofproto_v1_3_parser.OFPActionCopyTtlOut(type_=None, len_=None)
Copy TTL Out action
This action copies the TTL from the next-to-outermost header with TTL to the outermost header with TTL.
class ryu.ofproto.ofproto_v1_3_parser.OFPActionCopyTtlIn(type_=None, len_=None)
Copy TTL In action
This action copies the TTL from the outermost header with TTL to the next-to-outermost header with TTL.
class ryu.ofproto.ofproto_v1_3_parser.OFPActionPushVlan(ethertype=33024, type_=None , len_=None)
Push VLAN action
This action pushes a new VLAN tag to the packet.
Attribute Description ethertype Ether type. The default is 802.1Q. (0x8100) class ryu.ofproto.ofproto_v1_3_parser.OFPActionPushMpls(ethertype=34887, type_=None , len_=None)
Push MPLS action
This action pushes a new MPLS header to the packet.
Attribute Description ethertype Ether type class ryu.ofproto.ofproto_v1_3_parser.OFPActionPopVlan(type_=None, len_=None)
Pop VLAN action
This action pops the outermost VLAN tag from the packet.
class ryu.ofproto.ofproto_v1_3_parser.OFPActionPopMpls(ethertype=2048, type_=None , len_=None)
Pop MPLS action
This action pops the MPLS header from the packet.
class ryu.ofproto.ofproto_v1_3_parser.OFPActionSetField(field=None, **kwargs)
Set field action
This action modifies a header field in the packet.
The set of keywords available for this is same as OFPMatch.
Example: set_field = OFPActionSetField(eth_src = "00:00:00:00:00" ) class ryu.ofproto.ofproto_v1_3_parser.OFPActionExperimenter(experimenter)
Experimenter action
This action is an extensible action for the experimenter.
Attribute Description experimenter Experimenter ID
2.5. OpenFlow protocol API Reference 165
ryu Documentation, Release 3.21
2.5.4 OpenFlow v1.4 Messages and Structures
Controller-to-Switch Messages
Handshake
class ryu.ofproto.ofproto_v1_4_parser.OFPFeaturesRequest(datapath)
Features request message
The controller sends a feature request to the switch upon session establishment.
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Example:
def
send_features_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPFeaturesRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPFeaturesRequest" : {}
} class ryu.ofproto.ofproto_v1_4_parser.OFPSwitchFeatures(datapath, datapath_id=None, n_buffers=None , n_tables=None
, iary_id=None
, ties=None) auxilcapabili-
Features reply message
The switch responds with a features reply message to a features request.
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Example:
@set_ev_cls
(ofp_event .
EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def
switch_features_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPSwitchFeatures received: '
'datapath_id=0x %016x n_buffers= %d '
'n_tables= %d auxiliary_id= %d '
'capabilities=0x %08x ' , msg .
datapath_id, msg .
n_buffers, msg .
n_tables, msg .
auxiliary_id, msg .
capabilities)
JSON Example:
{
"OFPSwitchFeatures" : {
"auxiliary_id" : 99 ,
"capabilities" : 79 ,
"datapath_id" : 9210263729383 ,
"n_buffers" : 0 ,
"n_tables" : 255
166 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
Switch Configuration
class ryu.ofproto.ofproto_v1_4_parser.OFPSetConfig(datapath, flags=0, miss_send_len=0)
Set config request message
The controller sends a set config request message to set configuraion parameters.
Attribute flags
Description
Bitmap of the following flags.
miss_send_len
OFPC_FRAG_NORMAL
OFPC_FRAG_DROP
OFPC_FRAG_REASM
Max bytes of new flow that datapath should send to the controller
Example:
def
send_set_config ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPSetConfig(datapath, ofp .
OFPC_FRAG_NORMAL, 256 ) datapath .
send_msg(req)
JSON Example:
{
"OFPSetConfig" : {
"flags" : 0 ,
"miss_send_len" : 128
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPGetConfigRequest(datapath)
Get config request message
The controller sends a get config request to query configuration parameters in the switch.
Example:
def
send_get_config_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGetConfigRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPGetConfigRequest" : {}
}
2.5. OpenFlow protocol API Reference 167
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_4_parser.OFPGetConfigReply(datapath, flags=None miss_send_len=None)
,
Get config reply message
The switch responds to a configuration request with a get config reply message.
Attribute flags
Description
Bitmap of the following flags.
OFPC_FRAG_NORMAL
OFPC_FRAG_DROP
OFPC_FRAG_REASM miss_send_len Max bytes of new flow that datapath should send to the controller
Example:
@set_ev_cls
(ofp_event .
EventOFPGetConfigReply, MAIN_DISPATCHER)
def
get_config_reply_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto flags = []
if
msg .
flags & ofp .
OFPC_FRAG_NORMAL: flags .
append( 'NORMAL' )
if
msg .
flags & ofp .
OFPC_FRAG_DROP: flags .
append( 'DROP' )
if
msg .
flags & ofp .
OFPC_FRAG_REASM: flags .
append( 'REASM' ) self .
logger .
debug( 'OFPGetConfigReply received: '
'flags= %s miss_send_len= %d ' ,
',' .
join(flags), msg .
miss_send_len)
JSON Example:
{
"OFPGetConfigReply" : {
"flags" : 0 ,
"miss_send_len" : 128
}
}
Modify State Messages
class ryu.ofproto.ofproto_v1_4_parser.OFPTableMod(datapath, table_id, config, properties)
Flow table configuration message
The controller sends this message to configure table state.
168 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute table_id config
Description
ID of the table (OFPTT_ALL indicates all tables)
Bitmap of configuration flags.
OFPTC_EVICTION
OFPTC_VACANCY_EVENTS properties
Example:
def
send_table_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
List of OFPTableModProp subclass instance req = ofp_parser .
OFPTableMod(datapath, 1 , 3 ) flags = ofproto .
OFPTC_VACANCY_EVENTS properties = [ofp_parser .
OFPTableModPropEviction(flags)] req = ofp_parser .
OFPTableMod(datapath, 1 , 3 , properties) datapath .
send_msg(req)
JSON Example:
{
"OFPTableMod" : {
"config" : 0 ,
"properties" : [
{
"OFPTableModPropEviction" : {
"flags" : 0 ,
"length" : 8 ,
"type" : 2
}
},
{
"OFPTableModPropVacancy" : {
"length" : 8 ,
"type" : 3 ,
"vacancy" : 0 ,
"vacancy_down" : 0 ,
"vacancy_up" : 0
}
},
{
"OFPTableModPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPTableModPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
2.5. OpenFlow protocol API Reference 169
ryu Documentation, Release 3.21
}
}
},
{
"OFPTableModPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
],
"table_id" : 255
} class ryu.ofproto.ofproto_v1_4_parser.OFPFlowMod(datapath, cookie=0, cookie_mask=0, table_id=0 , command=0, idle_timeout=0, hard_timeout=0 , buffer_id=4294967295 , priority=32768 out_port=0
,
, out_group=0 , flags=0, importance=0, match=None , instructions=[])
Modify Flow entry message
The controller sends this message to modify the flow table.
170 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute cookie cookie_mask table_id command idle_timeout hard_timeout priority buffer_id out_port out_group flags
Description
Opaque controller-issued identifier
Mask used to restrict the cookie bits that must match when the command is OPFFC_MODIFY* or
OFPFC_DELETE*
ID of the table to put the flow in
One of the following values.
OFPFC_ADD
OFPFC_MODIFY
OFPFC_MODIFY_STRICT
OFPFC_DELETE
OFPFC_DELETE_STRICT
Idle time before discarding (seconds)
Max time before discarding (seconds)
Priority level of flow entry
Buffered packet to apply to (or OFP_NO_BUFFER)
For OFPFC_DELETE* commands, require matching entries to include this as an output port
For OFPFC_DELETE* commands, require matching entries to include this as an output group
Bitmap of the following flags.
OFPFF_SEND_FLOW_REM
OFPFF_CHECK_OVERLAP
OFPFF_RESET_COUNTS
OFPFF_NO_PKT_COUNTS
OFPFF_NO_BYT_COUNTS importance match instructions
Example:
def
send_flow_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
Eviction precedence
Instance of OFPMatch list of OFPInstruction* instance cookie = cookie_mask = 0 table_id = 0 idle_timeout = hard_timeout = 0 priority = 32768 buffer_id = ofp .
OFP_NO_BUFFER importance = 0 match = ofp_parser .
OFPMatch(in_port = 1 , eth_dst = 'ff:ff:ff:ff:ff:ff' ) actions = [ofp_parser .
OFPActionOutput(ofp .
OFPP_NORMAL, 0 )] inst = [ofp_parser .
OFPInstructionActions(ofp .
OFPIT_APPLY_ACTIONS, actions)] req = ofp_parser .
OFPFlowMod(datapath, cookie, cookie_mask, table_id, ofp .
OFPFC_ADD, idle_timeout, hard_timeout, priority, buffer_id, ofp .
OFPP_ANY, ofp .
OFPG_ANY,
2.5. OpenFlow protocol API Reference 171
ryu Documentation, Release 3.21
ofp .
OFPFF_SEND_FLOW_REM, imporotance, match, inst) datapath .
send_msg(req)
JSON Example:
{
"OFPFlowMod" : {
"buffer_id" : 65535 ,
"command" : 0 ,
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"importance" : 0 ,
"instructions" : [
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "vlan_vid" ,
"mask" : null,
"value" : 258
}
}
}
},
{
"OFPActionCopyTtlOut" : {
"len" : 8 ,
"type" : 11
}
},
{
"OFPActionCopyTtlIn" : {
"len" : 8 ,
"type" : 12
}
},
{
"OFPActionCopyTtlIn" : {
"len" : 8 ,
"type" : 12
}
},
{
"OFPActionPopPbb" : {
"len" : 8 ,
"type" : 27
}
},
{
"OFPActionPushPbb" : {
172 Chapter 2. Writing Your Ryu Application
},
{
}
"OFPActionPopMpls" : {
"ethertype" : 39030 ,
"len" : 8 ,
"type" : 20
}
},
{
"OFPActionPushMpls" : {
"ethertype" : 34887 ,
"len" : 8 ,
"type" : 19
}
},
{
"OFPActionPopVlan" : {
"len" : 8 ,
"type" : 18
}
},
{
"ethertype" : 4660 ,
"len" : 8 ,
"type" : 26
"OFPActionPushVlan" : {
"ethertype" : 33024 ,
"len" : 8 ,
"type" : 17
}
},
{
"OFPActionDecMplsTtl" : {
"len" : 8 ,
"type" : 16
}
},
{
"OFPActionSetMplsTtl" : {
"len" : 8 ,
"mpls_ttl" : 10 ,
"type" : 15
}
},
{
"OFPActionDecNwTtl" : {
"len" : 8 ,
"type" : 24
}
},
{
"OFPActionSetNwTtl" : {
"len" : 8 ,
"nw_ttl" : 10 ,
"type" : 23
}
},
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
173
ryu Documentation, Release 3.21
174
{
"OFPActionExperimenter" : {
"data" : "AAECAwQFBgc=" ,
"experimenter" : 101 ,
"len" : 16 ,
"type" : 65535
}
},
{
"OFPActionSetQueue" : {
"len" : 8 ,
"queue_id" : 3 ,
"type" : 21
}
},
{
"OFPActionGroup" : {
"group_id" : 99 ,
"len" : 8 ,
"type" : 22
}
},
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 6 ,
"type" : 0
}
}
],
"len" : 176 ,
"type" : 3
},
{
}
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "01:02:03:04:05:06"
}
}
}
},
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "pbb_uca" ,
"mask" : null,
"value" : 1
}
}
Chapter 2. Writing Your Ryu Application
}
{
}
}
}
],
"len" : 40 ,
"type" : 4
}
}
],
"match" : {
"OFPMatch" : {
"length" : 14 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"priority" : 123 ,
"table_id" : 1
"OFPFlowMod" : {
"buffer_id" : 65535 ,
"command" : 0 ,
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"importance" : 0 ,
"instructions" : [
{
"OFPInstructionGotoTable" : {
"len" : 8 ,
"table_id" : 1 ,
"type" : 1
}
}
],
"match" : {
"OFPMatch" : {
"length" : 22 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 6
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
175
ryu Documentation, Release 3.21
176
}
}
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"priority" : 123 ,
"table_id" : 0
{
"OFPFlowMod" : {
"buffer_id" : 65535 ,
"command" : 0 ,
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"importance" : 0 ,
"instructions" : [
{
"OFPInstructionMeter" : {
"len" : 8 ,
"meter_id" : 1 ,
"type" : 6
}
},
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 6 ,
"type" : 0
}
}
],
"len" : 24 ,
"type" : 3
}
}
],
"match" : {
"OFPMatch" : {
"length" : 14 ,
Chapter 2. Writing Your Ryu Application
}
{
}
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"priority" : 123 ,
"table_id" : 1
"OFPFlowMod" : {
"buffer_id" : 65535 ,
"command" : 0 ,
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"importance" : 0 ,
"instructions" : [],
"match" : {
"OFPMatch" : {
"length" : 329 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 84281096
}
},
{
"OXMTlv" : {
"field" : "in_phy_port" ,
"mask" : null,
"value" : 16909060
}
},
{
"OXMTlv" : {
"field" : "metadata" ,
"mask" : null,
"value" : 283686952306183
}
},
{
"OXMTlv" : {
"field" : "eth_type" ,
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
177
ryu Documentation, Release 3.21
178
"mask" : null,
"value" : 2054
}
},
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "ff:ff:ff:ff:ff:ff"
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
"OXMTlv" : {
"field" : "vlan_vid" ,
"mask" : null,
"value" : 999
}
},
{
"OXMTlv" : {
"field" : "ip_dscp" ,
"mask" : null,
"value" : 9
}
},
{
"OXMTlv" : {
"field" : "ip_ecn" ,
"mask" : null,
"value" : 3
}
},
{
"OXMTlv" : {
"field" : "ip_proto" ,
"mask" : null,
"value" : 99
}
},
{
"OXMTlv" : {
"field" : "ipv4_src" ,
"mask" : null,
"value" : "1.2.3.4"
}
},
{
"OXMTlv" : {
"field" : "ipv4_dst" ,
"mask" : null,
"value" : "1.2.3.4"
Chapter 2. Writing Your Ryu Application
}
},
{
"OXMTlv" : {
"field" : "tcp_src" ,
"mask" : null,
"value" : 8080
}
},
{
"OXMTlv" : {
"field" : "tcp_dst" ,
"mask" : null,
"value" : 18080
}
},
{
"OXMTlv" : {
"field" : "udp_src" ,
"mask" : null,
"value" : 28080
}
},
{
},
{
"OXMTlv" : {
"field" : "udp_dst" ,
"mask" : null,
"value" : 55936
}
"OXMTlv" : {
"field" : "sctp_src" ,
"mask" : null,
"value" : 48080
}
},
{
"OXMTlv" : {
"field" : "sctp_dst" ,
"mask" : null,
"value" : 59328
}
},
{
"OXMTlv" : {
"field" : "icmpv4_type" ,
"mask" : null,
"value" : 100
}
},
{
"OXMTlv" : {
"field" : "icmpv4_code" ,
"mask" : null,
"value" : 101
}
},
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
179
ryu Documentation, Release 3.21
180
{
"OXMTlv" : {
"field" : "arp_op" ,
"mask" : null,
"value" : 1
}
},
{
"OXMTlv" : {
"field" : "arp_spa" ,
"mask" : null,
"value" : "10.0.0.1"
}
},
{
"OXMTlv" : {
"field" : "arp_tpa" ,
"mask" : null,
"value" : "10.0.0.3"
}
},
{
"OXMTlv" : {
"field" : "arp_sha" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
"OXMTlv" : {
"field" : "arp_tha" ,
"mask" : null,
"value" : "00:00:00:00:00:00"
}
},
{
"OXMTlv" : {
"field" : "ipv6_src" ,
"mask" : null,
"value" : "fe80::f00b:a4ff:fe48:28a5"
}
},
{
"OXMTlv" : {
"field" : "ipv6_dst" ,
"mask" : null,
"value" : "fe80::f00b:a4ff:fe05:b7dc"
}
},
{
"OXMTlv" : {
"field" : "ipv6_flabel" ,
"mask" : null,
"value" : 541473
}
},
{
"OXMTlv" : {
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"field" : "icmpv6_type" ,
"mask" : null,
"value" : 200
},
{
}
"OXMTlv" : {
"field" : "icmpv6_code" ,
"mask" : null,
"value" : 201
}
},
{
"OXMTlv" : {
"field" : "ipv6_nd_target" ,
"mask" : null,
"value" : "fe80::a60:6eff:fe7f:74e7"
}
},
{
"OXMTlv" : {
"field" : "ipv6_nd_sll" ,
"mask" : null,
"value" : "00:00:00:00:02:9a"
}
},
{
"OXMTlv" : {
"field" : "ipv6_nd_tll" ,
"mask" : null,
"value" : "00:00:00:00:02:2b"
}
},
{
"OXMTlv" : {
"field" : "mpls_label" ,
"mask" : null,
"value" : 624485
}
},
{
"OXMTlv" : {
"field" : "mpls_tc" ,
"mask" : null,
"value" : 5
}
},
{
"OXMTlv" : {
"field" : "mpls_bos" ,
"mask" : null,
"value" : 1
}
},
{
"OXMTlv" : {
"field" : "pbb_isid" ,
"mask" : null,
2.5. OpenFlow protocol API Reference 181
ryu Documentation, Release 3.21
"value" : 11259375
}
},
{
"OXMTlv" : {
"field" : "tunnel_id" ,
"mask" : null,
"value" : 651061555542690057
}
},
{
"OXMTlv" : {
"field" : "ipv6_exthdr" ,
"mask" : null,
"value" : 500
}
},
{
"OXMTlv" : {
"field" : "pbb_uca" ,
"mask" : null,
"value" : 1
}
}
],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"priority" : 123 ,
"table_id" : 1
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPGroupMod(datapath, command=0
, type_=0
, group_id=0
, buckets=[])
Modify group entry message
The controller sends this message to modify the group table.
Attribute command
Description
One of the following values.
OFPGC_ADD
OFPGC_MODIFY
OFPGC_DELETE type group_id buckets
One of the following values.
OFPGT_ALL
OFPGT_SELECT
OFPGT_INDIRECT
OFPGT_FF
Group identifier list of OFPBucket
182 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
type attribute corresponds to type_ parameter of __init__.
Example:
def
send_group_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser port = 1 max_len = 2000 actions = [ofp_parser .
OFPActionOutput(port, max_len)] weight = 100 watch_port = 0 watch_group = 0 buckets = [ofp_parser .
OFPBucket(weight, watch_port, watch_group, actions)] group_id = 1 req = ofp_parser .
OFPGroupMod(datapath, ofp .
OFPGC_ADD, ofp .
OFPGT_SELECT, group_id, buckets) datapath .
send_msg(req)
JSON Example:
{
"OFPGroupMod" : {
"buckets" : [
{
"OFPBucket" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 2 ,
"type" : 0
}
}
],
"len" : 32 ,
"watch_group" : 1 ,
"watch_port" : 1 ,
"weight" : 1
}
}
],
"command" : 0 ,
"group_id" : 1 ,
"type" : 0
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPPortMod(datapath, port_no=0 hw_addr=‘00:00:00:00:00:00’ , con-
, fig=0 , mask=0, properties=None)
Port modification message
The controller sneds this message to modify the behavior of the port.
2.5. OpenFlow protocol API Reference 183
ryu Documentation, Release 3.21
184
Attribute port_no hw_addr config
Description
Port number to modify
The hardware address that must be the same as hw_addr of OFPPort of OFPSwitchFeatures
Bitmap of configuration flags.
OFPPC_PORT_DOWN
OFPPC_NO_RECV
OFPPC_NO_FWD
OFPPC_NO_PACKET_IN mask properties
Example:
def
send_port_mod ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
Bitmap of configuration flags above to be changed
List of OFPPortProp subclass instance port_no = 3 hw_addr = 'fa:c8:e8:76:1d:7e' config = 0 mask = (ofp .
OFPPC_PORT_DOWN | ofp .
OFPPC_NO_RECV | ofp .
OFPPC_NO_FWD | ofp .
OFPPC_NO_PACKET_IN) advertise = (ofp .
OFPPF_10MB_HD | ofp .
OFPPF_100MB_FD | ofp .
OFPPF_1GB_FD | ofp .
OFPPF_COPPER | ofp .
OFPPF_AUTONEG | ofp .
OFPPF_PAUSE | ofp .
OFPPF_PAUSE_ASYM) properties = ofp_parser .
OFPPortModPropEthernet(advertise) req = ofp_parser .
OFPPortMod(datapath, port_no, hw_addr, config, mask, properties) datapath .
send_msg(req)
JSON Example:
{
"OFPPortMod" : {
"config" : 0 ,
"hw_addr" : "00:11:00:00:11:11" ,
"mask" : 0 ,
"port_no" : 1 ,
"properties" : [
{
"OFPPortModPropEthernet" : {
"advertise" : 4096 ,
"length" : 8 ,
"type" : 0
}
},
{
"OFPPortModPropOptical" : {
"configure" : 3 ,
"fl_offset" : 2000 ,
"freq_lmda" : 1500 ,
"grid_span" : 3000 ,
"length" : 24 ,
"tx_pwr" : 300 ,
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
]
"type" : 1
},
{
}
"OFPPortModPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPPortModPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPPortModPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPMeterMod(datapath, command=0, flags=1, meter_id=1 , bands=[])
Meter modification message
The controller sends this message to modify the meter.
2.5. OpenFlow protocol API Reference 185
ryu Documentation, Release 3.21
Attribute command flags meter_id bands
JSON Example:
{
"OFPMeterMod" : {
"bands" : [
{
"OFPMeterBandDrop" : {
"burst_size" : 10 ,
"len" : 16 ,
"rate" : 1000 ,
"type" : 1
}
},
{
"OFPMeterBandDscpRemark" : {
"burst_size" : 10 ,
"len" : 16 ,
"prec_level" : 1 ,
"rate" : 1000 ,
"type" : 2
}
},
{
"OFPMeterBandExperimenter" : {
"burst_size" : 10 ,
"experimenter" : 999 ,
"len" : 16 ,
"rate" : 1000 ,
"type" : 65535
}
}
],
"command" : 0 ,
"flags" : 14 ,
Description
One of the following values.
OFPMC_ADD
OFPMC_MODIFY
OFPMC_DELETE
Bitmap of the following flags.
OFPMF_KBPS
OFPMF_PKTPS
OFPMF_BURST
OFPMF_STATS
Meter instance list of the following class instance.
OFPMeterBandDrop
OFPMeterBandDscpRemark
OFPMeterBandExperimenter
186 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
"meter_id" : 100
Multipart Messages
class ryu.ofproto.ofproto_v1_4_parser.OFPDescStatsRequest(datapath, type_=None)
Description statistics request message
The controller uses this message to query description of the switch.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_desc_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPDescStatsRequest(datapath, 0 ) datapath .
send_msg(req) flags=0
JSON Example:
{
"OFPDescStatsRequest" : {
"flags" : 0 ,
"type" : 0
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPDescStatsReply(datapath,
**kwargs)
Description statistics reply message
The switch responds with this message to a description statistics request.
Attribute Description body Instance of OFPDescStats
Example:
@set_ev_cls
(ofp_event .
EventOFPDescStatsReply, MAIN_DISPATCHER)
def
desc_stats_reply_handler ( self , ev): body = ev .
msg .
body type_=None self .
logger .
debug( 'DescStats: mfr_desc= %s hw_desc= %s sw_desc= %s '
'serial_num= %s dp_desc= %s ' , body .
mfr_desc, body .
hw_desc, body .
sw_desc, body .
serial_num, body .
dp_desc)
JSON Example:
{
"OFPDescStatsReply" : {
"body" : {
"OFPDescStats" : {
"dp_desc" : "dp" ,
,
,
2.5. OpenFlow protocol API Reference 187
ryu Documentation, Release 3.21
"hw_desc" : "hw" ,
"mfr_desc" : "mfr" ,
"serial_num" : "serial" ,
"sw_desc" : "sw"
}
},
"flags" : 0 ,
"type" : 0
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPFlowStatsRequest(datapath, table_id=255 , flags=0 out_port=4294967295 , out_group=4294967295 ,
, cookie=0 , cookie_mask=0, match=None , type_=None)
Individual flow statistics request message
The controller uses this message to query individual flow statistics.
Attribute flags table_id
Description
Zero or OFPMPF_REQ_MORE
ID of table to read out_port out_group
Require matching entries to include this as an output port
Require matching entries to include this as an output group cookie Require matching entries to contain this cookie value cookie_mask Mask used to restrict the cookie bits that must match match Instance of OFPMatch
Example:
def
send_flow_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser cookie = cookie_mask = 0 match = ofp_parser .
OFPMatch(in_port = 1 ) req = ofp_parser .
OFPFlowStatsRequest(datapath, 0 , ofp .
OFPTT_ALL, ofp .
OFPP_ANY, ofp .
OFPG_ANY, cookie, cookie_mask, match) datapath .
send_msg(req)
JSON Example:
{
"OFPFlowStatsRequest" : {
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
188 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"table_id" : 0 ,
"type" : 1
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPFlowStatsReply(datapath,
**kwargs)
Individual flow statistics reply message
The switch responds with this message to an individual flow statistics request.
Attribute Description body List of OFPFlowStats instance
Example: type_=None
@set_ev_cls
(ofp_event .
EventOFPFlowStatsReply, MAIN_DISPATCHER)
def
flow_stats_reply_handler ( self , ev): flows = []
for
stat
in
ev .
msg .
body: flows .
append( 'table_id= %s '
'duration_sec= %d duration_nsec= %d '
'priority= %d '
'idle_timeout= %d hard_timeout= %d flags=0x %04x '
'importance= %d cookie= %d packet_count= %d '
'byte_count= %d match= %s instructions= %s ' %
(stat .
table_id, stat .
duration_sec, stat .
duration_nsec, stat .
priority, stat .
idle_timeout, stat .
hard_timeout, stat .
flags, stat .
importance, stat .
cookie, stat .
packet_count, stat .
byte_count, stat .
match, stat .
instructions)) self .
logger .
debug( 'FlowStats: %s ' , flows)
,
JSON Example:
{
"OFPFlowStatsReply" : {
"body" : [
{
"OFPFlowStats" : {
"byte_count" : 0 ,
"cookie" : 0 ,
"duration_nsec" : 115277000 ,
"duration_sec" : 358 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"importance" : 0 ,
"instructions" : [],
"length" : 56 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
2.5. OpenFlow protocol API Reference 189
ryu Documentation, Release 3.21
190
}
},
"packet_count" : 0 ,
"priority" : 65535 ,
"table_id" : 0
}
},
{
"OFPFlowStats" : {
"byte_count" : 0 ,
"cookie" : 0 ,
"duration_nsec" : 115055000 ,
"duration_sec" : 358 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"importance" : 0 ,
"instructions" : [
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 0 ,
"port" : 4294967290 ,
"type" : 0
}
}
],
"len" : 24 ,
"type" : 4
}
}
],
"length" : 88 ,
"match" : {
"OFPMatch" : {
"length" : 10 ,
"oxm_fields" : [
{
"OXMTlv" : {
}
}
],
"type" : 1
"field" : "eth_type" ,
"mask" : null,
"value" : 2054
}
},
"packet_count" : 0 ,
"priority" : 65534 ,
"table_id" : 0
}
},
{
"OFPFlowStats" : {
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"byte_count" : 238 ,
"cookie" : 0 ,
"duration_nsec" : 511582000 ,
"duration_sec" : 316220 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"importance" : 0 ,
"instructions" : [
{
"OFPInstructionGotoTable" : {
"len" : 8 ,
"table_id" : 1 ,
"type" : 1
}
}
],
"length" : 80 ,
"match" : {
"OFPMatch" : {
"length" : 22 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 6
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
}
],
"type" : 1
}
},
"packet_count" : 3 ,
"priority" : 123 ,
"table_id" : 0
}
},
{
"OFPFlowStats" : {
"byte_count" : 98 ,
"cookie" : 0 ,
"duration_nsec" : 980901000 ,
"duration_sec" : 313499 ,
"flags" : 0 ,
"hard_timeout" : 0 ,
"idle_timeout" : 0 ,
"importance" : 0 ,
"instructions" : [
{
"OFPInstructionActions" : {
2.5. OpenFlow protocol API Reference 191
ryu Documentation, Release 3.21
192
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "vlan_vid" ,
"mask" : null,
"value" : 258
}
}
}
},
{
"OFPActionCopyTtlOut" : {
"len" : 8 ,
"type" : 11
}
},
{
"OFPActionCopyTtlIn" : {
"len" : 8 ,
"type" : 12
}
},
{
"OFPActionCopyTtlIn" : {
"len" : 8 ,
"type" : 12
}
},
{
"OFPActionPopPbb" : {
"len" : 8 ,
"type" : 27
}
},
{
"OFPActionPushPbb" : {
"ethertype" : 4660 ,
"len" : 8 ,
"type" : 26
}
},
{
"OFPActionPopMpls" : {
"ethertype" : 39030 ,
"len" : 8 ,
"type" : 20
}
},
{
"OFPActionPushMpls" : {
"ethertype" : 34887 ,
"len" : 8 ,
"type" : 19
}
},
{
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"OFPActionPopVlan" : {
"len" : 8 ,
"type" : 18
}
},
{
"OFPActionPushVlan" : {
"ethertype" : 33024 ,
"len" : 8 ,
"type" : 17
}
},
{
"OFPActionDecMplsTtl" : {
"len" : 8 ,
"type" : 16
}
},
{
"OFPActionSetMplsTtl" : {
"len" : 8 ,
"mpls_ttl" : 10 ,
"type" : 15
}
},
{
"OFPActionDecNwTtl" : {
"len" : 8 ,
"type" : 24
}
},
{
"OFPActionSetNwTtl" : {
"len" : 8 ,
"nw_ttl" : 10 ,
"type" : 23
}
},
{
"OFPActionSetQueue" : {
"len" : 8 ,
"queue_id" : 3 ,
"type" : 21
}
},
{
"OFPActionGroup" : {
"group_id" : 99 ,
"len" : 8 ,
"type" : 22
}
},
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 6 ,
"type" : 0
2.5. OpenFlow protocol API Reference 193
ryu Documentation, Release 3.21
194
}
}
],
"len" : 160 ,
"type" : 3
}
},
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "01:02:03:04:05:06"
}
}
}
},
{
"OFPActionSetField" : {
"field" : {
"OXMTlv" : {
"field" : "pbb_uca" ,
"mask" : null,
"value" : 1
}
}
}
}
],
"len" : 40 ,
"type" : 4
}
},
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 4294967293 ,
"type" : 0
}
}
],
"len" : 24 ,
"type" : 3
}
}
],
"length" : 280 ,
"match" : {
"OFPMatch" : {
"length" : 4 ,
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
],
"flags" : 0 ,
"type" : 1
"oxm_fields" : [],
"type" : 1
}
},
"packet_count" : 1 ,
"priority" : 0 ,
"table_id" : 0
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPAggregateStatsRequest(datapath, flags table_id , out_port,
, out_group , cookie, cookie_mask
, match
, type_=None)
Aggregate flow statistics request message
The controller uses this message to query aggregate flow statictics.
Attribute flags table_id out_port
Description
Zero or OFPMPF_REQ_MORE
ID of table to read
Require matching entries to include this as an output port out_group cookie
Require matching entries to include this as an output group
Require matching entries to contain this cookie value cookie_mask Mask used to restrict the cookie bits that must match match Instance of OFPMatch
Example:
def
send_aggregate_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser cookie = cookie_mask = 0 match = ofp_parser .
OFPMatch(in_port = 1 ) req = ofp_parser .
OFPAggregateStatsRequest(datapath, 0 , ofp .
OFPTT_ALL, ofp .
OFPP_ANY, ofp .
OFPG_ANY, cookie, cookie_mask, match) datapath .
send_msg(req)
JSON Example:
{
"OFPAggregateStatsRequest" : {
"cookie" : 0 ,
"cookie_mask" : 0 ,
"flags" : 0 ,
"match" : {
"OFPMatch" : {
2.5. OpenFlow protocol API Reference 195
ryu Documentation, Release 3.21
"length" : 4 ,
"oxm_fields" : [],
"type" : 1
}
},
"out_group" : 4294967295 ,
"out_port" : 4294967295 ,
"table_id" : 255 ,
"type" : 2
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPAggregateStatsReply(datapath, type_=None,
**kwargs)
Aggregate flow statistics reply message
The switch responds with this message to an aggregate flow statistics request.
Attribute Description body Instance of OFPAggregateStats
Example:
@set_ev_cls
(ofp_event .
EventOFPAggregateStatsReply, MAIN_DISPATCHER)
def
aggregate_stats_reply_handler ( self , ev): body = ev .
msg .
body self .
logger .
debug( 'AggregateStats: packet_count= %d byte_count= %d '
'flow_count= %d ' , body .
packet_count, body .
byte_count, body .
flow_count)
JSON Example:
{
"OFPAggregateStatsReply" : {
"body" : {
"OFPAggregateStats" : {
"byte_count" : 574 ,
"flow_count" : 6 ,
"packet_count" : 7
}
},
"flags" : 0 ,
"type" : 2
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPTableStatsRequest(datapath, type_=None)
Table statistics request message
The controller uses this message to query flow table statictics.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_table_stats_request ( self , datapath): ofp = datapath .
ofproto flags ,
196 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPTableStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPTableStatsRequest" : {
"flags" : 0 ,
"type" : 3
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPTableStatsReply(datapath,
**kwargs)
Table statistics reply message
The switch responds with this message to a table statistics request.
Attribute Description body List of OFPTableStats instance
Example:
@set_ev_cls(ofp_event.EventOFPTableStatsReply, MAIN_DISPATCHER) def table_stats_reply_handler(self, ev): tables = [] for stat in ev.msg.body: tables.append('table_id=%d active_count=%d lookup_count=%d '
' matched_count=%d' %
(stat.table_id, stat.active_count, stat.lookup_count, stat.matched_count)) self.logger.debug('TableStats: %s', tables) type_=None ,
JSON Example:
{
"OFPTableStatsReply" : {
"body" : [
{
"OFPTableStats" : {
"active_count" : 4 ,
"lookup_count" : 4 ,
"matched_count" : 4 ,
"table_id" : 0
}
},
{
"OFPTableStats" : {
"active_count" : 4 ,
"lookup_count" : 4 ,
"matched_count" : 4 ,
"table_id" : 1
}
}
],
"flags" : 0 ,
"type" : 3
2.5. OpenFlow protocol API Reference 197
ryu Documentation, Release 3.21
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPTableDescStatsRequest(datapath, flags=0
, type_=None)
Table description request message
The controller uses this message to query description of all the tables.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_tablet_desc_stats_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPTableDescStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPTableDescStatsRequest" : {
"flags" : 0 ,
"type" : 14
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPTableDescStatsReply(datapath, type_=None,
**kwargs)
Table description reply message
The switch responds with this message to a table description request.
Attribute Description body List of OFPTableDescStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPTableDescStatsReply, MAIN_DISPATCHER)
def
table_desc_stats_reply_handler ( self , ev): tables = []
for
p
in
ev .
msg .
body: tables .
append( 'table_id= %d config=0x %08x properties= %s ' %
(p .
table_id, p .
config, repr (p .
properties))) self .
logger .
debug( 'OFPTableDescStatsReply received: %s ' , ports)
JSON Example:
{
"OFPTableDescStatsReply" : {
"body" : [
{
"OFPTableDesc" : {
"config" : 0 ,
"length" : 24 ,
"properties" : [
{
"OFPTableModPropExperimenter" : {
"data" : "" ,
198 Chapter 2. Writing Your Ryu Application
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
}
],
"table_id" : 7
},
{
}
"OFPTableDesc" : {
"config" : 0 ,
"length" : 80 ,
"properties" : [
{
"OFPTableModPropEviction" : {
"flags" : 0 ,
"length" : 8 ,
"type" : 2
}
},
{
"OFPTableModPropVacancy" : {
"length" : 8 ,
"type" : 3 ,
"vacancy" : 0 ,
"vacancy_down" : 0 ,
"vacancy_up" : 0
}
},
{
"OFPTableModPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPTableModPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPTableModPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
199
ryu Documentation, Release 3.21
],
"table_id" : 8
}
}
],
"flags" : 0 ,
"type" : 14
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPTableFeaturesStatsRequest(datapath, flags=0
, body=[] , type_=None)
Table features statistics request message
The controller uses this message to query table features.
Attribute Description body List of OFPTableFeaturesStats instances. The default is [].
JSON Example:
See an example in: ryu/tests/unit/ofproto/json/of14/5-53-ofp_table_features_request.packet.json
class ryu.ofproto.ofproto_v1_4_parser.OFPTableFeaturesStatsReply(datapath, type_=None
,
**kwargs)
Table features statistics reply message
The switch responds with this message to a table features statistics request.
Attribute Description body List of OFPTableFeaturesStats instance
JSON Example:
See an example in: ryu/tests/unit/ofproto/json/of14/5-54-ofp_table_features_reply.packet.json
class ryu.ofproto.ofproto_v1_4_parser.OFPPortStatsRequest(datapath, flags, port_no, type_=None)
Port statistics request message
The controller uses this message to query information about ports statistics.
Attribute Description flags port_no
Zero or OFPMPF_REQ_MORE
Port number to read (OFPP_ANY to all ports)
Example:
def
send_port_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPPortStatsRequest(datapath, 0 , ofp .
OFPP_ANY) datapath .
send_msg(req)
JSON Example:
200 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
{
"OFPPortStatsRequest" : {
"flags" : 0 ,
"port_no" : 4294967295 ,
"type" : 4
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPPortStatsReply(datapath,
**kwargs)
Port statistics reply message
The switch responds with this message to a port statistics request.
Attribute Description body List of OFPPortStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPPortStatsReply, MAIN_DISPATCHER)
def
port_stats_reply_handler ( self , ev): ports = []
for
stat
in
ev .
msg .
body: ports .
append(stat .
length, stat .
port_no, stat .
duration_sec, stat .
duration_nsec, stat .
rx_packets, stat .
tx_packets, stat .
rx_bytes, stat .
tx_bytes, stat .
rx_dropped, stat .
tx_dropped, stat .
rx_errors, stat .
tx_errors, repr (stat .
properties)) self .
logger .
debug( 'PortStats: %s ' , ports)
JSON Example:
{
"OFPPortStatsReply" : {
"body" : [
{
"OFPPortStats" : {
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
"length" : 224 ,
"port_no" : 7 ,
"properties" : [
{
"OFPPortStatsPropEthernet" : {
"collisions" : 0 ,
"length" : 40 ,
"rx_crc_err" : 0 ,
"rx_frame_err" : 0 ,
"rx_over_err" : 0 ,
"type" : 0
}
},
{
"OFPPortStatsPropOptical" : {
"bias_current" : 300 ,
"flags" : 3 ,
"length" : 44 ,
"rx_freq_lmda" : 1500 , type_=None ,
2.5. OpenFlow protocol API Reference 201
ryu Documentation, Release 3.21
202
"rx_grid_span" : 500 ,
"rx_offset" : 700 ,
"rx_pwr" : 2000 ,
"temperature" : 273 ,
"tx_freq_lmda" : 1500 ,
"tx_grid_span" : 500 ,
"tx_offset" : 700 ,
"tx_pwr" : 2000 ,
"type" : 1
}
},
{
"OFPPortStatsPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPPortStatsPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPPortStatsPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
],
"rx_bytes" : 0 ,
"rx_dropped" : 0 ,
"rx_errors" : 0 ,
"rx_packets" : 0 ,
"tx_bytes" : 336 ,
"tx_dropped" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 4
},
{
}
"OFPPortStats" : {
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
"length" : 120 ,
"port_no" : 6 ,
"properties" : [
{
"OFPPortStatsPropEthernet" : {
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
],
"flags" : 0 ,
"type" : 4
"collisions" : 0 ,
"length" : 40 ,
"rx_crc_err" : 0 ,
"rx_frame_err" : 0 ,
"rx_over_err" : 0 ,
"type" : 0
}
}
],
"rx_bytes" : 336 ,
"rx_dropped" : 0 ,
"rx_errors" : 0 ,
"rx_packets" : 4 ,
"tx_bytes" : 336 ,
"tx_dropped" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 4
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPPortDescStatsRequest(datapath, flags=0 , type_=None)
Port description request message
The controller uses this message to query description of all the ports.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_port_desc_stats_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPPortDescStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPPortDescStatsRequest" : {
"flags" : 0 ,
"type" : 13
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPPortDescStatsReply(datapath, type_=None,
**kwargs)
Port description reply message
The switch responds with this message to a port description request.
Attribute Description body List of OFPPortDescStats instance
Example:
2.5. OpenFlow protocol API Reference 203
ryu Documentation, Release 3.21
@set_ev_cls
(ofp_event .
EventOFPPortDescStatsReply, MAIN_DISPATCHER)
def
port_desc_stats_reply_handler ( self , ev): ports = []
for
p
in
ev .
msg .
body: ports .
append( 'port_no= %d hw_addr= %s name= %s config=0x %08x '
'state=0x %08x properties= %s ' %
(p .
port_no, p .
hw_addr, p .
name, p .
config, p .
state, repr (p .
properties))) self .
logger .
debug( 'OFPPortDescStatsReply received: %s ' , ports)
JSON Example:
{
"OFPPortDescStatsReply" : {
"body" : [
{
"OFPPort" : {
"config" : 0 ,
"hw_addr" : "f2:0b:a4:d0:3f:70" ,
"length" : 168 ,
"name" : "Port7" ,
"port_no" : 7 ,
"properties" : [
{
"OFPPortDescPropEthernet" : {
"advertised" : 10240 ,
"curr" : 10248 ,
"curr_speed" : 5000 ,
"length" : 32 ,
"max_speed" : 5000 ,
"peer" : 10248 ,
"supported" : 10248 ,
"type" : 0
}
},
{
"OFPPortDescPropOptical" : {
"length" : 40 ,
"rx_grid_freq_lmda" : 1500 ,
"rx_max_freq_lmda" : 2000 ,
"rx_min_freq_lmda" : 1000 ,
"supported" : 1 ,
"tx_grid_freq_lmda" : 1500 ,
"tx_max_freq_lmda" : 2000 ,
"tx_min_freq_lmda" : 1000 ,
"tx_pwr_max" : 2000 ,
"tx_pwr_min" : 1000 ,
"type" : 1
}
},
{
"OFPPortDescPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
204 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
},
{
"OFPPortDescPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPPortDescPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
],
"state" : 4
}
},
{
"OFPPort" : {
"config" : 0 ,
"hw_addr" : "f2:0b:a4:7d:f8:ea" ,
"length" : 72 ,
"name" : "Port6" ,
"port_no" : 6 ,
"properties" : [
{
"OFPPortDescPropEthernet" : {
"advertised" : 10240 ,
"curr" : 10248 ,
}
}
],
"state" : 4
}
}
],
"flags" : 0 ,
"type" : 13
"curr_speed" : 5000 ,
"length" : 32 ,
"max_speed" : 5000 ,
"peer" : 10248 ,
"supported" : 10248 ,
"type" : 0
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPQueueStatsRequest(datapath, flags=0 port_no=4294967295 ,
, queue_id=4294967295 , type_=None)
Queue statistics request message
2.5. OpenFlow protocol API Reference 205
ryu Documentation, Release 3.21
The controller uses this message to query queue statictics.
Attribute Description flags Zero or OFPMPF_REQ_MORE port_no Port number to read queue_id ID of queue to read
Example:
def
send_queue_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPQueueStatsRequest(datapath, 0 , ofp .
OFPP_ANY, ofp .
OFPQ_ALL) datapath .
send_msg(req)
JSON Example:
{
"OFPQueueStatsRequest" : {
"flags" : 0 ,
"port_no" : 4294967295 ,
"queue_id" : 4294967295 ,
"type" : 5
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPQueueStatsReply(datapath,
**kwargs)
Queue statistics reply message
The switch responds with this message to an aggregate flow statistics request.
Attribute Description body List of OFPQueueStats instance
Example: type_=None
@set_ev_cls
(ofp_event .
EventOFPQueueStatsReply, MAIN_DISPATCHER)
def
queue_stats_reply_handler ( self , ev): queues = []
for
stat
in
ev .
msg .
body: queues .
append( 'port_no= %d queue_id= %d '
'tx_bytes= %d tx_packets= %d tx_errors= %d '
'duration_sec= %d duration_nsec= %d ' %
(stat .
port_no, stat .
queue_id, stat .
tx_bytes, stat .
tx_packets, stat .
tx_errors, stat .
duration_sec, stat .
duration_nsec, repr (stat .
properties))) self .
logger .
debug( 'QueueStats: %s ' , queues)
,
JSON Example:
{
"OFPQueueStatsReply" : {
"body" : [
{
"OFPQueueStats" : {
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
206 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
},
{
}
"OFPQueueStats" : {
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
"length" : 48 ,
"port_no" : 6 ,
"properties" : [],
"queue_id" : 1 ,
"tx_bytes" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 0
}
},
{
"length" : 104 ,
"port_no" : 7 ,
"properties" : [
{
"OFPQueueStatsPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPQueueStatsPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPQueueStatsPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
],
"queue_id" : 1 ,
"tx_bytes" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 0
"OFPQueueStats" : {
"duration_nsec" : 0 ,
"duration_sec" : 0 ,
"length" : 48 ,
"port_no" : 7 ,
"properties" : [],
"queue_id" : 2 ,
2.5. OpenFlow protocol API Reference 207
ryu Documentation, Release 3.21
"tx_bytes" : 0 ,
"tx_errors" : 0 ,
"tx_packets" : 0
}
}
],
"flags" : 0 ,
"type" : 5
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPQueueDescStatsRequest(datapath, flags=0 , port_no=4294967295 , queue_id=4294967295 , type_=None)
Queue description request message
The controller uses this message to query description of all the queues.
Attribute Description flags Zero or OFPMPF_REQ_MORE port_no Port number to read (OFPP_ANY for all ports) queue_id ID of queue to read (OFPQ_ALL for all queues)
Example:
def
send_tablet_desc_stats_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPQueueDescStatsRequest(datapath, 0 , ofp .
OFPP_ANY, ofp .
OFPQ_ALL) datapath .
send_msg(req)
JSON Example:
{
"OFPQueueDescStatsRequest" : {
"flags" : 0 ,
"port_no" : 7 ,
"queue_id" : 4294967295 ,
"type" : 15
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPQueueDescStatsReply(datapath, type_=None,
**kwargs)
Queue description reply message
The switch responds with this message to a queue description request.
Attribute Description body List of OFPQueueDescStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPQueueDescStatsReply, MAIN_DISPATCHER)
def
queue_desc_stats_reply_handler ( self , ev): queues = []
for
q
in
ev .
msg .
body: queues .
append( 'port_no= %d queue_id=0x %08x properties= %s ' %
208 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
(q .
port_no, q .
queue_id, repr (q .
properties))) self .
logger .
debug( 'OFPQueueDescStatsReply received: %s ' , queues)
JSON Example:
{
"OFPQueueDescStatsReply" : {
"body" : [
{
"OFPQueueDesc" : {
"len" : 32 ,
"port_no" : 7 ,
"properties" : [
{
"OFPQueueDescPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
}
],
"queue_id" : 0
}
},
{
"OFPQueueDesc" : {
"len" : 88 ,
"port_no" : 8 ,
"properties" : [
{
"OFPQueueDescPropMinRate" : {
"length" : 8 ,
"rate" : 300 ,
"type" : 1
}
},
{
"OFPQueueDescPropMaxRate" : {
"length" : 8 ,
"rate" : 900 ,
"type" : 2
}
},
{
"OFPQueueDescPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPQueueDescPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
2.5. OpenFlow protocol API Reference 209
ryu Documentation, Release 3.21
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPQueueDescPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
}
}
],
"flags" : 0 ,
"type" : 15
"length" : 20 ,
"type" : 65535
}
}
],
"queue_id" : 1
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPGroupStatsRequest(datapath, flags=0 , group_id=4294967292 , type_=None)
Group statistics request message
The controller uses this message to query statistics of one or more groups.
Attribute Description flags Zero or OFPMPF_REQ_MORE group_id ID of group to read (OFPG_ALL to all groups)
Example:
def
send_group_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGroupStatsRequest(datapath, 0 , ofp .
OFPG_ALL) datapath .
send_msg(req)
JSON Example:
{
"OFPGroupStatsRequest" : {
"flags" : 0 ,
"group_id" : 4294967292 ,
"type" : 6
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPGroupStatsReply(datapath,
**kwargs)
Group statistics reply message
The switch responds with this message to a group statistics request.
type_=None ,
210 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute Description body List of OFPGroupStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPGroupStatsReply, MAIN_DISPATCHER)
def
group_stats_reply_handler ( self , ev): groups = []
for
stat
in
ev .
msg .
body: groups .
append( 'length= %d group_id= %d '
'ref_count= %d packet_count= %d byte_count= %d '
'duration_sec= %d duration_nsec= %d ' %
(stat .
length, stat .
group_id, stat .
ref_count, stat .
packet_count, stat .
byte_count, stat .
duration_sec, stat .
duration_nsec)) self .
logger .
debug( 'GroupStats: %s ' , groups)
JSON Example:
{
"OFPGroupStatsReply" : {
"body" : [
{
"OFPGroupStats" : {
"bucket_stats" : [
{
"OFPBucketCounter" : {
"byte_count" : 2345 ,
"packet_count" : 234
}
}
}
],
"flags" : 0 ,
"type" : 6
}
],
"byte_count" : 12345 ,
"duration_nsec" : 609036000 ,
"duration_sec" : 9 ,
"group_id" : 1 ,
"length" : 56 ,
"packet_count" : 123 ,
"ref_count" : 2
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPGroupDescStatsRequest(datapath, flags=0 , type_=None)
Group description request message
The controller uses this message to list the set of groups on a switch.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_group_desc_stats_request ( self , datapath): ofp = datapath .
ofproto
2.5. OpenFlow protocol API Reference 211
ryu Documentation, Release 3.21
ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGroupDescStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPGroupDescStatsRequest" : {
"flags" : 0 ,
"type" : 7
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPGroupDescStatsReply(datapath, type_=None,
**kwargs)
Group description reply message
The switch responds with this message to a group description request.
Attribute Description body List of OFPGroupDescStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPGroupDescStatsReply, MAIN_DISPATCHER)
def
group_desc_stats_reply_handler ( self , ev): descs = []
for
stat
in
ev .
msg .
body: descs .
append( 'length= %d type= %d group_id= %d '
'buckets= %s ' %
(stat .
length, stat .
type, stat .
group_id, stat .
bucket)) self .
logger .
debug( 'GroupDescStats: %s ' , groups)
JSON Example:
{
"OFPGroupDescStatsReply" : {
"body" : [
{
"OFPGroupDescStats" : {
"buckets" : [
{
"OFPBucket" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 2 ,
"type" : 0
}
}
],
"len" : 32 ,
"watch_group" : 1 ,
"watch_port" : 1 ,
"weight" : 1
}
212 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
],
"flags" : 0 ,
"type" : 7
}
],
"group_id" : 1 ,
"length" : 40 ,
"type" : 0
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPGroupFeaturesStatsRequest(datapath, flags=0 , type_=None)
Group features request message
The controller uses this message to list the capabilities of groups on a switch.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_group_features_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGroupFeaturesStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPGroupFeaturesStatsRequest" : {
"flags" : 0 ,
"type" : 8
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPGroupFeaturesStatsReply(datapath, type_=None ,
**kwargs)
Group features reply message
The switch responds with this message to a group features request.
Attribute Description body Instance of OFPGroupFeaturesStats
Example:
@set_ev_cls
(ofp_event .
EventOFPGroupFeaturesStatsReply, MAIN_DISPATCHER)
def
group_features_stats_reply_handler ( self , ev): body = ev .
msg .
body self .
logger .
debug( 'GroupFeaturesStats: types= %d '
'capabilities=0x %08x max_groups= %s '
'actions= %s ' ,
2.5. OpenFlow protocol API Reference 213
ryu Documentation, Release 3.21
body .
types, body .
capabilities, body .
max_groups, body .
actions)
JSON Example:
{
"OFPGroupFeaturesStatsReply" : {
"body" : {
"OFPGroupFeaturesStats" : {
"actions" : [
67082241 ,
67082241 ,
67082241 ,
67082241
],
"capabilities" : 5 ,
"max_groups" : [
16777216 ,
16777216 ,
16777216 ,
16777216
],
"types" : 15
}
},
"flags" : 0 ,
"type" : 8
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPMeterStatsRequest(datapath, flags=0 , meter_id=4294967295 , type_=None)
Meter statistics request message
The controller uses this message to query statistics for one or more meters.
Attribute Description flags Zero or OFPMPF_REQ_MORE meter_id ID of meter to read (OFPM_ALL to all meters)
Example:
def
send_meter_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPMeterStatsRequest(datapath, 0 , ofp .
OFPM_ALL) datapath .
send_msg(req)
JSON Example:
{
"OFPMeterStatsRequest" : {
"flags" : 0 ,
"meter_id" : 4294967295 ,
"type" : 9
}
}
214 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_4_parser.OFPMeterStatsReply(datapath,
**kwargs)
Meter statistics reply message
The switch responds with this message to a meter statistics request.
Attribute Description body List of OFPMeterStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPMeterStatsReply, MAIN_DISPATCHER)
def
meter_stats_reply_handler ( self , ev): meters = []
for
stat
in
ev .
msg .
body: meters .
append( 'meter_id=0x %08x len= %d flow_count= %d '
'packet_in_count= %d byte_in_count= %d '
'duration_sec= %d duration_nsec= %d '
'band_stats= %s ' %
(stat .
meter_id, stat .
len, stat .
flow_count, stat .
packet_in_count, stat .
byte_in_count, stat .
duration_sec, stat .
duration_nsec, stat .
band_stats)) self .
logger .
debug( 'MeterStats: %s ' , meters) type_=None ,
JSON Example:
{
"OFPMeterStatsReply" : {
"body" : [
{
"OFPMeterStats" : {
"band_stats" : [
{
"OFPMeterBandStats" : {
"byte_band_count" : 0 ,
"packet_band_count" : 0
}
}
],
"byte_in_count" : 0 ,
"duration_nsec" : 480000 ,
"duration_sec" : 0 ,
}
}
],
"flags" : 0 ,
"type" : 9
"flow_count" : 0 ,
"len" : 56 ,
"meter_id" : 100 ,
"packet_in_count" : 0
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPMeterConfigStatsRequest(datapath, flags=0 , meter_id=4294967295 , type_=None)
Meter configuration statistics request message
2.5. OpenFlow protocol API Reference 215
ryu Documentation, Release 3.21
The controller uses this message to query configuration for one or more meters.
Attribute Description flags Zero or OFPMPF_REQ_MORE meter_id ID of meter to read (OFPM_ALL to all meters)
Example:
def
send_meter_config_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPMeterConfigStatsRequest(datapath, 0 , ofp .
OFPM_ALL) datapath .
send_msg(req)
JSON Example:
{
"OFPMeterConfigStatsRequest" : {
"flags" : 0 ,
"meter_id" : 4294967295 ,
"type" : 10
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPMeterConfigStatsReply(datapath, type_=None ,
**kwargs)
Meter configuration statistics reply message
The switch responds with this message to a meter configuration statistics request.
Attribute Description body List of OFPMeterConfigStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPMeterConfigStatsReply, MAIN_DISPATCHER)
def
meter_config_stats_reply_handler ( self , ev): configs = []
for
stat
in
ev .
msg .
body: configs .
append( 'length= %d flags=0x %04x meter_id=0x %08x '
'bands= %s ' %
(stat .
length, stat .
flags, stat .
meter_id, stat .
bands)) self .
logger .
debug( 'MeterConfigStats: %s ' , configs)
JSON Example:
{
"OFPMeterConfigStatsReply" : {
"body" : [
{
"OFPMeterConfigStats" : {
"bands" : [
{
"OFPMeterBandDrop" : {
"burst_size" : 10 ,
"len" : 16 ,
"rate" : 1000 ,
216 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"type" : 1
}
}
],
"flags" : 0 ,
"type" : 10
}
}
],
"flags" : 14 ,
"length" : 24 ,
"meter_id" : 100
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPMeterFeaturesStatsRequest(datapath, flags=0 , type_=None)
Meter features statistics request message
The controller uses this message to query the set of features of the metering subsystem.
Attribute Description flags Zero or OFPMPF_REQ_MORE
Example:
def
send_meter_features_stats_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPMeterFeaturesStatsRequest(datapath, 0 ) datapath .
send_msg(req)
JSON Example:
{
"OFPMeterFeaturesStatsRequest" : {
"flags" : 0 ,
"type" : 11
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPMeterFeaturesStatsReply(datapath, type_=None ,
**kwargs)
Meter features statistics reply message
The switch responds with this message to a meter features statistics request.
Attribute Description body List of OFPMeterFeaturesStats instance
Example:
@set_ev_cls
(ofp_event .
EventOFPMeterFeaturesStatsReply, MAIN_DISPATCHER)
def
meter_features_stats_reply_handler ( self , ev): features = []
for
stat
in
ev .
msg .
body: features .
append( 'max_meter= %d band_types=0x %08x '
'capabilities=0x %08x max_bands= %d '
'max_color= %d ' %
2.5. OpenFlow protocol API Reference 217
ryu Documentation, Release 3.21
(stat .
max_meter, stat .
band_types, stat .
capabilities, stat .
max_bands, stat .
max_color)) self .
logger .
debug( 'MeterFeaturesStats: %s ' , configs)
JSON Example:
{
"OFPMeterFeaturesStatsReply" : {
"body" : [
{
"OFPMeterFeaturesStats" : {
"band_types" : 2147483654 ,
"capabilities" : 15 ,
"max_bands" : 255 ,
"max_color" : 0 ,
"max_meter" : 16777216
}
}
],
"flags" : 0 ,
"type" : 11
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPFlowMonitorRequest(datapath, monitor_id=0
, flags=0 out_port=4294967295 ,
, out_group=4294967295 , monitor_flags=0 , table_id=255 , command=0 , match=None, type_=None)
Flow monitor request message
The controller uses this message to query flow monitors.
218 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Attribute flags monitor_id out_port out_group monitor_flags table_id command
Description
Zero or OFPMPF_REQ_MORE
Controller-assigned ID for this monitor
Require matching entries to include this as an output port
Require matching entries to include this as an output group
Bitmap of the following flags.
OFPFMF_INITIAL
OFPFMF_ADD
OFPFMF_REMOVED
OFPFMF_MODIFY
OFPFMF_INSTRUCTIONS
OFPFMF_NO_ABBREV
OFPFMF_ONLY_OWN
ID of table to monitor
One of the following values.
OFPFMC_ADD
OFPFMC_MODIFY
OFPFMC_DELETE match
Example:
Instance of OFPMatch
def
send_flow_stats_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser monitor_flags = [ofp .
OFPFMF_INITIAL, ofp .
OFPFMF_ONLY_OWN] match = ofp_parser .
OFPMatch(in_port = 1 ) req = ofp_parser .
OFPFlowMonitorRequest(datapath, 0 , 10000 , ofp .
OFPP_ANY, ofp .
OFPG_ANY, monitor_flags, ofp .
OFPTT_ALL, ofp .
OFPFMC_ADD, match) datapath .
send_msg(req)
JSON Example:
{
"OFPFlowMonitorRequest" : {
"command" : 0 ,
"flags" : 0 ,
"match" : {
"OFPMatch" : {
"length" : 14 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
2.5. OpenFlow protocol API Reference 219
ryu Documentation, Release 3.21
}
}
],
"type" : 1
}
},
"monitor_flags" : 15 ,
"monitor_id" : 100000000 ,
"out_group" : 4294967295 ,
"out_port" : 22 ,
"table_id" : 33 ,
"type" : 16
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPFlowMonitorReply(datapath,
**kwargs)
Flow monitor reply message
The switch responds with this message to a flow monitor request.
Attribute body type_=None
Description
List of list of the following class instance.
,
OFPFlowMonitorFull
OFPFlowMonitorAbbrev
OFPFlowMonitorPaused
Example:
@set_ev_cls(ofp_event.EventOFPFlowMonitorReply, MAIN_DISPATCHER) def flow_monitor_reply_handler(self, ev): msg = ev.msg
dp = msg.datapath
ofp = dp.ofproto
flow_updates = [] for update in msg.body: update_str = 'length=%d event=%d' %
(update.length, update.event) if (update.event == ofp.OFPFME_INITIAL or update.event == ofp.OFPFME_ADDED or update.event == ofp.OFPFME_REMOVED or update.event == ofp.OFPFME_MODIFIED): update_str += 'table_id=%d reason=%d idle_timeout=%d '
'hard_timeout=%d priority=%d cookie=%d '
'match=%d instructions=%s' %
(stat.table_id, stat.reason, stat.idle_timeout, stat.hard_timeout, stat.priority, stat.cookie, stat.match, stat.instructions) elif update.event == ofp.OFPFME_ABBREV: update_str += 'xid=%d' % (stat.xid) flow_updates.append(update_str) self.logger.debug('FlowUpdates: %s', flow_updates)
JSON Example:
220 Chapter 2. Writing Your Ryu Application
{
"OFPFlowMonitorReply" : {
"body" : [
{
"OFPFlowUpdateFull" : {
"cookie" : 0 ,
"event" : 0 ,
"hard_timeout" : 700 ,
"idle_timeout" : 600 ,
"instructions" : [
{
"OFPInstructionActions" : {
"actions" : [
{
"OFPActionOutput" : {
}
}
],
"len" : 24 ,
"type" : 4
"len" : 16 ,
"max_len" : 0 ,
"port" : 4294967290 ,
"type" : 0
}
}
],
"length" : 64 ,
"match" : {
"OFPMatch" : {
"length" : 10 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "eth_type" ,
"mask" : null,
"value" : 2054
}
}
],
"type" : 1
}
},
"priority" : 3 ,
"reason" : 0 ,
"table_id" : 0
}
},
{
"OFPFlowUpdateAbbrev" : {
"event" : 4 ,
"length" : 8 ,
"xid" : 1234
}
},
{
"OFPFlowUpdatePaused" : {
"event" : 5 ,
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
221
ryu Documentation, Release 3.21
"length" : 8
}
}
],
"flags" : 0 ,
"type" : 16
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPExperimenterStatsRequest(datapath, flags, experimenter , exp_type , data, type_=None)
Experimenter multipart request message
Attribute flags
Description
Zero or OFPMPF_REQ_MORE experimenter Experimenter ID exp_type data
Experimenter defined
Experimenter defined additional data
JSON Example:
{
"OFPExperimenterStatsRequest" : {
"data" : "aG9nZWhvZ2U=" ,
"exp_type" : 3405678728 ,
"experimenter" : 3735928495 ,
"flags" : 0 ,
"type" : 65535
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPExperimenterStatsReply(datapath, type_=None ,
**kwargs)
Experimenter multipart reply message
Attribute Description body An OFPExperimenterMultipart instance
JSON Example:
{
"OFPExperimenterStatsReply" : {
"body" : {
"OFPExperimenterMultipart" : {
"data" : "dGVzdGRhdGE5OTk5OTk5OQ==" ,
"exp_type" : 3405674359 ,
"experimenter" : 3735928495
}
},
"flags" : 0 ,
"type" : 65535
}
}
222 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
Packet-Out Message
class ryu.ofproto.ofproto_v1_4_parser.OFPPacketOut(datapath, in_port=None , data=None , actions_len=None)
Packet-Out message buffer_id=None , actions=None ,
The controller uses this message to send a packet out throught the switch.
Attribute Description buffer_id ID assigned by datapath (OFP_NO_BUFFER if none) in_port Packet’s input port or OFPP_CONTROLLER actions data list of OpenFlow action class
Packet data
Example:
def
send_packet_out ( self , datapath, buffer_id, in_port): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser actions = [ofp_parser .
OFPActionOutput(ofp .
OFPP_FLOOD, 0 )] req = ofp_parser .
OFPPacketOut(datapath, buffer_id, in_port, actions) datapath .
send_msg(req)
JSON Example:
{
"OFPPacketOut" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 4294967292 ,
"type" : 0
}
}
],
"actions_len" : 16 ,
"buffer_id" : 4294967295 ,
"data" : "8guk0D9w8gukffjqCABFAABU+BoAAP8Br4sKAAABCgAAAggAAgj3YAAAMdYCAAAAAACrjS0xAAAAABAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vAAAAAAAAAAA=" ,
"in_port" : 4294967293
}
}
Barrier Message
class ryu.ofproto.ofproto_v1_4_parser.OFPBarrierRequest(datapath)
Barrier request message
The controller sends this message to ensure message dependencies have been met or receive notifications for completed operations.
Example:
2.5. OpenFlow protocol API Reference 223
ryu Documentation, Release 3.21
def
send_barrier_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPBarrierRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPBarrierRequest" : {}
} class ryu.ofproto.ofproto_v1_4_parser.OFPBarrierReply(datapath)
Barrier reply message
The switch responds with this message to a barrier request.
Example:
@set_ev_cls
(ofp_event .
EventOFPBarrierReply, MAIN_DISPATCHER)
def
barrier_reply_handler ( self , ev): self .
logger .
debug( 'OFPBarrierReply received' )
JSON Example:
{
"OFPBarrierReply" : {}
}
Role Request Message
class ryu.ofproto.ofproto_v1_4_parser.OFPRoleRequest(datapath, role=None , generation_id=None)
Role request message
The controller uses this message to change its role.
Attribute role
Description
One of the following values.
OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
OFPCR_ROLE_SLAVE generation_id
Example:
def
send_role_request ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
Master Election Generation ID req = ofp_parser .
OFPRoleRequest(datapath, ofp .
OFPCR_ROLE_EQUAL, 0 ) datapath .
send_msg(req)
JSON Example:
224 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
{
"OFPRoleRequest" : {
"generation_id" : 17294086455919964160 ,
"role" : 2
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPRoleReply(datapath, role=None tion_id=None)
,
Role reply message
The switch responds with this message to a role request.
Attribute role
Description
One of the following values.
OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
OFPCR_ROLE_SLAVE generation_id
Example:
Master Election Generation ID
@set_ev_cls
(ofp_event .
EventOFPRoleReply, MAIN_DISPATCHER)
def
role_reply_handler ( self , ev): msg = ev .
msg ofp = dp .
ofproto
if
msg .
role == ofp .
OFPCR_ROLE_NOCHANGE: role = 'NOCHANGE'
elif
msg .
role == ofp .
OFPCR_ROLE_EQUAL: role = 'EQUAL'
elif
msg .
role == ofp .
OFPCR_ROLE_MASTER: role = 'MASTER'
elif
msg .
role == ofp .
OFPCR_ROLE_SLAVE: role = 'SLAVE'
else
: role = 'unknown' self .
logger .
debug( 'OFPRoleReply received: '
'role= %s generation_id= %d ' , role, msg .
generation_id)
JSON Example:
{
"OFPRoleReply" : {
"generation_id" : 17294086455919964160 ,
"role" : 3
}
} genera-
2.5. OpenFlow protocol API Reference 225
ryu Documentation, Release 3.21
Bundle Messages
class ryu.ofproto.ofproto_v1_4_parser.OFPBundleCtrlMsg(datapath, bundle_id , type_ , flags , properties)
Bundle control message
The controller uses this message to create, destroy and commit bundles
Attribute bundle_id type
Description
Id of the bundle
One of the following values.
OFPBCT_OPEN_REQUEST
OFPBCT_OPEN_REPLY
OFPBCT_CLOSE_REQUEST
OFPBCT_CLOSE_REPLY
OFPBCT_COMMIT_REQUEST
OFPBCT_COMMIT_REPLY
OFPBCT_DISCARD_REQUEST
OFPBCT_DISCARD_REPLY flags Bitmap of the following flags.
OFPBF_ATOMIC
OFPBF_ORDERED properties
Example:
def
send_bundle_control ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser
List of OFPBundleProp subclass instance req = ofp_parser .
OFPBundleCtrlMsg(datapath, 7 , ofp .
OFPBCT_OPEN_REQUEST,
[ofp .
OFPBF_ATOMIC], []) datapath .
send_msg(req)
JSON Example:
{
"OFPBundleCtrlMsg" : {
"bundle_id" : 1234 ,
"flags" : 1 ,
"properties" : [
{
"OFPBundlePropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPBundlePropExperimenter" : {
226 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPBundlePropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
}
}
],
"type" : 0
"length" : 20 ,
"type" : 65535
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPBundleAddMsg(datapath, bundle_id, flags, message , properties)
Bundle control message
The controller uses this message to create, destroy and commit bundles
Attribute bundle_id flags
Description
Id of the bundle
Bitmap of the following flags.
OFPBF_ATOMIC
OFPBF_ORDERED message properties
Example:
MsgBase subclass instance
List of OFPBundleProp subclass instance
def
send_bundle_add_message ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser msg = ofp_parser .
OFPRoleRequest(datapath, ofp .
OFPCR_ROLE_EQUAL, 0 ) req = ofp_parser .
OFPBundleAddMsg(datapath, 7 , [ofp .
OFPBF_ATOMIC], msg, []) datapath .
send_msg(req)
JSON Example:
{
"OFPBundleAddMsg" : {
"bundle_id" : 1234 ,
"flags" : 1 ,
"message" : {
"OFPEchoRequest" : {
"data" : null
}
2.5. OpenFlow protocol API Reference 227
ryu Documentation, Release 3.21
}
}
},
"properties" : [
{
"OFPBundlePropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPBundlePropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPBundlePropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
]
Set Asynchronous Configuration Message
class ryu.ofproto.ofproto_v1_4_parser.OFPSetAsync(datapath, properties=None)
Set asynchronous configuration message
The controller sends this message to set the asynchronous messages that it wants to receive on a given OpneFlow channel.
Attribute Description properties List of OFPAsyncConfigProp subclass instances
Example:
def
send_set_async ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser properties = [ofp_parser .
OFPAsyncConfigPropReasons(
8 , ofp_parser .
OFPACPT_PACKET_IN_SLAVE,
(ofp_parser .
OFPR_APPLY_ACTION | ofp_parser .
OFPR_INVALID_TTL)), ofp_parser .
OFPAsyncConfigPropExperimenter( ofproto .
OFPTFPT_EXPERIMENTER_MASTER,
16 , 100 , 2 , bytearray ())]
228 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
req = ofp_parser .
OFPSetAsync(datapath, properties) datapath .
send_msg(req)
JSON Example:
{
"OFPSetAsync" : {
"properties" : [
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 0
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 1
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 2
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 3
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 4
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 5
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 6
}
},
{
2.5. OpenFlow protocol API Reference 229
ryu Documentation, Release 3.21
230
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 7
}
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 24 ,
"type" : 8
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 24 ,
"type" : 9
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 10
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 11
}
},
{
"OFPAsyncConfigPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65534
}
},
{
"OFPAsyncConfigPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPAsyncConfigPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"type" : 65535
}
}
}
]
} class ryu.ofproto.ofproto_v1_4_parser.OFPGetAsyncRequest(datapath)
Get asynchronous configuration request message
The controller uses this message to query the asynchronous message.
Example:
def
send_get_async_request ( self , datapath): ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPGetAsyncRequest(datapath) datapath .
send_msg(req)
JSON Example:
{
"OFPGetAsyncRequest" : {}
} class ryu.ofproto.ofproto_v1_4_parser.OFPGetAsyncReply(datapath, properties=None)
Get asynchronous configuration reply message
The switch responds with this message to a get asynchronous configuration request.
Attribute Description properties List of OFPAsyncConfigProp subclass instances
Example:
@set_ev_cls
(ofp_event .
EventOFPGetAsyncReply, MAIN_DISPATCHER)
def
get_async_reply_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPGetAsyncReply received: '
'properties= %s ' , repr (msg .
properties))
JSON Example:
{
"OFPGetAsyncReply" : {
"properties" : [
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 0
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 1
}
2.5. OpenFlow protocol API Reference 231
ryu Documentation, Release 3.21
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 2
}
},
{
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 3
}
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 4
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 5
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 6
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 7
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 24 ,
"type" : 8
}
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 24 ,
"type" : 9
}
},
{
232 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
]
},
{
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 10
}
"OFPAsyncConfigPropReasons" : {
"length" : 8 ,
"mask" : 3 ,
"type" : 11
}
},
{
"OFPAsyncConfigPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65534
}
},
{
"OFPAsyncConfigPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPAsyncConfigPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
Asynchronous Messages
Packet-In Message
class ryu.ofproto.ofproto_v1_4_parser.OFPPacketIn(datapath, tal_len=None , buffer_id=None , toreason=None , table_id=None , cookie=None , match=None , data=None)
Packet-In message
The switch sends the packet that received to the controller by this message.
2.5. OpenFlow protocol API Reference 233
ryu Documentation, Release 3.21
Attribute buffer_id total_len reason
Description
ID assigned by datapath
Full length of frame
Reason packet is being sent.
OFPR_TABLE_MISS
OFPR_APPLY_ACTION
OFPR_INVALID_TTL
OFPR_ACTION_SET
OFPR_GROUP
OFPR_PACKET_OUT table_id cookie match data
Example:
ID of the table that was looked up
Cookie of the flow entry that was looked up
Instance of OFPMatch
Ethernet frame
@set_ev_cls
(ofp_event .
EventOFPPacketIn, MAIN_DISPATCHER)
def
packet_in_handler ( self , ev): msg = ev .
msg ofp = dp .
ofproto
if
msg .
reason == ofp .
TABLE_MISS: reason = 'TABLE MISS'
elif
msg .
reason == ofp .
OFPR_APPLY_ACTION: reason = 'APPLY ACTION'
elif
msg .
reason == ofp .
OFPR_INVALID_TTL: reason = 'INVALID TTL'
elif
msg .
reason == ofp .
OFPR_ACTION_SET: reason = 'ACTION SET'
elif
msg .
reason == ofp .
OFPR_GROUP: reason = 'GROUP'
elif
msg .
reason == ofp .
OFPR_PACKET_OUT: reason = 'PACKET OUT'
else
: reason = 'unknown' self .
logger .
debug( 'OFPPacketIn received: '
'buffer_id= %x total_len= %d reason= %s '
'table_id= %d cookie= %d match= %s data= %s ' , msg .
buffer_id, msg .
total_len, reason, msg .
table_id, msg .
cookie, msg .
match, utils .
hex_array(msg .
data))
JSON Example:
{
"OFPPacketIn" : {
"buffer_id" : 2 ,
"cookie" : 283686884868096 ,
"data" : "////////8gukffjqCAYAAQgABgQAAfILpH346goAAAEAAAAAAAAKAAAD" ,
"match" : {
"OFPMatch" : {
"length" : 80 ,
"oxm_fields" : [
234 Chapter 2. Writing Your Ryu Application
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 6
}
},
{
"OXMTlv" : {
"field" : "eth_type" ,
"mask" : null,
"value" : 2054
}
},
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "ff:ff:ff:ff:ff:ff"
}
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
"OXMTlv" : {
"field" : "arp_op" ,
"mask" : null,
"value" : 1
}
},
{
"OXMTlv" : {
"field" : "arp_spa" ,
"mask" : null,
"value" : "10.0.0.1"
}
},
{
"OXMTlv" : {
"field" : "arp_tpa" ,
"mask" : null,
"value" : "10.0.0.3"
}
},
{
"OXMTlv" : {
"field" : "arp_sha" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
"OXMTlv" : {
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
235
ryu Documentation, Release 3.21
236
}
}
}
}
],
"type" : 1
}
},
"reason" : 3 ,
"table_id" : 1 ,
"total_len" : 42
"field" : "arp_tha" ,
"mask" : null,
"value" : "00:00:00:00:00:00"
{
"OFPPacketIn" : {
"buffer_id" : 4026531840 ,
"cookie" : 283686884868096 ,
"data" : "" ,
"match" : {
"OFPMatch" : {
"length" : 329 ,
"oxm_fields" : [
{
"OXMTlv" : {
"field" : "in_port" ,
"mask" : null,
"value" : 84281096
}
},
{
"OXMTlv" : {
"field" : "in_phy_port" ,
"mask" : null,
"value" : 16909060
}
},
{
"OXMTlv" : {
"field" : "metadata" ,
"mask" : null,
"value" : 283686952306183
}
},
{
"OXMTlv" : {
"field" : "eth_type" ,
"mask" : null,
"value" : 2054
}
},
{
"OXMTlv" : {
"field" : "eth_dst" ,
"mask" : null,
"value" : "ff:ff:ff:ff:ff:ff"
}
Chapter 2. Writing Your Ryu Application
},
{
"OXMTlv" : {
"field" : "eth_src" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
},
{
"OXMTlv" : {
"field" : "vlan_vid" ,
"mask" : null,
"value" : 999
}
"OXMTlv" : {
"field" : "ip_dscp" ,
"mask" : null,
"value" : 9
}
},
{
"OXMTlv" : {
"field" : "ip_ecn" ,
"mask" : null,
"value" : 3
}
},
{
"OXMTlv" : {
"field" : "ip_proto" ,
"mask" : null,
"value" : 99
}
},
{
"OXMTlv" : {
"field" : "ipv4_src" ,
"mask" : null,
"value" : "1.2.3.4"
}
},
{
"OXMTlv" : {
"field" : "ipv4_dst" ,
"mask" : null,
"value" : "1.2.3.4"
}
},
{
"OXMTlv" : {
"field" : "tcp_src" ,
"mask" : null,
"value" : 8080
}
},
{
2.5. OpenFlow protocol API Reference ryu Documentation, Release 3.21
237
ryu Documentation, Release 3.21
},
{
"OXMTlv" : {
"field" : "tcp_dst" ,
"mask" : null,
"value" : 18080
}
"OXMTlv" : {
"field" : "udp_src" ,
"mask" : null,
"value" : 28080
}
},
{
"OXMTlv" : {
"field" : "udp_dst" ,
"mask" : null,
"value" : 55936
}
},
{
"OXMTlv" : {
"field" : "sctp_src" ,
"mask" : null,
"value" : 48080
}
},
{
"OXMTlv" : {
"field" : "sctp_dst" ,
"mask" : null,
"value" : 59328
}
},
{
"OXMTlv" : {
"field" : "icmpv4_type" ,
"mask" : null,
"value" : 100
}
},
{
"OXMTlv" : {
"field" : "icmpv4_code" ,
"mask" : null,
"value" : 101
}
},
{
"OXMTlv" : {
"field" : "arp_op" ,
"mask" : null,
"value" : 1
}
},
{
"OXMTlv" : {
"field" : "arp_spa" ,
238 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
"mask" : null,
"value" : "10.0.0.1"
}
},
{
"OXMTlv" : {
"field" : "arp_tpa" ,
"mask" : null,
"value" : "10.0.0.3"
}
},
{
"OXMTlv" : {
"field" : "arp_sha" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
{
"OXMTlv" : {
"field" : "arp_tha" ,
"mask" : null,
"value" : "00:00:00:00:00:00"
}
},
{
"OXMTlv" : {
"field" : "ipv6_src" ,
"mask" : null,
"value" : "fe80::f00b:a4ff:fe48:28a5"
}
},
{
"OXMTlv" : {
"field" : "ipv6_dst" ,
"mask" : null,
"value" : "fe80::f00b:a4ff:fe05:b7dc"
}
},
{
"OXMTlv" : {
"field" : "ipv6_flabel" ,
"mask" : null,
"value" : 541473
}
},
{
"OXMTlv" : {
"field" : "icmpv6_type" ,
"mask" : null,
"value" : 200
}
},
{
"OXMTlv" : {
"field" : "icmpv6_code" ,
"mask" : null,
"value" : 201
2.5. OpenFlow protocol API Reference 239
ryu Documentation, Release 3.21
240
}
},
{
"OXMTlv" : {
"field" : "ipv6_nd_target" ,
"mask" : null,
"value" : "fe80::a60:6eff:fe7f:74e7"
}
},
{
"OXMTlv" : {
"field" : "ipv6_nd_sll" ,
"mask" : null,
"value" : "00:00:00:00:02:9a"
}
},
{
"OXMTlv" : {
"field" : "ipv6_nd_tll" ,
"mask" : null,
"value" : "00:00:00:00:02:2b"
}
},
{
},
{
"OXMTlv" : {
"field" : "mpls_label" ,
"mask" : null,
"value" : 624485
}
"OXMTlv" : {
"field" : "mpls_tc" ,
"mask" : null,
"value" : 5
}
},
{
"OXMTlv" : {
"field" : "mpls_bos" ,
"mask" : null,
"value" : 1
}
},
{
"OXMTlv" : {
"field" : "pbb_isid" ,
"mask" : null,
"value" : 11259375
}
},
{
"OXMTlv" : {
"field" : "tunnel_id" ,
"mask" : null,
"value" : 651061555542690057
}
},
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
{
"OXMTlv" : {
"field" : "ipv6_exthdr" ,
"mask" : null,
"value" : 500
}
},
{
"OXMTlv" : {
"field" : "pbb_uca" ,
"mask" : null,
"value" : 1
}
}
],
"type" : 1
}
},
"reason" : 0 ,
"table_id" : 200 ,
"total_len" : 0
Flow Removed Message
class ryu.ofproto.ofproto_v1_4_parser.OFPFlowRemoved(datapath, cookie=None , priority=None , reason=None , table_id=None , duration_sec=None, duration_nsec=None , idle_timeout=None , hard_timeout=None , packet_count=None
, byte_count=None
, match=None)
Flow removed message
When flow entries time out or are deleted, the switch notifies controller with this message.
2.5. OpenFlow protocol API Reference 241
ryu Documentation, Release 3.21
242
Attribute cookie priority reason
Description
Opaque controller-issued identifier
Priority level of flow entry
One of the following values.
OFPRR_IDLE_TIMEOUT
OFPRR_HARD_TIMEOUT
OFPRR_DELETE
OFPRR_GROUP_DELETE
OFPRR_METER_DELETE
OFPRR_EVICTION table_id duration_sec duration_nsec idle_timeout hard_timeout packet_count byte_count match
Example:
ID of the table
Time flow was alive in seconds
Time flow was alive in nanoseconds beyond duration_sec
Idle timeout from original flow mod
Hard timeout from original flow mod
Number of packets that was associated with the flow
Number of bytes that was associated with the flow
Instance of OFPMatch
@set_ev_cls
(ofp_event .
EventOFPFlowRemoved, MAIN_DISPATCHER)
def
flow_removed_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto
if
msg .
reason == ofp .
OFPRR_IDLE_TIMEOUT: reason = 'IDLE TIMEOUT'
elif
msg .
reason == ofp .
OFPRR_HARD_TIMEOUT: reason = 'HARD TIMEOUT'
elif
msg .
reason == ofp .
OFPRR_DELETE: reason = 'DELETE'
elif
msg .
reason == ofp .
OFPRR_GROUP_DELETE: reason = 'GROUP DELETE'
else
: reason = 'unknown' self .
logger .
debug( 'OFPFlowRemoved received: '
'cookie= %d priority= %d reason= %s table_id= %d '
'duration_sec= %d duration_nsec= %d '
'idle_timeout= %d hard_timeout= %d '
'packet_count= %d byte_count= %d match.fields= %s ' , msg .
cookie, msg .
priority, reason, msg .
table_id, msg .
duration_sec, msg .
duration_nsec, msg .
idle_timeout, msg .
hard_timeout, msg .
packet_count, msg .
byte_count, msg .
match)
JSON Example:
{
"OFPFlowRemoved" : {
"byte_count" : 86 ,
"cookie" : 0 ,
Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
"duration_nsec" : 48825000 ,
"duration_sec" : 3 ,
"hard_timeout" : 0 ,
"idle_timeout" : 3 ,
"match" : {
"OFPMatch" : {
"length" : 14 ,
"oxm_fields" : [
{
"OXMTlv" : {
}
}
],
"type" : 1
"field" : "eth_dst" ,
"mask" : null,
"value" : "f2:0b:a4:7d:f8:ea"
}
},
"packet_count" : 1 ,
"priority" : 65535 ,
"reason" : 0 ,
"table_id" : 0
Port Status Message
class ryu.ofproto.ofproto_v1_4_parser.OFPPortStatus(datapath, desc=None)
Port status message
The switch notifies controller of change of ports.
Attribute reason
Description
One of the following values.
OFPPR_ADD
OFPPR_DELETE
OFPPR_MODIFY desc
Example: instance of OFPPort
@set_ev_cls
(ofp_event .
EventOFPPortStatus, MAIN_DISPATCHER)
def
port_status_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto
if
msg .
reason == ofp .
OFPPR_ADD: reason = 'ADD'
elif
msg .
reason == ofp .
OFPPR_DELETE: reason = 'DELETE'
elif
msg .
reason == ofp .
OFPPR_MODIFY: reason = 'MODIFY' reason=None ,
2.5. OpenFlow protocol API Reference 243
ryu Documentation, Release 3.21
else
: reason = 'unknown' self .
logger .
debug( 'OFPPortStatus received: reason= %s desc= %s ' , reason, msg .
desc)
JSON Example:
{
"OFPPortStatus" : {
"desc" : {
"OFPPort" : {
"config" : 0 ,
"hw_addr" : "f2:0b:a4:d0:3f:70" ,
"length" : 168 ,
"name" : "\u79c1\u306e\u30dd\u30fc\u30c8" ,
"port_no" : 7 ,
"properties" : [
{
"OFPPortDescPropEthernet" : {
"advertised" : 10240 ,
"curr" : 10248 ,
"curr_speed" : 5000 ,
"length" : 32 ,
"max_speed" : 5000 ,
"peer" : 10248 ,
"supported" : 10248 ,
"type" : 0
}
},
{
"OFPPortDescPropOptical" : {
"length" : 40 ,
"rx_grid_freq_lmda" : 1500 ,
"rx_max_freq_lmda" : 2000 ,
"rx_min_freq_lmda" : 1000 ,
"supported" : 1 ,
"tx_grid_freq_lmda" : 1500 ,
"tx_max_freq_lmda" : 2000 ,
"tx_min_freq_lmda" : 1000 ,
"tx_pwr_max" : 2000 ,
"tx_pwr_min" : 1000 ,
"type" : 1
}
},
{
"OFPPortDescPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPPortDescPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
244 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPPortDescPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
],
"state" : 4
}
},
"reason" : 0
Controller Role Status Message
class ryu.ofproto.ofproto_v1_4_parser.OFPRoleStatus(datapath, role=None, reason=None, generation_id=None , properties=None)
Role status message
The switch notifies controller of change of role.
Attribute role
Description
One of the following values.
OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER reason One of the following values.
OFPCRR_MASTER_REQUEST
OFPCRR_CONFIG
OFPCRR_EXPERIMENTER generation_id properties
Example:
Master Election Generation ID
List of OFPRoleProp subclass instance
@set_ev_cls
(ofp_event .
EventOFPRoleStatus, MAIN_DISPATCHER)
def
role_status_handler ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto
if
msg .
role == ofp .
OFPCR_ROLE_NOCHANGE:
2.5. OpenFlow protocol API Reference 245
ryu Documentation, Release 3.21
role = 'ROLE NOCHANGE'
elif
msg .
role == ofp .
OFPCR_ROLE_EQUAL: role = 'ROLE EQUAL'
elif
msg .
role == ofp .
OFPCR_ROLE_MASTER: role = 'ROLE MASTER'
else
: role = 'unknown'
if
msg .
reason == ofp .
OFPCRR_MASTER_REQUEST: reason = 'MASTER REQUEST'
elif
msg .
reason == ofp .
OFPCRR_CONFIG: reason = 'CONFIG'
elif
msg .
reason == ofp .
OFPCRR_EXPERIMENTER: reason = 'EXPERIMENTER'
else
: reason = 'unknown' self .
logger .
debug( 'OFPRoleStatus received: role= %s reason= %s '
'generation_id= %d properties= %s ' , role, reason, msg .
generation_id, repr (msg .
properties))
JSON Example:
{
"OFPRoleStatus" : {
"generation_id" : 7 ,
"properties" : [
{
"OFPRolePropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPRolePropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPRolePropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
],
"reason" : 0 ,
"role" : 2
}
246 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
Table Status Message
class ryu.ofproto.ofproto_v1_4_parser.OFPTableStatus(datapath, reason=None , table=None)
Table status message
The switch notifies controller of change of table status.
Attribute reason
Description
One of the following values.
OFPTR_VACANCY_DOWN
OFPTR_VACANCY_UP table
Example:
OFPTableDesc instance
@set_ev_cls
(ofp_event .
EventOFPTableStatus, MAIN_DISPATCHER)
def
table ( self , ev): msg = ev .
msg dp = msg .
datapath ofp = dp .
ofproto
if
msg .
reason == ofp .
OFPTR_VACANCY_DOWN: reason = 'VACANCY_DOWN'
elif
msg .
reason == ofp .
OFPTR_VACANCY_UP: reason = 'VACANCY_UP'
else
: reason = 'unknown' self .
logger .
debug( 'OFPTableStatus received: reason= %s '
'table_id= %d config=0x %08x properties= %s ' , reason, msg .
table .
table_id, msg .
table .
config, repr (msg .
table .
properties))
JSON Example:
{
"OFPTableStatus" : {
"reason" : 3 ,
"table" : {
"OFPTableDesc" : {
"config" : 0 ,
"length" : 80 ,
"properties" : [
{
"OFPTableModPropEviction" : {
"flags" : 0 ,
"length" : 8 ,
"type" : 2
}
},
{
"OFPTableModPropVacancy" : {
"length" : 8 ,
2.5. OpenFlow protocol API Reference 247
ryu Documentation, Release 3.21
}
}
}
}
"type" : 3 ,
"vacancy" : 0 ,
"vacancy_down" : 0 ,
"vacancy_up" : 0
}
},
{
"OFPTableModPropExperimenter" : {
"data" : "" ,
"exp_type" : 0 ,
"experimenter" : 101 ,
"length" : 12 ,
"type" : 65535
}
},
{
"OFPTableModPropExperimenter" : {
"data" : "AAAAAQ==" ,
"exp_type" : 1 ,
"experimenter" : 101 ,
"length" : 16 ,
"type" : 65535
}
},
{
"OFPTableModPropExperimenter" : {
"data" : "AAAAAQAAAAI=" ,
"exp_type" : 2 ,
"experimenter" : 101 ,
"length" : 20 ,
"type" : 65535
}
}
],
"table_id" : 8
Request Forward Message
class ryu.ofproto.ofproto_v1_4_parser.OFPRequestForward(datapath, request)
Forwarded request message
The swtich forwards request messages from one controller to other controllers.
Attribute Description request
OFPGroupMod or OFPMeterMod instance
Example:
def
send_bundle_add_message ( self , datapath): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser port = 1 max_len = 2000
248 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
actions = [ofp_parser .
OFPActionOutput(port, max_len)] weight = 100 watch_port = 0 watch_group = 0 buckets = [ofp_parser .
OFPBucket(weight, watch_port, watch_group, actions)] group_id = 1 msg = ofp_parser .
OFPGroupMod(datapath, ofp .
OFPGC_ADD, ofp .
OFPGT_SELECT, group_id, buckets) req = ofp_parser .
OFPRequestForward(datapath, msg) datapath .
send_msg(req)
JSON Example:
{
"OFPRequestForward" : {
"request" : {
"OFPGroupMod" : {
"buckets" : [
{
"OFPBucket" : {
"actions" : [
{
"OFPActionOutput" : {
"len" : 16 ,
"max_len" : 65535 ,
"port" : 2 ,
"type" : 0
}
}
],
"len" : 32 ,
"watch_group" : 1 ,
"watch_port" : 1 ,
"weight" : 1
}
}
],
"command" : 0 ,
"group_id" : 1 ,
"type" : 0
}
}
}
}
Symmetric Messages
Hello
class ryu.ofproto.ofproto_v1_4_parser.OFPHello(datapath, elements=[])
Hello message
When connection is started, the hello message is exchanged between a switch and a controller.
2.5. OpenFlow protocol API Reference 249
ryu Documentation, Release 3.21
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Attribute Description elements list of OFPHelloElemVersionBitmap instance
JSON Example:
{
"OFPHello" : {
"elements" : [
{
"OFPHelloElemVersionBitmap" : {
"length" : 8 ,
"type" : 1 ,
"versions" : [
1 ,
2 ,
3 ,
9 ,
10 ,
30
]
}
}
]
}
} class ryu.ofproto.ofproto_v1_4_parser.OFPHelloElemVersionBitmap(versions, type_=None , length=None)
Version bitmap Hello Element
Attribute Description versions list of versions of OpenFlow protocol a device supports
Echo Request
class ryu.ofproto.ofproto_v1_4_parser.OFPEchoRequest(datapath, data=None)
Echo request message
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Attribute Description data An arbitrary length data
Example:
def
send_echo_request ( self , datapath, data): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser req = ofp_parser .
OFPEchoRequest(datapath, data) datapath .
send_msg(req)
@set_ev_cls
(ofp_event .
EventOFPEchoRequest,
[HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def
echo_request_handler ( self , ev):
250 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
self .
logger .
debug( 'OFPEchoRequest received: data= %s ' , utils .
hex_array(ev .
msg .
data))
JSON Example:
{
"OFPEchoRequest" : {
"data" : "aG9nZQ=="
}
}
Echo Reply
class ryu.ofproto.ofproto_v1_4_parser.OFPEchoReply(datapath, data=None)
Echo reply message
This message is handled by the Ryu framework, so the Ryu application do not need to process this typically.
Attribute Description data An arbitrary length data
Example:
def
send_echo_reply ( self , datapath, data): ofp = datapath .
ofproto ofp_parser = datapath .
ofproto_parser reply = ofp_parser .
OFPEchoReply(datapath, data) datapath .
send_msg(reply)
@set_ev_cls
(ofp_event .
EventOFPEchoReply,
[HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def
echo_reply_handler ( self , ev): self .
logger .
debug( 'OFPEchoReply received: data= %s ' , utils .
hex_array(ev .
msg .
data))
JSON Example:
{
"OFPEchoReply" : {
"data" : "aG9nZQ=="
}
}
Error Message
class ryu.ofproto.ofproto_v1_4_parser.OFPErrorMsg(datapath, type_=None , code=None , data=None)
Error message
The switch notifies controller of problems by this message.
Attribute Description type High level type of error code data
Details depending on the type
Variable length data depending on the type and code type attribute corresponds to type_ parameter of __init__.
2.5. OpenFlow protocol API Reference 251
ryu Documentation, Release 3.21
Types and codes are defined in ryu.ofproto.ofproto.
Type
OFPET_HELLO_FAILED
OFPET_BAD_REQUEST
OFPET_BAD_ACTION
OFPET_BAD_INSTRUCTION
OFPET_BAD_MATCH
OFPET_FLOW_MOD_FAILED
OFPET_GROUP_MOD_FAILED
Code
OFPHFC_*
OFPBRC_*
OFPBAC_*
OFPBIC_*
OFPBMC_*
OFPFMFC_*
OFPGMFC_*
OFPET_PORT_MOD_FAILED
OFPET_TABLE_MOD_FAILED
OFPET_QUEUE_OP_FAILED
OFPET_SWITCH_CONFIG_FAILED
OFPET_ROLE_REQUEST_FAILED
OFPPMFC_*
OFPTMFC_*
OFPQOFC_*
OFPSCFC_*
OFPRRFC_*
OFPET_METER_MOD_FAILED OFPMMFC_*
OFPET_TABLE_FEATURES_FAILED OFPTFFC_*
OFPET_EXPERIMENTER N/A
Example:
@set_ev_cls
(ofp_event .
EventOFPErrorMsg,
[HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def
error_msg_handler ( self , ev): msg = ev .
msg self .
logger .
debug( 'OFPErrorMsg received: type=0x %02x code=0x %02x '
'message= %s ' , msg .
type, msg .
code, utils .
hex_array(msg .
data))
JSON Example:
{
"OFPErrorMsg" : {
"code" : 11 ,
"data" : "ZnVnYWZ1Z2E=" ,
"type" : 2
}
}
Experimenter
class ryu.ofproto.ofproto_v1_4_parser.OFPExperimenter(datapath, experimenter=None , exp_type=None , data=None)
Experimenter extension message
Attribute Description experimenter Experimenter ID exp_type Experimenter defined data Experimenter defined arbitrary additional data
JSON Example:
{
"OFPExperimenter" : {
"data" : "bmF6bw==" ,
"exp_type" : 123456789 ,
252 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
}
}
"experimenter" : 98765432
Flow Match Structure
class ryu.ofproto.ofproto_v1_4_parser.OFPMatch(type_=None, length=None dered_fields=None , **kwargs)
,
Flow Match Structure
This class is implementation of the flow match structure having compose/query API.
You can define the flow match by the keyword arguments. The following arguments are available.
_or-
Argument in_port in_phy_port metadata eth_dst eth_src eth_type vlan_vid vlan_pcp ip_dscp ip_ecn ip_proto ipv4_src ipv4_dst tcp_src tcp_dst
Value Description
Integer 32bit Switch input port
Integer 32bit Switch physical input port
Integer 64bit Metadata passed between tables
MAC address Ethernet destination address
MAC address Ethernet source address
Integer 16bit Ethernet frame type
Integer 16bit VLAN id
Integer 8bit VLAN priority
Integer 8bit
Integer 8bit
IP DSCP (6 bits in ToS field)
IP ECN (2 bits in ToS field)
Integer 8bit IP protocol
IPv4 address IPv4 source address
IPv4 address IPv4 destination address
Integer 16bit TCP source port
Integer 16bit TCP destination port udp_src udp_dst sctp_src sctp_dst icmpv4_type icmpv4_code arp_op arp_spa
Integer 16bit UDP source port
Integer 16bit UDP destination port
Integer 16bit SCTP source port
Integer 16bit SCTP destination port
Integer 8bit
Integer 8bit
ICMP type
ICMP code
Integer 16bit ARP opcode
IPv4 address ARP source IPv4 address arp_tpa arp_sha arp_tha ipv6_src
IPv4 address ARP target IPv4 address
MAC address ARP source hardware address
MAC address ARP target hardware address
IPv6 address IPv6 source address ipv6_dst ipv6_flabel icmpv6_type icmpv6_code
IPv6 address
Integer 32bit
Integer 8bit
Integer 8bit
IPv6 destination address
IPv6 Flow Label
ICMPv6 type
ICMPv6 code ipv6_nd_target IPv6 address Target address for ND ipv6_nd_sll ipv6_nd_tll mpls_label mpls_tc mpls_bos
MAC address Source link-layer for ND
MAC address Target link-layer for ND
Integer 32bit MPLS label
Integer 8bit MPLS TC
Integer 8bit MPLS BoS bit
Continued on next page
2.5. OpenFlow protocol API Reference 253
ryu Documentation, Release 3.21
Argument pbb_isid tunnel_id ipv6_exthdr pbb_uca
Table 2.3 – continued from previous page
Value Description
Integer 24bit PBB I-SID
Integer 64bit Logical Port Metadata
Integer 16bit IPv6 Extension Header pseudo-field
Integer 8bit PBB UCA header field
Example:
>>>
# compose
>>>
match = parser .
OFPMatch(
...
...
in_port = eth_type
1
=
,
0x86dd ,
...
...
...
ipv6_src = ( '2001:db8:bd05:1d2:288a:1fc0:1:10ee' ,
'ffff:ffff:ffff:ffff::' ), ipv6_dst = '2001:db8:bd05:1d2:288a:1fc0:1:10ee' )
>>>
# query
>>> if
'ipv6_src'
in
match:
...
...
match[ 'ipv6_src' ]
('2001:db8:bd05:1d2:288a:1fc0:1:10ee', 'ffff:ffff:ffff:ffff::')
254
Note: For VLAN id match field, special values are defined in OpenFlow Spec.
1.Packets with and without a VLAN tag
•Example: match = parser .
OFPMatch()
•Packet Matching non-VLAN-tagged MATCH
VLAN-tagged(vlan_id=3) MATCH
VLAN-tagged(vlan_id=5) MATCH
2.Only packets without a VLAN tag
•Example: match = parser .
OFPMatch(vlan_vid = 0x0000 )
•Packet Matching non-VLAN-tagged MATCH
VLAN-tagged(vlan_id=3) x
VLAN-tagged(vlan_id=5) x
3.Only packets with a VLAN tag regardless of its value
•Example: match = parser .
OFPMatch(vlan_vid = ( 0x1000 , 0x1000 ))
•Packet Matching non-VLAN-tagged x
VLAN-tagged(vlan_id=3) MATCH
VLAN-tagged(vlan_id=5) MATCH
Chapter 2. Writing Your Ryu Application
4.Only packets with VLAN tag and VID equal
•Example: match = parser .
OFPMatch(vlan_vid = ( 0x1000 | 3 ))
•Packet Matching non-VLAN-tagged x
VLAN-tagged(vlan_id=3) MATCH
VLAN-tagged(vlan_id=5) x
ryu Documentation, Release 3.21
Flow Instruction Structures
class ryu.ofproto.ofproto_v1_4_parser.OFPInstructionGotoTable(table_id, type_=None , len_=None)
Goto table instruction
This instruction indicates the next table in the processing pipeline.
Attribute Description table_id Next table class ryu.ofproto.ofproto_v1_4_parser.OFPInstructionWriteMetadata(metadata, metadata_mask
, type_=None , len_=None)
Write metadata instruction
This instruction writes the masked metadata value into the metadata field.
Attribute metadata
Description
Metadata value to write metadata_mask Metadata write bitmask class ryu.ofproto.ofproto_v1_4_parser.OFPInstructionActions(type_, actions=None , len_=None)
Actions instruction
This instruction writes/applies/clears the actions.
Attribute type
Description
One of following values.
OFPIT_WRITE_ACTIONS
OFPIT_APPLY_ACTIONS
OFPIT_CLEAR_ACTIONS actions list of OpenFlow action class type attribute corresponds to type_ parameter of __init__.
class ryu.ofproto.ofproto_v1_4_parser.OFPInstructionMeter(meter_id=1, type_=None, len_=None)
Meter instruction
This instruction applies the meter.
2.5. OpenFlow protocol API Reference 255
ryu Documentation, Release 3.21
Attribute Description meter_id Meter instance
Action Structures
class ryu.ofproto.ofproto_v1_4_parser.OFPActionOutput(port, max_len=65509 type_=None , len_=None)
,
Output action
This action indicates output a packet to the switch port.
Attribute Description port Output port max_len Max length to send to controller class ryu.ofproto.ofproto_v1_4_parser.OFPActionCopyTtlOut(type_=None, len_=None)
Copy TTL Out action
This action copies the TTL from the next-to-outermost header with TTL to the outermost header with TTL.
class ryu.ofproto.ofproto_v1_4_parser.OFPActionCopyTtlIn(type_=None, len_=None)
Copy TTL In action
This action copies the TTL from the outermost header with TTL to the next-to-outermost header with TTL.
class ryu.ofproto.ofproto_v1_4_parser.OFPActionSetMplsTtl(mpls_ttl, len_=None)
Set MPLS TTL action type_=None ,
This action sets the MPLS TTL.
Attribute Description mpls_ttl MPLS TTL class ryu.ofproto.ofproto_v1_4_parser.OFPActionDecMplsTtl(type_=None, len_=None)
Decrement MPLS TTL action
This action decrements the MPLS TTL.
class ryu.ofproto.ofproto_v1_4_parser.OFPActionPushVlan(ethertype=33024, type_=None , len_=None)
Push VLAN action
This action pushes a new VLAN tag to the packet.
Attribute Description ethertype Ether type. The default is 802.1Q. (0x8100) class ryu.ofproto.ofproto_v1_4_parser.OFPActionPopVlan(type_=None, len_=None)
Pop VLAN action
This action pops the outermost VLAN tag from the packet.
class ryu.ofproto.ofproto_v1_4_parser.OFPActionPushMpls(ethertype=34887, type_=None , len_=None)
Push MPLS action
This action pushes a new MPLS header to the packet.
Attribute Description ethertype Ether type
256 Chapter 2. Writing Your Ryu Application
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_4_parser.OFPActionPopMpls(ethertype=2048, type_=None , len_=None)
Pop MPLS action
This action pops the MPLS header from the packet.
class ryu.ofproto.ofproto_v1_4_parser.OFPActionSetQueue(queue_id, len_=None)
Set queue action type_=None
This action sets the queue id that will be used to map a flow to an already-configured queue on a port.
Attribute Description queue_id Queue ID for the packets class ryu.ofproto.ofproto_v1_4_parser.OFPActionGroup(group_id=0, len_=None)
Group action type_=None ,
,
This action indicates the group used to process the packet.
Attribute Description group_id Group identifier class ryu.ofproto.ofproto_v1_4_parser.OFPActionSetNwTtl(nw_ttl, len_=None)
Set IP TTL action type_=None ,
This action sets the IP TTL.
Attribute Description nw_ttl IP TTL class ryu.ofproto.ofproto_v1_4_parser.OFPActionDecNwTtl(type_=None, len_=None)
Decrement IP TTL action
This action decrements the IP TTL.
class ryu.ofproto.ofproto_v1_4_parser.OFPActionSetField(field=None, **kwargs)
Set field action
This action modifies a header field in the packet.
The set of keywords available for this is same as OFPMatch.
Example: set_field = OFPActionSetField(eth_src = "00:00:00:00:00" ) class ryu.ofproto.ofproto_v1_4_parser.OFPActionPushPbb(ethertype, len_=None)
Push PBB action
This action pushes a new PBB header to the packet.
type_=None
Attribute Description ethertype Ether type class ryu.ofproto.ofproto_v1_4_parser.OFPActionPopPbb(type_=None, len_=None)
Pop PBB action
This action pops the outermost PBB service instance header from the packet.
,
2.5. OpenFlow protocol API Reference 257
ryu Documentation, Release 3.21
class ryu.ofproto.ofproto_v1_4_parser.OFPActionExperimenter(experimenter, data=None , type_=None , len_=None)
Experimenter action
This action is an extensible action for the experimenter.
Attribute Description experimenter Experimenter ID
2.6 Ryu API Reference
258 Chapter 2. Writing Your Ryu Application
CHAPTER
3
Configuration
3.1 Setup TLS Connection
If you want to use secure channel to connect OpenFlow switches, you need to use TLS connection. This document describes how to setup Ryu to connect to the Open vSwitch over TLS.
3.1.1 Configuring a Public Key Infrastructure
If you don’t have a PKI, the ovs-pki script included with Open vSwitch can help you. This section is based on the
INSTALL.SSL in the Open vSwitch source code.
NOTE: How to install Open vSwitch isn’t described in this document. Please refer to the Open vSwitch documents.
Create a PKI by using ovs-pki script:
% ovs-pki init
(Default directory is /usr/local/var/lib/openvswitch/pki)
The pki directory consists of controllerca and switchca subdirectories. Each directory contains CA files.
Create a controller private key and certificate:
% ovs-pki req+sign ctl controller ctl-privkey.pem and ctl-cert.pem are generated in the current directory.
Create a switch private key and certificate:
% ovs-pki req+sign sc switch sc-privkey.pem and sc-cert.pem are generated in the current directory.
3.1.2 Testing TLS Connection
Configuring ovs-vswitchd to use CA files using the ovs-vsctl “set-ssl” command, e.g.:
% ovs-vsctl set-ssl /etc/openvswitch/sc-privkey.pem \
/etc/openvswitch/sc-cert.pem \
/usr/local/var/lib/openvswitch/pki/controllerca/cacert.pem
% ovs-vsctl add-br br0
% ovs-vsctl set-controller br0 ssl:127.0.0.1:6633
259
ryu Documentation, Release 3.21
Substitute the correct file names, if they differ from the ones used above. You should use absolute file names.
Run Ryu with CA files:
% ryu-manager --ctl-privkey ctl-privkey.pem \
--ctl-cert ctl-cert.pem \
--ca-certs /usr/local/var/lib/openvswitch/pki/switchca/cacert.pem \
--verbose
You can see something like: loading app ryu.controller.ofp_handler
instantiating app ryu.controller.ofp_handler
BRICK ofp_event
CONSUMES EventOFPSwitchFeatures
CONSUMES EventOFPErrorMsg
CONSUMES EventOFPHello
CONSUMES EventOFPEchoRequest connected socket:<SSLSocket fileno=4 sock=127.0.0.1:6633 peer=127.0.0.1:61302> a ddress:('127.0.0.1', 61302) hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x1047806d0> move onto config mode switch features ev version: 0x1 msg_type 0x6 xid 0xb0bb34e5 port OFPPhyPort(port
_no=65534, hw_addr='\x16\xdc\xa2\xe2}K', name='br0\x00\x00\x00\x00\x00\x00\x00\x
00\x00\x00\x00\x00\x00', config=0, state=0, curr=0, advertised=0, supported=0, p eer=0) move onto main mode
3.2 Topology Viewer
ryu.app.gui_topology.gui_topology provides topology visualization.
This depends on following ryu applications.
ryu.app.rest_topology
Get node and link data.
ryu.app.ws_topology
Being notified change of link up/down.
ryu.app.ofctl_rest
Get flows of datapaths.
3.2.1 Usage
Run mininet (or join your real environment):
$ sudo mn --controller remote --topo tree,depth=3
Run GUI application:
$ PYTHONPATH=. ./bin/ryu run --observe-links ryu/app/gui_topology/gui_topology.py
Access http:/ /<ip address of ryu host>:8080 with your web browser.
260 Chapter 3. Configuration
3.2.2 Screenshot ryu Documentation, Release 3.21
3.2. Topology Viewer 261
ryu Documentation, Release 3.21
262 Chapter 3. Configuration
CHAPTER
4
Tests
4.1 Testing VRRP Module
This page describes how to test Ryu VRRP service
4.1.1 Running integrated tests
Some testing scripts are available.
• ryu/tests/integrated/test_vrrp_linux_multi.py
• ryu/tests/integrated/test_vrrp_multi.py
Each files include how to run in the comment. Please refer to it.
4.1.2 Running multiple Ryu VRRP in network namespace
The following command lines set up necessary bridges and interfaces.
And then run RYU-VRRP:
# ip netns add gateway1
# ip netns add gateway2
# brctl addbr vrrp-br0
# brctl addbr vrrp-br1
# ip link add veth0 type veth peer name veth0-br0
# ip link add veth1 type veth peer name veth1-br0
# ip link add veth2 type veth peer name veth2-br0
# ip link add veth3 type veth peer name veth3-br1
# ip link add veth4 type veth peer name veth4-br1
# ip link add veth5 type veth peer name veth5-br1
# brctl addif vrrp-br0 veth0-br0
# brctl addif vrrp-br0 veth1-br0
# brctl addif vrrp-br0 veth2-br0
# brctl addif vrrp-br1 veth3-br1
# brctl addif vrrp-br1 veth4-br1
# brctl addif vrrp-br1 veth5-br1
# ip link set vrrp-br0 up
263
ryu Documentation, Release 3.21
# ip link set vrrp-br1 up
# ip link set veth0 up
# ip link set veth0-br0 up
# ip link set veth1-br0 up
# ip link set veth2-br0 up
# ip link set veth3-br1 up
# ip link set veth4-br1 up
# ip link set veth5 up
# ip link set veth5-br1 up
# ip link set veth1 netns gateway1
# ip link set veth2 netns gateway2
# ip link set veth3 netns gateway1
# ip link set veth4 netns gateway2
# ip netns exec gateway1 ip link set veth1 up
# ip netns exec gateway2 ip link set veth2 up
# ip netns exec gateway1 ip link set veth3 up
# ip netns exec gateway2 ip link set veth4 up
# ip netns exec gateway1 .ryu-vrrp veth1 '10.0.0.2' 254
# ip netns exec gateway2 .ryu-vrrp veth2 '10.0.0.3' 100
Caveats
Please make sure that all interfaces and bridges are UP. Don’t forget interfaces in netns gateway1/gateway2.
^ veth5
|
V veth5-br1
-----------------------
|Linux Brirge vrrp-br1|
----------------------veth3-br1^ ^ veth4-br1
| veth3V
----------
|netns |
|gateway1|
|ryu-vrrp|
---------veth1^
|
|
V veth4
----------
|netns
|gateway2|
|ryu-vrrp|
----------
^ veth2
|
| veth1-br0V V veth2-br0
-----------------------
|Linux Brirge vrrp-br0|
-----------------------
^ veth0-br0
|
V veth0
Here’s the helper executable, ryu-vrrp:
#!/usr/bin/env python
#
# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
264 Chapter 4. Tests
ryu Documentation, Release 3.21
# Copyright (C) 2013 Isaku Yamahata <yamahata at valinux co jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ryu.lib
import
hub hub .
patch()
# TODO:
# Right now, we have our own patched copy of ovs python bindings
# Once our modification is upstreamed and widely deployed,
# use it
#
# NOTE: this modifies sys.path and thus affects the following imports.
# eg. oslo.config.cfg.
import ryu.contrib
from oslo.config
import
cfg
import logging import netaddr import sys import time from ryu import
log log .
early_init_log(logging .
DEBUG)
from ryu import
flags
from ryu import
version
from ryu.base
import
app_manager
from ryu.controller
import
controller
from ryu.lib
import
mac
as
lib_mac
from ryu.lib.packet
import
vrrp
from ryu.services.protocols.vrrp
import
api
as
vrrp_api
from ryu.services.protocols.vrrp
import
event
as
vrrp_event
CONF = cfg .
CONF
_VRID = 7
_IP_ADDRESS = '10.0.0.1'
_PRIORITY = 100
class VRRPTestRouter
(app_manager .
RyuApp):
def
__init__ ( self ,
* args,
** kwargs): super (VRRPTestRouter, self ) .
__init__(
* args,
args self .
logger .
debug( 'vrrp_config %s ' , args)
** kwargs)
4.1. Testing VRRP Module 265
ryu Documentation, Release 3.21
self .
_ifname = args[ 0 ] self .
_primary_ip_address = args[ 1 ] self .
_priority = int (args[ 2 ])
def
start ( self ):
'start' hub .
spawn( self .
_main)
def
_main ( self ):
self interface = vrrp_event .
VRRPInterfaceNetworkDevice( lib_mac .
DONTCARE, self .
_primary_ip_address, None , self .
_ifname) self .
logger .
debug( ' %s ' , interface) ip_addresses = [_IP_ADDRESS] config = vrrp_event .
VRRPConfig( version = vrrp .
VRRP_VERSION_V3, vrid = _VRID, priority = self .
_priority, ip_addresses = ip_addresses) self .
logger .
debug( ' %s ' , config) rep = vrrp_api .
vrrp_config( self , interface, config) self .
logger .
debug( ' %s ' , rep)
def
main (): vrrp_config = sys .
argv[ 3 :] sys .
argv = sys .
argv[: 3 ]
CONF(project = 'ryu' , version = 'ryu-vrrp %s ' % version) log .
init_log()
# always enable ofp for now.
app_lists = [ 'ryu.services.protocols.vrrp.manager' ,
'ryu.services.protocols.vrrp.dumper' ,
'ryu.services.protocols.vrrp.sample_manager' ] app_mgr = app_manager .
AppManager .
get_instance() app_mgr .
load_apps(app_lists) contexts = app_mgr .
create_contexts() app_mgr .
instantiate_apps(
** contexts) vrrp_router = app_mgr .
instantiate(VRRPTestRouter, vrrp_router .
start()
* vrrp_config,
** contexts)
while
True : time .
sleep( 999999 ) app_mgr .
close()
if
__name__ == "__main__" : main()
4.2 Testing OF-config support with LINC
This page describes how to setup LINC and test Ryu OF-config with it.
The procedure is as follows. Although all the procedure is written for reader’s convenience, please refer to LINC
266 Chapter 4. Tests
ryu Documentation, Release 3.21
document for latest informations of LINC.
https://github.com/FlowForwarding/LINC-Switch
The test procedure
• install Erlang environment
• build LINC
• configure LINC switch
• setup for LINC
• run LINC switch
• run Ryu test_of_config app
For getting/installing Ryu itself, please refer to http://osrg.github.io/ryu/
4.2.1 Install Erlang environment
Since LINC is written in Erlang, you need to install Erlang execution environment. Required version is R15B+.
The easiest way is to use binary package from https://www.erlang-solutions.com/downloads/download-erlang-otp
The distribution may also provide Erlang package.
4.2.2 build LINC install necessary packages for build install necessary build tools
On Ubuntu:
# apt-get install git-core bridge-utils libpcap0.8 libpcap-dev libcap2-bin uml-utilities
On RedHat/CentOS:
# yum install git sudo bridge-utils libpcap libpcap-devel libcap tunctl
Note that on RedHat/CentOS 5.x you need a newer version of libpcap:
# yum erase libpcap libpcap-devel
# yum install flex byacc
# wget http://www.tcpdump.org/release/libpcap-1.2.1.tar.gz
# tar xzf libpcap-1.2.1.tar.gz
# cd libpcap-1.2.1
# ./configure
# make && make install
get LINC repo and built
Clone LINC repo:
% git clone git://github.com/FlowForwarding/LINC-Switch.git
4.2. Testing OF-config support with LINC 267
ryu Documentation, Release 3.21
Then compile everything:
% cd LINC-Switch
% make
Note: At the time of this writing, test_of_config fails due to a bug of LINC. You can try this test with LINC which is built by the following methods.
% cd LINC-Switch
% make
% cd deps/of_config
% git reset --hard f772af4b765984381ad024ca8e5b5b8c54362638
% cd ../..
% make offline
4.2.3 Setup LINC
edit LINC switch configuration file. rel/linc/releases/0.1/sys.config Here is the sample sys.config for test_of_config.py to run.
[{linc,
[{of_config,enabled},
{capable_switch_ports,
[{port,1,[{interface,"linc-port"}]},
{port,4,[{interface,"linc-port4"}]}]},
{capable_switch_queues,
[
{port,2,[{interface,"linc-port2"}]},
{port,3,[{interface,"linc-port3"}]},
{queue,991,[{min_rate,10},{max_rate,120}]},
{queue,992,[{min_rate,10},{max_rate,130}]},
{queue,993,[{min_rate,200},{max_rate,300}]},
{queue,994,[{min_rate,400},{max_rate,900}]}
]},
{logical_switches,
[{switch,0,
[{backend,linc_us4},
{controllers,[{"Switch0-Default-Controller","127.0.0.1",6633,tcp}]},
{controllers_listener,{"127.0.0.1",9998,tcp}},
{queues_status,enabled},
{ports,[{port,1,{queues,[]}},{port,2,{queues,[991,992]}}]}]}
,
{switch,7,
[{backend,linc_us3},
{controllers,[{"Switch7-Controller","127.0.0.1",6633,tcp}]},
{controllers_listener,disabled},
{queues_status,enabled},
{ports,[{port,4,{queues,[]}},{port,3,{queues,[993,994]}}]}]}
]}]},
{enetconf,
[{capabilities,
[{base,{1,0}},
{base,{1,1}},
{startup,{1,0}},
{'writable-running',{1,0}}]},
{callback_module,linc_ofconfig},
268 Chapter 4. Tests
ryu Documentation, Release 3.21
{sshd_ip,{127,0,0,1}},
{sshd_port,1830},
{sshd_user_passwords,[{"linc","linc"}]}]},
{lager,
[{handlers,
[{lager_console_backend,debug},
{lager_file_backend,
[{"log/error.log",error,10485760,"$D0",5},
{"log/console.log",info,10485760,"$D0",5}]}]}]},
{sasl,
[{sasl_error_logger,{file,"log/sasl-error.log"}},
{errlog_type,error},
{error_logger_mf_dir,"log/sasl"},
{error_logger_mf_maxbytes,10485760},
{error_logger_mf_maxfiles,5}]},
{sync,[{excluded_modules,[procket]}]}].
4.2.4 setup for LINC
As the above sys.config requires some network interface, create them:
# ip link add linc-port type veth peer name linc-port-peer
# ip link set linc-port up
# ip link add linc-port2 type veth peer name linc-port-peer2
# ip link set linc-port2 up
# ip link add linc-port3 type veth peer name linc-port-peer3
# ip link set linc-port3 up
# ip link add linc-port4 type veth peer name linc-port-peer4
# ip link set linc-port4 up
After stopping LINC, those created interfaces can be deleted:
# ip link delete linc-port
# ip link delete linc-port2
# ip link delete linc-port3
# ip link delete linc-port4
4.2.5 Starting LINC OpenFlow switch
Then run LINC:
# rel/linc/bin/linc console
4.2.6 Run Ryu test_of_config app
Run test_of_config app:
# ryu-manager --verbose ryu.tests.integrated.test_of_config ryu.app.rest
If you don’t install ryu and are working in the git repo directly:
# PYTHONPATH=. ./bin/ryu-manager --verbose ryu.tests.integrated.test_of_config ryu.app.rest
4.2. Testing OF-config support with LINC 269
ryu Documentation, Release 3.21
270 Chapter 4. Tests
CHAPTER
5
Using Ryu Network Operating System with OpenStack as OpenFlow controller
Ryu cooperates with OpenStack using Quantum Ryu plugin. The plugin is available in the official Quantum releases.
For more information, please visit http://github.com/osrg/ryu/wiki/OpenStack . We described instructions of the installation / configuration of OpenStack with Ryu, and we provide pre-configured VM image to be able to easily try
OpenStack with Ryu.
• OpenStack: http://www.openstack.org/
• Quantum: https://github.com/openstack/quantum/
271
ryu Documentation, Release 3.21
272 Chapter 5. Using Ryu Network Operating System with OpenStack as OpenFlow controller
CHAPTER
6
Built-in Ryu applications
Ryu has some built-in Ryu applications. Some of them are examples. Others provide some functionalities to other
Ryu applications.
6.1 ryu.app.ofctl
ryu.app.ofctl provides a convenient way to use OpenFlow messages synchronously.
OfctlService ryu application is automatically loaded if your Ryu application imports ofctl.api module.
Example:
import ryu.app.ofctl.api
OfctlService application internally uses OpenFlow barrier messages to ensure message boundaries. As OpenFlow messages are asynchronous and some of messages does not have any replies on success, barriers are necessary for correct error handling.
6.1.1 api module
6.1.2 exceptions
exception ryu.app.ofctl.exception.InvalidDatapath(result)
Datapath is invalid.
This can happen when the bridge disconnects.
exception ryu.app.ofctl.exception.OFError(result)
OFPErrorMsg is received.
exception ryu.app.ofctl.exception.UnexpectedMultiReply(result)
Two or more replies are received for reply_muiti=False request.
6.2 ryu.app.ofctl_rest
ryu.app.ofctl_rest provides REST APIs for retrieving the switch stats and Updating the switch stats. This application helps you debug your application and get various statistics.
This application supports OpenFlow version 1.0, 1.2 and 1.3.
273
ryu Documentation, Release 3.21
6.2.1 Retrieve the switch stats
Get all switches
Get the list of all switches which connected to the controller.
Usage:
Method GET
URI /stats/switches
Response message body:
Attribute Description Example dpid Datapath ID 1
Example of use:
$ curl -X GET http://localhost:8080/stats/switches
[
1 ,
2 ,
3
]
Note: The result of the REST command is formatted for easy viewing.
Get the desc stats
Get the desc stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/desc/<dpid>
Response message body:
Attribute dpid mfr_desc
Description
Datapath ID
Manufacturer description
Example
“1”
“Nicira, Inc.”, hw_desc sw_desc
Hardware description
Software description
“Open vSwitch”,
“2.3.90”, serial_num Serial number dp_desc Human readable description of datapath
“None”,
“None”
Example of use:
$ curl -X GET http://localhost:8080/stats/desc/1
{
"1" : {
"mfr_desc" : "Nicira, Inc." ,
"hw_desc" : "Open vSwitch" ,
"sw_desc" : "2.3.90" ,
"serial_num" : "None" ,
"dp_desc" : "None"
274 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
}
}
Get all flows stats
Get all flows stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/flow/<dpid>
Response message body:
Attribute dpid length
Description
Datapath ID
Length of this entry table_id Table ID duration_sec Time flow has been alive in seconds duration_nsec priority
Time flow has been alive in nanoseconds beyond duration_sec
Priority of the entry idle_timeout Number of seconds idle before expiration hard_timeout Number of seconds before expiration flags cookie
Bitmap of OFPFF_* flags
Opaque controller-issued identifier packet_count Number of packets in flow byte_count Number of bytes in flow match Fields to match actions Instruction set
Example of use:
$ curl -X GET http://localhost:8080/stats/flow/1
{
"1" : [
{
"length" : 88 ,
"table_id" : 0 ,
"duration_sec" : 2 ,
"duration_nsec" : 6.76e+08 ,
"priority" : 11111 ,
"idle_timeout" : 0 ,
"hard_timeout" : 0 ,
"flags" : 1 ,
"cookie" : 1 ,
"packet_count" : 0 ,
"byte_count" : 0 ,
"match" : {
"in_port" : 1
},
"actions" : [
"OUTPUT:2"
]
6.2. ryu.app.ofctl_rest
Example
“1”
88
0
2
6.76e+08
11111
0
0
1
1
0
0
{“in_port”:
1}
[”OUT-
PUT:2”]
275
ryu Documentation, Release 3.21
}
]
}
Get flows stats filtered by fields
Get flows stats of the switch filtered by the OFPFlowStats fields. This is POST method version of
Usage:
Method POST
URI /stats/flow/<dpid>
Request message body:
Attribute Description table_id Table ID (int)
Example
0
2
Default
OF-
PTT_ALL
OFPP_ANY out_port Require matching entries to include this as an output port (int) out_group Require matching entries to include this as an output group (int) cookie Require matching entries to contain this cookie value (int) cookie_maskMask used to restrict the cookie bits that must match (int) match Fields to match (dict)
1
1
1
{“in_port”:
1}
OFPG_ANY
0
0
{} #wildcarded
Response message body: The same as
Example of use:
$ curl -X POST -d '{
"table_id": 0,
"out_port": 2,
"cookie": 1,
"cookie_mask": 1,
"match":{
"in_port":1
}
}' http://localhost:8080/stats/flow/1
{
"1" : [
{
"table_id" : 0 ,
"duration_sec" : 2 ,
"duration_nsec" : 6.76e+08 ,
"priority" : 11111 ,
"idle_timeout" : 0 ,
"hard_timeout" : 0 ,
"cookie" : 1 ,
"packet_count" : 0 ,
"byte_count" : 0 ,
"match" : {
"in_port" : 1
276 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
}
]
}
},
"actions" : [
"OUTPUT:2"
]
Get aggregate flow stats
Get aggregate flow stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/aggregateflow/<dpid>
Response message body:
Attribute dpid
Description
Datapath ID
Example
“1” packet_count Number of packets in flows 18 byte_count Number of bytes in flows 756 flow_count Number of flows 3
Example of use:
$ curl -X GET http://localhost:8080/stats/aggregateflow/1
{
}
"1" : [
{
"packet_count" : 18 ,
"byte_count" : 756 ,
"flow_count" : 3
}
]
Get aggregate flow stats filtered by fields
Get aggregate flow stats of the switch filtered by the OFPAggregateStats fields. This is POST method version of
Usage:
Method POST
URI /stats/aggregateflow/<dpid>
Request message body:
6.2. ryu.app.ofctl_rest
277
ryu Documentation, Release 3.21
Attribute Description table_id Table ID (int) out_port Require matching entries to include this as an output port (int) out_group Require matching entries to include this as an output group (int) cookie Require matching entries to contain this cookie value (int) cookie_maskMask used to restrict the cookie bits that must match (int) match Fields to match (dict)
Example Default
0 OF-
PTT_ALL
2 OFPP_ANY
1 OFPG_ANY
1
1
0
0
{“in_port”:
1}
{} #wildcarded
Response message body: The same as
Example of use:
$ curl -X POST -d '{
"table_id": 0,
"out_port": 2,
"cookie": 1,
"cookie_mask": 1,
"match":{
"in_port":1
}
}' http://localhost:8080/stats/aggregateflow/1
{
}
"1" : [
{
"packet_count" : 18 ,
"byte_count" : 756 ,
"flow_count" : 3
}
]
Get ports stats
Get ports stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/port/<dpid>
Response message body:
278 Chapter 6. Built-in Ryu applications
Attribute Description dpid port_no rx_packets tx_packets rx_bytes tx_bytes
Datapath ID
Port number
Number of received packets
Number of transmitted packets
Number of received bytes
Number of transmitted bytes rx_dropped tx_dropped rx_errors tx_errors
Number of packets dropped by RX
Number of packets dropped by TX
Number of receive errors
Number of transmit errors rx_frame_err Number of frame alignment errors rx_over_err Number of packets with RX overrun rx_crc_err collisions
Number of CRC errors
Number of collisions duration_sec Time port has been alive in seconds duraTime port has been alive in nanoseconds beyond tion_nsec duration_sec
Example of use:
$ curl -X GET http://localhost:8080/stats/port/1
{
}
"1": [
{
"port_no": 1,
"rx_packets": 9,
"tx_packets": 6,
"rx_bytes": 738,
"tx_bytes": 252,
"rx_dropped": 0,
"tx_dropped": 0,
"rx_errors": 0,
"tx_errors": 0,
"rx_frame_err": 0,
"rx_over_err": 0,
},
"duration_sec": 12,
"duration_nsec": 9.76e+08
{
"rx_crc_err": 0,
"collisions": 0,
:
:
}
]
Get ports description
Get ports description of the switch which specified with Datapath ID in URI.
Usage:
ryu Documentation, Release 3.21
0
0
0
0
0
0
738
252
1
9
6
Example
“1”
0
0
12
9.76e+08
6.2. ryu.app.ofctl_rest
279
ryu Documentation, Release 3.21
Method GET
URI /stats/portdesc/<dpid>
Response message body:
Attribute dpid port_no hw_addr name config state
Description
Datapath ID
Port number
Ethernet hardware address
Name of port
Bitmap of OFPPC_* flags
Bitmap of OFPPS_* flags
Example
“1”
1
0
0
“0a:b6:d0:0c:e1:d7”
“s1-eth1” curr Current features 2112 advertised Features being advertised by the port 0 supported peer
Features supported by the port
Features advertised by peer
0
0 curr_speed Current port bitrate in kbps max_speed Max port bitrate in kbps
1e+07
0
Example of use:
$ curl -X GET http://localhost:8080/stats/portdesc/1
{
}
"1": [
{
"port_no": 1,
"hw_addr": "0a:b6:d0:0c:e1:d7",
"name": "s1-eth1",
"config": 0,
"state": 0,
"curr": 2112,
"advertised": 0,
},
{
:
:
}
"supported": 0,
"peer": 0,
"curr_speed": 1e+07,
"max_speed": 0
]
Get queues stats
Get queues stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/queue/<dpid>
Response message body:
280 Chapter 6. Built-in Ryu applications
Attribute dpid port_no queue_id tx_bytes tx_packets tx_errors
Description
Datapath ID
Port number
Queue ID
Number of transmitted bytes
Number of transmitted packets
Number of packets dropped due to overrun duration_sec Time queue has been alive in seconds duraTime queue has been alive in nanoseconds beyond tion_nsec duration_sec
Example of use:
$ curl -X GET http://localhost:8080/stats/queue/1
{
}
"1" : [
{
"port_no" : 1 ,
"queue_id" : 0 ,
"tx_bytes" : 0 ,
"tx_packets" : 0 ,
"tx_errors" : 0 ,
},
{
"duration_sec" : 4294963425 ,
"duration_nsec" : 3912967296
"port_no" : 1 ,
"queue_id" : 1 ,
"tx_bytes" : 0 ,
"tx_packets" : 0 ,
"tx_errors" : 0 ,
"duration_sec" : 4294963425 ,
"duration_nsec" : 3912967296
}
]
Get groups stats
Get groups stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/group/<dpid>
Response message body:
ryu Documentation, Release 3.21
0
0
0
0
Example
“1”
1
4294963425
3912967296
6.2. ryu.app.ofctl_rest
281
ryu Documentation, Release 3.21
Attribute Description dpid length
Datapath ID
Length of this entry group_id ref_count
Group ID
Number of flows or groups that directly forward to this group packet_count Number of packets processed by group byte_count Number of bytes processed by group duration_sec Time group has been alive in seconds duration_nsec Time group has been alive in nanoseconds beyond duration_sec bucket_stats
– packet_count struct ofp_bucket_counter
Number of packets processed by bucket
– byte_count Number of bytes processed by bucket
Example of use:
$ curl -X GET http://localhost:8080/stats/group/1
{
"1" : [
{
"length" : 56 ,
"group_id" : 1 ,
"ref_count" : 1 ,
"packet_count" : 0 ,
"byte_count" : 0 ,
"duration_sec" : 161 ,
"duration_nsec" : 3.03e+08 ,
"bucket_stats" : [
{
"packet_count" : 0 ,
"byte_count" : 0
}
]
}
]
}
Get group description stats
Get group description stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/groupdesc/<dpid>
Response message body:
0
0
Example
“1”
56
1
1
0
0
161
3.03e+08
282 Chapter 6. Built-in Ryu applications
Attribute Description dpid Datapath ID type One of OFPGT_* group_id Group ID buckets struct ofp_bucket
– weight
– watch_port
Relative weight of bucket (Only defined for select groups)
Port whose state affects whether this bucket is live (Only required for fast failover groups)
– Group whose state affects whether this bucket is live (Only watch_group required for fast failover groups)
– actions 0 or more actions associated with the bucket
Example of use:
$ curl -X GET http://localhost:8080/stats/groupdesc/1
{
}
"1" : [
{
"type" : "ALL" ,
"group_id" : 1 ,
"buckets" : [
{
"weight" : 0 ,
"watch_port" : 4294967295 ,
"watch_group" : 4294967295 ,
"actions" : [
"OUTPUT:1"
]
}
]
}
]
Get group features stats
Get group features stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/groupfeatures/<dpid>
Response message body:
ryu Documentation, Release 3.21
Example
“1”
“ALL”
1
0
4294967295
4294967295
[”OUT-
PUT:1”]
6.2. ryu.app.ofctl_rest
283
ryu Documentation, Release 3.21
Attribute dpid types capabilities
Description
Datapath ID
Bitmap of (1 << OFPGT_*) values supported
Bitmap of OFPGFC_* capability supported max_groupsMaximum number of groups for each type actions Bitmaps of (1 << OFPAT_*) values supported
Example of use:
Example
“1”
[]
[”SE-
LECT_WEIGHT”,”SELECT_LIVENESS”,”CHAINING”]
[{“ALL”: 4294967040},...]
[{“ALL”: [”OUTPUT”,...]},...]
$ curl -X GET http://localhost:8080/stats/groupfeatures/1
{
"1" : [
{
"types" : [],
"capabilities" : [
"SELECT_WEIGHT" ,
"SELECT_LIVENESS" ,
],
"CHAINING"
"max_groups" : [
{
},
{
"ALL" : 4294967040
},
"SELECT" : 4294967040
{
},
"INDIRECT" : 4294967040
{
"FF" : 4294967040
],
}
"actions" : [
{
"ALL" : [
"OUTPUT" ,
"COPY_TTL_OUT" ,
"COPY_TTL_IN" ,
"SET_MPLS_TTL" ,
"DEC_MPLS_TTL" ,
"PUSH_VLAN" ,
"POP_VLAN" ,
"PUSH_MPLS" ,
"POP_MPLS" ,
"SET_QUEUE" ,
"GROUP" ,
"SET_NW_TTL" ,
"DEC_NW_TTL" ,
"SET_FIELD"
},
]
284 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
}
]
}
]
{
},
"SELECT" : []
{
},
"INDIRECT" : []
{
"FF" : []
}
Get meters stats
Get meters stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/meter/<dpid>
Response message body:
Attribute Description dpid meter_id len flow_count packet_in_count
Datapath ID
Meter ID
Length in bytes of this stats
Number of flows bound to meter
Number of packets in input byte_in_count duration_sec
Number of bytes in input
Time meter has been alive in seconds duration_nsec Time meter has been alive in nanoseconds beyond duration_sec struct ofp_meter_band_stats band_stats
– packet_band_count
Number of packets in band
– byte_band_count Number of bytes in band
Example of use:
$ curl -X GET http://localhost:8080/stats/meter/1
{
"1" : [
{
"meter_id" : 1 ,
"len" : 56 ,
"flow_count" : 0 ,
"packet_in_count" : 0 ,
"byte_in_count" : 0 ,
"duration_sec" : 37 ,
"duration_nsec" : 988000 ,
"band_stats" : [
{
6.2. ryu.app.ofctl_rest
56
0
0
Example
“1”
1
0
37
988000
0
0
285
ryu Documentation, Release 3.21
}
]
}
]
}
"packet_band_count" : 0 ,
"byte_band_count" : 0
Get meter config stats
Get meter config stats of the switch which specified with Datapath ID in URI.
Usage:
Method GET
URI /stats/meterconfig/<dpid>
Response message body:
Attribute dpid flags meter_id
Description
Datapath ID
All OFPMC_* that apply
Meter ID bands
– type struct ofp_meter_band_header
One of OFPMBT_*
– rate Rate for this band
– burst_size Size of bursts
Example of use:
Example
“1”
“KBPS”
1
“DROP”
1000
0
$ curl -X GET http://localhost:8080/stats/meterconfig/1
{
"1" : [
{
"flags" : [
"KBPS"
],
"meter_id" : 1 ,
"bands" : [
{
"type" : "DROP" ,
"rate" : 1000 ,
"burst_size" : 0
}
]
}
]
}
Get meter features stats
Get meter features stats of the switch which specified with Datapath ID in URI.
Usage:
286 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
Method GET
URI /stats/meterfeatures/<dpid>
Response message body:
Attribute Description dpid Datapath ID max_meter Maximum number of meters band_types Bitmaps of (1 << OFPMBT_*) values supported capabilities
Bitmaps of “ofp_meter_flags” max_bands Maximum bands per meters max_color Maximum color value
Example of use:
Example
“1”
256
[”DROP”]
[”KBPS”, “BURST”,
“STATS”]
16
8
$ curl -X GET http://localhost:8080/stats/meterfeatures/1
{
}
"1" : [
{
"max_meter" : 256 ,
"band_types" : [
"DROP"
],
"capabilities" : [
"KBPS" ,
"BURST" ,
],
"STATS"
"max_bands" : 16 ,
"max_color" : 8
}
]
6.2.2 Update the switch stats
Add a flow entry
Add a flow entry to the switch.
Usage:
Method POST
URI /stats/flowentry/add
Request message body:
6.2. ryu.app.ofctl_rest
287
ryu Documentation, Release 3.21
288
Attribute dpid cookie
Description
Datapath ID (int)
Opaque controller-issued identifier
(int)
Example
1
1
1
(int) table_id Table ID to put the flow in (int) idle_timeoutIdle time before discarding (seconds)
(int)
0
30
30 priority
(seconds) (int)
Priority level of flow entry (int) buffer_id Buffered packet to apply to, or
OFP_NO_BUFFER (int) flags Bitmap of OFPFF_* flags (int) match Fields to match (dict) actions Instruction set (list of dict)
11111
1
1
{“in_port”:1}
[{“type”:”OUTPUT”,
“port”:2}]
Default
(Mandatory)
0
0
0
0
0
0
OFP_NO_BUFFER
0
{}
#wildcarded
[] #DROP
Note: For description of match and actions, please see
Reference: Description of Match and Actions
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"OUTPUT",
"port": 2
}
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"priority": 22222,
"match":{
"in_port":1
},
"actions":[
{
"type":"GOTO_TABLE",
"table_id": 1
}
Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"priority": 33333,
"match":{
"in_port":1
},
"actions":[
{
"type":"WRITE_METADATA",
"metadata": 1,
"metadata_mask": 1
}
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"priority": 44444,
"match":{
"in_port":1
},
"actions":[
{
"type":"METER",
"meter_id": 1
}
]
}' http://localhost:8080/stats/flowentry/add
Note: To confirm flow entry registration, please see
or
Get flows stats filtered by fields
Modify all matching flow entries
Modify all matching flow entries of the switch.
Usage:
Method POST
URI /stats/flowentry/modify
Request message body:
6.2. ryu.app.ofctl_rest
289
ryu Documentation, Release 3.21
Attribute dpid cookie
Description
Datapath ID (int)
Opaque controller-issued identifier
(int)
Example
1
1
Default
(Mandatory)
0
1 0
(int) table_id Table ID to put the flow in (int) idle_timeoutIdle time before discarding (seconds)
(int)
0
30
0
0
30 0 priority
(seconds) (int)
Priority level of flow entry (int) buffer_id Buffered packet to apply to, or
OFP_NO_BUFFER (int) flags Bitmap of OFPFF_* flags (int) match Fields to match (dict)
11111
1
1
{“in_port”:1} actions Instruction set (list of dict) [{“type”:”OUTPUT”,
“port”:2}]
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"OUTPUT",
"port": 2
}
]
}' http://localhost:8080/stats/flowentry/modify
0
OFP_NO_BUFFER
0
{}
#wildcarded
[] #DROP
Modify flow entry strictly
Modify flow entry strictly matching wildcards and priority
Usage:
Method POST
URI /stats/flowentry/modify_strict
Request message body:
290 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
Attribute dpid cookie
Description
Datapath ID (int)
Opaque controller-issued identifier
(int)
Example
1
1
Default
(Mandatory)
0
1 0
(int) table_id Table ID to put the flow in (int) idle_timeoutIdle time before discarding (seconds)
(int)
0
30
0
0
30 0 priority
(seconds) (int)
Priority level of flow entry (int) buffer_id Buffered packet to apply to, or
OFP_NO_BUFFER (int) flags Bitmap of OFPFF_* flags (int) match Fields to match (dict)
11111
1
1
{“in_port”:1} actions Instruction set (list of dict) [{“type”:”OUTPUT”,
“port”:2}]
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"OUTPUT",
"port": 2
}
]
}' http://localhost:8080/stats/flowentry/modify_strict
0
OFP_NO_BUFFER
0
{}
#wildcarded
[] #DROP
Delete all matching flow entries
Delete all matching flow entries of the switch.
Usage:
Method POST
URI /stats/flowentry/delete
Request message body:
6.2. ryu.app.ofctl_rest
291
ryu Documentation, Release 3.21
Attribute dpid cookie
Description
Datapath ID (int)
Opaque controller-issued identifier
(int)
Example
1
1
Default
(Mandatory)
0
1 0
(int) table_id Table ID to put the flow in (int) idle_timeoutIdle time before discarding (seconds)
(int)
0
30
0
0
30 0 priority
(seconds) (int)
Priority level of flow entry (int) buffer_id Buffered packet to apply to, or
OFP_NO_BUFFER (int) out_port Output port (int) out_group Output group (int) flags match
Bitmap of OFPFF_* flags (int)
Fields to match (dict)
11111
1
1
1
1
{“in_port”:1} actions Instruction set (list of dict) [{“type”:”OUTPUT”,
“port”:2}]
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"OUTPUT",
"port": 2
}
]
}' http://localhost:8080/stats/flowentry/delete
0
OFP_NO_BUFFER
OFPP_ANY
OFPG_ANY
0
{}
#wildcarded
[] #DROP
Delete flow entry strictly
Delete flow entry strictly matching wildcards and priority.
Usage:
Method POST
URI /stats/flowentry/delete_strict
Request message body:
292 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
Attribute dpid cookie
Description
Datapath ID (int)
Opaque controller-issued identifier
(int)
Example
1
1
Default
(Mandatory)
0
1 0
(int) table_id Table ID to put the flow in (int) idle_timeoutIdle time before discarding (seconds)
(int)
0
30
0
0
30 0 priority
(seconds) (int)
Priority level of flow entry (int) buffer_id Buffered packet to apply to, or
OFP_NO_BUFFER (int) out_port Output port (int) out_group Output group (int) flags match
Bitmap of OFPFF_* flags (int)
Fields to match (dict)
11111
1
1
1
1
{“in_port”:1} actions Instruction set (list of dict) [{“type”:”OUTPUT”,
“port”:2}]
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"OUTPUT",
"port": 2
}
]
}' http://localhost:8080/stats/flowentry/delete_strict
0
OFP_NO_BUFFER
OFPP_ANY
OFPG_ANY
0
{}
#wildcarded
[] #DROP
Delete all flow entries
Delete all flow entries of the switch which specified with Datapath ID in URI.
Usage:
Method DELETE
URI /stats/flowentry/clear/<dpid>
Example of use:
6.2. ryu.app.ofctl_rest
293
ryu Documentation, Release 3.21
$ curl -X DELETE http://localhost:8080/stats/flowentry/clear/1
Add a group entry
Add a group entry to the switch.
Usage:
Method POST
URI /stats/groupentry/add
Request message body:
Attribute dpid
Description
Datapath ID (int)
Example
1 type One of OFPGT_* (string) group_id Group ID (int) buckets struct ofp_bucket
– weight
Relative weight of bucket (Only defined for select groups)
– Port whose state affects whether this bucket is watch_port live (Only required for fast failover groups)
– Group whose state affects whether this bucket is
“ALL”
1
0
4294967295
4294967295
– actions
0 or more actions associated with the bucket
(list of dict)
[{“type”:
“OUTPUT”,
“port”: 1}]
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"type": "ALL",
"group_id": 1,
"buckets": [
{
"actions": [
{
"type": "OUTPUT",
"port": 1
}
]
}
]
}' http://localhost:8080/stats/groupentry/add
Note: To confirm group entry registration, please see
Default
(Mandatory)
“ALL”
0
0
OFPP_ANY
OFPG_ANY
[]
#DROP
Modify a group entry
Modify a group entry to the switch.
294 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
Usage:
Method POST
URI /stats/groupentry/modify
Request message body:
Attribute dpid
Description
Datapath ID (int)
– actions
0 or more actions associated with the bucket
(list of dict)
Example
1 type One of OFPGT_* (string) group_id Group ID (int) buckets struct ofp_bucket
– Relative weight of bucket (Only defined for weight select groups)
– Port whose state affects whether this bucket is watch_port live (Only required for fast failover groups)
– Group whose state affects whether this bucket is
“ALL”
1
0
4294967295
4294967295
[{“type”:
“OUTPUT”,
“port”: 1}]
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"type": "ALL",
"group_id": 1,
"buckets": [
{
"actions": [
{
"type": "OUTPUT",
"port": 1
}
]
}
]
}' http://localhost:8080/stats/groupentry/modify
Delete a group entry
Delete a group entry to the switch.
Usage:
Method POST
URI /stats/groupentry/delete
Request message body:
Attribute Description dpid Datapath ID (int)
Example
1
Default
(Mandatory) group_id Group ID (int) 1 0
Example of use:
Default
(Mandatory)
“ALL”
0
0
OFPP_ANY
OFPG_ANY
[]
#DROP
6.2. ryu.app.ofctl_rest
295
ryu Documentation, Release 3.21
$ curl -X POST -d '{
"dpid": 1,
"group_id": 1
}' http://localhost:8080/stats/groupentry/delete
Modify the behavior of the port
Modify the behavior of the physical port.
Usage:
Method POST
URI /stats/portdesc/modify
Request message body:
Attribute Description dpid Datapath ID (int) port_no config mask
Port number (int)
Bitmap of OFPPC_* flags (int)
Bitmap of OFPPC_* flags to be changed (int)
Example Default
1 (Mandatory)
1
1
1
0
0
0
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"port_no": 1,
"config": 1,
"mask": 1
}' http://localhost:8080/stats/portdesc/modify
Note: To confirm port description, please see
Add a meter entry
Add a meter entry to the switch.
Usage:
Method POST
URI /stats/meterentry/add
Request message body:
Attribute dpid flags
Description
Datapath ID (int)
Example
1
Default
(Mandatory) meter_id bands
– type
– rate
Bitmap of OFPMF_* flags (list) [”KBPS”] [] #Empty
Meter ID (int) struct ofp_meter_band_header
One of OFPMBT_* (string)
Rate for this band (int)
– burst_size Size of bursts (int)
1
“DROP”
1000
100
0
None
None
None
Example of use:
296 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
$ curl -X POST -d '{
"dpid": 1,
"flags": "KBPS",
"meter_id": 1,
"bands": [
{
"type": "DROP",
"rate": 1000
}
]
}' http://localhost:8080/stats/meterentry/add
Note: To confirm meter entry registration, please see
Modify a meter entry
Modify a meter entry to the switch.
Usage:
Method POST
URI /stats/meterentry/modify
Request message body:
Attribute dpid flags meter_id bands
– type
– rate
– burst_size
Description
Datapath ID (int)
Example
1
Default
(Mandatory)
Bitmap of OFPMF_* flags (list) [”KBPS”] [] #Empty
1 0 Meter ID (int) struct ofp_meter_band_header
One of OFPMBT_* (string)
Rate for this band (int)
Size of bursts (int)
“DROP”
1000
100
None
None
None
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [
{
"type": "DROP",
"rate": 1000
}
]
}' http://localhost:8080/stats/meterentry/modify
Delete a meter entry
Delete a meter entry to the switch.
Usage:
Method POST
URI /stats/meterentry/delete
6.2. ryu.app.ofctl_rest
297
ryu Documentation, Release 3.21
Request message body:
Attribute Description dpid Datapath ID (int)
Example
1
Default
(Mandatory) meter_id Meter ID (int) 1 0
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"meter_id": 1
}' http://localhost:8080/stats/meterentry/delete
6.2.3 Support for experimenter multipart
Send a experimenter message
Send a experimenter message to the switch which specified with Datapath ID in URI.
Usage:
Method POST
URI /stats/experimenter/<dpid>
Request message body:
Attribute dpid
Description
Datapath ID (int) experimenter Experimenter ID (int) exp_type data_type data
Experimenter defined (int)
Data format type (“ascii” or “base64”)
Data to send (string)
Example
1
1
1
“ascii”
“data”
Default
(Mandatory)
0
0
“ascii”
“” #Empty
Example of use:
$ curl -X POST -d '{
"dpid": 1,
"experimenter": 1,
"exp_type": 1,
"data_type": "ascii",
"data": "data"
}' http://localhost:8080/stats/experimenter/1
6.2.4 Reference: Description of Match and Actions
Description of Match on request messages
List of Match fields (OpenFlow1.0):
298 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
Match field in_port dl_src dl_dst dl_vlan
Description
Input switch port (int)
Ethernet source address (string)
Example
{“in_port”: 7}
{“dl_src”: “aa:bb:cc:11:22:33”}
Ethernet destination address (string) {“dl_dst”: “aa:bb:cc:11:22:33”}
Input VLAN id (int) {“dl_vlan”: 5} dl_vlan_pcp Input VLAN priority (int) dl_type Ethernet frame type (int)
{“dl_vlan_pcp”: 3, “dl_vlan”: 3}
{“dl_type”: 123} nw_tos nw_proto nw_src
IP ToS (int)
IP protocol or lower 8 bits of ARP opcode (int)
IPv4 source address (string)
{“nw_tos”: 16, “dl_type”: 2048}
{“nw_proto”: 5, “dl_type”: 2048} nw_dst tp_src tp_dst
IPv4 destination address (string)
TCP/UDP source port (int)
TCP/UDP destination port (int)
{“nw_src”: “192.168.0.1”,
“dl_type”: 2048}
{“nw_dst”: “192.168.0.1/24”,
“dl_type”: 2048}
{“tp_src”: 1, “nw_proto”: 6,
“dl_type”: 2048}
{“tp_dst”: 2, “nw_proto”: 6,
“dl_type”: 2048}
Note: IPv4 address field can be described as IP Prefix like as follows.
IPv4 address:
"192.168.0.1"
"192.168.0.2/24"
List of Match fields (OpenFlow1.2 or later):
Match field in_port in_phy_port metadata dl_dst dl_src eth_dst eth_src dl_type eth_type dl_vlan vlan_vid vlan_pcp ip_dscp ip_ecn nw_proto ip_proto tp_src tp_dst nw_src nw_dst ipv4_src ipv4_dst
Description
Switch input port (int)
Switch physical input port (int)
Metadata passed between tables (string)
Ethernet destination address (string)
Ethernet source address (string)
Ethernet destination address (string)
Ethernet source address (string)
Ethernet frame type (int)
Ethernet frame type (int)
VLAN id (int or string)
VLAN id (int or string)
VLAN priority (int)
IP DSCP (6 bits in ToS field) (int)
IP ECN (2 bits in ToS field) (int)
IP protocol (int)
IP protocol (int)
Transport layer source port (int)
Transport layer destination port (int)
IPv4 source address (string)
IPv4 destination address (string)
IPv4 source address (string)
IPv4 destination address (string)
Example
{“in_port”: 7}
{“in_phy_port”: 5, “in_port”: 3}
{“metadata”: “0x1212121212121212”}
{“dl_dst”: “aa:bb:cc:11:22:33/00:00:00:00:ff:ff”}
{“dl_src”: “aa:bb:cc:11:22:33”}
{“eth_dst”: “aa:bb:cc:11:22:33/00:00:00:00:ff:ff”}
{“eth_src”: “aa:bb:cc:11:22:33”}
{“dl_type”: 123}
{“eth_type”: 2048}
See
Example of VLAN ID match field
See
Example of VLAN ID match field
{“vlan_pcp”: 3, “vlan_vid”: 3}
{“ip_dscp”: 3, “eth_type”: 2048}
{“ip_ecn”: 0, “eth_type”: 34525}
{“nw_proto”: 5, “eth_type”: 2048}
{“ip_proto”: 5, “eth_type”: 34525}
{“tp_src”: 1, “ip_proto”: 6, “eth_type”: 2048}
{“tp_dst”: 2, “ip_proto”: 6, “eth_type”: 2048}
{“nw_src”: “192.168.0.1”, “eth_type”: 2048}
{“nw_dst”: “192.168.0.1/24”, “eth_type”: 2048}
{“ipv4_src”: “192.168.0.1”, “eth_type”: 2048}
{“ipv4_dst”: “192.168.10.10/255.255.255.0”, “eth_type”: 2048}
6.2. ryu.app.ofctl_rest
299
Continued on next page
ryu Documentation, Release 3.21
Match field tcp_src tcp_dst udp_src udp_dst sctp_src sctp_dst
Description
TCP source port (int)
TCP destination port (int)
UDP source port (int)
UDP destination port (int)
SCTP source port (int)
SCTP destination port (int)
Table 6.1 – continued from previous page
Example
{“tcp_src”: 3, “ip_proto”: 6, “eth_type”: 2048}
{“tcp_dst”: 5, “ip_proto”: 6, “eth_type”: 2048}
{“udp_src”: 2, “ip_proto”: 17, “eth_type”: 2048}
{“udp_dst”: 6, “ip_proto”: 17, “eth_type”: 2048} icmpv4_type icmpv4_code arp_op arp_spa arp_tpa arp_sha arp_tha ipv6_src
ICMP type (int)
ICMP code (int)
ARP opcode (int)
ARP source IPv4 address (string)
ARP target IPv4 address (string)
ARP source hardware address (string)
ARP target hardware address (string)
IPv6 source address (string)
{“sctp_src”: 99, “ip_proto”: 132, “eth_type”: 2048}
{“sctp_dst”: 99, “ip_proto”: 132, “eth_type”: 2048}
{“icmpv4_type”: 5, “ip_proto”: 1, “eth_type”: 2048}
{“icmpv4_code”: 6, “ip_proto”: 1, “eth_type”: 2048}
{“arp_op”: 3, “eth_type”: 2054}
{“arp_spa”: “192.168.0.11”, “eth_type”: 2054}
{“arp_tpa”: “192.168.0.44/24”, “eth_type”: 2054}
{“arp_sha”: “aa:bb:cc:11:22:33”, “eth_type”: 2054} ipv6_dst ipv6_flabel icmpv6_type
IPv6 destination address (string)
IPv6 Flow Label (int)
ICMPv6 type (int)
{“arp_tha”: “aa:bb:cc:11:22:33/00:00:00:00:ff:ff”, “eth_type”: 2054}
{“ipv6_src”: “2001::aaaa:bbbb:cccc:1111”, “eth_type”: 34525}
{“ipv6_dst”: “2001::ffff:cccc:bbbb:1111/64”, “eth_type”: 34525}
{“ipv6_flabel”: 2, “eth_type”: 34525}
{“icmpv6_type”: 3, “ip_proto”: 58, “eth_type”: 34525} icmpv6_code ICMPv6 code (int) ipv6_nd_target Target address for Neighbor Discovery (string) ipv6_nd_sll ipv6_nd_tll
Source link-layer for Neighbor Discovery (string)
Target link-layer for Neighbor Discovery (string)
{“icmpv6_code”: 4, “ip_proto”: 58, “eth_type”: 34525}
{“ipv6_nd_target”: “2001::ffff:cccc:bbbb:1111”, “icmpv6_type”: 135, “ip_proto”: 58, “eth_type”: 34525}
{“ipv6_nd_sll”: “aa:bb:cc:11:22:33”, “icmpv6_type”: 135, “ip_proto”: 58, “eth_type”: 34525}
{“ipv6_nd_tll”: “aa:bb:cc:11:22:33”, “icmpv6_type”: 136, “ip_proto”: 58, “eth_type”: 34525} mpls_label mpls_tc mpls_bos pbb_isid tunnel_id ipv6_exthdr
MPLS label (int)
MPLS Traffic Class (int)
MPLS BoS bit (int)
PBB I-SID (int)
Logical Port Metadata (int)
IPv6 Extension Header pseudo-field (string)
{“mpls_label”: 3, “eth_type”: 34888}
{“mpls_tc”: 2, “eth_type”: 34888}
{“mpls_bos”: 1, “eth_type”: 34888}
{“pbb_isid”: 5, “eth_type”: 35047}
{“tunnel_id”: 7}
{“ipv6_exthdr”: “0x40/0x1F0”, “eth_type”: 34525}
300
Note: Some field can be described with mask like as follows.
Ethernet address:
"aa:bb:cc:11:22:33"
"aa:bb:cc:11:22:33/00:00:00:00:ff:ff"
IPv4 address:
"192.168.0.11"
"192.168.0.44/24"
"192.168.10.10/255.255.255.0"
IPv6 address:
"2001::ffff:cccc:bbbb:1111"
"2001::ffff:cccc:bbbb:2222/64"
"2001::ffff:cccc:bbbb:2222/ffff:ffff:ffff:ffff::0"
Metadata:
"0x1212121212121212"
"0x3434343434343434/0x01010101010101010"
Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
Example of VLAN ID match field
The following is available in OpenFlow1.0 or later.
• To match only packets with VLAN tag and VLAN ID equal value 5:
$ curl -X POST -d '{
"dpid": 1,
"match":{
"dl_vlan": 5
},
"actions":[
{
"type":"OUTPUT",
"port": 1
}
]
}' http://localhost:8080/stats/flowentry/add
Note: When “dl_vlan” field is described as decimal int value, OFPVID_PRESENT(0x1000) bit is automatically applied.
The following is available in OpenFlow1.2 or later.
• To match only packets without a VLAN tag:
$ curl -X POST -d '{
"dpid": 1,
"match":{
"dl_vlan": "0x0000" # Describe OFPVID_NONE(0x0000)
},
"actions":[
{
"type":"OUTPUT",
"port": 1
}
]
}' http://localhost:8080/stats/flowentry/add
• To match only packets with a VLAN tag regardless of its value:
$ curl -X POST -d '{
"dpid": 1,
"match":{
"dl_vlan": "0x1000/0x1000" # Describe OFPVID_PRESENT(0x1000/0x1000)
},
"actions":[
{
"type":"OUTPUT",
"port": 1
}
]
}' http://localhost:8080/stats/flowentry/add
• To match only packets with VLAN tag and VLAN ID equal value 5:
6.2. ryu.app.ofctl_rest
301
ryu Documentation, Release 3.21
$ curl -X POST -d '{
"dpid": 1,
"match":{
"dl_vlan": "0x1005" # Describe sum of VLAN-ID(e.g. 5) | OFPVID_PRESENT(0x1000)
},
"actions":[
{
"type":"OUTPUT",
"port": 1
}
]
}' http://localhost:8080/stats/flowentry/add
Note: When using the descriptions for OpenFlow1.2 or later, please describe “dl_vlan” field as hexadecimal string value, and OFPVID_PRESENT(0x1000) bit is NOT automatically applied.
Description of Actions on request messages
List of Actions (OpenFlow1.0):
Actions
OUTPUT
Description
Output packet from “port”
“vlan_vid”
Example
{“type”: “OUTPUT”, “port”: 3}
{“type”: “SET_VLAN_VID”,
“vlan_vid”: 5}
{“type”: “SET_VLAN_PCP”,
“vlan_pcp”: 3} “vlan_pcp”
STRIP_VLANStrip the 802.1Q header
SET_DL_SRCSet ethernet source address using
“dl_src”
{“type”: “STRIP_VLAN”}
{“type”: “SET_DL_SRC”, “dl_src”:
“aa:bb:cc:11:22:33”}
SET_DL_DSTSet ethernet destination address using “dl_dst”
{“type”: “SET_DL_DST”, “dl_dst”:
“aa:bb:cc:11:22:33”}
SET_NW_SRCIP source address using “nw_src” {“type”: “SET_NW_SRC”,
“nw_src”: “10.0.0.1”}
SET_NW_DSTIP destination address using
“nw_dst”
SET_NW_TOSSet IP ToS (DSCP field, 6 bits) using “nw_tos”
SET_TP_SRC Set TCP/UDP source port using
“tp_src”
SET_TP_DST Set TCP/UDP destination port using “tp_dst”
ENQUEUE Output to queue with “queue_id” attached to “port”
{“type”: “SET_NW_DST”,
“nw_dst”: “10.0.0.1”}
{“type”: “SET_NW_TOS”, “nw_tos”:
184}
{“type”: “SET_TP_SRC”, “tp_src”:
8080}
{“type”: “SET_TP_DST”, “tp_dst”:
8080}
{“type”: “ENQUEUE”, “queue_id”:
3, “port”: 1}
List of Actions (OpenFlow1.2 or later):
302 Chapter 6. Built-in Ryu applications
ryu Documentation, Release 3.21
Actions
OUT-
PUT
Description
Output packet from “port” outputting to a port
Apply group identified by “group_id”
Example
{“type”: “OUTPUT”, “port”: 3}
{“type”: “COPY_TTL_OUT”}
{“type”: “COPY_TTL_IN”}
{“type”: “SET_MPLS_TTL”,
“mpls_ttl”: 64}
POP_VLANPop the outer VLAN tag
{“type”: “DEC_MPLS_TTL”}
{“type”: “PUSH_VLAN”,
“ethertype”: 33024}
{“type”: “POP_VLAN”}
{“type”: “PUSH_MPLS”,
“ethertype”: 34887}
POP_MPLS Pop the outer MPLS tag with “ethertype” {“type”: “POP_MPLS”,
“ethertype”: 2054}
GROUP
{“type”: “SET_QUEUE”,
“queue_id”: 7}
{“type”: “GROUP”, “group_id”:
5}
{“type”: “SET_NW_TTL”,
“nw_ttl”: 64}
{“type”: “DEC_NW_TTL”}
See
SET_FIELDSet a “field” using “value” (The set of keywords available for “field” is the same as match field)
PUSH_PBB Push a new PBB service tag with
“ethertype”
POP_PBB Pop the outer PBB service tag
METER identified by “table_id” using “metadata” and “metadata_mask”
(Instruction) Apply meter identified by
“meter_id”
{“type”: “PUSH_PBB”,
“ethertype”: 35047}
{“type”: “POP_PBB”}
{“type”: “GOTO_TABLE”,
“table_id”: 8}
{“type”:
“WRITE_METADATA”,
“metadata”: 0x3,
“metadata_mask”: 0x3}
{“type”: “METER”, “meter_id”:
3}
Example of set-field action
To set VLAN ID to non-VLAN-tagged frame:
"actions":[
{
"type": "PUSH_VLAN",
"ethertype": 33024
},
{
"type": "SET_FIELD",
"field": "vlan_vid",
"value": 4102
},
{
"type": "OUTPUT",
"port": 2
# Push a new VLAN tag if a input frame is non-VLAN-tagged
# Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
# Set VLAN ID
# Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
6.2. ryu.app.ofctl_rest
303
ryu Documentation, Release 3.21
]
}
304 Chapter 6. Built-in Ryu applications
• genindex
• modindex
• search
CHAPTER
7
Indices and tables
305
ryu Documentation, Release 3.21
306 Chapter 7. Indices and tables
r ryu.app.ofctl.exception
,
ryu.controller.ofp_event
,
ryu.lib.netconf
,
ryu.lib.of_config
,
ryu.lib.ovs
,
ryu.lib.packet
,
ryu.lib.packet.arp
,
ryu.lib.packet.cfm
,
ryu.lib.packet.ethernet
,
ryu.lib.packet.icmp
,
ryu.lib.packet.icmpv6
,
ryu.lib.packet.ipv4
,
ryu.lib.packet.ipv6
,
ryu.lib.packet.mpls
,
ryu.lib.packet.packet
,
ryu.lib.packet.packet_base
,
ryu.lib.packet.pbb
,
ryu.lib.packet.sctp
,
ryu.lib.packet.stream_parser
,
ryu.lib.packet.tcp
,
ryu.lib.packet.udp
,
ryu.lib.packet.vlan
,
ryu.lib.xflow
,
ryu.ofproto.ofproto_v1_0
,
ryu.ofproto.ofproto_v1_0_parser
,
ryu.ofproto.ofproto_v1_2
,
ryu.ofproto.ofproto_v1_2_parser
,
ryu.ofproto.ofproto_v1_3
,
ryu.ofproto.ofproto_v1_3_parser
,
ryu.ofproto.ofproto_v1_4
,
ryu.ofproto.ofproto_v1_4_parser
,
ryu.topology
,
Python Module Index
307
ryu Documentation, Release 3.21
308 Python Module Index
Index
Symbols C
_TYPE (ryu.ofproto.ofproto_parser.MsgBase attribute),
A
cause_cookie_while_shutdown ryu.lib.packet.sctp),
(class in cause_invalid_param (class in ryu.lib.packet.sctp),
cause_invalid_stream_id (class in ryu.lib.packet.sctp),
add_protocol() (ryu.lib.packet.packet.Packet method),
cause_missing_param (class in ryu.lib.packet.sctp),
arp (class in ryu.lib.packet.arp),
cause_no_userdata (class in ryu.lib.packet.sctp),
arp_ip() (in module ryu.lib.packet.arp),
cause_out_of_resource (class in ryu.lib.packet.sctp),
ASPathFilter (class in cause_protocol_violation (class in ryu.lib.packet.sctp),
ryu.services.protocols.bgp.info_base.base), cause_restart_with_new_addr (class in
ryu.lib.packet.sctp),
attribute_map_get() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
cause_unrecognized_chunk (class in ryu.lib.packet.sctp), method),
AttributeMap (class ryu.services.protocols.bgp.info_base.base), in
auth (class in ryu.lib.packet.ipv6),
authenticate() (ryu.lib.packet.bfd.bfd method),
authenticate() (ryu.lib.packet.bfd.KeyedMD5 method),
authenticate() (ryu.lib.packet.bfd.KeyedSHA1 method),
authenticate() method),
(ryu.lib.packet.bfd.SimplePassword
B bfd (class in ryu.lib.packet.bfd),
BGPKeepAlive (class in ryu.lib.packet.bgp),
BGPMessage (class in ryu.lib.packet.bgp),
BGPNotification (class in ryu.lib.packet.bgp),
BGPOpen (class in ryu.lib.packet.bgp),
BGPSpeaker (class ryu.services.protocols.bgp.bgpspeaker),
BGPUpdate (class in ryu.lib.packet.bgp),
in cause_unrecognized_param (class in ryu.lib.packet.sctp),
cause_unresolvable_addr (class in ryu.lib.packet.sctp),
cause_user_initiated_abort (class in ryu.lib.packet.sctp),
cc_message (class in ryu.lib.packet.cfm),
cfm (class in ryu.lib.packet.cfm),
chunk_abort (class in ryu.lib.packet.sctp),
chunk_cookie_ack (class in ryu.lib.packet.sctp),
chunk_cookie_echo (class in ryu.lib.packet.sctp),
chunk_cwr (class in ryu.lib.packet.sctp),
chunk_data (class in ryu.lib.packet.sctp),
chunk_ecn_echo (class in ryu.lib.packet.sctp),
chunk_error (class in ryu.lib.packet.sctp),
chunk_heartbeat (class in ryu.lib.packet.sctp),
chunk_heartbeat_ack (class in ryu.lib.packet.sctp),
chunk_init (class in ryu.lib.packet.sctp),
chunk_init_ack (class in ryu.lib.packet.sctp),
chunk_sack (class in ryu.lib.packet.sctp),
chunk_shutdown (class in ryu.lib.packet.sctp),
chunk_shutdown_ack (class in ryu.lib.packet.sctp),
method),
method),
bpdu (class in ryu.lib.packet.bpdu),
method),
clone() (ryu.services.protocols.bgp.info_base.base.AttributeMap
309
ryu Documentation, Release 3.21
method),
igmpv3_query (class in ryu.lib.packet.igmp),
clone() (ryu.services.protocols.bgp.info_base.base.PrefixFilter
method),
ConfigurationBPDUs (class in ryu.lib.packet.bpdu),
ControlFormatI (class in ryu.lib.packet.llc),
ControlFormatS (class in ryu.lib.packet.llc),
igmpv3_report_group (class in ryu.lib.packet.igmp),
in_filter_get() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
in_filter_set() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
ControlFormatU (class in ryu.lib.packet.llc),
create() (ryu.lib.packet.vrrp.vrrpv2 static method),
create() (ryu.lib.packet.vrrp.vrrpv3 static method),
create_packet() (ryu.lib.packet.vrrp.vrrp method),
D method),
InvalidDatapath,
interface_status_tlv (class in ryu.lib.packet.cfm),
ipv4 (class in ryu.lib.packet.ipv4),
ipv6 (class in ryu.lib.packet.ipv6),
itag (class in ryu.lib.packet.pbb),
data_tlv (class in ryu.lib.packet.cfm),
dest_unreach (class in ryu.lib.packet.icmp),
dhcp (class in ryu.lib.packet.dhcp),
dst_opts (class in ryu.lib.packet.ipv6),
K
KeyedMD5 (class in ryu.lib.packet.bfd),
KeyedSHA1 (class in ryu.lib.packet.bfd),
I
E
L echo (class in ryu.lib.packet.icmp),
lacp (class in ryu.lib.packet.slow),
echo (class in ryu.lib.packet.icmpv6),
link_trace_message (class in ryu.lib.packet.cfm),
ethernet (class in ryu.lib.packet.ethernet),
method),
link_trace_reply (class in ryu.lib.packet.cfm), evaluate() (ryu.services.protocols.bgp.info_base.base.ASPathFilter
loopback_message (class in ryu.lib.packet.cfm),
evaluate() (ryu.services.protocols.bgp.info_base.base.AttributeMap
method),
ltm_egress_identifier_tlv (class in ryu.lib.packet.cfm),
evaluate() (ryu.services.protocols.bgp.info_base.base.PrefixFilter
method),
EventPrefix (class in ryu.services.protocols.bgp.bgpspeaker),
M
MeticulousKeyedMD5 (class in ryu.lib.packet.bfd),
MeticulousKeyedSHA1 (class in ryu.lib.packet.bfd),
F mld (class in ryu.lib.packet.icmpv6),
fragment (class in ryu.lib.packet.ipv6),
from_jsondict() (ryu.ofproto.ofproto_parser.MsgBase
method),
G mldv2_query (class in ryu.lib.packet.icmpv6),
mldv2_report (class in ryu.lib.packet.icmpv6),
mldv2_report_group (class in ryu.lib.packet.icmpv6),
mpls (class in ryu.lib.packet.mpls),
MsgBase (class in ryu.ofproto.ofproto_parser),
get_packet_type() (ryu.lib.packet.ethernet.ethernet class method),
get_packet_type() (ryu.lib.packet.packet_base.PacketBase
class method),
get_packet_type() (ryu.lib.packet.vlan.vlan
class method),
get_protocol() (ryu.lib.packet.packet.Packet method),
get_protocols() (ryu.lib.packet.packet.Packet method),
H header (class in ryu.lib.packet.ipv6),
hop_opts (class in ryu.lib.packet.ipv6),
icmp (class in ryu.lib.packet.icmp),
icmpv6 (class in ryu.lib.packet.icmpv6),
igmp (class in ryu.lib.packet.igmp),
N nd_neighbor (class in ryu.lib.packet.icmpv6),
nd_option_pi (class in ryu.lib.packet.icmpv6),
nd_option_sla (class in ryu.lib.packet.icmpv6),
nd_option_tla (class in ryu.lib.packet.icmpv6),
nd_router_advert (class in ryu.lib.packet.icmpv6),
nd_router_solicit (class in ryu.lib.packet.icmpv6),
neighbor_add() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
neighbor_del() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
neighbor_get() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
neighbor_reset() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
neighbor_update() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
310 Index
ryu Documentation, Release 3.21
O
OFError,
ofp_msg_from_jsondict() (in ryu.ofproto.ofproto_parser),
OFPActionCopyTtlIn (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionCopyTtlIn (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionCopyTtlIn (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionCopyTtlOut (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionCopyTtlOut (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionCopyTtlOut (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionDecMplsTtl (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionDecMplsTtl (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionDecMplsTtl (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionDecNwTtl (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionDecNwTtl (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionDecNwTtl (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionExperimenter (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionExperimenter (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionExperimenter (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionGroup (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionGroup (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionGroup (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionOutput (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionOutput (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionOutput (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionPopMpls (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionPopMpls (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionPopMpls (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionPopPbb (class ryu.ofproto.ofproto_v1_4_parser),
module in in in in in in in in in in in in in in in in in in in in in in in in in
OFPActionPopVlan (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionPopVlan (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionPopVlan (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionPushMpls (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionPushMpls (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionPushMpls (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionPushPbb (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionPushVlan (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionPushVlan (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionPushVlan (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionSetField (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionSetField (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionSetField (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionSetMplsTtl (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionSetMplsTtl (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionSetMplsTtl (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionSetNwTtl (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionSetNwTtl (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionSetNwTtl (class ryu.ofproto.ofproto_v1_4_parser),
OFPActionSetQueue (class ryu.ofproto.ofproto_v1_2_parser),
OFPActionSetQueue (class ryu.ofproto.ofproto_v1_3_parser),
OFPActionSetQueue (class ryu.ofproto.ofproto_v1_4_parser),
OFPAggregateStatsReply (class ryu.ofproto.ofproto_v1_2_parser),
OFPAggregateStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPAggregateStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPAggregateStatsRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPAggregateStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
Index 311
in in in in in in in in in in in in in in in in in in in in in in in in in in in
ryu Documentation, Release 3.21
OFPAggregateStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPBarrierReply (class ryu.ofproto.ofproto_v1_2_parser),
OFPBarrierReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPBarrierReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPBarrierRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPBarrierRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPBarrierRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPBundleAddMsg (class ryu.ofproto.ofproto_v1_4_parser),
OFPBundleCtrlMsg (class ryu.ofproto.ofproto_v1_4_parser),
OFPDescStats (class ryu.ofproto.ofproto_v1_2_parser),
OFPDescStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPDescStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPDescStatsRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPDescStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPDescStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPEchoReply (class ryu.ofproto.ofproto_v1_2_parser),
OFPEchoReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPEchoReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPEchoRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPEchoRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPEchoRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPErrorMsg (class ryu.ofproto.ofproto_v1_2_parser),
OFPErrorMsg (class ryu.ofproto.ofproto_v1_3_parser),
OFPErrorMsg (class ryu.ofproto.ofproto_v1_4_parser),
OFPExperimenter (class ryu.ofproto.ofproto_v1_2_parser),
OFPExperimenter (class ryu.ofproto.ofproto_v1_3_parser),
OFPExperimenter (class ryu.ofproto.ofproto_v1_4_parser),
312
in in in in in in in in in in in in in in in in in in in in in in in in in in in
OFPExperimenterStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPExperimenterStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPFeaturesRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPFeaturesRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPFeaturesRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPFlowMod (class ryu.ofproto.ofproto_v1_2_parser),
OFPFlowMod (class ryu.ofproto.ofproto_v1_3_parser),
OFPFlowMod (class ryu.ofproto.ofproto_v1_4_parser),
OFPFlowMonitorReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPFlowMonitorRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPFlowRemoved (class ryu.ofproto.ofproto_v1_2_parser),
OFPFlowRemoved (class ryu.ofproto.ofproto_v1_3_parser),
OFPFlowRemoved (class ryu.ofproto.ofproto_v1_4_parser),
OFPFlowStats (class ryu.ofproto.ofproto_v1_2_parser),
OFPFlowStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPFlowStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPFlowStatsRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPFlowStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPFlowStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPGetAsyncReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPGetAsyncReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPGetAsyncRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPGetAsyncRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPGetConfigReply (class ryu.ofproto.ofproto_v1_2_parser),
OFPGetConfigReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPGetConfigReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPGetConfigRequest (class ryu.ofproto.ofproto_v1_2_parser),
in in in in in in in in in in in in in in in in in in in in in in in in in in in
Index
ryu Documentation, Release 3.21
OFPGetConfigRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPGetConfigRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPGroupDescStats (class ryu.ofproto.ofproto_v1_2_parser),
OFPGroupDescStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPGroupDescStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPGroupDescStatsRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPGroupDescStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPGroupDescStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPGroupFeaturesStats (class ryu.ofproto.ofproto_v1_2_parser),
OFPGroupFeaturesStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPGroupFeaturesStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPGroupFeaturesStatsRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPGroupFeaturesStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPGroupFeaturesStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPGroupMod (class ryu.ofproto.ofproto_v1_2_parser),
OFPGroupMod (class ryu.ofproto.ofproto_v1_3_parser),
OFPGroupMod (class ryu.ofproto.ofproto_v1_4_parser),
OFPGroupStats (class ryu.ofproto.ofproto_v1_2_parser),
in in in in in in in in in in in in in in in in in in
OFPGroupStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPGroupStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPGroupStatsRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPGroupStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
in in in in
OFPGroupStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
in
OFPHello (class in ryu.ofproto.ofproto_v1_2_parser),
OFPHello (class in ryu.ofproto.ofproto_v1_3_parser),
OFPHello (class in ryu.ofproto.ofproto_v1_4_parser),
OFPHelloElemVersionBitmap (class ryu.ofproto.ofproto_v1_3_parser),
in
OFPHelloElemVersionBitmap (class ryu.ofproto.ofproto_v1_4_parser),
OFPInstructionActions (class ryu.ofproto.ofproto_v1_2_parser),
OFPInstructionActions (class ryu.ofproto.ofproto_v1_3_parser),
OFPInstructionActions (class ryu.ofproto.ofproto_v1_4_parser),
OFPInstructionGotoTable (class ryu.ofproto.ofproto_v1_2_parser),
in in in in in
OFPInstructionGotoTable (class ryu.ofproto.ofproto_v1_3_parser),
OFPInstructionGotoTable (class ryu.ofproto.ofproto_v1_4_parser),
OFPInstructionMeter (class ryu.ofproto.ofproto_v1_3_parser),
OFPInstructionMeter (class ryu.ofproto.ofproto_v1_4_parser),
OFPInstructionWriteMetadata (class ryu.ofproto.ofproto_v1_2_parser),
OFPInstructionWriteMetadata (class in in in in in in ryu.ofproto.ofproto_v1_3_parser),
OFPInstructionWriteMetadata (class in ryu.ofproto.ofproto_v1_4_parser),
OFPMatch (class in ryu.ofproto.ofproto_v1_2_parser),
OFPMatch (class in ryu.ofproto.ofproto_v1_3_parser),
OFPMatch (class in ryu.ofproto.ofproto_v1_4_parser),
OFPMeterConfigStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPMeterConfigStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPMeterConfigStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
in in in in OFPMeterConfigStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPMeterFeaturesStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPMeterFeaturesStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPMeterFeaturesStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
in in in in OFPMeterFeaturesStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPMeterMod (class ryu.ofproto.ofproto_v1_3_parser),
OFPMeterMod (class ryu.ofproto.ofproto_v1_4_parser),
OFPMeterStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPMeterStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
in in in in
Index 313
ryu Documentation, Release 3.21
OFPMeterStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPMeterStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
in in
OFPPacketIn (class in ryu.ofproto.ofproto_v1_2_parser),
OFPPacketIn (class in ryu.ofproto.ofproto_v1_3_parser),
OFPPacketIn (class in ryu.ofproto.ofproto_v1_4_parser),
OFPPacketOut (class ryu.ofproto.ofproto_v1_2_parser),
in in OFPPacketOut (class ryu.ofproto.ofproto_v1_3_parser),
OFPPacketOut (class ryu.ofproto.ofproto_v1_4_parser),
in
OFPPortDescStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPPortDescStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPPortDescStatsRequest (class in in in ryu.ofproto.ofproto_v1_3_parser),
OFPPortDescStatsRequest (class in ryu.ofproto.ofproto_v1_4_parser),
OFPPortMod (class in ryu.ofproto.ofproto_v1_2_parser),
OFPPortMod (class in ryu.ofproto.ofproto_v1_3_parser),
OFPPortMod (class in ryu.ofproto.ofproto_v1_4_parser),
OFPPortStats (class in ryu.ofproto.ofproto_v1_2_parser),
OFPPortStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPPortStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
in in in OFPPortStatsRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPPortStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
in in OFPPortStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPPortStatus (class ryu.ofproto.ofproto_v1_2_parser),
OFPPortStatus (class ryu.ofproto.ofproto_v1_3_parser),
OFPPortStatus (class ryu.ofproto.ofproto_v1_4_parser),
OFPQueueDescStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPQueueDescStatsRequest (class in in in in in ryu.ofproto.ofproto_v1_4_parser),
OFPQueueGetConfigReply (class ryu.ofproto.ofproto_v1_2_parser),
in
OFPQueueGetConfigReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPQueueGetConfigRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPQueueGetConfigRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPQueueStats (class ryu.ofproto.ofproto_v1_2_parser),
OFPQueueStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPQueueStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPQueueStatsRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPQueueStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPQueueStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPRequestForward (class ryu.ofproto.ofproto_v1_4_parser),
OFPRoleReply (class ryu.ofproto.ofproto_v1_2_parser),
OFPRoleReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPRoleReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPRoleRequest (class ryu.ofproto.ofproto_v1_2_parser),
OFPRoleRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPRoleRequest (class ryu.ofproto.ofproto_v1_4_parser),
OFPRoleStatus (class ryu.ofproto.ofproto_v1_4_parser),
OFPSetAsync (class ryu.ofproto.ofproto_v1_3_parser),
OFPSetAsync (class ryu.ofproto.ofproto_v1_4_parser),
OFPSetConfig (class ryu.ofproto.ofproto_v1_2_parser),
OFPSetConfig (class ryu.ofproto.ofproto_v1_3_parser),
OFPSetConfig (class ryu.ofproto.ofproto_v1_4_parser),
OFPSwitchFeatures (class ryu.ofproto.ofproto_v1_2_parser),
OFPSwitchFeatures (class ryu.ofproto.ofproto_v1_3_parser),
OFPSwitchFeatures (class ryu.ofproto.ofproto_v1_4_parser),
OFPTableDescStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPTableDescStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
314 Index
in in in in in in in in in in in in in in in in in in in in in in in in in in in
ryu Documentation, Release 3.21
OFPTableFeaturesStatsReply (class ryu.ofproto.ofproto_v1_3_parser),
OFPTableFeaturesStatsReply (class ryu.ofproto.ofproto_v1_4_parser),
OFPTableFeaturesStatsRequest (class ryu.ofproto.ofproto_v1_3_parser),
OFPTableFeaturesStatsRequest (class ryu.ofproto.ofproto_v1_4_parser),
in in in in parser() (ryu.lib.packet.packet_base.PacketBase
class method),
port_status_tlv (class in ryu.lib.packet.cfm),
prefix_add() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
prefix_del() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
PrefixFilter (class in ryu.services.protocols.bgp.info_base.base),
OFPTableMod (class ryu.ofproto.ofproto_v1_2_parser),
in
OFPTableMod (class in
R ryu.ofproto.ofproto_v1_3_parser),
register_packet_type() (ryu.lib.packet.packet_base.PacketBase
OFPTableMod (class in class method),
ryu.ofproto.ofproto_v1_4_parser),
reply_egress_tlv (class in ryu.lib.packet.cfm),
OFPTableStats (class in reply_ingress_tlv (class in ryu.lib.packet.cfm),
ryu.ofproto.ofproto_v1_2_parser),
rib_get() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
OFPTableStatsReply (class in method),
ryu.ofproto.ofproto_v1_3_parser),
routing (class in ryu.lib.packet.ipv6),
OFPTableStatsReply (class in routing_type3 (class in ryu.lib.packet.ipv6),
ryu.ofproto.ofproto_v1_4_parser),
OFPTableStatsRequest (class in
RstBPDUs (class in ryu.lib.packet.bpdu), ryu.app.ofctl.exception (module),
ryu.ofproto.ofproto_v1_2_parser),
ryu.controller.ofp_event (module),
OFPTableStatsRequest (class in ryu.lib.netconf (module),
ryu.ofproto.ofproto_v1_3_parser),
OFPTableStatsRequest (class
in ryu.lib.of_config (module),
ryu.lib.ovs (module),
ryu.ofproto.ofproto_v1_4_parser),
ryu.lib.packet (module),
OFPTableStatus (class in ryu.lib.packet.arp (module),
ryu.ofproto.ofproto_v1_4_parser),
ryu.lib.packet.cfm (module),
opt_header (class in ryu.lib.packet.ipv6),
ryu.lib.packet.ethernet (module),
option (class in ryu.lib.packet.dhcp),
ryu.lib.packet.icmp (module),
option (class in ryu.lib.packet.ipv6),
ryu.lib.packet.icmpv6 (module),
options (class in ryu.lib.packet.dhcp),
ryu.lib.packet.ipv4 (module),
organization_specific_tlv (class in ryu.lib.packet.cfm),
ryu.lib.packet.ipv6 (module),
out_filter_get() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
ryu.lib.packet.packet (module),
out_filter_set() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
ryu.lib.packet.pbb (module),
P pack() (ryu.lib.packet.bfd.bfd method),
Packet (class in ryu.lib.packet.packet),
PacketBase (class in ryu.lib.packet.packet_base),
param_cookie_preserve (class in ryu.lib.packet.sctp),
param_ecn (class in ryu.lib.packet.sctp),
param_heartbeat (class in ryu.lib.packet.sctp),
param_host_addr (class in ryu.lib.packet.sctp),
param_ipv4 (class in ryu.lib.packet.sctp),
param_ipv6 (class in ryu.lib.packet.sctp),
param_state_cookie (class in ryu.lib.packet.sctp),
param_supported_addr (class in ryu.lib.packet.sctp),
param_unrecognized_param (class in ryu.lib.packet.sctp),
parse() (ryu.lib.packet.stream_parser.StreamParser
method),
ryu.lib.packet.sctp (module),
ryu.lib.packet.stream_parser (module),
ryu.lib.packet.tcp (module),
ryu.lib.packet.udp (module),
ryu.lib.packet.vlan (module),
ryu.lib.xflow (module),
ryu.ofproto.ofproto_v1_0 (module),
ryu.ofproto.ofproto_v1_0_parser (module),
ryu.ofproto.ofproto_v1_2 (module),
ryu.ofproto.ofproto_v1_2_parser (module),
ryu.ofproto.ofproto_v1_3 (module),
ryu.ofproto.ofproto_v1_3_parser (module),
ryu.ofproto.ofproto_v1_4 (module),
ryu.ofproto.ofproto_v1_4_parser (module),
ryu.topology (module),
Index 315
ryu Documentation, Release 3.21
S sctp (class in ryu.lib.packet.sctp),
sender_id_tlv (class in ryu.lib.packet.cfm),
serialize() (ryu.lib.packet.bfd.KeyedMD5 method),
serialize() (ryu.lib.packet.bfd.KeyedSHA1 method),
serialize() (ryu.lib.packet.bfd.SimplePassword method),
serialize() (ryu.lib.packet.packet.Packet method),
serialize() (ryu.lib.packet.packet_base.PacketBase
method),
shutdown() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
SimplePassword (class in ryu.lib.packet.bfd),
slow (class in ryu.lib.packet.slow),
StreamParser (class in ryu.lib.packet.bgp),
StreamParser (class in ryu.lib.packet.stream_parser),
svlan (class in ryu.lib.packet.vlan),
T tcp (class in ryu.lib.packet.tcp),
TimeExceeded (class in ryu.lib.packet.icmp),
to_jsondict() (ryu.ofproto.ofproto_parser.MsgBase
method),
TopologyChangeNotificationBPDUs ryu.lib.packet.bpdu),
(class in try_parse() (ryu.lib.packet.stream_parser.StreamParser
method),
U udp (class in ryu.lib.packet.udp),
UnexpectedMultiReply,
V vlan (class in ryu.lib.packet.vlan),
vrf_add() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
vrf_del() (ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker
method),
vrrp (class in ryu.lib.packet.vrrp),
vrrpv2 (class in ryu.lib.packet.vrrp),
vrrpv3 (class in ryu.lib.packet.vrrp),
316 Index
advertisement
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Related manuals
advertisement
Table of contents
- 7 Getting Started
- 7 What's Ryu
- 7 Quick Start
- 7 Optional Requirements
- 8 Support
- 9 Writing Your Ryu Application
- 9 The First Application
- 10 Components of Ryu
- 13 Ryu application API
- 18 Library
- 65 OpenFlow protocol API Reference
- 262 Ryu API Reference
- 263 Configuration
- 263 Setup TLS Connection
- 264 Topology Viewer
- 267 Tests
- 267 Testing VRRP Module
- 270 Testing OF-config support with LINC
- 275 Using Ryu Network Operating System with OpenStack as OpenFlow controller
- 277 Built-in Ryu applications
- 277 ryu.app.ofctl
- 277 ryu.app.ofctl_rest
- 309 Indices and tables
- 311 Python Module Index