Final Comprehensive Network Programming Guide
50 Extensive Exam Questions & Answers
1. **Define a client-server system and provide an example.**
- A client-server system is a distributed computing model where clients request services, and servers
provide them.
- Example: A web browser (client) requesting a webpage from a web server.
2. **Explain the differences between TCP and UDP with examples.**
- TCP: Reliable, connection-oriented (e.g., web browsing).
- UDP: Unreliable, connectionless (e.g., video streaming).
3. **How does the TCP three-way handshake work? Explain each step.**
- SYN: Client sends connection request.
- SYN-ACK: Server acknowledges and responds.
- ACK: Client confirms, and connection is established.
4. **What are sockets and how are they used in network programming?**
- Sockets provide endpoints for sending/receiving data in network applications.
5. **What is the structure of an IPv4 socket address?**
```c
struct sockaddr_in {
short sin_family;
unsigned short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
```
6. **Explain the role of middleware in distributed systems.**
- Middleware provides communication between distributed applications, abstracting low-level network
details.
7. **What is RPC and why is it used in networking?**
- Remote Procedure Call (RPC) allows executing functions on remote machines as if they were local.
8. **How does a concurrent server handle multiple clients?**
- Uses threading, forking, or asynchronous I/O to manage multiple connections.
9. **What is the purpose of the select() function in socket programming?**
- Monitors multiple sockets to check which are ready for reading/writing.
10. **What are zombie processes and how do you prevent them?**
- Zombie processes occur when a child process exits but its parent does not read its exit status.
- Solution: Use `waitpid()` or handle `SIGCHLD`.
11. **Explain the role of DNS in networking.**
- DNS maps domain names to IP addresses.
12. **What is a proxy server and how does it work?**
- A proxy server acts as an intermediary between clients and the internet.
13. **How does a firewall impact network traffic?**
- A firewall filters network traffic to block unauthorized access.
14. **What is the difference between unicast, multicast, and broadcast?**
- Unicast: One-to-one communication.
- Multicast: One-to-many communication (selected receivers).
- Broadcast: One-to-all communication.
15. **Explain the concept of load balancing in network applications.**
- Load balancing distributes traffic across multiple servers to improve performance.
16. **How does SSL/TLS enhance network security?**
- Provides encryption and authentication for secure data transmission.
17. **What is NAT (Network Address Translation)?**
- NAT maps private IP addresses to public ones, allowing multiple devices to share a single IP.
18. **Explain the difference between IPv4 and IPv6.**
- IPv4: 32-bit addresses, supports ~4 billion devices.
- IPv6: 128-bit addresses, supports a virtually unlimited number of devices.
19. **What is a socket descriptor?**
- A file descriptor representing a network connection.
20. **How does TCP handle flow control?**
- Uses the sliding window protocol to regulate data transmission rates.
21. **Explain how connection termination occurs in TCP.**
- Uses the four-step FIN-ACK handshake.
22. **What is the significance of TIME_WAIT in TCP?**
- Ensures all packets have been received before closing the connection.
23. **How do you monitor active TCP connections using Linux commands?**
- Use `netstat -an | grep ESTABLISHED`.
24. **What are the key fields in a TCP header?**
- Source port, destination port, sequence number, acknowledgment number, flags.
25. **How does the select() function manage multiple connections?**
- Allows a program to monitor multiple sockets and detect activity.
26. **What is a network protocol stack?**
- A layered model (e.g., OSI, TCP/IP) defining network communication.
27. **How does the accept() function work in a server?**
- Blocks until a client connects, then returns a new socket for communication.
28. **What is a connection-oriented protocol?**
- A protocol that establishes a reliable connection before transmitting data (e.g., TCP).
29. **Explain the different TCP congestion control mechanisms.**
- Slow start, congestion avoidance, fast retransmit, fast recovery.
30. **What is the purpose of SO_REUSEADDR in socket programming?**
- Allows a socket to bind to a port that is in a TIME_WAIT state.
31. **What are the advantages of using multithreading in a server?**
- Improves performance by handling multiple clients concurrently.
32. **What is the purpose of the htons() function?**
- Converts a number to network byte order.
33. **How does a router function in a network?**
- Forwards packets between different networks.
34. **What is the role of an HTTP server?**
- Serves web pages to clients using the HTTP protocol.
35. **Explain the different layers of the OSI model.**
- Physical, Data Link, Network, Transport, Session, Presentation, Application.
36. **What are the benefits of using IPv6?**
- Larger address space, better security, simplified header.
37. **How does a TCP retransmission work?**
- If an acknowledgment is not received, TCP retransmits the lost packet.
38. **What is a SYN flood attack?**
- A Denial-of-Service attack that overwhelms a server with SYN requests.
39. **Explain the role of a DHCP server.**
- Automatically assigns IP addresses to network devices.
40. **What is a VPN and how does it enhance security?**
- A Virtual Private Network encrypts internet traffic, providing secure remote access.
41. **What is the difference between HTTP and HTTPS?**
- HTTPS encrypts data using SSL/TLS.
42. **How does ARP (Address Resolution Protocol) work?**
- Maps an IP address to a MAC address within a local network.
43. **What is ICMP used for in networking?**
- Sends error messages (e.g., used in ping).
44. **What is the main purpose of the TTL field in an IP packet?**
- Prevents packets from looping indefinitely.
45. **How does the traceroute command work?**
- Displays the path packets take to a destination.
46. **What is the function of a network switch?**
- Forwards data packets based on MAC addresses.
47. **How does DNS caching improve network performance?**
- Reduces lookup times by storing previously resolved domain names.
48. **What are the differences between a modem and a router?**
- A modem connects to the ISP, while a router distributes the connection to multiple devices.
49. **What is a subnet mask and why is it used?**
- Determines the network and host portions of an IP address.
50. **How does load balancing work with multiple servers?**
- Distributes client requests across servers to optimize performance.