// Compile me with: // cc -std=c99 -Wall -Werror -o Q4-soln Q4-soln.c // This version is the same as Q2-soln.c // but gets its data from a large file, rather than generating random data. #include #include #include #include #include #include #include #include /* We use textual inclusion here to obtain the checksum files - saves typing, and the need for more complicated compilation and linking. DON'T DO THIS IN MORE SIGNIFICANT PROGRAMS. */ #include "./checksum_ccitt.c" #include "./checksum_crc16.c" #include "./checksum_internet.c" // VALUES DEFINING THE 'SIZE' OF OUR EXPERIMENTS #define FRAMESIZE 100 #define NFRAMES 1000000 #define BIGFILE "/usr/bin/crash" int data_fd; // CORRUPT A FRAME WITH A BURST ERROR void corrupt_frame(unsigned char frame[], int length) { #define MIN_BURSTLENGTH 10 #define MAX_BURSTLENGTH 100 int nbits = (length * NBBY); while(true) { int b0 = rand() % nbits; int b1 = rand() % nbits; int burst = b1 - b0; if(burst >= MIN_BURSTLENGTH && burst <= MAX_BURSTLENGTH) { for(int b=b0 ; b