TCP Datagram Analysis

pcapkit.foundation.analysis.tcp contains tcp_datagram() only, which parses the application-layer payload of a TCP datagram that TCP reassembled.

Added in version 1.6.0.

pcapkit.foundation.analysis.tcp.tcp_datagram(datagram, *, layer=None, protocol=None, context=None)[source]

Parse the payload of a TCP datagram reassembled by TCP.

A reassembled datagram carries no protocol number, so its payload is dispatched on its (source, destination) ports by Transport.analyze of TCP. Each port is resolved to its TCP member by Transport._make_port, as TCP._make_ports resolves them for the reassembly.

Parameters:
Return type:

ProtocolBase | None

Returns:

The parsed payload. A payload reported as one contiguous run is parsed whether or not datagram is complete, as strict=False reports an incomplete one. None if the payload is the tuple of runs received, as strict=True reports an incomplete one.

Note

Datagram.packet holds what this returns given the stops and context the extraction’s engine parses its frames with (#2933), parsed on its first read, unless the reassembly’s __protocol_type__ names another protocol, which then parses it instead.

Changed in version 1.8.0: Takes keyword-only layer, protocol and context, as the parse behind Datagram.packet does (#2947).