HW 6 Hints
- A simple TCP sender/receiver
- Problem 3 / make sure that your implementation generates packets which conform the specification(e.g., payload size, fields, sequence number) given. Sequence numbers should be in network-byte order.
PROJECT PROBLEM Hints
- Use this audio file for test.
- Test the audio device by writing the audio file to /dev/audio,
# cat pp.au > /dev/audio
- If you don't hear anything from your headset, adjust the volume using the volume control applet(upper right corner of the screen) on the GNOME desktop(audioctl will not be provided).
- Please be advised that writing to /dev/audio is only allowed when you
are working from the console (you cannot write to /dev/audio with ssh.)
- If there's any problem with the sound system, report me EARLY!
- An example code for sound output
#include
#include
int main()
{
int fi, fo, n,i;
char buf[256];
fi = open("pp.au", O_RDONLY);
fo = open("/dev/audio", O_WRONLY | O_NONBLOCK);
for (i=0; i<300; ++i) {
read(fi, buf, sizeof(buf));
n = write(fo, buf, sizeof(buf));
printf("%d\n", n);
usleep(25000);
}
return 1;
}
So this is a much better example than I posted earlier. You may notice
that /dev/audio is opened with non-blocking mode since we don't want
the program blocks while playing sound; since we are using only one
process/thread the program should receive and process packets (also
feedback).
This example code writes 256 bytes to /dev/audio each time. 25ms of
usleep duration can be interpreted as your sigalarm interval. This
example sounds quite well. However, if you increase the usleep duration
you can hear some pause in playback. Likewise, if you decrease
the usleep duration the playback skips some data so that it makes some
scratch noise.
The thing you need to deal with is, now, engineering the interval
of calling write() and the amount of data writing to /dev/audio each time.