TCP:TCP is a reliable method of sending data between computers,
ensuring everything arrives safely, completely, and in the correct
order.
What are TCP Flags
TCP flags are small indicators used in network packets to show
what is happening in a TCP connection.
They help computers understand:
Are we starting a connection?
Are we sending data?
Are we closing the connection?
Did we receive your message?
Each flag is just 1 bit (ON or OFF).
Most Common TCP Flags
SYN (Synchronize):Used when two computers start a connection.
ACK:Every time a device receives data, it sends ACK back.
FIN:Used when one side wants to end the connection.
Step Handshake
1. Client → Server: SYN
“I want to connect.”
2. Server → Client: SYN + ACK
“I got your message and I also want to connect.”
3. Client → Server: ACK
“Great, let’s start communicating!”
TTL
TTL(Time to Live):TTL
is a number attached to every packet that tells
how long it is allowed to travel in the network before being thrown
away.
Think of TTL like a timer or expiry limit for packets.
If TTL > 0 → Packet continues
If TTL = 0 → Packet is discarded (dropped)
Without TTL, a packet could get stuck in a loop between routers
and:
overload the network
slow down traffic
waste resources
TTL protects the network by deleting packets that travel for too
long.
How TTL Works
1. Sender gives the packet a TTL value (ex: 64 or 255).
2. Every time the packet crosses a router (hop), TTL is reduced by
1.
3. if TTL becomes 0, the router drops the packet.
4. Router sends a message back to the sender saying:
“Packet expired!” (ICMP Time Exceeded)
What is ICMP? (Internet
Control Message Protocol)
ICMP is a helper protocol that computers and routers use to send
error messages and status information in a network.
It does NOT transfer normal data (like files, videos, emails).
It only sends messages about the health of the network.
Why do we need ICMP?
Because when something goes wrong in the network, devices need
a way to say:
1. I can’t reach that destination.
2. The route is broken.
3. Packet took too long.
4. I am here.
5. Are you reachable?
ICMP Types
1. Type8 — Echo Request
Message: “Are you there?”
Used by: ping
2. Type
0 — Echo Reply
Message: “Yes, I'm here!”
Response to Type 8.
3. Type 3 — Destination Unreachable
4. ICMP Type 5 — Redirect Message
A Redirect Message is sent by a router to tell a computer: “Hey, you are using the wrong
route. There is a better path. Use that instead.”
5. ICMP Type 11 — Time Exceeded
This message is sent when a packet has been traveling too long,
and its TTL (Time To Live) becomes 0.
In the diagram, A sends data toward destination D through routers
1, 2, and 3, but something on the path fails—like a broken link,
hardware problem, or port failure. When a router detects that it
cannot deliver the packet any further, it discards the packet and
sends an ICMP “Destination Unreachable” message back to A. This
message tells A that the packet could not reach its destination, so A
does not keep waiting or retrying blindly.
PING is used to check if another computer, server, or device is reachable on the
network, and to measure how fast it responds.
PING works using ICMP (Internet Control Message Protocol).
A Story
Step 1. A wants to talk to B
A wants to send a message to B.
A breaks the message into pieces called packets.