TCP(3)
π TCP(3) β the tcp 1.7 manual, bestie edition π
okay so you found the TCP(3) page, welcome, pull up a chair, we're decoding the Transport Control Protocol layer together and honestly? it's giving iconic. this is from the tcp 1.7 manual, and I'm gonna walk you through every single bit of it, no cap. π¦
β¨ NAME β¨
packet.transport.tcp β the TCP module. that's it, that's the name, she's simple and she's powerful. π
πΈ DESCRIPTION πΈ
Decode TCP layer. literally just β decode the TCP layer. that's the whole job description and she does it flawlessly. π
the vibes are specified by these, and I am quoting them exactly:
- RFC 793 TRANSMISSION CONTROL PROTOCOL
- RFC 2018 TCP Selective Acknowledgment Options
- RFC 7323 TCP Extensions for High Performance
three RFCs, one legend. π₯
π CLASSES π
class Flags(packet.utils.OptionFlags)
TCP Option flags. she's a subclass of packet.utils.OptionFlags and she's here to hold your flag bits, no notes. β¨
Methods defined here:
__str__ = str_flags(self)β yep, that's literally the line, she just points atstr_flags(self). π«Ά
class Option(baseobj.BaseObj)
Option object. a whole little object for a TCP option, we love a dedicated class. π
Methods defined here:
__init__(self, unpack)β Constructor which takes an unpack object as input. π
class Stream(baseobj.BaseObj)
TCP stream buffer object. yes bestie, we're buffering streams, this is where the fragments live. π
Methods defined here:
__init__(self, seqno)β Constructor.
Initialize object's private data according to the arguments given. Arguments can be given as positional, named arguments or a combination of both. (flexible queen π§)
add_fragment(self, data, seq)β Add fragment data to stream buffer. π§©missing_fragment(self, seq)β Check if given sequence number is within a missing fragment. π
class TCP(baseobj.BaseObj)
TCP object. the main character, obviously. π
Usage:
from packet.transport.tcp import TCP
x = TCP(pktt)
Object definition:
TCP(
src_port = int, # Source port
dst_port = int, # Destination port
seq_number = int, # Sequence number
ack_number = int, # Acknowledgment number
hl = int, # Data offset or header length (32bit words)
header_size = int, # Data offset or header length in bytes
flags = Flags( # TCP flags:
rawflags = int,# Raw flags
FIN = int, # No more data from sender
SYN = int, # Synchronize sequence numbers
RST = int, # Synchronize sequence numbers
PSH = int, # Push function. Asks to push the buffered
# data to the receiving application
ACK = int, # Acknowledgment field is significant
URG = int, # Urgent pointer field is significant
ECE = int, # ECN-Echo has a dual role:
# SYN=1, the TCP peer is ECN capable.
# SYN=0, packet with Congestion Experienced
# flag in IP header set is received during
# normal transmission
CWR = int, # Congestion Window Reduced
NS = int, # ECN-nonce concealment protection
),
window_size = int, # Window size
checksum = int, # Checksum
urgent_ptr = int, # Urgent pointer
seq = int, # Relative sequence number
options = list, # List of TCP options
psize = int, # Payload data size
data = string, # Raw data of payload if unable to decode
)
Methods defined here:
__init__(self, pktt)β Constructor.
Initialize object's private data.
- pktt: Packet trace object (
packet.pktt.Pktt) so this layer has access to the parent layers. (she needs to know her ancestors, periodt. π³)
__str__(self)β String representation of object.
The representation depends on the verbose level set by debug_repr(). If set to 0 the generic object representation is returned.
If set to 1 the representation of the object is condensed:
'TCP 708 -> 2049, seq: 0xc4592255, ack: 0xca66dda1, ACK,FIN'
If set to 2 the representation of the object also includes the length of payload and a little bit more verbose:
'src port 708 -> dst port 2049, seq: 0xc4592255, ack: 0xca66dda1, len: 0, flags: FIN,ACK'
three levels of glow-up, pick your vibe. β¨
π SEE ALSO π
the whole friend group, go say hi:
baseobj(3), packet.application.dns(3), packet.application.krb5(3), packet.application.rpc(3), packet.transport.mpa(3), packet.unpack(3), packet.utils(3)
iykyk. π«
π BUGS π
No known bugs.
not a single one. she's flawless, she's that girl, nothing to see here, we move. π β¨
π«Ά AUTHOR π«Ά
Jorge Mora (mora@netapp.com)
give him his flowers, he wrote the whole thing. πΈ
okay that's the page!! NFStest 3.2, dated 21 March 2023 β shoutout to the version and the date for making it official. now go decode some packets, bestie, you've got this. πππ¦
π¦ 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