Question
Need to be done in c crc16 Program Submission Instructions: You must submit your source code file plus a README file All source code must
Need to be done in c
crc16
Program Submission Instructions:
You must submit your source code file plus a README file
All source code must be in exactly one file of type .c,
The README file must be a text file
Write a program that calculates the CRC-16 value for a given file and which can also verify the correctness of a given file that already has a CRC-16 value appended to it, as more fully described below.
Use the CRC polynomial: .
Program operation:
1. The program must compile from the command line.
2. The program executable file name must be crcheck.
3. The program must run from the command line and take two (2) command line parameters.
4. The first command line parameter will be a flag value that identifies the mode of operation: c for calculating a CRC value, or v for verifying a CRC value. Only these two values are allowed. Any other values should produce a simple error message and a graceful exit from the program.
5. The second command line parameter will be the name of the file to be examined. The file should be a text file that is in the same folder as the program executable. If the file is not found, the program should issue a simple error message and exit gracefully.
6. The program should direct all output to the command window (terminal) screen. The details of what to output are described below.
7. The program MUST run on Eustis. Please make sure to test your program on Eustis before submitting the assignment.
What to submit:
Put all classes, functions, and methods in the one file.
.
If you are coding in C or C++, you must use only the standard libraries, such as stdio.h, math.h, and Standard Template Library.
You must also submit a README file, which must be a text file, and which contains:
The compilation command for your program
The run command for your program
Your statement that the program is entirely your own work and that you have neither developed your code together with any another person, nor copied program code from any other person, nor permitted your code to be copied or otherwise used by any other person, nor have you copied, modified, or otherwise used program code that you have found in any external source, including but not limited to, online sources.
Input file format:
Valid input files will be ASCII files that contain printable data. There will be no pad or fill characters in a raw input file.
If an input file contains any invalid data (other than an end-of-file marker), then the program should issue an appropriate brief error message and terminate gracefully.
The raw input file will consist of ASCII data of varying length up to 512 bytes, with the last 8 bytes reserved for the checksum. (Note: The CRC or checksum will be a 16 bit integer, or 4 hexadecimal digits, which will fill the last 4 bytes/characters, the leading 4 characters should be zeroes.)
In the event the input file is not 504 characters (512 8) the deficiency should be padded with the . character as shown in the examples below. Note that the . character will affect the generated CRC.
Output format:
Output the ASCII file that is read, 64 characters to a line. Alphabetic characters in this output must be represented as it was read from the input file, regardless of case.
Next, you will show the result of each 64 characters lines cumulative XOR operation involved in the CRC calculation or verification. For example:
abcdefghijklmnopqrstuvwxyz12345-ABCDEFGHIJKLMNOPQRSTUVWXYZ12345a - 0000206c
Note that the input is shown in black and the lines CRC is shown in red. (There is no need to use color in the output for the assignment.)
At the end, when calculating CRC, you must show the CRC result in hexadecimal. Please note that in the event the input file is less than 512 characters, you must pad the remainder of the output file with blank spaces reserving the last 8 characters for the ASCII representation of the CRC, with leading zeroes as needed to obtain a 16-bit value for the CRC-16 code.
On the other hand, if verifying CRC, you must output (a) the accumulated CRC value in hexadecimal at the end of each 64 character output of the input file including pad spaces and the stated hexadecimal CRC (Note that the CRC even though it is hexadecimal data it will be printed in ASCII.); (b) the CRC (hexadecimal) calculated by the program; and (c) a message whether the CRC check passed or failed.
Specific Functions inside code:
You must implement the following functions/methods:
A function/method to read the data in the input file into an array.
An XOR function/method that takes as input two 32 bit unsigned binary integers and returns the XOR result
A function/method for CRC calculation
A function/method for CRC verification
input:
This is the lesson: never give in, never give in, never, never, never, never - in nothing, great or small, large or petty - never give in except to convictions of honour and good sense. Never yield to force; never yield to the apparently overwhelming might of the enemy.
output:
This is the lesson: never give in, never give in, never, never, - 00004af8 never, never - in nothing, great or small, large or petty - neve - 00005c68 r give in except to convictions of honour and good sense. Never - 000041b9 yield to force; never yield to the apparently overwhelming might - 000020fe of the enemy................................................... - 000051c9 ................................................................ - 000021f1 ................................................................ - 00000fab ........................................................0000754e - 0000754e CRC 16 result : 0000754e
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started