The TCP/IP (Transmission Control Protocol/Internet Protocol) stack is a set of networking protocols used for communication over the internet and other networks. It consists of four layers, each with specific functions.
The top layer of the stack, responsible for interacting with applications that use network communication.
It prepares data for transmission by using appropriate protocols.
Common protocols include:
HTTP (HyperText Transfer Protocol) – Used for web browsing.
HTTPS (Secure HTTP) – Encrypts web traffic for security.
FTP (File Transfer Protocol) – Transfers files between computers.
SMTP (Simple Mail Transfer Protocol) – Sends emails.
IMAP (Internet Message Access Protocol) – Retrieves emails.
Manages end-to-end communication between devices.
Ensures data is broken into packets and reassembled correctly at the destination.
Uses two main protocols:
TCP (Transmission Control Protocol) – Provides reliable, ordered delivery of packets with error checking and retransmission.
UDP (User Datagram Protocol) – A faster but less reliable alternative, often used for live streaming and online gaming.
Handles routing of data across different networks.
Uses IP (Internet Protocol) to assign unique addresses to devices and ensure data reaches the correct destination.
Uses two key protocols:
IP (Internet Protocol) – Assigns IP addresses and handles packet forwarding.
ICMP (Internet Control Message Protocol) – Sends error messages and diagnostics (e.g., "destination unreachable").
The lowest layer, responsible for transmitting data over physical network hardware (e.g., Ethernet, Wi-Fi).
Ensures that data is correctly formatted for the physical connection.
Uses MAC (Media Access Control) addresses to identify devices on a local network.
Layer NamePurposeExample Protocols | ||
Application Layer | Provides services to applications | HTTP, FTP, SMTP |
Transport Layer | Splits data into packets, ensures correct delivery | TCP, UDP |
Internet Layer | Routes packets using IP addresses | IP, ICMP |
Link Layer | Controls physical network connections | Ethernet, Wi-Fi |
Each layer only communicates with the layer directly above or below it, making the network more efficient and structured. The TCP/IP model is the foundation of the internet and modern networking.
Application Layer Protocols
Used for transferring web pages over the internet.
Works in a client-server model, where the client (web browser) requests a web page, and the server responds with the required content.
Uses request-response cycles:
GET request – Requests a web page from a server.
POST request – Sends data to a server (e.g., form submission).
HTTP is stateless, meaning it does not remember previous requests.
Data is not encrypted, making it vulnerable to hacking and interception.
No authentication is built-in, allowing for man-in-the-middle attacks.
A secure version of HTTP, using SSL/TLS encryption to protect data.
Encrypts the communication between the client and the web server, preventing interception or tampering.
Commonly used for online banking, e-commerce, and secure logins.
The browser requests a secure connection to the server.
The server sends an SSL/TLS certificate to verify its identity.
The browser and server establish an encrypted connection using a secure key exchange.
The encrypted communication begins.
Data confidentiality – Encrypts data to prevent eavesdropping.
Authentication – Verifies the identity of the server.
Data integrity – Ensures data is not altered in transit.
Used for transferring files between a client and a server over a network.
Supports two modes of operation:
Active mode – The server opens a connection back to the client.
Passive mode – The client opens both connections (safer behind firewalls).
The user logs into an FTP server using a username and password.
The client can upload, download, or delete files on the server.
Files are transferred in binary (for software) or ASCII mode (for text).
No encryption, meaning data is sent in plaintext (vulnerable to attacks).
Replaced by SFTP (Secure FTP), which encrypts file transfers.
Used for sending emails from a client to a mail server.
Works by routing emails between different servers until they reach their destination.
The email client sends the message to an SMTP server.
The SMTP server forwards the email to the recipient’s mail server.
The recipient retrieves the email using IMAP or POP3.
Only handles sending emails, not receiving them.
Lacks built-in security, making encryption (e.g., TLS) necessary.
Used for retrieving emails from a mail server.
Unlike POP3, IMAP stores emails on the server, allowing users to access them from multiple devices.
The email client connects to the mail server and retrieves only the email headers.
The user can read emails without downloading them, as they stay on the server.
When an email is deleted, it is removed from the server for all devices.
Allows multiple device access (ideal for modern email use).
Emails are backed up on the server.
Faster as only necessary parts of emails are downloaded.
Used for retrieving emails, but unlike IMAP, it downloads emails to a single device and deletes them from the server.
The email client connects to the mail server.
All emails are downloaded to the user’s device.
Emails are removed from the server once downloaded.
Emails cannot be accessed from multiple devices.
If the device is lost, emails are permanently gone unless backed up.
IMAP is preferred over POP3 for modern email usage.
ProtocolPurposeKey Features | ||
HTTP | Loads web pages | Stateless, no encryption |
HTTPS | Secure web browsing | Uses SSL/TLS encryption |
FTP | Transfers files | No encryption, replaced by SFTP |
SMTP | Sends emails | Handles outgoing mail only |
IMAP | Retrieves emails | Stores emails on the server, multi-device access |
POP3 | Retrieves emails | Downloads and deletes emails from the server |
Each protocol is designed for a specific function, and together they enable efficient communication over the internet
Transport Layer Protocols
The Transport Layer of the TCP/IP stack is responsible for managing data transmission between devices. It ensures that data is sent, received, and reassembled correctly. The two main protocols used in this layer are:
TCP (Transmission Control Protocol) – Provides reliable, error-checked communication.
UDP (User Datagram Protocol) – Provides fast, connectionless communication with no guarantee of delivery.
TCP is a connection-oriented protocol, meaning it establishes a reliable connection before data is transmitted. It ensures that all packets arrive in order and without errors.
Connection Establishment (Three-Way Handshake)
The sender sends a SYN (synchronize) packet to request a connection.
The receiver responds with a SYN-ACK (synchronize-acknowledge) packet.
The sender replies with an ACK (acknowledge) packet, and the connection is established.
Data Transmission
The data is divided into packets and assigned a sequence number.
Each packet is checked for errors using checksums.
The receiver acknowledges each received packet.
Retransmission of Lost Packets
If a packet is lost or arrives corrupted, the receiver requests a retransmission.
The sender resends the missing packet to ensure complete data transfer.
Connection Termination
Either device can initiate termination by sending a FIN (finish) packet.
The receiver responds with an ACK.
Once both sides acknowledge, the connection is closed.
✅ Reliable – Ensures all data is received correctly and in order.
✅ Error-checked – Corrupted or missing packets are resent.
✅ Used for important communications, such as web browsing, file transfers, and emails.
❌ Slower than UDP due to its error-checking and retransmission processes.
❌ More overhead due to the need for acknowledgments and retransmissions.
UDP is a connectionless protocol, meaning it sends data without establishing a connection. It does not guarantee delivery, order, or error checking.
The sender divides data into datagrams (similar to packets).
Datagrams are sent to the receiver without acknowledgments.
If a datagram is lost, UDP does not request retransmission.
The receiver processes whatever datagrams arrive, but some may be missing or out of order.
✅ Fast – No need for acknowledgments or retransmissions.
✅ Efficient – Uses less bandwidth and processing power.
✅ Ideal for real-time applications, such as video streaming, online gaming, and VoIP (voice calls).
❌ Unreliable – No guarantee that all data will arrive.
❌ Packets may be lost – No retransmission if data is missing.
❌ No error checking – Corrupt packets may still be delivered.
Feature | TCP (Transmission Control Protocol) | UDP (User Datagram Protocol) |
Connection Type | Connection-oriented (establishes a connection) | Connectionless (no connection) |
Reliability | Reliable – ensures all data arrives correctly | Unreliable – no guarantee of delivery |
Packet Ordering | Packets arrive in order | Packets may arrive out of order |
Error Checking | Uses error checking and retransmission | Minimal error checking, no retransmission |
Speed | Slower due to acknowledgments and retransmission | Faster due to no retransmission |
Use Cases | Web browsing (HTTP/HTTPS), emails (SMTP/IMAP), file transfers (FTP) | Video streaming, online gaming, VoIP (Skype, WhatsApp calls) |
Use TCP when accuracy and reliability are important (e.g., loading web pages, sending emails, downloading files).
Use UDP when speed and efficiency are more important than reliability (e.g., live video streaming, online gaming, voice calls).
TCP and UDP are both essential in networking, each suited for different types of data transmission.
Internet Layer Protocols
The IP (Internet Protocol) is a fundamental part of the TCP/IP stack and is used in the Internet Layer. It is responsible for addressing, routing, and delivering data packets between devices across networks, including the internet.
The IP protocol performs three key functions:
Addressing – Assigns a unique IP address to each device on a network.
Packetization – Breaks data into smaller packets for transmission.
Routing – Determines the best path for packets to travel across networks.
Each packet contains the source IP address (sender’s address) and the destination IP address (receiver’s address) to ensure it reaches the correct device.
Every device connected to a network has an IP address, which is a unique numerical identifier used for communication. There are two main types of IP addresses:
Uses a 32-bit address format, written as four decimal numbers separated by dots (e.g., 192.168.1.1
).
Example:
CopyEdit
192.168.0.10 172.16.254.1 8.8.8.8
IPv4 allows for about 4.3 billion unique addresses, but this is not enough due to the rapid growth of internet-connected devices.
Uses a 128-bit address, written in hexadecimal and separated by colons (e.g., 2001:db8::ff00:42:8329
).
Example:
makefile
CopyEdit
2001:0db8:85a3:0000:0000:8a2e:0370:7334
Provides a much larger address space (trillions of unique IP addresses), solving the shortage of IPv4 addresses.
When data is sent over a network, it is divided into packets. Each IP packet has a header and a payload:
ComponentDescription | |
Header | Contains control information, such as source IP, destination IP, packet length, and time-to-live (TTL). |
Payload | Contains the actual data being transmitted. |
Source IP Address – Identifies the sender’s device.
Destination IP Address – Identifies the receiver’s device.
Packet Length – Defines the total packet size.
Time-To-Live (TTL) – Specifies how long a packet can stay in the network before being discarded.
Checksum – Ensures the packet is not corrupted.
IP uses routers to move packets from the sender to the receiver across multiple networks.
A router receives a packet and reads the destination IP address.
It looks at its routing table to find the best path to the destination.
The router forwards the packet to the next router or the destination device.
The process repeats until the packet reaches its final destination.
Routers play a crucial role in directing traffic efficiently across networks.
The IP protocol is connectionless, meaning:
✅ Packets are sent independently without establishing a connection first.
✅ Packets may take different routes to the destination.
✅ Packets may arrive out of order and must be reassembled at the destination.
Because IP does not guarantee reliable delivery, it is often used with TCP, which provides error checking and packet reordering.
❌ No built-in error checking – If packets are lost or corrupted, they are not automatically resent.
❌ No packet ordering – Packets may arrive out of order, requiring TCP for reassembly.
❌ Security concerns – IP addresses can be spoofed, leading to cyber attacks (e.g., DDoS attacks).
Feature Description | |
Layer | Internet Layer (TCP/IP Stack) |
Purpose | Addressing and routing packets |
Addressing | Uses IPv4 (32-bit) or IPv6 (128-bit) |
Connection Type | Connectionless (does not establish a connection) |
Reliability | No error checking or packet ordering |
Works with | TCP (for reliability) or UDP (for speed) |
IP is essential for identifying devices and routing data across the internet.
IPv6 is replacing IPv4 due to a shortage of available addresses.
Routers play a key role in directing IP packets to the correct destination.
Together with TCP or UDP, IP ensures that data is efficiently transmitted across networks.
Link Layer Protocol
The Ethernet protocol is a key standard used in wired networks to define how data is formatted, transmitted, and received within a local area network (LAN). It operates at the Link Layer (also known as the Network Interface Layer) of the TCP/IP stack and ensures that data is transmitted efficiently and reliably between devices connected via cables (e.g., twisted-pair, coaxial, or fiber optic cables).
Ethernet is responsible for:
✅ Defining communication rules for wired networks.
✅ Ensuring reliable data transfer within a LAN.
✅ Handling error detection in transmitted data.
✅ Identifying devices using MAC addresses.
Ethernet is the most common wired networking standard and is used in homes, schools, and businesses to connect devices like computers, routers, and switches.
Ethernet transmits data in the form of frames, which contain important information about the sender, receiver, and the actual data being sent.
Each Ethernet frame consists of several sections:
FieldDescription | |
Preamble | A sequence of bits that signals the start of a frame. |
Destination MAC Address | Identifies the receiving device. |
Source MAC Address | Identifies the sender’s device. |
Payload (Data) | The actual data being transmitted. |
FCS (Frame Check Sequence) | A checksum used to detect transmission errors. |
The sender creates an Ethernet frame containing the destination MAC address, source MAC address, and data.
The frame is sent over the network cable to the recipient.
Switches and routers direct the frame to the correct device.
The receiving device checks for errors using the FCS (Frame Check Sequence) and, if valid, processes the data.
Ethernet uses MAC addresses (Media Access Control addresses) to identify devices on a network.
A MAC address is a unique 48-bit identifier assigned to a network interface card (NIC).
MAC addresses are written in hexadecimal format, e.g., 00:1A:2B:3C:4D:5E
.
Ethernet delivers frames to specific MAC addresses instead of using IP addresses (which operate at a higher layer).
This makes Ethernet ideal for local communication within a LAN.
Before transmitting data, Ethernet ensures that devices avoid sending data at the same time, which could cause a collision (when two devices send data simultaneously).
In older Ethernet networks (using hubs), a method called CSMA/CD was used:
Devices listen to the network before transmitting.
If the network is busy, they wait.
If two devices transmit at the same time, a collision occurs.
Both devices stop sending and wait a random amount of time before retrying.
Modern Ethernet networks use switches instead of hubs, meaning:
✅ Devices transmit and receive data simultaneously (full-duplex).
✅ Collisions are eliminated since each device has a direct connection.
Ethernet works with different types of cables, depending on speed and distance requirements:
Cable TypeSpeedMax DistanceUsage | |||
Cat5 | Up to 100 Mbps | 100m | Basic networking |
Cat5e | Up to 1 Gbps | 100m | Home networks |
Cat6 | Up to 10 Gbps | 55m | High-speed LANs |
Fiber Optic | 100+ Gbps | Several km | Long-distance, fast data transfer |
Modern Ethernet networks mostly use Cat5e or Cat6 cables.
✅ Reliable – Uses error checking to detect corrupted data.
✅ Fast – Supports high data transfer speeds (1 Gbps and beyond).
✅ Secure – Harder to intercept than Wi-Fi since it requires physical access.
✅ Cost-effective – Ethernet cables and switches are affordable and widely available.
❌ Limited Mobility – Devices must be physically connected via cables.
❌ Installation Can Be Complex – Requires running cables through walls and floors.
❌ Expensive for Large Networks – Requires switches, routers, and extensive cabling.
FeatureDescription | |
Layer | Link Layer (TCP/IP Stack) |
Purpose | Wired communication within a LAN |
Uses | Ethernet frames and MAC addresses |
Error Checking | Frame Check Sequence (FCS) |
Collision Avoidance | Uses CSMA/CD (older) or switches (modern) |
Speed | 100 Mbps – 100 Gbps |
Cables | Cat5, Cat5e, Cat6, Fiber Optic |
Ethernet is the standard for wired LANs and provides fast, secure, and reliable communication.
It transmits data in frames and uses MAC addresses for delivery.
Modern networks use Ethernet switches to eliminate collisions and improve efficiency.
Ethernet remains widely used, even with the rise of Wi-Fi.