Built-in Support#

PCAP Tools#

pcapkit.toolkit.pcap contains all you need for PCAP file format handling. All functions returns with a flag to indicate if usable for its caller.

pcapkit.toolkit.pcap.ipv4_reassembly(frame)#

Make data for IPv4 reassembly.

Parameters:

frame (Frame) – PCAP frame.

Return type:

Optional[Packet[IPv4Address]]

Returns:

Data for IPv4 reassembly.

  • If the frame can be used for IPv4 reassembly. A frame can be reassembled if it contains IPv4 layer (pcapkit.protocols.internet.ipv4.IPv4) and the DF (IPv4.flags.df) flag is False.

  • If the frame can be reassembled, then the dict mapping of data for IPv4 reassembly (c.f. reasm.ipv4.packet) will be returned; otherwise, returns None.

pcapkit.toolkit.pcap.ipv6_reassembly(frame)#

Make data for IPv6 reassembly.

Parameters:

frame (Frame) – PCAP frame.

Returns:

A tuple of data for IPv6 reassembly.

Return type:

Tuple[bool, Dict[str, Any]]

pcapkit.toolkit.pcap.tcp_reassembly(frame)#

Make data for TCP reassembly.

Parameters:

frame (Frame) – PCAP frame.

Returns:

A tuple of data for TCP reassembly.

Return type:

Tuple[bool, Dict[str, Any]]

pcapkit.toolkit.pcap.tcp_traceflow(frame, *, data_link)#

Trace packet flow for TCP.

Parameters:
  • frame (Frame) – PCAP frame.

  • data_link (LinkType) – Data link layer protocol (from global header).

Return type:

Optional[Packet]

Returns:

Data for TCP reassembly.

PCAP-NG Tools#

pcapkit.toolkit.pcapng contains all you need for PCAP-NG file format handling. All functions returns with a flag to indicate if usable for its caller.

pcapkit.toolkit.pcapng.ipv4_reassembly(frame)#

Make data for IPv4 reassembly.

Parameters:

frame (PCAPNG) – PCAP-NG frame.

Return type:

Optional[Packet[IPv4Address]]

Returns:

Data for IPv4 reassembly.

  • If the frame can be used for IPv4 reassembly. A frame can be reassembled if it contains IPv4 layer (pcapkit.protocols.internet.ipv4.IPv4) and the DF (IPv4.flags.df) flag is False.

  • If the frame can be reassembled, then the dict mapping of data for IPv4 reassembly (c.f. reasm.ipv4.packet) will be returned; otherwise, returns None.

pcapkit.toolkit.pcapng.ipv6_reassembly(frame)#

Make data for IPv6 reassembly.

Parameters:

frame (PCAPNG) – PCAP-NG frame.

Returns:

A tuple of data for IPv6 reassembly.

Return type:

Tuple[bool, Dict[str, Any]]

pcapkit.toolkit.pcapng.tcp_reassembly(frame)#

Make data for TCP reassembly.

Parameters:

frame (PCAPNG) – PCAP-NG frame.

Returns:

A tuple of data for TCP reassembly.

Return type:

Tuple[bool, Dict[str, Any]]

pcapkit.toolkit.pcapng.tcp_traceflow(frame, *, nanosecond=False)#

Trace packet flow for TCP.

Parameters:
  • frame (PCAPNG) – PCAP-NG frame.

  • nanosecond (bool) – Whether to use nanosecond precision.

Return type:

Optional[Packet]

Returns:

Data for TCP reassembly.

pcapkit.toolkit.pcapng.block2frame(block, *, nanosecond=False)#

Convert PCAP-NG block to PCAP frame.

Parameters:
Return type:

Frame

Returns:

PCAP frame.