Packets Reassembly¶
pcapkit.foundation.reassembly bases on algorithms described
in RFC 791 and RFC 815, implements datagram reassembly
of IP and TCP packets.
See also
For more information on customisation and extension, please refer to Customisation & Extensions.
All reassembly classes are implemented as ReassemblyBase
subclasses, which are responsible for processing extracted packets and
reassemble the datagrams to a nonfragmented packet. Below is a brief
diagram of the class hierarchy of pcapkit.foundation.reassembly:
flowchart LR
A{{ReassemblyMeta}} -.->|metaclass| B(ReassemblyBase)
B --> IP & TCP
IP --> IPv4 & IPv6
B --> C(Reassembly)
C --> D([user customisation ...])
click A "reassembly.html#pcapkit.foundation.reassembly.reassembly.ReassemblyMeta"
click B "reassembly.html#pcapkit.foundation.reassembly.reassembly.ReassemblyBase"
click C "reassembly.html#pcapkit.foundation.reassembly.reassembly.Reassembly"
click D "../../../ext.html#reassembly-and-flow-tracing"
click IP "ip/ip.html#pcapkit.foundation.reassembly.ip.IP"
click IPv4 "ip/ipv4.html#pcapkit.foundation.reassembly.ipv4.IPv4"
click IPv6 "ip/ipv6.html#pcapkit.foundation.reassembly.ipv6.IPv6"
click TCP "tcp.html#pcapkit.foundation.reassembly.tcp.TCP"
Auxiliary Data¶
- class pcapkit.foundation.reassembly.ReassemblyManager(*args: VT, **kwargs: VT)[source]¶
Bases:
InfoReassembly Manager.
- class pcapkit.foundation.reassembly.data.data.ReassemblyData(*args: VT, **kwargs: VT)[source]¶
Bases:
InfoData storage for reassembly.
- class pcapkit.foundation.reassembly.data.data.Deferred(analyze, proto, payload)[source]¶
Bases:
objectA postponed analysis of a reassembled payload.
A reassembled datagram’s
packetis a second, full parse of the payload the datagram just reassembled. Nothing about postponing it is specific to any one reassembler, which is why this lives besideReassemblyDatarather than in either protocol’s data module.IP reassembly is the case that made it necessary. It submits a datagram for every frame – not only the fragmented ones, since a frame that is not fragmented in any sense still reaches
IP.reassemblyand is submitted there as a trivially complete datagram – so an eager parse would re-parse captures holding no fragments at all:http.pcaphas 1117 IPv4 frames, none of them fragmented, and the eager parse measured 86% of the cost of IP reassembly over it.TCP reassembly defers its
packetas well (TCP.submit), at a far smaller saving, being FIN/RST-driven rather than per-frame – 222 submits perhttp.pcappass against 1117.Holding the call here defers it to the first read of
Datagram.packet, whereDeferredPacketruns it, so a caller that wants the parsed payload still gets exactly the object an eager call would produce, and one that does not never pays for it.- Parameters:
analyze (
Callable[[TransType,bytes],ProtocolBase]) – The analyser to call, i.e.Protocol.analyzebound to the reassembly object’s protocol.proto (
TransType) – Payload protocol type.payload (
bytes) – Reassembled payload to parse.
Added in version 1.5.0.