IPV4(3)
π IPV4(3) β the ipv4 module, bestie edition π
okay so this is packet.internet.ipv4, from ipv4 1.3, and it's the glow-up your packet parsing deserved. sit down, grab a boba, we're decoding the internet layer together π§β¨
β¨ NAME β¨
packet.internet.ipv4 β the IPv4 module. that's it, that's the name, she's simple and she serves π
πΈ DESCRIPTION πΈ
Decode the IP version 4 layer. like, that whole "hello i am an IPv4 header and i contain the plot" situation. literally the main character of the network stack π
π CLASSES π
π class Flags(baseobj.BaseObj)
the Flags object. tiny, but she holds the drama (the fragment drama, specifically).
Methods defined here:
__init__(self, data)β the constructor, and she takes exactly one thing: a single byte as input. one byte. that's all she needs π«Ά
π¦ class IPv4(baseobj.BaseObj)
the IPv4 object herself. iconic. no notes.
Usage:
from packet.internet.ipv4 import IPv4
x = IPv4(pktt)
Object definition:
IPv4(
version = int,
IHL = int, # Internet Header Length (in 32bit words)
header_size = int, # IHL in actual bytes
DSCP = int, # Differentiated Services Code Point
ECN = int, # Explicit Congestion Notification
total_size = int, # Total length
id = int, # Identification
flags = Flags( # Flags:
DF = int, # Don't Fragment
MF = int, # More Fragments
)
fragment_offset = int, # Fragment offset (in 8-byte blocks)
TTL = int, # Time to Live
protocol = int, # Protocol of next layer (RFC790)
checksum = int, # Header checksum
src = "%d.%d.%d.%d", # source IP address
dst = "%d.%d.%d.%d", # destination IP address
options = string, # IP options if available
psize = int # Payload data size
data = string, # Raw data of payload if protocol
# is not supported
)
Methods defined here:
π __init__(self, pktt)
Constructor. she initializes the object's private data, very "let me set up my little world" energy π«
pktt: the Packet trace object (packet.pktt.Pktt), passed in so this layer has access to the parent layers. it's giving family reunion, but useful π«Ά
β __str__(self)
String representation of the object. and the way she represents depends on the verbose level you set with debug_repr() π
- if it's set to
0, you get the generic object representation. no frills, just vibes. - if it's set to
1, the representation of the object is condensed:
'192.168.0.20 -> 192.168.0.61 '
- if it's set to
2, the representation of the object also includes the protocol and the length of payload:
'192.168.0.20 -> 192.168.0.61, protocol: 17(UDP), len: 84'
so basically level 2 is the full lore drop π₯
π SEE ALSO π
baseobj(3), packet.transport.tcp(3), packet.transport.udp(3), packet.utils(3)
the friend group. go say hi π
π BUGS π
No known bugs. she's clean, she's unproblematic, we love to see it β¨
π AUTHOR π
Jorge Mora (mora@netapp.com) β thank you for your service, king π«‘π
and that's the whole page, bestie!! this was NFStest 3.2, dated 21 March 2023, and honestly? a classic. go forth and decode some packets. mwah π π
π¦ where this page comes from
- debian trixie: nfstest 3.2-3
- fedora 43: NFStest 3.2-14.fc43 Β· GPL-2.0-or-later
- fedora 44: NFStest 3.2-16.fc44 Β· GPL-2.0-or-later
- ubuntu noble: nfstest 3.2-2
- ubuntu questing: nfstest 3.2-3
- ubuntu resolute: nfstest 3.2-3build1
- ubuntu stonking: nfstest 3.2-5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms