Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

TCP (tcp)

Reached from

Lower layerSelectorValue
ipv4protocol6 (0x06)
ipv6next_header6 (0x06)
ipv6_hopoptsnext_header6 (0x06)
ipv6_routenext_header6 (0x06)
ipv6_srhnext_header6 (0x06)
ipv6_fragnext_header6 (0x06)
ipv6_dstoptsnext_header6 (0x06)

Fields

FieldTypeDefaultAutoDescription
src_portuint(16)49152Source port.
dst_portuint(16)80Destination port; selects the next layer (179 = BGP, 646 = LDP, 3868 = Diameter, 5060 = SIP).
sequint(32)0Sequence number of the first data octet (the initial sequence number with SYN).
ackuint(32)0Acknowledgement number, valid when the ACK flag is set.
data_offsetuint(4)Length of the header in 32-bit wordsHeader length in 32-bit words, 5 to 15 (Auto, includes the options).
reserveduint(4)0Reserved bits, 0.
flagsflags(8)0x2Control flags: CWR, ECE, URG, ACK, PSH, RST, SYN, FIN (default SYN).
windowuint(16)65535Receive window in octets (scaled by the window scale option).
checksumuint(16)Internet checksum with pseudo header over the header and everything after itInternet checksum with the IPv4 / IPv6 pseudo header (Auto).
urgent_ptruint(16)0Urgent pointer, valid when the URG flag is set.
optionstlv — data_offset * 4 - 20 octetsTCP options as TLVs: EOL, NOP, MSS, window scale, SACK permitted, SACK, timestamps.
paddingpadding(4)Zero padding of the options to a 32-bit boundary (Auto).

flags

BitMaskName
7128 (0x80)cwr
664 (0x40)ece
532 (0x20)urg
416 (0x10)ack
38 (0x08)psh
24 (0x04)rst
12 (0x02)syn
01 (0x01)fin

options

  • Type 8 bits, length 8 bits.
  • The length counts the type and length fields too.
  • Unknown types are kept as raw value octets.
TypeNameValue fieldsDescription
0 (0x00)eol(type only, no length or value)
1 (0x01)nop(type only, no length or value)
2 (0x02)mssvalue
3 (0x03)wsshift
4 (0x04)sack_permitted
5 (0x05)sackblocks
8 (0x08)timestampstsval, tsecr

options › mss

FieldTypeDefaultAutoDescription
valueuint(16)

options › ws

FieldTypeDefaultAutoDescription
shiftuint(8)

options › sack

FieldTypeDefaultAutoDescription
blockslist<struct> — rest of the PDU
options › sack › blocks

Each item is a group of the fields below.

FieldTypeDefaultAutoDescription
leftuint(32)
rightuint(32)

options › timestamps

FieldTypeDefaultAutoDescription
tsvaluint(32)
tsecruint(32)

Next layer

The next layer is selected by dst_port; when the field is Auto the builder writes the value of the protocol stacked above. When decoding, src_port is looked up too if the first field matches no entry.

ValueProtocolNote
179 (0x00b3)bgp
646 (0x0286)ldp
3868 (0x0f1c)diameter
5060 (0x13c4)sip

Constraints

LevelRule
errordata_offset within 5..15

Sample templates