Client/Server Architecture, Protocol Suites & Network Utilities
Idea in plain words
Client-server model: The server is a passive entity that opens a port and waits for requests; the client is an active entity that initiates communication.
Exam tip
High-yield exam topic (Very High).
Explanation
Network programming under Unix/Linux systems relies on the BSD Socket API as the standard abstraction for inter-process communication (IPC) across IP networks. In client/server paradigms, servers are classified into iterative (handling one client transaction to completion before accepting another) and concurrent (spawning child processes or worker threads per client). Application protocols operate atop the TCP/IP stack where the 16-bit port number (0-65535) identifies specific host processes (Well-known: 0-1023, Registered: 1024-49151, Dynamic/Private: 49152-65535). POSIX socket wrappers ensure uniform error diagnostics by interrogating errno upon system call failure (-1).
Key points
- OSI vs TCP/IP: TCP/IP combines OSI Session and Presentation layers into the Application layer, prioritizing pragmatic internetworking over rigid modularity.
- Unix Standards: POSIX.1g establishes API standardization for networking; Open Group Single UNIX Specification guarantees cross-platform socket portability.
- Essential Network Utilities: netstat (active connections & routing tables), ifconfig/ip (interface configuration), ping (ICMP echo round-trip time), traceroute (TTL expiration probing).
- Wrapper functions: Robust network programming wraps system calls with error-checking wrappers (e.g., Socket(), Bind()) to terminate or log cleanly on failure.
Example
Example
Common Unix utilities: 'netstat -tuln' displays listening TCP/UDP sockets without DNS reverse lookups. 'traceroute host' sends UDP/ICMP packets with increasing TTL (1, 2, 3...) to discover each router hop via ICMP Time Exceeded messages.
Code examples
// Robust Socket Wrapper Function Pattern in C
int Socket(int family, int type, int protocol) {
int n;
if ((n = socket(family, type, protocol)) < 0) {
perror("socket error");
exit(EXIT_FAILURE);
}
return n;
}
Exam questions
- [8 Marks] Differentiate between iterative and concurrent servers with architectural diagrams and suitable application examples.
- [7 Marks] Explain the role of wrapper functions in network programming. Describe how netstat, ping, and traceroute operate under Unix.