What is a TCP segment?
A TCP segment is a unit of data at the transport layer (L4) used by the TCP protocol to transfer information between applications.
In short: a TCP segment is a piece of application data, wrapped by TCP with control information for reliable transmission.
Why a TCP segment is needed
Applications transfer data in large blocks. TCP:
- splits the data stream into segments
- sends them over the network
- reassembles them in the correct order on the receiver's side
This lets TCP:
- control delivery
- detect loss
- retransmit data
What a TCP segment consists of
A TCP segment consists of two parts:
1. The TCP header
Contains the control information needed for reliability:
- source port
- destination port
- sequence number
- acknowledgment number
- flags (SYN, ACK, FIN, and others)
- window size (for flow control)
- checksum
It is the header that makes TCP a reliable protocol.
2. The payload (data)
This is:
- the application's data
- a part of the overall data stream
The payload size depends on:
- the MTU
- TCP settings
- the state of the network
What happens to a TCP segment next
When transmitted over the network:
- TCP forms a segment
- It is passed to the network layer
- The TCP segment is encapsulated in an IP packet
- The IP packet is transmitted over the network
Routers:
- do not see TCP segments
- work only with IP packets
Important to remember
- a TCP segment belongs to L4
- it exists only between the end nodes
- it provides:
- reliability
- order
- no duplicates
- UDP uses a similar unit, but without these guarantees
In short, for the interview
A TCP segment is a unit of data at the transport layer containing the TCP header and application data, used for reliable transmission of information between applications over an end-to-end connection.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.