Course No. : IS ZC462 Course Title : NETWORK PROGRAMMING Nature of Exam : Open Book Weightage : 60% Duration : 3 Hours Date of Exam : 29/09/2007 (FN) Note: 1. Please follow all the Instructions to Candidates given on the cover page of the answer book. 2. All parts of a question should be answered consecutively. Each answer should start from a fresh page. 3. Mobile phones and computers of any kind should not be brought inside the examination hall. 4. Use of any unfair means will result in severe disciplinary action.
Q.1 Consider the following code : int y; main() { int status, pid=fork(); y = 5; if ( !pid) setY(); else { wait(&status); printf("y = %d\n",y); } } void setY() { y = 10; } (a) What is the output of the above code? (b) What does the wait (&status) statement do in the above code? (c) Consider a TCP server, what exactly does the kernel do when the server calls the following functions?
(i) listen (ii) connect [2 + 2 + 4 = 8]
Q.2 (a). Can we have an address such as y.x.z.t/27? Explain with suitable example. Q.2 (b). In DNS system how recursive resolution differ from iterative resolution? Explain with suitable diagram. Q.2 (c). How does the DNS handle the response of a query message if resolver does not know the size of the response message? [3 + 4 + 4 = 11]
Page 1 of 2 No. of Pages = 2 No. of Questions = 6 IS ZC462 (EC-2 REGULAR) FIRST SEMESTER 2007-2008 PAGE 2
Q.3 (a). A router with an IP address 108.5.18.22 sends a direct broadcast packet to all hosts in this network .What are source and destination IP address used in this packet? Q.3 (b). Consider the socket related system calls: socket, connect, bind, accept, fork, close, read. Differentiate them into slow and fast system calls, and tell why briefly. Assume the I/O model is blocking mode. Q.3 (c). What effects does the SO_LINGER socket option have over clients close? [3 + 7 + 3 = 13]
Q.4 (a). In a concurrent server, assume the child runs first after the call to fork. The child then completes the service of the client before the call to fork returns to the parent. What happens in the two calls to Close in the concurrent server? Q.4 (b). Consider an iterative server design for a TCP service. While your server is processing a client request, what happens to other clients trying to send a request to the server at the same time? Q.4 (c). There are many issues being needed to be handled by a server. Consider a server that forks child processes to serve clients. To handle SIGCHLD signals, avoid zombie processes, and resume interrupted system calls, what need to be added into the server program, respectively? [3 + 3 + 6 = 12]
Q.5 Write a program that contains two processes such that two processes displays characters 8 and 9. Synchronize the processes so that they display only one character at a time and after that wait for another process. It means that the output displayed on the standard output must look like 89898989 . . . . . . so on. Use appropriate signals so that synchronization must work perfectly such that your programs run infinitely without a deadlock and the characters 8 and 9 always follow each other in the output. You are not allowed to use any global variables or delays in the program. Your program will terminate only if user ask for it. [6]
Q.6 Write a concurrent server program to facilitate a calculation service using unix domain stream protocol family. Your server must work as follows: After establishment of connection, client sends the users credential to the server. Clients also send a mathematical equation to the server. And server returns the result once it has been calculated in a single string containing the equation and its result. Server displays the received credential information of client. In your server code also add some functionality so that it can deny the calculation service access to some client having a particular user id or group id taken from the command line argument. You need to write only the server program. [10]