The assignment is due Monday, March 2, 4 pm EDT, to be submitted via CourseWorks.
Some of the questions below are research questions, where you are asked to find information about a particular issue. You may use the Engineering Library, any text books you have, one of the paper from the class readings, or the web to come up with answers. Be sure to cite your sources. Generally, a paragraph or two should be sufficient to answer the question. There is no need to write a tutorial.
Programming problem: This is the first part of the semester project of building a video application, although you'll only re-use parts of this project later. The goal of this programming assignment is to (re)-acquaint you with basic unicast socket programming and timer handling, which you will need for the following projects.
Build a "ping-pong" application that uses threads,
select()
or poll()
to receive UDP packets sent
to port 5000. Upon receiving the packet, your application should return
it to the sender, after waiting for 800 ms. The packet contains a JSON
structure consisting of a counter and a timestamp (date and time). The
counter is incremented on each transmission, e.g., a node that receives
a packet with counter value 17 would return one with counter 18.
You can use any port number you like, but 5000 is recommended.
The cycle repeats, so that an observer would see packets echoing back and forth between the two systems.
To get things started automatically, each system should start a timer when waiting for a packet. The timer value should be chosen randomly, i.e., differently for each invocation of your client, and range between 2 and 5 seconds. If there is no packet within that interval, the client initiates the ping-pong. There is a slight chance that both sides will start transmiting, but this should be rare.
Each side should print out the counter (sequence number) in the JSON packet payload and the timestamp when the packet was received as well as when the answer was sent.
The destination address for the packets is specified as a commandline argument -d, as in
(berlin)$ pingpong -d chicago.cs.columbia.edu (chicago)$ pingpong -d berlin.cs.columbia.edu
if you want the two machines, berlin and chicago, to play ping-poing with each other.
The application can be written in C, C++, C#, Python or Java. You may choose either Linux or MacOS. The programming style guidelines apply.
You should also capture the exchange for about 10 packets, including the start-up, using Ethereal or tcpdump. Include the dump, as a text file or dump file, with your assignment. See for advice on capturing packets.