Spring
2000
Prof.
Arthur P. Goldberg, Computer Science Department
Write a program that solves Comer 7.11 and 7.12. This assignment is worth 10 points and due on 3/7.
Write a modified UDPecho.c that creates and sends a new request to the server at one second intervals, verifies that each reply matches a request, and reports the round trip time (rtt) in milliseconds for each reply (without printing the message contents). The program should handle situations when the network duplicates, loses, or reorders either requests or responses.
Make the following assumptions:
· The network duplicates and drops packets.
· The network or server can corrupt the contents of a packet.
· The network and the echo server can delay a packet significantly more than one second.
· Read one line from stdin or the command line for message content.
· Send each request exactly one second after the previous request.
· Discard and report corrupted responses.
· Measure the rtt for the first successful response, if any, to each request. Measure the rtt in milliseconds from before the request’s write until after the response’s read.
· Report duplicated responses.
· Eventually the client needs to decide that a request will not receive a reply. One implementation approach defines a delay constant maximum_delay_plus_rtt, at least 10 seconds. If a reply takes longer than maximum_delay_plus_rtt, assume it was dropped or corrupted.
With respect to termination, either
· 1. take an argument which inputs the number of messages it should send, or
· 2. runs indefinitely, and will be terminated by a kill (cntl-C on Unix).
· In either case, print summary statistics before exiting.
Source code.
Example test output which demonstrates the specified functionality.
You may write in any commonly used programming language you wish and run it on any machine you wish. We will provide a UDP echo server which duplicates, loses, or reorders either requests or responses.
Several different approaches can be used to concurrently send a new request at one second intervals and make timing measurements
Use select to delay until the earlier of the next send or the next read. The trick is to set the time-out to the delay needed until the next send.
One thread sends messages in a loop with a one second interval between sends. The other thread reads messages and measures round trip delay.
A master thread (or process) creates a new thread (or process) every second to handle each message.
Set SIGNAL or alarm every second and send a message in the SIGNAL handler.
The client should avoid these errors:
· Deadlock.
· Busy-wait or infinite memory use.