Connection-Oriented Communication at Transport Layer
Connection-oriented communication is a key feature of the Transport Layer, especially when using the TCP (Transmission Control Protocol). It ensures that data is delivered reliably, in order, and without duplication between two devices across a network.
Main Features of Connection-Oriented Communication
Let discuss the main features of connection oriented communication
1. Three-Step Handshake
Before data is sent, TCP establishes a connection using a three-step handshake explained below
Step 1: SYN (Synchronize)
- The client (e.g. your computer) wants to connect to a server (e.g. a website).
- It sends a message called SYN to say:
“Hi! I want to start a connection and I’m ready to send data.”
Step 2: SYN-ACK (Synchronize + Acknowledge)
-
The server gets the SYN and replies with SYN-ACK:
“Got your request! I’m ready too. Here’s my info.”
Step 3: ACK (Acknowledge)
-
The client gets the SYN-ACK and replies with ACK:
“Thanks! Let’s start communicating.”
After this 3-step exchange, the connection is open, and both sides can send and receive data.
Real-life Example: Think of two people starting a phone call:
- Caller: Rings the phone – “Are you there?” (SYN)
- Receiver: Picks up – “Yes, I hear you. Ready to talk!” (SYN-ACK)
- Caller: “Great, let’s talk.” (ACK)
Now the conversation begins, just like a data transfer.
2. Reliable Delivery
Reliable delivery means making sure all the data you send actually reaches the destination, in the correct order, and without errors or loss.
Networks can be unreliable, data can be lost, delayed, duplicated, or arrive out of order. TCP adds extra features to detect problems and fix them automatically.
The following steps are necessary
1. Sequence Numbers:
Each segment of data is given a sequence number. These help the receiver reassemble segments in the correct order, even if they arrive at different times.
Example: If you’re sending “HELLO”, TCP might send:
“HE” (Seq 1), “LL” (Seq 2), “O” (Seq 3)
2. Acknowledgments (ACKs)
After receiving a segment, the receiver sends back an ACK to confirm it arrived. If the sender sends segment 1 and gets back ACK 2, it means:
“I received everything up to segment 1. Please send segment 2 next.”
3. Retransmission
If a segment is lost or corrupted, the receiver does not send an ACK. The sender waits for a short time, then resends the segment.
If the sender doesn’t hear back after sending segment 2, it assumes it was lost and resends it.
4. Checksums
Each TCP segment includes a checksum to detect errors. If a segment arrives with errors, the receiver discards it and waits for a clean copy (which is resent). Ensures that all segments arrive at the destination. Uses acknowledgments (ACKs) and retransmissions if needed.
UDP is not connection-oriented; it’s connectionless.
Real-Life Example
Phone Call vs. Walkie-Talkie:
TCP = Phone Call
-
You dial, the other person picks up (handshake).
-
You talk, both sides take turns or talk simultaneously.
-
You hang up (connection termination).
UDP = Walkie-Talkie
-
You just talk — no setup or guarantee they’re listening.
How TCP Detects a Missing or Corrupted Packet?
1. Every TCP Segment Has a Sequence Number
-
If you send packets from sequence 1 to 1000, each one is labeled with its own sequence number (e.g., packet 20 = Seq 20).
-
The receiver keeps track of which numbers it has successfully received.
2. Receiver Sends Acknowledgments (ACKs)
-
When the receiver gets a packet, it replies with an ACK indicating the next expected sequence number.
Example: If receiver got packets 1–19 correctly, it sends
ACK 20
, meaning:“I got everything up to 19; I’m now expecting 20.”
3. If Packet 20 Is Missing or Corrupted
-
The receiver does not receive Seq 20 — or receives it with checksum errors.
-
It will not send an ACK for 21 — it keeps repeating
ACK 20
.
This is called a duplicate ACK.
4. Sender Notices Repeated ACKs
-
The sender keeps seeing repeated
ACK 20
(instead of moving forward). -
It realizes:
“The receiver didn’t get Seq 20, I need to resend it.”
-
TCP uses this pattern to trigger retransmission, even before a timeout occurs (this is called fast retransmit).
Note: If the sender receives three duplicate ACKs (i.e., four ACKs with the same number in total), it assumes a packet was lost without waiting for a timeout and retransmits it immediately.
Example Flow
Seq Sent | ACK Received | What It Means |
---|---|---|
19 | ACK 20 | Receiver got up to Seq 19 |
20 (lost) | (no new ACK) | Receiver doesn’t move forward |
21 | ACK 20 again | Receiver still waiting for Seq 20 |
22 | ACK 20 again | Sender sees repeated ACKs |
20 (resent) | ACK 23 | Receiver finally got 20–22 |
Extra: TCP Uses a Checksum to Detect Corruption
-
If a packet arrives but is corrupted, TCP uses a checksum in the header.
-
If the checksum doesn’t match, the receiver silently discards the packet and waits for a good copy.
Summary
What Goes Wrong | How TCP Detects It |
---|---|
Packet lost | Receiver never sends ACK → retransmit after timeout or duplicate ACKs |
Packet corrupted | Fails checksum → discarded silently → sender resends after not getting ACK |
Out-of-order packet | Receiver buffers it but still ACKs the missing one |