Packet library API Reference

Packet class

class ryu.lib.packet.packet.Packet(data=None, protocols=None, parse_cls=<class 'ryu.lib.packet.ethernet.ethernet'>)

A packet decoder/encoder class.

An instance is used to either decode or encode a single packet.

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.

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.
  • 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 Example
dst destination address ‘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 Canonical Format Indicator. In a case to be used as B-TAG, this field means DEI(Drop Eligible Indication).
vid 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
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 Use Customer Address
sid 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 Experimental Use
bsb Bottom of Stack
ttl 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 ar$pro  
hlen ar$hln  
plen ar$pln  
opcode ar$op  
src_mac ar$sha ‘08:60:6e:7f:74:e7’
src_ip ar$spa ‘192.0.2.1’
dst_mac ar$tha ‘00:00:00:00:00:00’
dst_ip ar$tpa ‘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)
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.

Attribute Description Example
version Version  
header_length IHL  
tos Type of Service  
total_length Total Length (0 means automatically-calculate when encoding)  
identification Identification  
flags Flags  
offset Fragment Offset  
ttl Time to Live  
proto Protocol  
csum Header Checksum (Ignored and automatically-calculated when encoding)  
src Source Address ‘192.0.2.1’
dst Destination Address ‘192.0.2.2’
option A bytearray which contains the entire Options, or None for no Options  
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

Next-Hop MTU

NOTE: This field is required when icmp code is 4

code 4 = fragmentation needed and DF set

data 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.

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 Sequence Number
data 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 CheckSum (0 means automatically-calculate when encoding)
data 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 the length of the Authentication Header in 64-bit words, subtracting 1.
spi security parameters index.
seq sequence number.
data 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.

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 offset, in 8-octet units, relative to the start of the fragmentable part of the original packet.
more 1 means more fragments follow; 0 means last fragment.
id_ 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 the length of the Hop-by-Hop Options header, not include the first 8 octet.
data 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.

Attribute Description Example
version Version  
traffic_class Traffic Class  
flow_label When decoding, Flow Label. When encoding, the most significant 8 bits of Flow Label.  
payload_length Payload Length  
nxt Next Header  
hop_limit Hop Limit  
src Source Address ‘ff02::1’
dst Destination Address ‘::’
ext_hdrs Extension Headers  
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_ the length of data. -1 if type_ is 0.
data an option value. None if len_ is 0 or -1.
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 Description Reference
0 Source Route (DEPRECATED) [[IPV6]][RFC5095]
1 Nimrod (DEPRECATED 2009-05-06)  
2 Type 2 Routing Header [RFC6275]
3 RPL Source Route Header [RFC6554]
4 - 252 Unassigned  
253 RFC3692-style Experiment 1 [2] [RFC4727]
254 RFC3692-style Experiment 2 [2] [RFC4727]
255 Reserved  
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 Identifies the particular Routing header variant.
seg Number of route segments remaining.
cmpi Number of prefix octets from segments 1 through n-1.
cmpe Number of prefix octets from segment n.
pad Number of octets that are used for padding after Address[n] at the end of the SRH.
adrs 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 Sequence Number
data 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.

Attribute Description
type_ Type
code Code
csum CheckSum (0 means automatically-calculate when encoding)
data

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 max response time in millisecond. it is meaningful only in Query Message.
address a group address value.
s_flg when set to 1, routers suppress the timer process.
qrv robustness variable for a querier.
qqic an interval time for a querier in unit of seconds.
num a number of the multicast servers.
srcs 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)

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 the length of the auxiliary data in 32-bit words.
num a number of the multicast servers.
address a group address value.
srcs a list of IPv6 addresses of the multicast servers.
aux 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 Target Address
option 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 L,A,R* Flags for Prefix Information.
val_l Valid Lifetime.
pre_l Preferred Lifetime.
res2 This field is unused. It MUST be initialized to zero.
prefix 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.

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 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_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 M,O Flags for Router Advertisement.
rou_l Router Lifetime.
rea_t Reachable Time.
ret_t Retrans Timer.
options 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.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 Description
src_port Source Port
dst_port Destination Port
seq Sequence Number
ack Acknowledgement Number
offset Data Offset (0 means automatically-calculate when encoding)
bits Control Bits
window_size Window
csum Checksum (0 means automatically-calculate when encoding)
urgent Urgent Pointer
option 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 Description
src_port 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.

Attribute Description
op Message op code / message type. 1 = BOOTREQUEST, 2 = BOOTREPLY
htype Hardware address type (e.g. ‘1’ = 10mb ethernet).
hlen Hardware address length (e.g. ‘6’ = 10mb ethernet).
hops Client sets to zero, optionally used by relay agent when booting via a relay agent.
xid 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.
secs Filled in by client, seconds elapsed since client began address acquisition or renewal process.
flags Flags.
ciaddr Client IP address; only filled in if client is in BOUND, RENEW or REBINDING state and can respond to ARP requests.
yiaddr ‘your’ (client) IP address.
siaddr IP address of next server to use in bootstrap; returned in DHCPOFFER, DHCPACK by server.
giaddr Relay agent IP address, used in booting via a relay agent.
chaddr 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, options_len=0, magic_cookie='99.130.83.99')

DHCP (RFC 2132) options encoder/decoder class.

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 Description
option_list ‘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.

Attribute Description
version Version
type Type
vrid Virtual Rtr ID (VRID)
priority Priority
count_ip Count IPvX Addr. Calculated automatically when encoding.
max_adver_int Maximum Advertisement Interval (Max Adver Int)
checksum Checksum. Calculated automatically when encoding.
ip_addresses IPvX Address(es). A python list of IP addresses.
auth_type Authentication Type (only for VRRPv2)
auth_data 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

Subtype Value Protocol Name
0 Unused - Illegal Value
1 Link Aggregation Control Protocol(LACP)
2 Link Aggregation - Marker Protocol
3 Operations, Administration, and Maintenance(OAM)
4 - 9 Reserved for future use
10 Organization Specific Slow Protocol(OSSP)
11 - 255 Unused - Illegal values
class ryu.lib.packet.slow.lacp(version=1, actor_system_priority=0, actor_system='00:00:00:00:00:00', actor_key=0, actor_port_priority=0, actor_port=0, actor_state_activity=0, actor_state_timeout=0, actor_state_aggregation=0, actor_state_synchronization=0, actor_state_collecting=0, actor_state_distributing=0, actor_state_defaulted=0, actor_state_expired=0, partner_system_priority=0, partner_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

LACPDU structure Octets
Subtype = LACP 1
Version Number 1
TLV Actor TLV_type = Actor Information 1
  Actor_Information_Length = 20 1
  Actor_System_Priority 2
  Actor_System 6
  Actor_Key 2
  Actor_Port_Priority 2
  Actor_Port 2
  Actor_State 1
  Reserved 3
TLV Partner TLV_type = Partner Information 1
  Partner_Information_Length = 20 1
  Partner_System_Priority 2
  Partner_System 6
  Partner_Key 2
  Partner_Port_Priority 2
  Partner_Port 2
  Partner_State 1
  Reserved 3
TLV Collector TLV_type = Collector Information 1
  Collector_Information_Length = 16 1
  Collector_Max_Delay 2
  Reserved 12
TLV Terminator TLV_type = Terminator 1
  Terminator_Length = 0 1
  Reserved 50

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.

Attribute Description
version LACP version. This parameter must be set to LACP_VERSION_NUMBER(i.e. 1).
actor_system_priority The priority assigned to this System.
actor_system The Actor’s System ID, encoded as a MAC address.
actor_key The operational Key value assigned to the port by the Actor.
actor_port_priority The priority assigned to this port.
actor_port The port number assigned to the port by the Actor.
actor_state_activity

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 The priority assigned to the Partner System.
partner_system The Partner’s System ID, encoded as a MAC address.
partner_key The operational Key value assigned to the port by the Partner.
partner_port_priority The priority assigned to this port by the Partner.
partner_port The port number assigned to the port by the Partner.
partner_state_activity See actor_state_activity.
partner_state_timeout See actor_state_timeout.
partner_state_aggregation See actor_state_aggregation.
partner_state_synchronization See actor_state_synchronization.
partner_state_collecting See actor_state_collecting.
partner_state_distributing See actor_state_distributing.
partner_state_defaulted See actor_state_defaulted.
partner_state_expired See actor_state_expired.
collector_max_delay the maximum time that the Frame Collector may delay.
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, pf_bit=0, receive_sequence_number=0)

LLC sub encoder/decoder class for control I-format field.

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
send_sequence_number 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, pf_bit=0, receive_sequence_number=0)

LLC sub encoder/decoder class for control S-format field.

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
supervisory_function supervisory function bit
pf_bit poll/final bit
receive_sequence_number sender receive sequence number
class ryu.lib.packet.llc.ControlFormatU(modifier_function1=0, pf_bit=0, modifier_function2=0)

LLC sub encoder/decoder class for control U-format field.

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)

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 Description
flags
Bit 1: Topology Change flag
Bits 2 through 7: unused and take the value 0
Bit 8: Topology Change Acknowledgment flag
root_priority Root Identifier priority set 0-61440 in steps of 4096
root_system_id_extension Root Identifier system ID extension
root_mac_address Root Identifier MAC address
root_path_cost Root Path Cost
bridge_priority Bridge Identifier priority set 0-61440 in steps of 4096
bridge_system_id_extension Bridge Identifier system ID extension
bridge_mac_address Bridge Identifier MAC address
port_priority Port Identifier priority set 0-240 in steps of 16
port_number Port Identifier number
message_age Message Age timer value
max_age Max Age timer value
hello_time Hello Time timer value
forward_delay 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.

Attribute Description
flags
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 Identifier priority set 0-61440 in steps of 4096
root_system_id_extension Root Identifier system ID extension
root_mac_address Root Identifier MAC address
root_path_cost Root Path Cost
bridge_priority Bridge Identifier priority set 0-61440 in steps of 4096
bridge_system_id_extension Bridge Identifier system ID extension
bridge_mac_address Bridge Identifier MAC address
port_priority Port Identifier priority set 0-240 in steps of 16
port_number Port Identifier number
message_age Message Age timer value
max_age Max Age timer value
hello_time Hello Time timer value
forward_delay 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 a check sum value. 0 means automatically-calculate when encoding.
address a group address value.
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 Length field. Ignored when encoding.
type Type field. one of BGP_MSG_ constants.
class ryu.lib.packet.bgp.BGPOpen(my_as, bgp_identifier, type_=1, opt_param_len=0, opt_param=[], version=4, hold_time=0, len_=None, marker=None)

BGP-4 OPEN 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 Length field. Ignored when encoding.
type Type field. The default is BGP_MSG_OPEN.
version Version field. The default is 4.
my_as 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, withdrawn_routes_len=None, withdrawn_routes=[], total_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 Description
marker Marker field. Ignored when encoding.
len Length field. Ignored when encoding.
type Type field. The default is BGP_MSG_UPDATE.
withdrawn_routes_len 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 Path Attributes field. A list of BGPPathAttribute instances. The default is [].
nlri 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 Length field. Ignored when encoding.
type 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 Description
marker Marker field. Ignored when encoding.
len Length field. Ignored when encoding.
type Type field. The default is BGP_MSG_NOTIFICATION.
error_code Error code field.
error_subcode Error subcode field.
data Data field. The default is ‘’.

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 Number of missing params. (0 means automatically-calculate when encoding)
length 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)
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)

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).

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.

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)

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 Description
unordered if set to ‘1’, the receiver ignores the sequence number.
begin if set to ‘1’, this chunk is the first fragment.
end if set to ‘1’, this chunk is the last fragment.
length length of this chunk containing this header. (0 means automatically-calculate when encoding)
tsn Transmission Sequence Number.
sid stream id.
seq 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.

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 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_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 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_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.

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 the tag that be used as Verification Tag.
a_rwnd Advertised Receiver Window Credit.
os number of outbound streams.
mis number of inbound streams.
i_tsn Transmission Sequence Number that the sender will use.
params

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 the tag that be used as Verification Tag.
a_rwnd Advertised Receiver Window Credit.
os number of outbound streams.
mis number of inbound streams.
i_tsn Transmission Sequence Number that the sender will use.
params

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 Description
flags set to ‘0’. this field will be ignored.
length length of this chunk containing this header. (0 means automatically-calculate when encoding)
tsn_ack TSN of the last DATA chunk received in sequence before a gap.
a_rwnd Advertised Receiver Window Credit.
gapack_num number of Gap Ack blocks.
duptsn_num number of duplicate TSNs.
gapacks 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]]
duptsns 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 (SHUTDOWN) 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)
tsn_ack 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 (SHUTDOWN 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)

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).

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)

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)
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 Destination Port
vtag Verification Tag
csum Checksum (0 means automatically-calculate when encoding)
chunks a list of derived classes of ryu.lib.packet.sctp.chunk.