Network Programming Elective)

3

Click here to load reader

Transcript of Network Programming Elective)

Page 1: Network Programming Elective)

07CS661

USN

R. V. COLLEGE OF ENGINEERINGAutonomous Institution under VTU

VI Semester B. E. Examinations May/June-10Computer Science and Engineering

NETWORK PROGRAMMING (ELECTIVE)Time: 03 Hours Maximum Marks: 100Instructions to candidates:Answer any FIVE full choosing atleast 2 out of 4 questions from Part-A and Part-B

PART- A1 a How do you discover network topology? Explain with examples 06

b With a neat diagram explain the TCP connection establishment and termination

08

c A connection is established between a host on an Ethernet, whose TCP advertises an MSS of 1460 and a host on a token ring, whose TCP advertises an MSS of 4096. Neither host implements pata MTU discovery. Watching the packets, we never see more than 1460 bytes of data in either direction. Why?

06

2 a With a neat diagram, compare the different socket address structures

06

b Why must value-result arguments such as the length of a socket address structure be passed by reference? Explain with an example

06

c What is byte ordering? Explain the following function(i) htons ( ) (ii) htonl ( ) (iii) ntohs ( ) (iv) ntohl ( )

08

3 a Explain the socket functions for elementary TCP client/server with a neat diagram

06

b 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 ( ) functioin in the following codepid_ t pid;9nt listenfd, connfd ;listenfd = socket ( . . .) ;bind (listenfd. . . .) ;listen (listenfd, LISTENФ);for ( ; ; ) {connfd= accept (listenfd, . . .) ;if ( ( pid=fork ( ) ) = = 0 ){ close (listenfd); doit (connfd) ; close (connfd);

Page 2: Network Programming Elective)

exit (0) :} close (connfd) ; // parent}

c Write a C program to implement the TCP echo server 08

4 a What is fcntl function? Explain the features provided by fcntl with respect to network programming

06

b Assume two TCP clients start at about the same time. Both set the SO__REUSEADDR socket option and then call bind with the same local IP address and the same local port say ( 1500).But one client connects to 19.69.10.2 port 7000 and the second connects to 198.69.10.2 ( same peer IP address) but port 8000. Describe the race condition that occurs

08

c There are two applications, one using TCP and other using UDP9

4096 bytes are in the receive buffer for the TCP socket and 2048 byte datagrams are in the receive buffer for the UDP socket. The TCP application calls read with a third argument of 4096 and the UDP application calls recv from with a third argument of 4096. Is there any difference explain

06

PART- B

5 a Describe DNS with resource records 06b Write a C program that calls gethostbyname for any number of

command-line arguments and prints all the returned information 08

6 a What is dual stack host? Explain with a neat diagram 10b Explain the different ways to start a daemon 10

7 a What are the two ways of passing an open descriptor from one process to another? Explain the steps involved in passing a descriptor between two processes

08

b What happens if a unix domain server calls unlink after calling bind? 04c What is resource discovery? Explain 4 internet applications that use

broadcasting for this purpose08

8 a What is a race condition? Explain 04b Differentiate between thread and fork 06c Write a C program to implement TCP echo server using threads 10