packet.transport.tcp man page

packet.transport.tcp — TCP module


Decode TCP layer.


class Flags(baseobj.BaseObj)

Flags object

Methods defined here:

__init__(self, data)
Constructor which takes a short integer as input

class TCP(baseobj.BaseObj)

TCP object

    from packet.transport.tcp import TCP

    x = TCP(pktt)

Object definition:

    src_port    = int, # Source port
    dst_port    = int, # Destination port
    seq_number  = int, # Sequence number
    ack_number  = int, # Acknowledgment number
    hl          = int, # Data offset or header length (32bit words)
    header_size = int, # Data offset or header length in bytes
    flags_raw   = int, # Raw flags
    flags = Flags(     # Individual flags:
        FIN = int,     #   No more data from sender
        SYN = int,     #   Synchronize sequence numbers
        RST = int,     #   Synchronize sequence numbers
        PSH = int,     #   Push function. Asks to push the buffered
                       #     data to the receiving application
        ACK = int,     #   Acknowledgment field is significant
        URG = int,     #   Urgent pointer field is significant
        ECE = int,     #   ECN-Echo has a dual role:
                       #     SYN=1, the TCP peer is ECN capable.
                       #     SYN=0, packet with Congestion Experienced
                       #     flag in IP header set is received during
                       #     normal transmission
        CWR = int,     #   Congestion Window Reduced
        NS  = int,     #   ECN-nonce concealment protection
    window_size = int, # Window size
    checksum    = int, # Checksum
    urgent_ptr  = int, # Urgent pointer
    seq         = int, # Relative sequence number
    options = string,  # Raw data of TCP options if available
    data = string,     # Raw data of payload if unable to decode

Methods defined here:

__init__(self, pktt)

Initialize object's private data.

    Packet trace object (packet.pktt.Pktt) so this layer has
    access to the parent layers.

String representation of object

The representation depends on the verbose level set by debug_repr().
If set to 0 the generic object representation is returned.
If set to 1 the representation of the object is condensed:
    'TCP 708 -> 2049, seq: 3294175829, ack: 3395739041, ACK,FIN'

If set to 2 the representation of the object also includes the
length of payload and a little bit more verbose:
    'src port 708 -> dst port 2049, seq: 3294175829, ack: 3395739041, len: 0, flags: ACK,FIN'

See Also

baseobj(3), packet.application.rpc(3)


No known bugs.


Jorge Mora (

Referenced By

packet.internet.ipv4(3), packet.internet.ipv6(3).

23 November 2015 NFStest 2.1.1 tcp 1.0.3