1.What is the difference between a process and a thread?
- Process: The basic unit for resource allocation in an OS, with independent memory space and system resources.
- Thread: The basic unit for CPU scheduling, belongs to a process, shares the process’s memory and resources, but has its own stack and registers.
- Differences:
- Inter-process communication (IPC) is complex; inter-thread communication is simple (shared memory).
- Thread switching has lower overhead than process switching.
- Multithreading suits I/O-intensive tasks; multiprocessing suits CPU-intensive tasks.(待研究)
- What is the difference between TCP and UDP?
- TCP:
- Connection-oriented, reliable transmission.
- Provides flow control, congestion control, and sequence guarantee.
- Suitable for file transfers, HTTP, etc., where reliability is critical.
- UDP:
- Connectionless, unreliable.
- Low overhead, fast.
- Suitable for video streaming, DNS queries, where real-time performance is prioritized.
- What is the TCP three-way handshake? Why is it necessary?
- Process:
- Client sends SYN (seq=x).
- Server responds with SYN+ACK (seq=y, ack=x+1).
- Client sends ACK (ack=y+1).
- Reason:
- Ensures both sides can send and receive data (bidirectional confirmation).
- Prevents interference from old connections (using sequence numbers).
- Initializes sequence numbers for synchronized communication.
- What is the TCP four-way wave?
- Process:
- Active party sends FIN (indicating it stops sending data).
- Passive party responds with ACK (acknowledging FIN).
- Passive party sends FIN (indicating it also stops).
- Active party responds with ACK (confirming closure).
- Note:
- Passive party may have unsent data, so closure is split into two steps.
- TIME_WAIT ensures the final ACK is received, avoiding connection issues.
- What is the difference between HTTP and HTTPS?
- HTTP:
- Plaintext transmission, port 80.
- No encryption, vulnerable to eavesdropping or tampering.
- HTTPS:
- HTTP+SSL/TLS, port 443.
- Provides encryption, authentication, and data integrity.
- Requires certificates, adds handshake overhead.
- What is the DNS resolution process?
- Process:
- Local query: Check browser cache, system hosts file.
- Query local DNS server (recursive resolver).
- Local DNS queries root server for top-level domain server address.
- Query top-level domain server (e.g., .com) for authoritative server address.
- Query authoritative server for target IP.
- Return result to client, cache for faster future queries.
- Types: Recursive query (client to local DNS), iterative query (local DNS to root/authoritative servers).
- What is the ARP protocol? How does it work?
- Definition: Address Resolution Protocol, maps IP addresses to MAC addresses.
- Working Principle:
- Sender broadcasts ARP request with target IP.
- Target host responds with ARP reply containing its MAC address.
- Sender caches IP-MAC mapping for future communication.
- Scenario: Used in LANs, where the link layer requires MAC addresses.
- What is congestion control? How does TCP implement it?
- Definition: Prevents network overload by controlling sending rates.
- TCP Implementation:
- Slow Start: Exponentially increases sending window to probe network capacity.
- Congestion Avoidance: Linearly increases window to avoid rapid growth.
- Fast Retransmit: Retransmits lost packet immediately after 3 duplicate ACKs.
- Fast Recovery: Reduces window but avoids slow start.
- Algorithms: Reno, Cubic, etc.