Network

TCP Retransmission
- Timeout Retransmission: A timer is set, which should be slightly longer than the Round-Trip Time (RTT). If the timer expires before an ACK is received, the segment is immediately retransmitted.
- Fast Retransmission: When three consecutive duplicate ACKs are received, the segment is retransmitted immediately.
- SACK (Selective Acknowledgment): The receiver can inform the sender which segments have been received and which are missing.
- DSACK (Duplicate SACK): If the receiver gets two identical segments (e.g., two 2s), it uses DSACK to inform the sender that it has received duplicates, preventing unnecessary retransmissions due to network latency.
TCP Flow Control
Slow Start
When transmission begins, the sender doubles its congestion window for each ACK received (exponential growth). The initial window size is 1.
Congestion Avoidance
When the window size reaches a threshold (ssthresh), the growth changes from exponential to linear (window size +1 per round trip).
- If a timeout retransmission occurs, the threshold is set to half of the current window size, and the window size is reset to 1, initiating a slow start.
- If a fast retransmission occurs, both the threshold and the window size are set to half of the current window size, entering the fast recovery phase, where the window size grows linearly.
OSI Seven-Layer Model
1. Application Layer:
- HTTP, with the transmission unit being a message.
- FTP for file transfer.
- SMTP for email.
2. Presentation Layer:
- Handles encoding/decoding and encryption/decryption.
3. Session Layer:
- Manages login status and is responsible for synchronization.
4. Transport Layer:
- TCP/UDP.
- Adds a port (source and destination port numbers) to the message, encapsulating it into a segment.
- Upon reception, TCP reassembles the byte stream into segments and forwards the messages to different ports based on the port number.
5. Network Layer:
- Adds the source and destination IP addresses to the segment, encapsulating it into a packet.
- In IPv4, the first 24 bits represent the subnet, and the last 8 bits represent the device ID.
- Its function is to route packets from one router to another and to plan the packet’s transfer path using routing algorithms.
6. Data Link Layer:
- Adds the client and destination MAC addresses to the packet, encapsulating it into a frame. The MAC address is the network card address.
- If on the same subnet, it sends an ARP request to all devices on the subnet, asking for the device with a specific IP. The target device responds with its MAC address.
7. Physical Layer:
- Transmits bitstreams of 0s and 1s.
HTTP 1.0, 1.1, 2.0
- HTTP 1.0:
- Requires a three-way handshake and a four-way handshake for each request.
- HTTP 1.1:
- Supports persistent connections, allowing multiple requests to be sent over the same connection.
- HTTP 2.0:
- Multiplexing: A single connection can handle multiple requests simultaneously.
- HPACK Algorithm: The server maintains an HPACK table that stores request headers from the client.
- Binary Format: Faster data transmission.
HTTP Request Message
- Request Line:
- GET/POST
- HTTP version
- URL
- Request Headers:
User-AgentHost: www.test.edu.cnCookie: 123456Accept: image/jpegAccept-Encoding: gzip, deflate(indicates which compression methods are supported)Content-Type:(if there is a request body)Content-Length: 112(if there is a request body)Connection: Keep-alive
- Request Body: The request body is empty for GET methods but present for POST and PUT methods.