IPv4

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