TCP Header
TCP (Transmission Control Protocol) is a reliable transport protocol as it establishes a connection before sending any data and everything that it sends is acknowledged by the receiver.
- Source port: this is a 16-bit field that specifies the port number of the sender.
- Destination port: this is a 16-bit field that specifies the port number of the receiver.
- Sequence number: the sequence number is a 32-bit field that indicates how much data is sent during the TCP session...
- Acknowledgment number: this 32-bit field is used by the receiver to request the next TCP segment...
- DO: this is the 4-bit data offset field, also known as the header length...
- RSV: these are 3 bits for the reserved field...
- Flags: there are 9 bits for flags, also called control bits...
- Window: the 16-bit window field specifies how many bytes the receiver is willing to receive...
- Checksum: 16 bits are used for a checksum to check if the TCP header is OK or not.
- Urgent pointer: these 16 bits are used when the URG bit has been set...
- Options: this field is optional and can be anywhere between 0 and 320 bits.
TCP Architecture
TCP (Transmission Control Protocol) is a core protocol of the Internet Protocol Suite (commonly known as TCP/IP). It's responsible for establishing and maintaining a reliable connection between two network devices...
- Connection Establishment (Three-Way Handshake): The client initiates a connection by sending a SYN packet...
- Data Transfer: Once the connection is established, data can be transferred between the client and server...
- Reliability and Error Checking: TCP provides reliable data delivery by using acknowledgments and retransmissions...
- Flow Control: TCP uses a mechanism called flow control to prevent the sender from overwhelming the receiver...
- Congestion Control: TCP also implements congestion control to avoid network congestion...
- Connection Termination (Four-Way Handshake): When the data transfer is complete, the client initiates the connection termination...
- TCP Header: The TCP header contains various fields, including source and destination port numbers...
TCP/IP Model
The TCP/IP model, also known as the Internet Protocol Suite, is a conceptual model used to understand and describe how data is transmitted over a network...
- Application Layer: The Application Layer is the top layer of the TCP/IP model and is closest to the end user...
- Transport Layer: The Transport Layer is responsible for end-to-end communication between the sender and receiver...
- Internet Layer: The Internet Layer is responsible for addressing, routing, and packaging data for transmission...
- Link Layer (or Network Access Layer): The Link Layer is responsible for the physical transmission of data...
TCP Three-Way Handshake
The TCP three-way handshake is the process used to establish a reliable connection between a client and a server.
- Step 1: SYN (Synchronize)
- The client initiates a connection by sending a SYN packet to the server.
- This packet contains an initial sequence number (ISN), which is a randomly chosen number.
- Step 2: SYN-ACK (Synchronize-Acknowledge)
- The server responds with a SYN-ACK packet.
- The server also selects its own sequence number and acknowledges the client's ISN by incrementing it by one.
- Step 3: ACK (Acknowledge)
- The client sends an ACK packet back to the server, confirming receipt of the server’s SYN-ACK.
- At this point, the connection is established, and data transfer can begin.
This process ensures that both the client and server are synchronized before data is exchanged.