Fragmented Packets Reassembly

pcapkit.reassembly.reassembly contains class:~pcapkit.reassembly.reassembly.Reassembly only, which is an abstract base class for all reassembly classes, bases on algorithms described in RFC 815, implements datagram reassembly of IP and TCP packets.

class pcapkit.reassembly.reassembly.Reassembly(*, strict=True)[source]

Bases: object

Base class for reassembly procedure.

__call__(packet)[source]

Call packet reassembly.

Parameters

packet (dict) – packet dict to be reassembled (detailed format described in corresponding protocol)

__init__(*, strict=True)[source]

Initialise packet reassembly.

Keyword Arguments

strict (bool) – if return all datagrams (including those not implemented) when submit

fetch()[source]

Fetch datagram.

Returns

Tuple of reassembled datagrams.

Return type

Tuple[dict]

Fetch reassembled datagrams from _dtgram and returns a tuple of such datagrams.

If _newflg set as True, the method will call submit() to (force) obtain newly reassembled payload. Otherwise, the already calculated _dtgram will be returned.

index(pkt_num)[source]

Return datagram index.

Parameters

pkt_num (int) – index of packet

Returns

reassembled datagram index which was from No. pkt_num packet; if not found, returns None

Return type

Optional[int]

abstract reassembly(info)[source]

Reassembly procedure.

Parameters

info (pcapkit.corekit.infoclass.Info) – info dict of packets to be reassembled

run(packets)[source]

Run automatically.

Parameters

packets (List[dict]) – list of packet dicts to be reassembled

abstract submit(buf, **kwargs)[source]

Submit reassembled payload.

Parameters

buf (dict) – buffer dict of reassembled packets

_buffer

dict buffer field

_dtgram

list reassembled datagram

_newflg

if new packets reassembled flag

Type

bool

_strflg

strict mode flag

Type

bool

property count

Total number of reassembled packets.

Return type

int

property datagram

Reassembled datagram.

Return type

tuple

abstract property name

Protocol of current packet.

Return type

str

abstract property protocol

Protocol of current reassembly object.

Return type

str