<!doctype html public "-//w3c//dtd html 4.0 transitional//en">

CS 779/879
Design of Network Protocols
Spring 2003
Midterm Exam
Time 2 & 1/2 hours
Open Book & Notes

 

 

 

Name:                              
Login:

 

NOTE: In order to make the programs short, you may NOT write any include, comments or non-essential error statements, i.e., keep the programs as short as you can.

 


Question 1: (20 points)

 

Write a program that test each non-privileged tcp port X in the local host and display the message: “port X is busy” if the port is being used by another process.


Solution (Q1)


Question 2: (20  points)

Write a client program that test each tcp port X on any given non-local host and displays the message: “there is a tcp server running at port X” if it can connect to port X. The host is specified as a command-line argument and the program checks if the server is not running at the same host as the client program.

Solution (Q2)


Question 3: (20 points)

 

A.     Is it possible to redo Question 1 for udp instead of tcp?

YES                 NO

Explain:

 

 

 

 

 

 

 

 

 

 

 

 

 

B.     Is it possible to redo Question 2 for udp instead of tcp?

YES                 NO

Explain:

 

 

 

 


Question 4: (20 points)

 

Write a tcp Hello-World server at port 2222 that sends the message

“Hello-world”

to only those clients running at hosts in its own domain. Two hosts are considered to be in the same domain if they have the same network address. For the purpose of this question, the network address is the first two bytes of the ipv4 address.

 

Solution (Q4)


Question 5: (20 points)

 

Write a tcp Sleep server at port 2222 that creates a process for each client. The process sleeps N seconds and then closes the connection. N is the port number where the client is coming from.

 

Solution (Q5)