0% found this document useful (0 votes)
15 views4 pages

Network Programming Exam Guide

The document is a comprehensive guide for a network programming exam, providing detailed answers to various questions related to client-server systems, TCP and UDP protocols, socket programming, and networking concepts. It covers topics such as the TCP three-way handshake, socket functions, remote procedure calls (RPC), and the role of firewalls. Additionally, it includes extensive exam questions for further study and understanding of network programming principles.

Uploaded by

joshuaonyango372
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Network Programming Exam Guide

The document is a comprehensive guide for a network programming exam, providing detailed answers to various questions related to client-server systems, TCP and UDP protocols, socket programming, and networking concepts. It covers topics such as the TCP three-way handshake, socket functions, remote procedure calls (RPC), and the role of firewalls. Additionally, it includes extensive exam questions for further study and understanding of network programming principles.

Uploaded by

joshuaonyango372
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Comprehensive Network Programming Exam Guide

Full Answers to Exam Questions

1. **Explain what you understand by client-server systems.** [2 marks]


- The client-server model is a distributed computing architecture where clients request services,
and servers provide them. Clients initiate communication while servers wait for requests.
- Example: A web browser (client) requests a webpage from a web server.

2. **Role of Client and Server in Coursework Portal Access** [4 marks]


- Client: The student's device sends a request to access coursework marks.
- Server: The university's server processes the request and returns the marks.

3. **How is a TCP connection established? (Three-Way Handshake)** [2 marks]


- Step 1: SYN - Client sends a connection request to the server.
- Step 2: SYN-ACK - Server acknowledges and responds.
- Step 3: ACK - Client confirms, establishing the connection.

4. **Explain the significance of using a value-result argument.** [2 marks]


- Value-result arguments allow a function to return multiple values, ensuring flexibility.

5. **Why is the socket address size passed as a value-result argument in accept()?** [2 marks]
- This allows the kernel to update the actual address length of the connected client dynamically.

6. **What type of socket is created by the accept() function?** [2 marks]


- A new, fully connected TCP socket, which can send and receive data, distinct from the listening socket.

7. **Differentiate between TCP and UDP.** [4 marks]


- TCP: Connection-oriented, reliable, ensures data delivery.
- UDP: Connectionless, faster but unreliable.

8. **Big-endian vs Little-endian Byte Ordering (Diagram Required).** [3 marks]


- Big-endian: Stores the most significant byte first (used in networking).
- Little-endian: Stores the least significant byte first (used in x86 architectures).

9. **Purpose of ntohs(), htons(), ntohl(), and htonl() in Networking.** [4 marks]


- These functions convert between host byte order and network byte order for proper communication.
10. **Address Conversion Functions in IPv4 and IPv6.** [4 marks]
- inet_pton(): Converts presentation format (text) to binary form.
- inet_ntop(): Converts binary form to presentation format.

11. **Explain fork() and exec() in TCP Sockets.** [4 marks]


- fork(): Creates a new process (used for concurrent servers).
- exec(): Replaces a process image with a new program.

12. **What is RPC and why is it needed in networking?** [2 marks]


- Remote Procedure Call (RPC) allows execution of procedures on remote systems, simplifying distributed
applications.

13. **Explain the purpose of marshaling in RPC.** [2 marks]


- Marshaling converts function parameters into a format suitable for network transmission.

14. **Write the IPv4 Socket Address Structure.** [3 marks]


```c
struct sockaddr_in {
short sin_family; // Address family (AF_INET)
unsigned short sin_port; // Port number
struct in_addr sin_addr; // IP address
char sin_zero[8]; // Padding
};
```

15. **Explain the socket functions with code snippets.** [12 marks]
- **socket()** - Creates a socket.
```c
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
```
- **bind()** - Binds the socket to an address.
```c
bind(sockfd, (struct sockaddr*)&server_addr, sizeof(server_addr));
```
- **listen()** - Puts the server in listening mode.
```c
listen(sockfd, 5);
```
- **accept()** - Accepts incoming client connections.
```c
int client_sock = accept(sockfd, (struct sockaddr*)&client_addr, &client_len);
```

16. **Using netstat to Monitor TCP Connections.** [3 marks]


- Run:
```sh
netstat -an | grep 8080
```
- This displays active TCP connections.

17. **How do TCP and UDP handle data transmission differently?** [4 marks]
- TCP: Uses acknowledgments and retransmission to ensure reliability.
- UDP: Sends packets without waiting for acknowledgments.

18. **Explain the differences between active and passive sockets.** [3 marks]
- Active Socket: Initiates connections (e.g., client sockets).
- Passive Socket: Waits for incoming connections (e.g., server sockets).

19. **How does congestion control work in TCP?** [4 marks]


- TCP uses slow start, congestion avoidance, and retransmission timers to manage congestion.

20. **How do firewalls affect network programming?** [3 marks]


- Firewalls block unauthorized network traffic, requiring proper configurations for network applications.

50 Extensive Exam Questions & Answers

1. Define a client-server system and provide an example.


2. Explain the differences between TCP and UDP with examples.
3. How does the TCP three-way handshake work? Explain each step.
4. What are sockets and how are they used in network programming?
5. What is the structure of an IPv4 socket address?
6. Explain the role of middleware in distributed systems.
7. What is RPC and why is it used in networking?
8. How does a concurrent server handle multiple clients?
9. What is the purpose of the select() function in socket programming?
10. What are zombie processes and how do you prevent them?
11. Explain the role of DNS in networking.
12. What is a proxy server and how does it work?
13. How does a firewall impact network traffic?
14. What is the difference between unicast, multicast, and broadcast?
15. Explain the concept of load balancing in network applications.
16. How does SSL/TLS enhance network security?
17. What is NAT (Network Address Translation)?
18. Explain the difference between IPv4 and IPv6.
19. What is a socket descriptor?
20. How does TCP handle flow control?
21. Explain how connection termination occurs in TCP.
22. What is the significance of TIME_WAIT in TCP?
23. How do you monitor active TCP connections using Linux commands?
24. What are the key fields in a TCP header?
25. How does the select() function manage multiple connections?
26. What is a network protocol stack?
27. How does the accept() function work in a server?
28. What is a connection-oriented protocol?
29. Explain the different TCP congestion control mechanisms.
30. What is the purpose of SO_REUSEADDR in socket programming?
31. What are the advantages of using multithreading in a server?
32. What is the purpose of the htons() function?
33. How does a router function in a network?
34. What is the role of an HTTP server?
35. Explain the different layers of the OSI model.

Common questions

Powered by AI

The accept() function is used by a server to accept incoming client connections on a listening socket. When a client attempts to connect, accept() completes the TCP handshake, creating and returning a new, fully connected TCP socket specifically for communication with the client. This separate socket allows the server to handle multiple clients by distinguishing communication channels .

Firewalls affect network programming by blocking unauthorized network traffic, which means that applications must be properly configured to communicate through firewalls. This includes defining rules that specify allowed traffic, potentially restricting application functionality or requiring modifications for compliance . For developers, this means considering firewall settings during application development to ensure seamless network communication and security.

The select() function allows a server to monitor multiple file descriptors to see if any have become ready for reading, writing, or if an error has occurred. This non-blocking approach enables the server to efficiently manage multiple connections by attending only to those ready for I/O operations, thus improving resource utilization and responsiveness in handling concurrent client requests .

The client-server model facilitates interactions by allowing web browsers (clients) to request specific services, such as web pages, from web servers (servers). The client initiates communication by sending a request for a webpage, and the server responds by providing the requested data . This architecture supports distributed computing by clearly delineating the roles of clients and servers.

Active sockets are used by clients to initiate connections, like a user's web browser connecting to a web server. Passive sockets, on the other hand, are used by servers to listen for incoming connections, such as a mail server waiting for clients to fetch emails. This distinction allows networked applications to manage different connection phases and roles, ensuring organized communication .

RPC plays a critical role by allowing programs to execute procedures on remote systems as if they were local, abstracting the complexity of network communication. This is achieved by using marshaling to format data for network transmission. By simplifying the interface and handling network details behind the scenes, RPC facilitates the development of distributed applications, enabling seamless integration of components located on different network nodes .

The TCP three-way handshake consists of three steps: 1) The client sends a SYN (synchronize) packet to initiate a connection to the server, 2) The server responds with a SYN-ACK (synchronize-acknowledge) to confirm receipt and willingness to establish a connection, and 3) The client sends an ACK (acknowledge) to the server, confirming the connection is established. This sequence ensures that both parties are ready to exchange data and establishes connection parameters .

TCP handles flow control using a mechanism called the sliding window protocol, where it adjusts the rate of data transmission based on the receiver's buffer capacity. This prevents data overflow at the receiver's end and ensures efficient use of network resources. By allowing the receiver to adjust the window size dynamically, TCP can adapt to changing network conditions, preventing congestion and maintaining data integrity .

Endianness affects how data is interpreted across systems with differing byte orders. Networking commonly uses big-endian order, whereas many architectures use little-endian. Conversion functions like htons() and ntohl() ensure data is correctly interpreted by converting it between the host byte order and network byte order, facilitating accurate and consistent communication between diverse systems .

TCP is a connection-oriented protocol ensuring reliable data transmission through acknowledgments and retransmissions. Applications like web browsers and email rely on TCP for its reliability. Conversely, UDP is connectionless, providing faster data transmission but without guarantees of delivery, making it suitable for applications like video streaming and online gaming where speed is prioritized over reliability .

You might also like