The usual note:
- Start early. Start often.
- 11-28-2001:
Only few students signed up for today's demonstration. So we will extend the session after today's class. Just come by and we will wait for you (till 8 PM). And there is a change on tomorrow's schedule. The session for tomorrow afternoon 2~3 PM will be shortened to 2~2:30 PM to accomandate dept's seminar. Extra sessions will be held from 3:30~6 PM.
When you come by for demo, please bring a copy of your report. Sorry for the last minute announcement.- 11-27-2001:
OK. Finally. The command for submission is ready. Check here for detail.- 11-26-2001:
Whoops! It seems I missed out something over the weekend.OK. Now, the new stuff. Sign-up sheets for demonstration are ready outside 591 PGH. The available time slots are Wed., Nov. 28, 1~4 PM and 5:30 ~ 6:30 PM, and Thur., Nov. 29, 1~3 PM. If you can't come either days/time, send us an e-mail to arrange different time slot.
- If you haven't put empty message in your program, you can use "z4 z4" or just leave it blank.
- I have produced a very long ABC file (GreigMorning_repeat12.abc) with about 290 packets. Each packet is pretty short.
- The submit script is not ready. I have asked TA to get this done ASAP. Will post instruction late. Sorry for the inconvenience.
- 11-20-2001:
There is another program structure for sender you could consider. The psuedo program structure announced previously (11-08-2001) has a problem. If there is a message sent from receiver while sender is sleeping. That message might be lost. So instead of sleeping after checking next-expired-time, you can keep running "select - recieve - send_missing_packet". For example,Loop 1 ... send packets [1] ... Loop 2 if gettimeofday() not expired select() if received message (NAK) re-send missing packets endif else break loop 2 endif End Loop 2 End Loop 1Please note in "send packets [1]" that you can send one or more packets at a time and then check if there a message from receiver. Or alternate "send packets" and "select-receive". This is implementation decision.- 11-19-2001:
Here is late assignment policy. 10% penality each day till midnight, Friday, Nov. 30.- 11-13-2001:
As far as I know, there is no select() in standard JDK libraries. One guy in Berkeley implements NBIO (Nonblocking I/O for Java) which includes select(). This library is for JDK on UNIX only.
There is another option. I was told you can set timeout to receiving function (not confirmed).- 11-12-2001:
Here are the sample programs for using datagram select and corresponding sender program with random sending delay -- receiver_select.c and sender_random.c.
Plus two long sample ABC files -- bach_air.abc and bach_suite_no_1_1.abc. The maximum size for each segment will be less than 120 Bytes.
For your report, showsome measurements of lost packets with different sending rates and window sizes.- 11-08-2001:
In case you missed it, here is the spec/hints mentioned in Wed's class.
- Assume receiver's window size is 8 (this number is a variable and will be inputed from command line). Receiver should ouput 8 packets (or segments) after next 8 are received.
This is like to have two buffers (can hold 8 packets each). When second buffer is full, you have to write out the content of first buffer. You can also implement this as a circular array/queue of size 16.- There are several ways to implement sending rate. You can use signal() to implement precise sending rate. Or, you may want to check sending rate every 2 seconds and sleep if necessary. The following pseudo code will give you some idea.
Loop if gettimeofday() sleep() (or usleep) ... send packets ... End Loopgettimeofday() is used to get current wall clock. Please note that gettimeofday() will return a structure (smallest unit is msec; check man page for detail). For example, if sending rate is 5 packets/sec, sender will send 10 packets during each iteration.- To detect if sender receives a request of missing packet, you can use select(). I will post a sample code late.
- You can keep all packets in the memory and output them to a file after all packets are received. The test file is likely less than 100KB (so it will fit in the memory).
- Not mentioned in the class:The format of output file is similar to input file, except each segment of music notes (separated by bar, '|') will be on one line (instead of having 4 segments on one line as in the example). So the output file of sample (Row, Row, Row Your Boat) will have 24 lines (last 16 lines are music notes). This should be easier to implement.
- 11-05-2001:
For term project, you don't need client.c and server.c (as in Assignment #2) that I listed in Reference. Those two programs were based on TCP. I have removed that part from reference. Sorry for the confusion.
You will write a sender and a receiver program to perform a simplified version of stream audio using UDP. Sender will send an audio file (text format; in simplified ABC musical notation language) to receiver and the received audio file will be saved and later played by an external program (might be converted to midi format before playing).A typical audio file (in ABC) would look like this.
% Sample ABC file X: 1 T:Row, Row, Row Your Boat M:3/4 L:1/4 Q:1/4=300 C:Trad K:C C3|C3|C2 D|E3| E2 D|E2 F|G3-|G3| c c c|G G G|E E E|C C C| G2 F|E2 D|C3-|C3||Audio file should be spilit into smaller segments to be sent over network. Carriage return and vertical bar ('|') will be used as separators. Double bar ('||') denotes end of audio stream. The sample audio file (above) will be split into 24 segments.
Your project is to implement "semi-reliable" transfer of such audio files using UDP between two machines on the network. Each packet contains one segment of audio file. The sender and receiver have "windows" as in other sliding window protocols.
- The sender should be able to control the sending rate. In your program, the sending rate could be a command line parameter. The sender should ensure that the sending rate is being followed after a window full of data has been sent, by adding appropriate delays.
- The receiver should request any lost packets but not routinely send acknowledgements. It is acceptable if the protocol occasionaly fails but the overhead should be kept to a minimum. If the protocol fails and a packet is not accounted for, a dummy string should be entered.
- If the sender receives a request for a transmission more than a window size behind the packet it sent most recently, it should ignore it. If the receiver receives a (re)transmission more than a window size behind the last packet it received, it should ignore it too.
- In order to test your program, it should be possible to make the sender drop packets with a given probability.
At the end of transmission, receiver will write received audio stream into a file. This output file can be played through other programs (might need to be converted to midi). I
You will design your own header and communication protocol. And you should design your programs as flexiable as possible. All variables can be command line parameters, such as receiver hostname, port number, sending rate, drop packet probability, receiver window size, input/output filename, etc.After you turn-in your programs, we will schedule a demo.
Submit your assignment:
- You should turn in your programs (client and sever), your student information file, Makefile, and README (with instruction and answers of discussion questions).
- You will use your CS account to submit your assignment. If you don't have one, please apply for one. If you can't get your CS account in time or having trouble with your account, e-mail submission to TA, Mark, or Dr. Subhlok will be accepted.
- Detail of how and where to submit will be given later.
- Here is the command to submit your files.
- Run the command from any of RedHat machines (redhat01 ~ redhat37).
- Submission CMD:
/auto/disk01/grad/cosc/y2000/zhu/4377/submit Assign#No FILE1 FILE2 FILE3 ...or~zhu/4377/submit 4 [*.c] [*.h] [readme] ....where Assign#No is the number of assignment (it's "4" for your project), and FILE1, etc. are the file you want to submit.
Reference:
ABC musical notation language and Midi:UNIX Programming:
- ABC musical notation language official site
- The ABC Project on sourceforge.net
- ABC player for Windows
- abcMIDI convert ABC to midi. You can get pre-compiled player for DOS.
- Don't have soundcard on your PC to play midi? No problem. Get midiplay MIDI player program which uses PC's internal speaker.
- To play midi on Linux, use TiMidity++. Just type "timidity my_midi_filename" at prompt. It is available on all RedHat machines.
Socket Programming:
- Unix Programming Frequently Asked Questions -
- Introduction To Unix Signals Programming
- High-resolution timing - part of Linux I/O port programming mini-Howto
- Timer based signals - with example of settimer() and gettimer()
- Sample socket programs using UDP: udpclient.c and udpserver.c).
- A simple Socket example.
- BSD Sockets: A Quick And Dirty Primer - a brief introduction to Sockets.
- BSD Sockets - a more detail introduction to Sockets with examples.i
- Spencer's Socket Site: Network Programming with Sockets - A good reference on Socket programming.
- Beej's Guide to Network Programming - Using Internet Sockets - A well-written guide for socket programming and it's easy to read. It also covers sockets for Windows.
- Unix Socket FAQ - Frequently Asked Questions about programming with sockets in UNIX environments.
- Davin's collection of UNIX programming links - an excellent resource for UNIX programming (including Sockets).
- List of known port numbers from IANA.org.
- A great UNIX network programming reference book, "UNIX Network Programming," by W. Richard Stevens, Prentice Hall, 1990. (ANDERSON/RESERVES QA76.76.O63 S755 1990). Sockets programming covered in 84 pages.
- Another book about client/server programming is " Power Programming with RPC," by John Bloomer, O'Reilly, 1991. (ANDERSON/RESERVES QA76.8.U65B4 1991 3-WK LOAN). You can find some sockets programming example from this book (actually the example in the first link is from this book.) Socket programming were covered in 25 pages.
- If you want to know how sockets is implemented, you should check out " TCP/IP Illustrated, Vol. 2 - The Implementation," by Gary R. Wright and W. Richard Stevens, Addison-Wesley, 1995. Sockets were covered in 124 pages.
Last modified: November 28, 2001.
tihuang at cs . uh . edu