TCP - Transmission Control Protocol#

pcapkit.protocols.transport.tcp contains TCP only, which implements extractor for Transmission Control Protocol (TCP) [*], whose structure is described as below:

Octets

Bits

Name

Description

0

0

tcp.srcport

Source Port

2

16

tcp.dstport

Destination Port

4

32

tcp.seq

Sequence Number

8

64

tcp.ack

Acknowledgement Number (if ACK set)

12

96

tcp.hdr_len

Data Offset

12

100

Reserved (must be \x00)

12

103

tcp.flags.ns

ECN Concealment Protection (NS)

13

104

tcp.flags.cwr

Congestion Window Reduced (CWR)

13

105

tcp.flags.ece

ECN-Echo (ECE)

13

106

tcp.flags.urg

Urgent (URG)

13

107

tcp.flags.ack

Acknowledgement (ACK)

13

108

tcp.flags.psh

Push Function (PSH)

13

109

tcp.flags.rst

Reset Connection (RST)

13

110

tcp.flags.syn

Synchronize Sequence Numbers (SYN)

13

111

tcp.flags.fin

Last Packet from Sender (FIN)

14

112

tcp.window_size

Size of Receive Window

16

128

tcp.checksum

Checksum

18

144

tcp.urgent_pointer

Urgent Pointer (if URG set)

20

160

tcp.opt

TCP Options (if data offset > 5)

class pcapkit.protocols.transport.tcp.TCP(file=None, length=None, **kwargs)#

Bases: Transport[TCP, TCP]

This class implements Transmission Control Protocol.

This class currently supports parsing of the following protocols, which are registered in the self.__proto__ attribute:

This class currently supports parsing of the following TCP options, which are directly mapped to the pcapkit.const.tcp.option.Option enumeration:

This class currently supports parsing of the following Multipath TCP options, which are directly mapped to the pcapkit.const.tcp.mp_tcp_option.MPTCPOption enumeration:

Parameters:
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

Protocol[PT, ST]

property name: Literal['Transmission Control Protocol']#

Name of current protocol.

property length: int#

Header length of current protocol.

property src: int#

Source port.

property dst: int#

Destination port.

property connection: Flags#

Connection flags.

classmethod register_option(code, meth)#

Register an option parser.

Parameters:
  • code (Enum_Option) – TCP option code.

  • meth (str | tuple[OptionParser, OptionConstructor]) – Method name or callable to parse and/or construct the option.

Return type:

None

classmethod register_mp_option(code, meth)#

Register an MPTCP option parser.

Parameters:
  • code (Enum_MPTCPOption) – MPTCP option code.

  • meth (str | tuple[MPOptionParser, MPOptionConstructor]) – Method name or callable to parse and/or construct the option.

Return type:

None

read(length=None, **kwargs)#

Read Transmission Control Protocol (TCP).

Structure of TCP header [RFC 793]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   Acknowledgement Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data |           |U|A|P|R|S|F|                               |
| Offset| Reserved  |R|C|S|S|Y|I|            Window             |
|       |           |G|K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             data                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

TCP

Returns:

Parsed packet data.

make(srcport=0, dstport=0, seq_no=0, ack_no=0, ns=False, cwr=False, ece=False, urg=False, ack=False, psh=False, rst=False, syn=False, fin=False, window=65535, checksum=b'\\x00\\x00', urgent=0, options=None, payload=b'', **kwargs)#

Make (construct) packet data.

Parameters:
  • srcport (int) – Source port.

  • dstport (int) – Destination port.

  • seq_no (int) – Sequence number.

  • ack_no (int) – Acknowledgement number.

  • ns (bool) – ECN-nonce concealment protection.

  • cwr (bool) – Congestion window reduced.

  • ece (bool) – ECN-Echo.

  • urg (bool) – Urgent.

  • ack (bool) – Acknowledgement.

  • psh (bool) – Push function.

  • rst (bool) – Reset connection.

  • syn (bool) – Synchronize sequence numbers.

  • fin (bool) – Last packet from sender.

  • window (int) – Window size.

  • checksum (bytes) – Checksum.

  • urgent (int) – Urgent pointer.

  • options (Optional[list[Schema_Option | tuple[Enum_Option, dict[str, Any]] | bytes] | Option]) – TCP options.

  • payload (bytes | Protocol | Schema) – Payload of the packet.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

Schema_TCP

Returns:

Constructed packet data.

classmethod _make_data(data)#

Create key-value pairs from data for protocol construction.

Parameters:

data (TCP) – protocol data

Return type:

dict[str, Any]

Returns:

Key-value pairs for protocol construction.

_read_tcp_options(size)#

Read TCP option list.

Parameters:

size (int) – length of option list

Return type:

Option

Returns:

Extracted TCP options.

Raises:

ProtocolError – If the threshold is NOT matching.

_read_mode_donone(schema, *, options)#

Read options request no process.

Parameters:
  • schema (Schema_UnassignedOption) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_UnassignedOption

Returns:

Parsed option data.

_read_mode_eool(schema, *, options)#

Read TCP End of Option List option.

Structure of TCP end of option list option [RFC 793]:

+--------+
|00000000|
+--------+
 Kind=0
Parameters:
  • schema (Schema_EndOfOptionList) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_EndOfOptionList

Returns:

Parsed option data.

_read_mode_nop(schema, *, options)#

Read TCP No Operation option.

Structure of TCP maximum segment size option [RFC 793]:

+--------+
|00000001|
+--------+
 Kind=1
Parameters:
  • schema (Schema_NoOperation) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_NoOperation

Returns:

Parsed option data.

_read_mode_mss(schema, *, options)#

Read TCP max segment size option.

Structure of TCP maximum segment size option [RFC 793]:

+--------+--------+---------+--------+
|00000010|00000100|   max seg size   |
+--------+--------+---------+--------+
 Kind=2   Length=4
Parameters:
  • schema (Schema_MaximumSegmentSize) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MaximumSegmentSize

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 4.

_read_mode_ws(schema, *, options)#

Read TCP windows scale option.

Structure of TCP window scale option [RFC 7323]:

+---------+---------+---------+
| Kind=3  |Length=3 |shift.cnt|
+---------+---------+---------+
     1         1         1
Parameters:
  • schema (Schema_WindowScale) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_WindowScale

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 3.

_read_mode_sackpmt(schema, *, options)#

Read TCP SACK permitted option.

Structure of TCP SACK permitted option [RFC 2018]:

+---------+---------+
| Kind=4  | Length=2|
+---------+---------+
Parameters:
  • schema (Schema_SACKPermitted) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_SACKPermitted

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 2.

_read_mode_sack(schema, *, options)#

Read TCP SACK option.

Structure of TCP SACK option [RFC 2018]:

                  +--------+--------+
                  | Kind=5 | Length |
+--------+--------+--------+--------+
|      Left Edge of 1st Block       |
+--------+--------+--------+--------+
|      Right Edge of 1st Block      |
+--------+--------+--------+--------+
|                                   |
/            . . .                  /
|                                   |
+--------+--------+--------+--------+
|      Left Edge of nth Block       |
+--------+--------+--------+--------+
|      Right Edge of nth Block      |
+--------+--------+--------+--------+
Parameters:
  • schema (Schema_SACK) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_SACK

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT multiply of 8 plus 2.

_read_mode_echo(schema, *, options)#

Read TCP echo option.

Structure of TCP echo option [RFC 1072]:

+--------+--------+--------+--------+--------+--------+
| Kind=6 | Length |   4 bytes of info to be echoed    |
+--------+--------+--------+--------+--------+--------+
Parameters:
  • schema (Schema_Echo) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_Echo

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 6.

_read_mode_echore(schema, *, options)#

Read TCP echo reply option.

Structure of TCP echo reply option [RFC 1072]:

+--------+--------+--------+--------+--------+--------+
| Kind=7 | Length |    4 bytes of echoed info         |
+--------+--------+--------+--------+--------+--------+
Parameters:
  • schema (Schema_EchoReply) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_EchoReply

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 6.

_read_mode_ts(schema, *, options)#

Read TCP timestamps option.

Structure of TCP timestamp option [RFC 7323]:

+-------+-------+---------------------+---------------------+
|Kind=8 |  10   |   TS Value (TSval)  |TS Echo Reply (TSecr)|
+-------+-------+---------------------+---------------------+
    1       1              4                     4
Parameters:
  • schema (Schema_Timestamp) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_Timestamp

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 10.

_read_mode_poc(schema, *, options)#

Read TCP partial order connection service profile option.

Structure of TCP POC-Permitted option [RFC 1693][RFC 6247]:

+-----------+-------------+
|  Kind=9   |  Length=2   |
+-----------+-------------+
Parameters:
  • schema (Schema_PartialOrderConnectionPermitted) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_PartialOrderConnectionPermitted

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 2.

_read_mode_pocsp(schema, *, options)#

Read TCP partial order connection service profile option.

Structure of TCP POC-SP option [RFC 1693][RFC 6247]:

                          1 bit        1 bit    6 bits
+----------+----------+------------+----------+--------+
|  Kind=10 | Length=3 | Start_flag | End_flag | Filler |
+----------+----------+------------+----------+--------+
Parameters:
  • schema (Schema_PartialOrderConnectionProfile) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_PartialOrderConnectionProfile

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 3.

_read_mode_cc(schema, *, options)#

Read TCP connection count option.

Structure of TCP CC option [RFC 1644]:

+--------+--------+--------+--------+--------+--------+
|00001011|00000110|    Connection Count:  SEG.CC      |
+--------+--------+--------+--------+--------+--------+
 Kind=11  Length=6
Parameters:
  • schema (Schema_CC) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_CC

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 6.

_read_mode_ccnew(schema, *, options)#

Read TCP connection count (new) option.

Structure of TCP CC.NEW option [RFC 1644]:

+--------+--------+--------+--------+--------+--------+
|00001100|00000110|    Connection Count:  SEG.CC      |
+--------+--------+--------+--------+--------+--------+
 Kind=12  Length=6
Parameters:
  • schema (Schema_CCNew) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_CCNew

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 6.

_read_mode_ccecho(schema, *, options)#

Read TCP connection count (echo) option.

Structure of TCP CC.ECHO option [RFC 1644]:

+--------+--------+--------+--------+--------+--------+
|00001101|00000110|    Connection Count:  SEG.CC      |
+--------+--------+--------+--------+--------+--------+
 Kind=13  Length=6
Parameters:
  • schema (Schema_CCEcho) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_CCEcho

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 6.

_read_mode_chkreq(schema, *, options)#

Read TCP Alternate Checksum Request option.

Structure of TCP CHKSUM-REQ [RFC 1146][RFC 6247]:

+----------+----------+----------+
|  Kind=14 | Length=3 |  chksum  |
+----------+----------+----------+
Parameters:
  • schema (Schema_AlternateChecksumRequest) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_AlternateChecksumRequest

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 3.

_read_mode_chksum(schema, *, options)#

Read Alternate Checksum Data option.

Structure of TCP CHKSUM [RFC 1146][RFC 6247]:

+---------+---------+---------+     +---------+
| Kind=15 |Length=N |  data   | ... |  data   |
+---------+---------+---------+     +---------+
Parameters:
  • schema (Schema_AlternateChecksumData) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_AlternateChecksumData

Returns:

Parsed option data.

_read_mode_sig(schema, *, options)#

Read MD5 Signature option.

Structure of TCP SIG option [RFC 2385]:

+---------+---------+-------------------+
| Kind=19 |Length=18|   MD5 digest...   |
+---------+---------+-------------------+
|                                       |
+---------------------------------------+
|                                       |
+---------------------------------------+
|                                       |
+-------------------+-------------------+
|                   |
+-------------------+
Parameters:
  • schema (Schema_MD5Signature) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MD5Signature

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 18.

_read_mode_qs(schema, *, options)#

Read Quick-Start Response option.

Structure of TCP QSopt [RFC 4782]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Kind      |  Length=8     | Resv. | Rate  |   TTL Diff    |
|               |               |       |Request|               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   QS Nonce                                | R |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • schema (Schema_QuickStartResponse) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_QuickStartResponse

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 8.

_read_mode_timeout(schema, *, options)#

Read User Timeout option.

Structure of TCP TIMEOUT [RFC 5482]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Kind = 28   |   Length = 4  |G|        User Timeout         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • schema (Schema_UserTimeout) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_UserTimeout

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 4.

_read_mode_ao(schema, *, options)#

Read Authentication option.

Structure of TCP AOopt [RFC 5925]:

+------------+------------+------------+------------+
|  Kind=29   |   Length   |   KeyID    | RNextKeyID |
+------------+------------+------------+------------+
|                     MAC           ...
+-----------------------------------...

...-----------------+
...  MAC (con't)    |
...-----------------+
Parameters:
  • schema (Schema_Authentication) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_Authentication

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT larger than or equal to 4.

_read_mode_mp(schema, *, options)#

Read Multipath TCP option.

Structure of MP-TCP [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----------------------+
|     Kind      |    Length     |Subtype|                       |
+---------------+---------------+-------+                       |
|                     Subtype-specific data                     |
|                       (variable length)                       |
+---------------------------------------------------------------+
Parameters:
  • schema (Schema_MPTCP) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCP

Returns:

Parsed option data.

_read_mode_fastopen(schema, *, options)#

Read Fast Open option.

Structure of TCP FASTOPEN [RFC 7413]:

                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |      Kind     |    Length     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
~                            Cookie                             ~
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • schema (Schema_FastOpenCookie) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_FastOpenCookie

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT valid.

_read_mptcp_unknown(schema, *, options)#

Read unknown MPTCP subtype.

Parameters:
  • schema (Schema_MPTCPUnknown) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPUnknown

Returns:

Parsed option data.

_read_mptcp_capable(schema, *, options)#

Read Multipath Capable option.

Structure of MP_CAPABLE [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-------+---------------+
|     Kind      |    Length     |Subtype|Version|A|B|C|D|E|F|G|H|
+---------------+---------------+-------+-------+---------------+
|                   Option Sender's Key (64 bits)               |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
|                  Option Receiver's Key (64 bits)              |
|                     (if option Length == 20)                  |
|                                                               |
+---------------------------------------------------------------+
Parameters:
  • schema (Schema_MPTCPCapable) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPCapable

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 20 or 32.

_read_mptcp_join(schema, *, options)#

Read Join Connection option.

Parameters:
  • schema (Schema_MPTCPJoin) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPJoin

Returns:

Parsed option data.

Raises:

ProtocolError – If the option is not given on a valid SYN/ACK packet.

_read_mptcp_dss(schema, *, options)#

Read Data Sequence Signal (Data ACK and Data Sequence Mapping) option.

Structure of DSS [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+----------------------+
|     Kind      |    Length     |Subtype| (reserved) |F|m|M|a|A|
+---------------+---------------+-------+----------------------+
|                                                              |
|           Data ACK (4 or 8 octets, depending on flags)       |
|                                                              |
+--------------------------------------------------------------+
|                                                              |
|   Data sequence number (4 or 8 octets, depending on flags)   |
|                                                              |
+--------------------------------------------------------------+
|              Subflow Sequence Number (4 octets)              |
+-------------------------------+------------------------------+
|  Data-Level Length (2 octets) |      Checksum (2 octets)     |
+-------------------------------+------------------------------+
Parameters:
  • schema (Schema_MPTCPDSS) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPDSS

Returns:

Parsed option data.

_read_mptcp_addaddr(schema, *, options)#

Read Add Address option.

Structure of ADD_ADDR [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-------+---------------+
|     Kind      |     Length    |Subtype| IPVer |  Address ID   |
+---------------+---------------+-------+-------+---------------+
|          Address (TCP - 4 octets / IPv6 - 16 octets)         |
+-------------------------------+-------------------------------+
|   Port (2 octets, optional)   |
+-------------------------------+
Parameters:
  • schema (Schema_MPTCPAddAddress) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPAddAddress

Returns:

Parsed option data.

Raises:

ProtocolError – Invalid IP version and/or addresses.

_read_mptcp_remove(schema, *, options)#

Read Remove Address option.

Structure of REMOVE_ADDR [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-------+---------------+
|     Kind      |  Length = 3+n |Subtype|(resvd)|   Address ID  | ...
+---------------+---------------+-------+-------+---------------+
                           (followed by n-1 Address IDs, if required)
Parameters:
  • schema (Schema_MPTCPRemoveAddress) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPRemoveAddress

Returns:

Parsed option data.

Raises:

ProtocolError – If the length is smaller than 3.

_read_mptcp_prio(schema, *, options)#

Read Change Subflow Priority option.

Structure of MP_PRIO [RFC 6824]:

                      1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----+-+--------------+
|     Kind      |     Length    |Subtype|     |B| AddrID (opt) |
+---------------+---------------+-------+-----+-+--------------+
Parameters:
  • schema (Schema_MPTCPPriority) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPPriority

Returns:

Parsed option data.

Raises:

ProtocolError – If the length is smaller than 3.

_read_mptcp_fail(schema, *, options)#

Read Fallback option.

Structure of MP_FAIL [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+----------------------+
|     Kind      |   Length=12   |Subtype|      (reserved)      |
+---------------+---------------+-------+----------------------+
|                                                              |
|                 Data Sequence Number (8 octets)              |
|                                                              |
+--------------------------------------------------------------+
Parameters:
  • schema (Schema_MPTCPFallback) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPFallback

Returns:

Parsed option data.

Raises:

ProtocolError – If the length is NOT 12.

_read_mptcp_fastclose(schema, options)#

Read Fast Close option.

Structure of MP_FASTCLOSE [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----------------------+
|     Kind      |    Length     |Subtype|      (reserved)       |
+---------------+---------------+-------+-----------------------+
|                      Option Receiver's Key                    |
|                            (64 bits)                          |
|                                                               |
+---------------------------------------------------------------+
Parameters:
  • schema (Schema_MPTCPFastclose) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPFastclose

Returns:

Parsed option data.

Raises:

ProtocolError – If the length is NOT 16.

_read_join_syn(schema, *, options)#

Read Join Connection option for Initial SYN.

Structure of MP_JOIN-SYN [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----+-+---------------+
|     Kind      |  Length = 12  |Subtype|     |B|   Address ID  |
+---------------+---------------+-------+-----+-+---------------+
|                   Receiver's Token (32 bits)                  |
+---------------------------------------------------------------+
|                Sender's Random Number (32 bits)               |
+---------------------------------------------------------------+
Parameters:
  • schema (Schema_MPTCPJoinSYN) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPJoinSYN

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 12.

_read_join_synack(schema, options)#

Read Join Connection option for Responding SYN/ACK.

Structure of MP_JOIN-SYN/ACK [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----+-+---------------+
|     Kind      |  Length = 16  |Subtype|     |B|   Address ID  |
+---------------+---------------+-------+-----+-+---------------+
|                                                               |
|                Sender's Truncated HMAC (64 bits)              |
|                                                               |
+---------------------------------------------------------------+
|                Sender's Random Number (32 bits)               |
+---------------------------------------------------------------+
Parameters:
  • schema (Schema_MPTCPJoinSYNACK) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPJoinSYNACK

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 20.

_read_join_ack(schema, *, options)#

Read Join Connection option for Third ACK.

Structure of MP_JOIN-ACK [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----------------------+
|     Kind      |  Length = 24  |Subtype|      (reserved)       |
+---------------+---------------+-------+-----------------------+
|                                                               |
|                                                               |
|                   Sender's HMAC (160 bits)                    |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
Parameters:
  • schema (Schema_MPTCPJoinACK) – parsed option schema

  • options (Option) – extracted TCP options

Return type:

Data_MPTCPJoinACK

Returns:

Parsed option data.

Raises:

ProtocolError – If length is NOT 24.

_make_tcp_options(options)#

Make options for TCP.

Parameters:
Return type:

tuple[list[Schema_Option | bytes], int]

Returns:

Tuple of options and total length of options.

_make_mode_donone(code, opt=None, *, data=b'', **kwargs)#

Make TCP unassigned option.

Parameters:
Return type:

UnassignedOption

Returns:

Constructed option schema.

_make_mode_eool(code, opt=None, **kwargs)#

Make TCP End of Option List option.

Parameters:
Return type:

EndOfOptionList

Returns:

Constructed option schema.

_make_mode_nop(code, opt=None, **kwargs)#

Make TCP NoOperation option.

Parameters:
Return type:

NoOperation

Returns:

Constructed option schema.

_make_mode_mss(code, opt=None, *, mss=65535, **kwargs)#

Make TCP maximum segment size option.

Parameters:
Return type:

MaximumSegmentSize

Returns:

Constructed option schema.

_make_mode_ws(code, opt=None, *, shift=0, **kwargs)#

Make TCP window scale option.

Parameters:
  • code (Option) – option code

  • opt (Optional[WindowScale]) – option data

  • shift (int) – window scale shift count

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

WindowScale

Returns:

Constructed option schema.

_make_mode_sackpmt(code, opt=None, **kwargs)#

Make TCP SACK permitted option.

Parameters:
Return type:

SACKPermitted

Returns:

Constructed option schema.

_make_mode_sack(code, opt=None, *, sack=None, **kwargs)#

Make TCP SACK option.

Parameters:
Return type:

SACK

Returns:

Constructed option schema.

_make_mode_echo(code, opt=None, *, data=b'\\x00\\x00\\x00\\x00', **kwargs)#

Make TCP echo option.

Parameters:
  • code (Option) – option code

  • opt (Optional[Echo]) – option data

  • data (bytes) – 4 bytes of info to be echoed

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

Echo

Returns:

Constructed option schema.

_make_mode_echore(code, opt=None, *, data=b'\\x00\\x00\\x00\\x00', **kwargs)#

Make TCP echo reply option.

Parameters:
  • code (Option) – option code

  • opt (Optional[EchoReply]) – option data

  • data (bytes) – 4 bytes of echoed info

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

EchoReply

Returns:

Constructed option schema.

_make_mode_ts(code, opt=None, *, tsval=0, tsecr=0, **kwargs)#

Make TCP timestamps option.

Parameters:
  • code (Option) – option code

  • opt (Optional[Timestamp]) – option data

  • tsval (int) – timestamp value

  • tsecr (int) – timestamp echo reply

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

Timestamp

Returns:

Constructed option schema.

_make_mode_poc(code, opt=None, **kwargs)#

Make TCP partial order connection option.

Parameters:
Return type:

PartialOrderConnectionPermitted

Returns:

Constructed option schema.

_make_mode_pocsp(code, opt=None, *, start=False, end=False, **kwargs)#

Make TCP partial order connection service profile option.

Parameters:
Return type:

PartialOrderConnectionProfile

Returns:

Constructed option schema.

_make_mode_cc(code, opt=None, *, count=0, **kwargs)#

Make TCP connection count option.

Parameters:
  • code (Option) – option code

  • opt (Optional[CC]) – option data

  • count (int) – connection count

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

CC

Returns:

Constructed option schema.

_make_mode_ccnew(code, opt=None, *, count=0, **kwargs)#

Make TCP connection count new option.

Parameters:
  • code (Option) – option code

  • opt (Optional[CCNew]) – option data

  • count (int) – connection count

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

CCNew

Returns:

Constructed option schema.

_make_mode_ccecho(code, opt=None, *, count=0, **kwargs)#

Make TCP connection count echo option.

Parameters:
  • code (Option) – option code

  • opt (Optional[CCEcho]) – option data

  • count (int) – connection count

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

CCEcho

Returns:

Constructed option schema.

_make_mode_chkreq(code, opt=None, *, algorithm=Checksum.TCP_checksum, algorithm_default=None, algorithm_namespace=None, algorithm_reversed=False, **kwargs)#

Make TCP alternate checksum request option.

Parameters:
Return type:

AlternateChecksumRequest

Returns:

Constructed option schema.

_make_mode_chksum(code, opt=None, *, data=b'', **kwargs)#

Make TCP alternate checksum data option.

Parameters:
Return type:

AlternateChecksumData

Returns:

Constructed option schema.

_make_mode_sig(code, opt=None, *, digest=b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00', **kwargs)#

Make TCP MD5 signature option.

Parameters:
Return type:

MD5Signature

Returns:

Constructed option schema.

_make_mode_qs(code, opt=None, *, rate=0, diff=0, nonce=0, **kwargs)#

Make TCP quick start response option.

Parameters:
Return type:

QuickStartResponse

Returns:

Constructed option schema.

_make_mode_timeout(code, opt=None, *, timeout=0, **kwargs)#

Make TCP user timeout option.

Parameters:
Return type:

UserTimeout

Returns:

Constructed option schema.

_make_mode_ao(code, opt=None, *, key_id=0, next_key_id=0, mac=b'', **kwargs)#

Make TCP authentication option.

Parameters:
Return type:

Authentication

Returns:

Constructed option schema.

_make_mode_mp(code, opt=None, *, subtype=MPTCPOption.MP_CAPABLE, subtype_default=None, subtype_namespace=None, subtype_reversed=False, **kwargs)#

Make multipath TCP option.

Parameters:
  • code (Enum_Option) – option code

  • opt (Optional[Data_MPTCP]) – option data

  • subtype (Enum_MPTCPOption | StdlibEnum | AenumEnum | int | str) – MPTCP subtype

  • subtype_default (Optional[int]) – default value for MPTCP subtype

  • subtype_namespace (Optional[dict[str, int] | dict[int, str] | Type[StdlibEnum] | Type[AenumEnum]]) – namespace for MPTCP subtype

  • subtype_reversed (bool) – reversed flag for MPTCP subtype

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

Schema_MPTCP

Returns:

Constructed option schema.

_make_mode_fastopen(code, opt=None, *, cookie=None, **kwargs)#

Make TCP Fast Open option.

Parameters:
Return type:

FastOpenCookie

Returns:

Constructed option schema.

_make_mptcp_unknown(subtype, opt=None, *, data=b'\\x00', **kwargs)#

Make unknown multipath TCP option.

Parameters:
Return type:

MPTCPUnknown

Returns:

Constructed option schema.

_make_mptcp_capable(subtype, opt=None, *, version=0, flag_req=False, flag_ext=False, flag_hsa=False, skey=0, rkey=0, **kwargs)#

Make multipath TCP capable option.

Parameters:
  • subtype (MPTCPOption) – MPTCP subtype

  • opt (Optional[MPTCPCapable]) – option data

  • version (int) – MPTCP version

  • flag_req (bool) – checksum required flag

  • flag_ext (bool) – extensability flag

  • flag_hsa (bool) – use of HMAC-SHA1 flag

  • skey (int) – option sender’s key

  • rkey (Optional[int]) – option receiver’s key

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

MPTCPCapable

Returns:

Constructed option schema.

_make_mptcp_join(subtype, opt=None, **kwargs)#

Make multipath TCP join option.

Parameters:
  • subtype (Enum_MPTCPOption) – MPTCP subtype

  • opt (Optional[Data_MPTCPJoin]) – option data

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

Schema_MPTCPJoin

Returns:

Constructed option schema.

_make_mptcp_dss(subtype, opt=None, *, data_fin=False, ack=None, dsn=None, ssn=None, dl_len=None, checksum=None, **kwargs)#

Make multipath TCP DSS option.

Parameters:
Return type:

MPTCPDSS

Returns:

Constructed option schema.

_make_mptcp_addaddr(subtype, opt=None, *, addr_id=0, addr='0.0.0.0', port=None, **kwargs)#

Make multipath TCP add address option.

Parameters:
Return type:

MPTCPAddAddress

Returns:

Constructed option schema.

_make_mptcp_remove(subtype, opt=None, *, addr_id=None, **kwargs)#

Make multipath TCP remove address option.

Parameters:
Return type:

MPTCPRemoveAddress

Returns:

Constructed option schema.

_make_mptcp_prio(subtype, opt=None, *, backup=False, addr_id=None, **kwargs)#

Make multipath TCP priority option.

Parameters:
Return type:

MPTCPPriority

Returns:

Constructed option schema.

_make_mptcp_fail(subtype, opt=None, *, dsn=0, **kwargs)#

Make multipath TCP fail option.

Parameters:
  • subtype (MPTCPOption) – MPTCP subtype

  • opt (Optional[MPTCPFallback]) – option data

  • dsn (int) – data sequence number

  • **kwargs (Any) – arbitrary keyword arguments

  • Returns – Constructed option schema.

Return type:

MPTCPFallback

_make_mptcp_fastclose(subtype, opt=None, *, key=0, **kwargs)#

Make multipath TCP fastclose option.

Parameters:
  • subtype (MPTCPOption) – MPTCP subtype

  • opt (Optional[MPTCPFastclose]) – option data

  • key (int) – option receiver’s key

  • **kwargs (Any) – arbitrary keyword arguments

  • Returns – Constructed option schema.

Return type:

MPTCPFastclose

_make_join_syn(subtype, opt=None, *, backup=False, addr_id=0, token=0, nonce=0, **kwargs)#

Make multipath TCP join SYN option.

Parameters:
  • subtype (MPTCPOption) – MPTCP subtype

  • opt (Optional[MPTCPJoinSYN]) – option data

  • backup (bool) – backup flag

  • addr_id (int) – address ID

  • token (int) – receiver’s token

  • nonce (int) – sender’s random number

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

MPTCPJoinSYN

Returns:

Constructed option schema.

_make_join_synack(subtype, opt=None, *, backup=False, addr_id=0, hmac=b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00', nonce=0, **kwargs)#

Make multipath TCP join SYN/ACK option.

Parameters:
  • subtype (MPTCPOption) – MPTCP subtype

  • opt (Optional[MPTCPJoinSYNACK]) – option data

  • backup (bool) – backup flag

  • addr_id (int) – address ID

  • hmac (bytes) – sender’s truncated HMAC

  • nonce (int) – sender’s random number

  • **kwargs (Any) – arbitrary keyword arguments

Return type:

MPTCPJoinSYNACK

Returns:

Constructed option schema.

_make_join_ack(subtype, opt=None, *, hmac=b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00', **kwargs)#

Make multipath TCP join ACK option.

Parameters:
Return type:

MPTCPJoinACK

Returns:

Constructed option schema.

__proto__: DefaultDict[int, tuple[str, str]]#

Protocol index mapping for decoding next layer, c.f. self._decode_next_layer & self._import_next_layer.

Type:

DefaultDict[int, tuple[str, str]]

__option__: DefaultDict[int, str | tuple[OptionParser, OptionConstructor]]#

DefaultDict[Enum_Option, str | tuple[OptionParser, OptionConstructor]]: Option code to method mapping, c.f. _read_tcp_options() and _make_tcp_options(). Method names are expected to be referred to the class by _read_mode_${name} and _make_mode_${name}, and if such name not found, the value should then be a method that can parse the option by itself.

__mp_option__: DefaultDict[int, str | tuple[MPOptionParser, MPOptionConstructor]]#

DefaultDict[Enum_MPTCPOption, str | tuple[MPOptionParser, MPOptionConstructor]]: Option code to method mapping, c.f. _read_mode_mp() and _make_mode_mp(). Method names are expected to be referred to the class by _read_mptcp_${name} and _make_mptcp_${name}, and if such name not found, the value should then be a method that can parse the option by itself.

classmethod __index__()#

Numeral registry index of the protocol.

Return type:

TransType

Returns:

Numeral registry index of the protocol in IANA.

Connection Flags#

class pcapkit.protocols.transport.tcp.Flags(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: IntFlag

TCP connection control flags.

Parameters:
  • *args – Arbitrary positional arguments.

  • **kwargs – Arbitrary keyword arguments.

FIN = 1#

No more data from sender (FIN).

SYN = 2#

Synchronize sequence numbers (SYN).

RST = 4#

Reset the connection (RST).

PSH = 8#

Push function (PSH).

ACK = 16#

Acknowledgment number valid (ACK).

URG = 32#

Urgent pointer (URG).

ECE = 64#

ECN-Echo (ECE).

CWR = 128#

Congestion window reduced (CWR).

Header Schemas#

class pcapkit.protocols.schema.transport.tcp.TCP(dict_=None, **kwargs)#

Bases: Schema

Header schema for TCP packet.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

srcport: int = <UInt16Field>#

Source port.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

dstport: int = <UInt16Field>#

Destination port.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

seq: int = <UInt32Field>#

Sequence number.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

ack: int = <UInt32Field>#

Acknowledgement number.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

offset: OffsetFlag = <BitField>#

Data offset.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

flags: Flags = <BitField>#

TCP flags.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

window: int = <UInt16Field>#

Window size.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

checksum: bytes = <BytesField>#

Checksum.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

urgent: int = <UInt16Field>#

Urgent pointer.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

options: list[Option] = <OptionField>#

Options.

Parameters:

packet (dict[str, Any]) –

Return type:

ListField

padding: bytes = <PaddingField>#

Padding.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

payload: bytes = <PayloadField>#

Payload.

Parameters:

packet (dict[str, Any]) –

Return type:

PayloadField

class pcapkit.protocols.schema.transport.tcp.Option(dict_=None, **kwargs)#

Bases: Schema

Header schema for TCP options.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

kind: Enum_Option = <EnumField>#

Option kind.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

length: int = <ConditionalField>#

Option length.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

classmethod post_process(schema, data, length, packet)#

Revise schema data after unpacking process.

Parameters:
  • schema (Schema) – parsed schema

  • data (IO[bytes]) – Packed data.

  • length (int) – Length of data.

  • packet (dict[str, Any]) – Unpacked data.

Return type:

Schema

Returns:

Revised schema.

class pcapkit.protocols.schema.transport.tcp.UnassignedOption(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP unassigned options.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

data: bytes = <BytesField>#

Option data.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.EndOfOptionList(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP end of option list.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

class pcapkit.protocols.schema.transport.tcp.NoOperation(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP no operation.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

class pcapkit.protocols.schema.transport.tcp.MaximumSegmentSize(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP max segment size option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

mss: int = <UInt16Field>#

Maximum segment size.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.WindowScale(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP window scale option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

shift: int = <UInt8Field>#

Window scale (shift count).

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.SACKPermitted(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP SACK permitted option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

class pcapkit.protocols.schema.transport.tcp.SACK(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP SACK option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

sack: list[SACKBlock] = <ListField>#

Selected ACK data.

Parameters:

packet (dict[str, Any]) –

Return type:

ListField

class pcapkit.protocols.schema.transport.tcp.Echo(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP echo option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

data: bytes = <BytesField>#

Info to be echoed.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.EchoReply(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP echo reply option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

data: bytes = <BytesField>#

Echoed info.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.Timestamp(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP timestamps option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

value: int = <UInt32Field>#

Timestamp value.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

reply: int = <UInt32Field>#

Timestamp echo reply.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.PartialOrderConnectionPermitted(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP partial order connection permitted option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

class pcapkit.protocols.schema.transport.tcp.PartialOrderConnectionProfile(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP partial order connection service profile option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

profile: POCProfile = <BitField>#

Profile data.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.CC(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP CC option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

count: int = <UInt32Field>#

Connection count.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.CCNew(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP connection count (new) option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

count: int = <UInt32Field>#

Connection count.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.CCEcho(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP connection count (echo) option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

count: int = <UInt32Field>#

Connection count.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.AlternateChecksumRequest(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP alternate checksum request option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

algorithm: Enum_Checksum = <EnumField>#

Checksum algorithm.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.AlternateChecksumData(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP alternate checksum data option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

data: bytes = <BytesField>#

Checksum data.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.MD5Signature(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP MD5 signature option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

digest: bytes = <BytesField>#

MD5 digest.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.QuickStartResponse(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP quick start response option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

flags: QuickStartFlags = <BitField>#

Flags.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

diff: int = <UInt8Field>#

TTL difference.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

nonce: QuickStartNonce = <BitField>#

QS nonce.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.UserTimeout(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP user timeout option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

info: TimeoutInfo = <BitField>#

Granularity and user timeout.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.Authentication(dict_=None, **kwargs)#

Bases: Option

Header schema for TCP authentication option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

key_id: int = <UInt8Field>#

Key ID.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

next_key_id: int = <UInt8Field>#

Next key ID.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

mac: bytes = <BytesField>#

MAC value.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.FastOpenCookie(dict_=None, **kwargs)#

Bases: Option

“Header schema for TCP Fast Open option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

cookie: bytes = <ConditionalField>#

Cookie.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

class pcapkit.protocols.schema.transport.tcp.MPTCP(dict_=None, **kwargs)#

Bases: Option

Header schema for Multipath TCP options.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

subtype: Enum_MPTCPOption#

MPTCP subtype.

class pcapkit.protocols.schema.transport.tcp.MPTCPUnknown(dict_=None, **kwargs)#

Bases: MPTCP

Header schema for unknown Multipath TCP option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtypeUnknown = <BitField>#

Subtype and data.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

data: bytes = <BytesField>#

Data.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.MPTCPCapable(dict_=None, **kwargs)#

Bases: MPTCP

Header schema for Multipath TCP capable option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtypeCapable = <BitField>#

Subtype and version.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

flags: MPTCPCapableFlags = <BitField>#

Flags.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

skey: int = <UInt64Field>#

Option sender’s key.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

rkey: int = <ConditionalField>#

Option receiver’s key.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

class pcapkit.protocols.schema.transport.tcp.MPTCPJoin(dict_=None, **kwargs)#

Bases: MPTCP

Header schema for Multipath TCP join option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

class pcapkit.protocols.schema.transport.tcp.MPTCPJoinSYN(dict_=None, **kwargs)#

Bases: MPTCPJoin

Header schema for Multipath TCP join option for SYN connection.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtypeJoin = <BitField>#

Subtype and flags.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

addr_id: int = <UInt8Field>#

Address ID.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

token: int = <UInt32Field>#

Receiver’s token.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

nonce: int = <UInt32Field>#

Sender’s random number.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.MPTCPJoinSYNACK(dict_=None, **kwargs)#

Bases: MPTCPJoin

Header schema for Multipath TCP join option for SYN/ACK connection.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtypeJoin = <BitField>#

Subtype and flags.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

addr_id: int = <UInt8Field>#

Address ID.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

hmac: bytes = <BytesField>#

Sender’s truncated HMAC

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

nonce: int = <UInt32Field>#

Sender’s random number.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.MPTCPJoinACK(dict_=None, **kwargs)#

Bases: MPTCPJoin

Header schema for Multipath TCP join option for ACK connection.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtype = <BitField>#

Subtype.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

reserved: bytes = <PaddingField>#

Reserved.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

hmac: bytes = <BytesField>#

Sender’s HMAC.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

class pcapkit.protocols.schema.transport.tcp.MPTCPDSS(dict_=None, **kwargs)#

Bases: MPTCP

Header schema for Multipath TCP DSS option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtype = <BitField>#

Subtype and flags.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

flags: MPTCPDSSFlags = <BitField>#

Flags.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

ack: int = <ConditionalField>#

Data ACK.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

dsn: int = <ConditionalField>#

Data sequence number.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

ssn: int = <ConditionalField>#

Subflow sequence number.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

dl_len: int = <ConditionalField>#

Data level length.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

checksum: bytes = <ConditionalField>#

Checksum.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

class pcapkit.protocols.schema.transport.tcp.MPTCPAddAddress(dict_=None, **kwargs)#

Bases: MPTCP

Header schema for Multipath TCP add address option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtypeAddAddress = <BitField>#

Subtype and IP version.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

addr_id: int = <UInt8Field>#

Address ID.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

address: IPv4Address | IPv6Address = <SwitchField>#

Address.

Parameters:

packet (dict[str, Any]) –

Return type:

SwitchField[_TC]

port: int = <ConditionalField>#

Port.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

class pcapkit.protocols.schema.transport.tcp.MPTCPRemoveAddress(dict_=None, **kwargs)#

Bases: MPTCP

Header schema for Multipath TCP remove address option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtype = <BitField>#

Subtype.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

addr_id: list[int] = <ListField>#

Address ID.

Parameters:

packet (dict[str, Any]) –

Return type:

ListField

class pcapkit.protocols.schema.transport.tcp.MPTCPPriority(dict_=None, **kwargs)#

Bases: MPTCP

Header schema for Multipath TCP priority option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtypePriority = <BitField>#

Subtype.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

addr_id: int = <ConditionalField>#

Address ID.

Parameters:

packet (dict[str, Any]) –

Return type:

ConditionalField

class pcapkit.protocols.schema.transport.tcp.MPTCPFallback(dict_=None, **kwargs)#

Bases: MPTCP

Header schema for Multipath TCP fallback option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtype = <BitField>#

Subtype.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

dsn: int = <UInt64Field>#

Data sequence number.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

class pcapkit.protocols.schema.transport.tcp.MPTCPFastclose(dict_=None, **kwargs)#

Bases: MPTCP

Header schema for Multipath TCP fastclose option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Schema

test: MPTCPSubtype = <BitField>#

Subtype.

Parameters:

packet (dict[str, Any]) –

Return type:

_TextField

key: int = <UInt64Field>#

Option receiver’s key.

Parameters:

packet (dict[str, Any]) –

Return type:

NumberField

Type Stubs#

Auxiliary Functions#

pcapkit.protocols.schema.transport.tcp.mptcp_data_selector(pkt)#

Selector function for _MPTCP.data field.

Parameters:

pkt (dict[str, Any]) – Packet data.

Return type:

_Field

Returns:

A SchemaField wrapped MPTCP subclass instance.

pcapkit.protocols.schema.transport.tcp.mptcp_add_address_length(pkt)#

Length callback function for MPTCPAddAddress.address field.

Parameters:

pkt (dict[str, Any]) – Packet data.

Return type:

Literal[4, 16]

Returns:

Length of MPTCPAddAddress.address field.

pcapkit.protocols.schema.transport.tcp.mptcp_add_address_selector(pkt)#

Selector function for MPTCPAddAddress.address field.

Parameters:

pkt (dict[str, Any]) – Packet data.

Return type:

_Field

Returns:

Data Models#

class pcapkit.protocols.data.transport.tcp.TCP(dict_=None, **kwargs)#

Bases: Data

Data model for TCP packet.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

srcport: int#

Source port.

dstport: int#

Destination port.

seq: int#

Sequence number.

ack: int#

Acknowledgment number.

hdr_len: int#

Data offset.

flags: Flags#

Flags.

window_size: int#

Window size.

checksum: bytes#

Checksum.

urgent_pointer: int#

Urgent pointer.

options: OrderedMultiDict[OptionNumber, Option]#

TCP options.

connection: TCP_Flags#

Connection control flags.

class pcapkit.protocols.data.transport.tcp.Flags(dict_=None, **kwargs)#

Bases: Data

Data model for TCP flags.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

ns: bool#

ECN-nonce concealment protection.

cwr: bool#

Congestion window reduced.

ece: bool#

ECN-Echo.

urg: bool#

Urgent.

ack: bool#

Acknowledgment.

psh: bool#

Push function.

rst: bool#

Reset connection.

syn: bool#

Synchronize sequence numbers.

fin: bool#

Last packet from sender.

class pcapkit.protocols.data.transport.tcp.Option(dict_=None, **kwargs)#

Bases: Data

Data model for TCP options.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

kind: OptionNumber#

Option kind.

length: int#

Option length.

class pcapkit.protocols.data.transport.tcp.UnassignedOption(dict_=None, **kwargs)#

Bases: Option

Data model for unassigned TCP option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

data: bytes#

Option data.

class pcapkit.protocols.data.transport.tcp.EndOfOptionList(dict_=None, **kwargs)#

Bases: Option

Data model for TCP end of option list option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

class pcapkit.protocols.data.transport.tcp.NoOperation(dict_=None, **kwargs)#

Bases: Option

Data model for TCP no operation option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

class pcapkit.protocols.data.transport.tcp.MaximumSegmentSize(dict_=None, **kwargs)#

Bases: Option

Data model for TCP maximum segment size option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

mss: int#

Maximum segment size.

class pcapkit.protocols.data.transport.tcp.WindowScale(dict_=None, **kwargs)#

Bases: Option

Data model for TCP window scale option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

shift: int#

Window scale.

class pcapkit.protocols.data.transport.tcp.SACKPermitted(dict_=None, **kwargs)#

Bases: Option

Data model for TCP SACK permitted option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

class pcapkit.protocols.data.transport.tcp.SACK(dict_=None, **kwargs)#

Bases: Option

Data model for TCP SACK option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

sack: tuple[SACKBlock, ...]#

SACK blocks.

class pcapkit.protocols.data.transport.tcp.Echo(dict_=None, **kwargs)#

Bases: Option

Data model for TCP echo option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

data: bytes#

Echo data.

class pcapkit.protocols.data.transport.tcp.EchoReply(dict_=None, **kwargs)#

Bases: Option

Data model for TCP echo reply option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

data: bytes#

Echo data.

class pcapkit.protocols.data.transport.tcp.Timestamp(dict_=None, **kwargs)#

Bases: Option

Data model for TCP timestamp option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

timestamp: int#

Timestamp .

echo: int#

Echo data.

class pcapkit.protocols.data.transport.tcp.PartialOrderConnectionPermitted(dict_=None, **kwargs)#

Bases: Option

Data model for TCP partial order connection permitted option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

class pcapkit.protocols.data.transport.tcp.PartialOrderConnectionProfile(dict_=None, **kwargs)#

Bases: Option

Data model for TCP partial order connection profile option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

start: bool#

Start flag.

end: bool#

End flag.

class pcapkit.protocols.data.transport.tcp.CC(dict_=None, **kwargs)#

Bases: Option

Data model for TCP CC option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

cc: int#

Connection count.

class pcapkit.protocols.data.transport.tcp.CCNew(dict_=None, **kwargs)#

Bases: Option

Data model for TCP CC.NEW option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

cc: int#

Connection count.

class pcapkit.protocols.data.transport.tcp.CCEcho(dict_=None, **kwargs)#

Bases: Option

Data model for TCP CC.ECHO option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

cc: int#

Connection count.

class pcapkit.protocols.data.transport.tcp.AlternateChecksumRequest(dict_=None, **kwargs)#

Bases: Option

Data model for TCP alternate checksum request option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

chksum: Checksum#

Checksum algorithm.

class pcapkit.protocols.data.transport.tcp.AlternateChecksumData(dict_=None, **kwargs)#

Bases: Option

Data model for TCP alternate checksum data option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

data: bytes#

Checksum data.

class pcapkit.protocols.data.transport.tcp.MD5Signature(dict_=None, **kwargs)#

Bases: Option

Data model for TCP MD5 signature option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

digest: bytes#

MD5 signature.

class pcapkit.protocols.data.transport.tcp.QuickStartResponse(dict_=None, **kwargs)#

Bases: Option

Data model for TCP quick start response option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

req_rate: int#

Rate request.

ttl_diff: int#

TTL difference.

nonce: int#

QS nonce.

class pcapkit.protocols.data.transport.tcp.UserTimeout(dict_=None, **kwargs)#

Bases: Option

Data model for TCP user timeout option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

timeout: timedelta#

User timeout.

class pcapkit.protocols.data.transport.tcp.Authentication(dict_=None, **kwargs)#

Bases: Option

Data model for TCP authentication option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

key_id: int#

Key ID.

next_key_id: int#

Receive next key ID.

mac: bytes#

MAC.

class pcapkit.protocols.data.transport.tcp.FastOpenCookie(dict_=None, **kwargs)#

Bases: Option

Data model for TCP fast open cookie option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

cookie: bytes#

Cookie.

class pcapkit.protocols.data.transport.tcp.MPTCP(dict_=None, **kwargs)#

Bases: Option

Data model for TCP MPTCP option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

subtype: MPTCPOption#

Subtype.

class pcapkit.protocols.data.transport.tcp.MPTCPUnknown(dict_=None, **kwargs)#

Bases: MPTCP

Data model for TCP unknown MPTCP option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

data: bytes#

Data.

class pcapkit.protocols.data.transport.tcp.MPTCPCapable(dict_=None, **kwargs)#

Bases: MPTCP

Data model for TCP MP_CAPABLE option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

version: int#

Version.

flags: MPTCPCapableFlag#

Flags.

skey: int#

Option sender’s key.

rkey: Optional[int]#

Option receiver’s key.

class pcapkit.protocols.data.transport.tcp.MPTCPJoin(dict_=None, **kwargs)#

Bases: MPTCP

Data model for TCP MP_JOIN option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

connection: TCP_Flags#

Connection type.

class pcapkit.protocols.data.transport.tcp.MPTCPJoinSYN(dict_=None, **kwargs)#

Bases: MPTCPJoin

Data model for TCP MP_JOIN-SYN option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

backup: bool#

Backup path flag.

addr_id: int#

Address ID.

token: int#

Receiver’s token.

nonce: int#

Sendder’s random number.

class pcapkit.protocols.data.transport.tcp.MPTCPJoinSYNACK(dict_=None, **kwargs)#

Bases: MPTCPJoin

Data model for TCP MP_JOIN-SYNACK option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

backup: bool#

Backup path flag.

addr_id: int#

Address ID.

hmac: bytes#

Sender’s truncated HMAC.

nonce: int#

Sendder’s random number.

class pcapkit.protocols.data.transport.tcp.MPTCPJoinACK(dict_=None, **kwargs)#

Bases: MPTCPJoin

Data model for TCP MP_JOIN-ACK option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

hmac: bytes#

HMAC value.

class pcapkit.protocols.data.transport.tcp.MPTCPDSS(dict_=None, **kwargs)#

Bases: MPTCP

Data model for TCP DSS option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

data_fin: bool#

DATA_FIN flag.

ack: Optional[int]#

Data ACK.

dsn: Optional[int]#

Data sequence number.

ssn: Optional[int]#

Subflow sequence number.

dl_len: Optional[int]#

Data-level length.

checksum: Optional[bytes]#

Checksum.

class pcapkit.protocols.data.transport.tcp.MPTCPAddAddress(dict_=None, **kwargs)#

Bases: MPTCP

Data model for TCP ADD_ADDR option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

version: int#

IP version.

addr_id: int#

Address ID.

addr: IPAddress#

Address.

port: Optional[int]#

Port number.

class pcapkit.protocols.data.transport.tcp.MPTCPRemoveAddress(dict_=None, **kwargs)#

Bases: MPTCP

Data model for TCP REMOVE_ADDR option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

addr_id: tuple[int, ...]#

Address ID.

class pcapkit.protocols.data.transport.tcp.MPTCPPriority(dict_=None, **kwargs)#

Bases: MPTCP

Data model for TCP MP_PRIO option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

backup: bool#

Backup path flag.

addr_id: Optional[int]#

Address ID.

class pcapkit.protocols.data.transport.tcp.MPTCPFallback(dict_=None, **kwargs)#

Bases: MPTCP

Data model for TCP MP_FAIL option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

dsn: int#

Data sequence number.

class pcapkit.protocols.data.transport.tcp.MPTCPFastclose(dict_=None, **kwargs)#

Bases: MPTCP

Data model for TCP MP_FASTCLOSE option.

Parameters:
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type:

Info

rkey: int#

Option receiver’s key.