Services and Segment structure in TCP
Last Updated :
01 Oct, 2025
The Transmission Control Protocol is the most common transport layer protocol. It works together with IP and provides a reliable transport service between processes using the network layer service provided by the IP protocol. The various services provided by the TCP to the application layer are as follows:
1. Process-to-Process Communication: TCP enables process-to-process communication using 16-bit port numbers to identify the sending and receiving processes.
2. Stream oriented: TCP sends data as a byte stream, grouping it into segments with headers, which are then encapsulated into IP packets.
3. Full-duplex service: This means that the communication can take place in both directions at the same time.
4.Connection-oriented service: Unlike UDP, TCP provides a connection-oriented service. It defines 3 different phases:
- Connection establishment
- Data transfer
- Connection termination
5. Reliability: TCP ensures reliability through checksums, retransmissions, acknowledgements, sequencing, and congestion control.
6. Multiplexing: TCP does multiplexing and de-multiplexing at the sender and receiver ends respectively as a number of logical connections can be established between port numbers over a physical connection.
TCP headers mainly consist of three components:
1. Byte Number
- Every byte in a TCP connection is assigned a unique number.
- Numbering starts from an arbitrary initial value chosen at the start of the connection.
2. Sequence Number
- Represents the byte number of the first byte in the current segment.
- Helps the receiver correctly reassemble data, even if segments arrive out of order.
3. Acknowledgement Number
- Indicates the next expected byte number from the sender.
- Confirms that all bytes up to this number have been successfully received.

In the above image, if A sends ACK 1001, it means it received bytes up to 1000 and expects 1001 next. Likewise, B sends ACK 13002 after receiving bytes up to 13001.
TCP Segment structure
A TCP segment consists of data bytes to be sent and a header that is added to the data by TCP as shown:

The header of a TCP segment can range from 20-60 bytes. 40 bytes are for options. If there are no options, a header is 20 bytes else it can be of upmost 60 bytes.
1. Source Port Address: A 16-bit field that holds the port address of the application that is sending the data segment.
2. Destination Port Address: A 16-bit field that holds the port address of the application in the host that is receiving the data segment.
3. Sequence Number: A 32-bit field that holds the sequence number, i.e, the byte number of the first byte that is sent in that particular segment. It is used to reassemble the message at the receiving end of the segments that are received out of order.
4. Acknowledgement Number: A 32-bit field that holds the acknowledgement number, i.e, the byte number that the receiver expects to receive next. It is an acknowledgement for the previous bytes being received successfully.
5. Header Length (HLEN): This is a 4-bit field that indicates the length of the TCP header by a number of 4-byte words in the header, i.e if the header is 20 bytes(min length of TCP header), then this field will hold 5 (because 5 x 4 = 20) and the maximum length: 60 bytes, then it'll hold the value 15(because 15 x 4 = 60). Hence, the value of this field is always between 5 and 15.
6. Control flags: These are 6 1-bit control bits that control connection establishment, connection termination, connection abortion, flow control, mode of transfer etc. Their function is:
- URG: Urgent pointer is valid
- ACK: Acknowledgement number is valid( used in case of cumulative acknowledgement)
- PSH: Request for push
- RST: Reset the connection
- SYN: Synchronize sequence numbers
- FIN: Terminate the connection
7. Window size: This field tells the window size of the sending TCP in bytes.
8. Checksum: This field holds the checksum for error control. It is mandatory in TCP as opposed to UDP.
9. Urgent pointer: This field (valid only if the URG control flag is set) is used to point to data that is urgently required that needs to reach the receiving process at the earliest. The value of this field is added to the sequence number to get the byte number of the last urgent byte.
Note: TCP is connection-oriented. A TCP connection is established by a 3-way handshake.
Explore
Computer Network Basics
Physical Layer
Data Link Layer
Network Layer
Transport Layer
Session Layer & Presentation Layer
Application Layer
Advanced Topics
Practice