Overview of TCP/IP
TCP/IP (Transmission Control Protocol/Internet Protocol) is the fundamental communication protocol suite used on the internet and in most local area networks. It's a layered architecture that governs how data is transmitted across networks.
TCP/IP Layers
The TCP/IP model is divided into four layers:
- Application Layer: Handles user-facing applications (e.g., HTTP, SMTP, FTP).
- Transport Layer: Provides reliable data delivery (TCP) or connectionless delivery (UDP).
- Network Layer: Handles IP addressing and routing.
- Link Layer: Handles physical transmission of data over the network medium.
IP Addressing
IP addresses are unique numerical identifiers assigned to devices on a network. There are two main versions:
- IPv4: Uses 32-bit addresses (e.g., 192.168.1.1)
- IPv6: Uses 128-bit addresses (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334)
TCP Connection Establishment
The TCP connection establishment process involves a three-way handshake:
- SYN: The client sends a SYN (synchronize) packet to the server.
- SYN-ACK: The server responds with a SYN-ACK (synchronize-acknowledge) packet.
- ACK: The client sends an ACK (acknowledge) packet to confirm the connection.
// Client:
// 1. Send SYN packet
// 2. Receive SYN-ACK packet
// 3. Send ACK packet
// Server:
// 1. Receive SYN packet
// 2. Send SYN-ACK packet
// 3. Receive ACK packet
Data Transmission
TCP data transmission is based on segments, which are divided into smaller units for efficient routing. Each segment includes a header with control information and data. The application layer data is appended to the segment. The sender utilizes sequence numbers to ensure reliable delivery and receiver’s acknowledgment is crucial for the flow.