Here's a comprehensive overview of TCP (Transmission Control Protocol) that should help you prepare for your midterm:
What is TCP?
TCP is a transport-layer protocol that ensures reliable, error-checked, and sequential delivery of data between devices over IP networks. It's a connection-oriented protocol, which means that a connection is established between the sender and receiver before data is sent.
Key Features of TCP:
- Connection-Oriented: TCP establishes a connection between the sender and receiver before data is sent. This connection is maintained throughout the duration of the communication.
- Reliable: TCP ensures that data is delivered reliably, without errors, duplication, or loss.
- Error-Checked: TCP performs error-checking on data to detect any corruption or errors during transmission.
- Sequential Delivery: TCP ensures that data is delivered in the correct order, even if packets are received out of order.
- Flow Control: TCP regulates the amount of data that can be sent at one time, preventing network congestion.
TCP Header:
The TCP header is a 20-byte structure that contains the following fields:
- Source Port: The port number of the sender.
- Destination Port: The port number of the receiver.
- Sequence Number: The sequence number of the first byte of data in the segment.
- Acknowledgment Number: The sequence number of the next byte of data expected by the receiver.
- Data Offset: The offset of the data in the segment.
- Reserved: Reserved for future use.
- Flags: Control flags, such as SYN, FIN, ACK, and RST.
- Window: The size of the receive window.
- Checksum: A checksum of the header and data.
- Urgent Pointer: A pointer to urgent data.
TCP Connection Establishment:
The TCP connection establishment process involves the following steps:
- SYN (Synchronize) Packet: The sender sends a SYN packet to the receiver to initiate the connection.
- SYN-ACK (Synchronize-Acknowledgment) Packet: The receiver responds with a SYN-ACK packet, acknowledging the sender's SYN packet and sending its own SYN packet.
- ACK (Acknowledgment) Packet: The sender responds with an ACK packet, acknowledging the receiver's SYN packet and completing the connection establishment.
TCP Connection Termination:
The TCP connection termination process involves the following steps:
- FIN (Finish) Packet: The sender sends a FIN packet to the receiver to initiate the connection termination.
- ACK Packet: The receiver responds with an ACK packet, acknowledging the sender's FIN packet.
- FIN Packet: The receiver sends a FIN packet to the sender, indicating that it has finished sending data.
- ACK Packet: The sender responds with an ACK packet, acknowledging the receiver's FIN packet and completing the connection termination.
TCP Congestion Control:
TCP congestion control is a mechanism that prevents network congestion by regulating the amount of data that can be sent at one time. The following algorithms are used:
- Slow Start: The sender starts with a small window size and gradually increases it as packets are acknowledged.
- Congestion Avoidance: The sender maintains a stable window size to prevent network congestion.
- Fast Retransmit: The sender retransmits lost packets quickly to minimize delay.
Common TCP Ports:
Some common TCP ports include:
- HTTP (80): Used for web browsing.
- FTP (21): Used for file transfer.
- SSH (22): Used for secure remote access.
- SMTP (25): Used for email transmission.
- Telnet (23): Used for remote access.
I hope this comprehensive overview of TCP helps you prepare for your midterm!