Ask Question, Ask an Expert


Ask C/C++ Expert

Home >> C/C++

problem 1) prepare the program which compute the CRC-16 value for a given file and also verifies the correctness of a given file that already has CRC-16 value appended at the end, as more fully described below.

Use the CRC polynomial x^(16) + x^(11) + x^(8) + x^(7) + x^(3) + x^(2) + 1.

Program operation:

1) The program should compile from the command line.

2) The program executable file name must be “crcfile”.

3) The program should run from the command line and take two (2) command line parameters.

4) The first command line parameter would be a flag value which 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 must produce a simple error message and a graceful exit from the program.

5) The second command line parameter would be the name of the file to be examined. The file must be a text file that is in the same folder as the program executable. If the file is not found, the program must issue a simple error message and exit gracefully.

6) The program must direct all output to the command window (terminal) screen. The details of what to output are describeed below.
Specific Functions inside code:

You should implement the following functions/methods:

• A function/method for converting a hexadecimal string into binary string

• A function/method for converting a binary string to hexadecimal

• A function/method to validate the characters in the input file

• An XOR function/method that takes as input two binary strings and returns the XOR result.

• A function/method for CRC calculation

• A function/method for CRC verification

Input file format:

Create YOUR OWN VALID input file.

Valid input files would be text files which contain only hexadecimal characters. Either upper or lower case letters may appear, but they would only be letters which correspond to hexadecimal characters. There would be no whitespace, punctuation, or special characters in the input files.

You should check for input correctness by implementing code to verify that each character in the input file is a valid hexadecimal character (0,1,2,3,4,5,6,7,8,9A,B,C,D,E,F,a,b,c,d,e,f). Valid upper and lower case hex letters will be given the same meaning (“a” = “A” = 1010, etc.)
If an input file contains any invalid characters (other than an end-¬?of-¬?file marker), then the program should issue an appropriate brief error message and terminate gracefully.

Output format:

Print out the hexadecimal file that is read, 80 hex characters to a line.

Next, you should convert the hexadecimal file into binary. Recall that one hex character is four bits. Read the input file and form a binary string. The length of the binary string will be four times the length of the input file because each hexadecimal character will be replaced by 4 binary bits. You will have to define a separate function to get the binary equivalent of a hexadecimal character.

You must state how many zeroes are appended to the input. You must then print the binary version of the input file (after appending) 64 binary bits per line. You must also insert a space after every four binary bits that you print (increasing the line length to 80 characters).

Next, you will show the result of each XOR operation involved in the CRC calculation or verification. The result value at each step is a binary value that contains all of the digits of the dividend after an XOR operation.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M94600

Have any Question? 

Related Questions in C/C++

1 three employees in a company are up special pay increase

1. Three employees in a company are up special pay increase. You are given a file, with the following data: Miller Andrew 65789.87 5 Green Sheila 75892.56 6 Sethi Amit 74900.50 6.1 Each input line consists of an employee ...

Cs 2410workshop make-up assignmentwrite a c program that

CS 2410 Workshop Make-Up Assignment Write a C++ program that will output to a file called output.txt EVERY 10 digit phone number from 713-000-0000 through 713-000-0998. These numbers MUST only contain an odd number of ev ...

Writing a c code its a beginner level code design a class

Writing a C++ code, its a beginner level code. Design a class house that defines a house on a street. A house has a house number and an (x,y) location, where x and y are numbers between -10 and 10. the key member is plot ...

Write a program to draw a symmetric shape of your own using

Write a program to draw a symmetric shape of your own using C++ user-defined functions and arrays. The program should draw a shape in its original and opposite forms (black and white and then white and black). Please con ...

Assignment part acreate a checkbook program using c

Assignment (part a) Create a Checkbook program using C : • Create a Check structure. Include:   o Check number (should be an integer).   o Date (use type char[ ]).   o To   o Amount   o Description • Add functions to:   ...

Write a program that reads numbers from cin and then sums

Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Construct three versions of this program, using the while ,do - while , and for loops. Add the following to your program: ...

Programming assignment 5write a c program that allows the

PROGRAMMING ASSIGNMENT #5 Write a C program that allows the user to make some banking transactions. The program should first prompt the user to enter the current balance of his/her bank account (in dollars and cents, not ...

Transaction processing system tpsxyz electronics is one of

Transaction Processing System (TPS) XYZ Electronics is one of the most popular electronics companies In Sultanate of Oman the company offers affordable electronic gadgets such as mp3 players, portable movie players, mobi ...

Projectdecision statementsdirections read carefully and

Project: Decision Statements Directions (Read CAREFULLY and follow COMPLETELY): - Create the following programs in C++ that perform the purpose described and show the sample output (with user input where applicable). - I ...

Assignmentwhen writing c programs include comments in your

Assignment When writing C++ programs include comments in your code, make the program readable by indenting, use meaningful variable and function names, and produce meaningful output. This assignment will be to write a bm ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen