// written by Chris.McDonald@uwa.edu.au // // Compile me with: // cc -std=c99 -Wall -Werror -o Q2-soln Q2-soln.c #include #include #include #include #include #include #include // provides number-of-bits-per-byte NBBY // VALUES DEFINING THE PARAMETERS OF OUR EXPERIMENTS #define FRAMELEN 100 #define NFRAMES 1000000 #define MIN_BURSTLEN 15 #define MAX_BURSTLEN 50 // WE USE TEXTUAL INCLUSION HERE TO OBTAIN THE CHECKSUM FUNCTIONS - // SAVES 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" // --------------------------------------------------------------------- // CORRUPT A FRAME WITH A BURST ERROR // WE EMPLOY THE setbit() MACRO FROM // cf: https://code.woboq.org/qt5/include/sys/param.h.html void corrupt_frame(unsigned char frame[], int framelen, int burstlen) { int nbits = (framelen * NBBY); int firstbit = rand() % (nbits - burstlen); // 1st bit of burst for(int b=0 ; b