<!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)
Solution (Q2)
Question
3: (20 points)
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)