TCP Features
TCP Features
To provide the services discussed earlier—reliable communication, stream delivery, flow control, error control, and full-duplex communication—TCP uses several important features.
The TCP numbering system, which consists of:
- Byte numbering
- Sequence numbers
- Acknowledgment numbers
These are fundamental to TCP's flow and error control.
1. Numbering System
TCP keeps track of the data being transmitted and received.
An important point is that TCP does not number segments directly.
Instead, TCP uses two fields in the TCP header:
- Sequence Number
- Acknowledgment Number
These numbers refer to bytes (octets) rather than segments.
TCP Header ┌─────────────────────────┬─────────────────────────┐ │ Sequence Number │ Acknowledgment Number │ └─────────────────────────┴─────────────────────────┘
Therefore:
TCP is byte-oriented in its numbering system.
This numbering is used for:
- identifying data,
- error control,
- retransmission,
- flow control.
2. Byte Numbering
TCP assigns a number to every byte of data transmitted in a connection.
For example, suppose an application wants to send:
6000 bytes of data
TCP assigns a number to every byte.
Importantly, TCP does not necessarily start numbering from 0.
TCP chooses an arbitrary starting number between:
Suppose TCP chooses:
1057as the number of the first byte.
Then the 6000 bytes are numbered:
1057, 1058, 1059, ... , 7056
because:
Why does TCP number bytes?
Byte numbering allows TCP to determine:
- which bytes have been received,
- which bytes are missing,
- which bytes need to be retransmitted,
- which bytes should be acknowledged.
3. Sequence Number
After numbering the bytes, TCP assigns a sequence number to each segment.
The sequence number of a segment identifies the byte number of the first data byte carried by that segment.
There are two important rules.
Rule 1: First segment
The sequence number of the first segment is called the:
Initial Sequence Number (ISN)
The ISN is an arbitrarily generated/random number.
Rule 2: Subsequent segments
The sequence number of the next segment is:
Therefore, the sequence number does not simply increase by 1 for every segment.
Example: Sequence Numbers
Suppose a TCP connection transfers 5000 bytes.
The first byte is numbered:
10001The data is divided into five segments, each carrying 1000 bytes.
The sequence numbers are:
| Segment | Bytes carried | Sequence number |
|---|---|---|
| 1 | 1000 | 10001 |
| 2 | 1000 | 11001 |
| 3 | 1000 | 12001 |
| 4 | 1000 | 13001 |
| 5 | 1000 | 14001 |
Why?
The first segment carries bytes:
10001 to 11000Therefore, the next segment begins with:
11001Similarly:
Segment 1 → 10001 Segment 2 → 11001 Segment 3 → 12001 Segment 4 → 13001 Segment 5 → 14001
Key idea
The sequence number identifies the first byte of data in the segment.
4. Sequence Number in Both Directions
TCP provides full-duplex communication.
Therefore, both sides independently number their bytes.
For example:
TCP Connection Host A ─────────────────────────→ Host B Sequence numbers: 5000, ... Host A ←───────────────────────── Host B Sequence numbers: 9000, ...
The starting sequence number in one direction does not have to be the same as that in the other direction.
Thus:
TCP maintains an independent byte-numbering system for each direction.
5. Control Segments and Sequence Numbers
Not every TCP segment carries application data.
Some segments carry only control information, such as those used for:
- connection establishment,
- connection termination,
- connection abortion.
Normally, a segment that carries no user data does not consume a sequence number.
However, some control segments are treated as if they carry one imaginary byte.
Therefore, they consume one sequence number.
For example:
Control segment ↓ Consumes 1 sequence number ↓ Next sequence number increases by 1
This allows the control segment itself to be acknowledged.
6. Acknowledgment Number
TCP uses the acknowledgment number to inform the sender about the bytes successfully received.
But there is an important rule:
The acknowledgment number specifies the sequence number of the next byte that the receiver expects.
It does not indicate the number of the last byte received.
Example
Suppose the receiver has successfully received bytes:
10001 10002 10003 ... 11000
The next byte it expects is:
11001
Therefore, the receiver sends:
ACK = 11001
So:
Last byte received = 11000 Next byte expected = 11001 ACK number = 11001
7. Cumulative Acknowledgment
TCP acknowledgment numbers are cumulative.
Suppose the receiver sends:
ACK = 5643
This means that the receiver has successfully received all bytes up to byte 5642.
Therefore:
ACK = 5643 ↓ All bytes through 5642 have been received ↓ Next expected byte = 5643
The receiver is essentially saying:
"I have received everything up to byte 5642; please send me byte 5643 next."
Important
An acknowledgment number of 5643 does not mean that 5643 bytes have been received.
The first byte may have had a number other than 0.
8. Sequence Number vs Acknowledgment Number
This distinction is very important for understanding TCP.
| Feature | Sequence Number | Acknowledgment Number |
|---|---|---|
| Refers to | Bytes being sent | Bytes received |
| Meaning | Number of the first byte in the segment | Number of the next byte expected |
| Direction | Identifies transmitted data | Confirms received data |
| Nature | Byte-based | Byte-based |
| Example | SEQ = 10001 | ACK = 11001 |
Simple Example
Suppose Host A sends 1000 bytes beginning with byte number 5000.
Host A → Host B SEQ = 5000 Data = 1000 bytes
The bytes are:
5000 ─────────────────── 5999
If Host B receives all these bytes correctly, it sends:
ACK = 6000
because byte 6000 is the next byte expected.
1000 bytes A ─────────────────────────→ B SEQ = 5000 A ←───────────────────────── B ACK = 6000
9. Why TCP Uses Byte Numbering
Byte numbering allows TCP to provide reliable communication.
Suppose three segments are transmitted:
Segment 1: bytes 1000–1999 Segment 2: bytes 2000–2999 Segment 3: bytes 3000–3999
If Segment 2 is lost:
Segment 1 ✓ Segment 2 ✗ Segment 3 ✓
TCP can identify the missing portion because the byte numbers reveal the gap.
The receiver can use acknowledgment information to indicate what byte it expects.
Thus, byte numbering supports:
- error detection
- retransmission
- ordering of data
- cumulative acknowledgment
- flow control
Summary of the TCP Numbering System
TCP Numbering │ ┌───────────┴───────────┐ │ │ Byte Numbering Acknowledgment │ │ ↓ ↓ Every byte gets a number Next byte expected │ │ ↓ ↓ Sequence Number Cumulative ACK │ ↓ First byte in a segment
Remember these three statements
- TCP numbers bytes, not segments.
- The sequence number identifies the first byte carried by a segment.
- The acknowledgment number identifies the next byte expected and is cumulative.
These numbering mechanisms form the basis for TCP's reliable data transfer, error control, and flow control
Comments
Post a Comment