"Sebastian Gazey" <23*1*1*
1@s*u*e*t*u*a*e*u*a*> wrote:
> I am a little confused how to read a file from the drive as if it was going to be sent over the network - is the question wanting us to convert the file into another format (as in, convert a text file into a file containing ints)? In other words - how do we go about making the frames from the file? Or is the question expecting us to use a binary file and convert that into ints (similar to question 1 on the labsheet)
>
> Otherwise, how would you use the corrupt files function (or the CRC functions) on the frames?
Hi Sebastian,
For this exercise, we're not really passing frames across a network, and not having the network (possibly) corrupt those frames, we're just simulating/emulating all of the actions with a single process on a single computer (no network required).
We can read the contents of any file (doesn't matter whether it's a text file or a 'binary' file) by reading the contents into an array of bytes, using the read() system call. We could read the whole file into a huge array but, more realistically, we'll read them in a size representative of a frame, say 1KB.
We then pass each of the read 'frames' to the corrupt_frame() function, which may modify the contents of the frame.
In some pseudo-code:
foreach frame to be 'transmitted'
calculate the checksum of the frame before 'transmitting' it
// pretend we've transmitted it
// call corrupt_frame() to change it while it's in transit
// receive the frame at the other end
calculate the checksum of the frame that 'arrived'
if the pre-transmission-checksum is different to the post-transmission-checksum
the checksum algorithm has successfully detected the corruption
otherwise
the checksum algorithm has failed to detect the corruption
You've been given a number of (real) checksum algorithms, and you can 'invent' some addition brutal or gentle ways to corrupt each frame.
We're interested in knowing how effective (and eventually, how fast) each checksum algorithm is.
Hope this helps,