Welcome to the Most Reliable, Essay Writing Service on the internet

write-a-program-that-calculates-the-crc-16-of-a-given-file-and-appends-it-to-the-end-of-the-same-file

Mar 23

Short C Program.

Write a program that calculates the CRC-16 of a given file and appends it to the end of the same file. Your program must also be able to verify the correctness of a given file that already has CRC appended at the end. Use the CRC polynomial x16+ x10+ x8+ x7+ x3+ 1.

What to submit:

Submit an archive file (zip or rar) with the name yourlastname_yourfirstname_crc. Include the following three files in your archive file:

• An executable of your program

• Source code in one file as a .c

• A read me file so that TAs can execute your program to check your results

Input format:

Your program should prompt the user for the following input:

Enter the name of the file you want to check:

————-Menu————-

1. Calculate CRC

2. Verify CRC

3. Exit

Choose from the above menu:

You must check for input correctness also, by implementing code to:

• Verify that user has input a valid option in the menu. If invalid, prompt for menu again.

• Verify that the file that the user has entered actually exists. If the file does not exist, prompt for file again.

• 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

Output format:

The input file will contain data in hexadecimal character. Print out the hexadecimal file that is read.

Next, you must 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 print the binary version of the input file 32 binary bits per line. You must also insert a space after every four binary bits that you print.

Next, you will show the step-by-step of the CRC calculation or verification.

In the end, when calculating CRC, you must show the CRC answer, then convert it to hexadecimal and append it to the end of the file and close the file.

On the other hand, if verifying CRC, you must print a message whether the CRC check passed or failed.

Specific Functions inside code:

You must implement the following functions:

• A function for converting hexadecimal string into binary string

• A function for converting binary to hexadecimal

• A function to validate the input

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

• A function for CRC calculation

• A function for CRC verification

Sample Output from Menu Choice 1: Calculate CRC

As an example, consider that you have to calculate CRC-8 for an input file using the polynomial x8+x7+x6+x5+x4+x3+x+1

And assume the input file has the following contents: AB1245

Then, the CRC calculation output would be:

The input file (hex): AB1245
The input file (bin):

1010 1011 0001 0010 0100 0101

The polynomial that was used (binary bit string): 1 1111 1011
We will append eight zeros at the end of the binary input.

The binary string answer at each XOR step of CRC calculation:

1010 1011 0001 0010 0100 0101 0000 0000

0101 0110 1001 0010 0100 0101 0000 0000

0010 1000 0101 0010 0100 0101 0000 0000

0001 0111 0011 0010 0100 0101 0000 0000

0000 1000 1000 0010 0100 0101 0000 0000

0000 0111 0101 1010 0100 0101 0000 0000

0000 0000 1011 0110 0100 0101 0000 0000

0000 0000 0100 1011 1100 0101 0000 0000

0000 0000 0011 0101 0000 0101 0000 0000

0000 0000 0000 1010 0110 0101 0000 0000

0000 0000 0000 0101 1011 1101 0000 0000

0000 0000 0000 0010 0101 0001 0000 0000

0000 0000 0000 0001 1010 0111 0000 0000

0000 0000 0000 0000 0101 1100 0000 0000

0000 0000 0000 0000 0010 0010 1100 0000

0000 0000 0000 0000 0001 1101 1010 0000

0000 0000 0000 0000 0000 0010 0001 0000

0000 0000 0000 0000 0000 0001 1110 0110

0000 0000 0000 0000 0000 0000 0001 1101

Thus, the CRC is 0001 1101 (bin) = 1D (hex)

CRC has been appended to the end of the input file.

Reading input file again: AB12451D

Closing input file.

Remember that this is just an example. In the programming assignment you have to solve using a different polynomial.

Sample Output from Menu Choice 2: Verify CRC

As an example, consider that you have to verify the CRC-8 of an input file using the polynomial x8+x7+x6+x5+x4+x3+x+1

And assume the input file has the following contents: AB12451D

Then, the CRC verification output would be:

The input file (hex): AB12451D
The input file (bin):

1010 1011 0001 0010 0100 0101 0001 1101

The polynomial that was used (bin): 1 1111 1011
The 8-bit CRC at the end of the file: 1D (hex) = 0001 1101 (bin)

The binary string answer at each XOR step of CRC verification:

1010 1011 0001 0010 0100 0101 0001 1101

0101 0110 1001 0010 0100 0101 0001 1101

0010 1000 0101 0010 0100 0101 0001 1101

0001 0111 0011 0010 0100 0101 0001 1101

0000 1000 1000 0010 0100 0101 0001 1101

0000 0111 0101 1010 0100 0101 0001 1101

0000 0000 1011 0110 0100 0101 0001 1101

0000 0000 0100 1011 1100 0101 0001 1101

0000 0000 0011 0101 0000 0101 0001 1101

0000 0000 0000 1010 0110 0101 0001 1101

0000 0000 0000 0101 1011 1101 0001 1101

0000 0000 0000 0010 0101 0001 0001 1101

0000 0000 0000 0001 1010 0111 0001 1101

0000 0000 0000 0000 0101 1100 0001 1101

0000 0000 0000 0000 0010 0010 1101 1101

0000 0000 0000 0000 0001 1101 1011 1101

0000 0000 0000 0000 0000 0010 0000 1101

0000 0000 0000 0000 0000 0001 1111 1011

0000 0000 0000 0000 0000 0000 0000 0000

Did the CRC check pass? (Yes or No): Yes

  

CLIENT TESTIMONIALS

The Service Is Okay. I won’t Complain

The writers on the website are courteous and the customer service responds quickly. My paper was handled well; They promised...

Writers here are very professional and are native British

Thanks a lot for helping me out with my PhD Thesis, Writers here are very professional and are native British!!

Jack, The United Kingdom

Very Very Helpful, and On time.

Very Very Helpful, and On time.

Adelio M, Spain

I scored complete A’s in 3 out of four courses

I scored complete A’s in 3 out of four courses

Anonymous, Illinoi Chicago

CLICK HERE  To order your paper

About Essaysmiths Assignment writing service

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for upto 20% off in their first Order. Our payment method is safe and secure.

 CLICK HERE to Order Your Assignment

 

Get access to cheap essays online, and forget about all your worries

Quality assurance

When we accept your assignment order, we treat it with the utmost seriousness. This means that only the best experts will conduct research on your topic and that they will deliver your paper only after making sure that it is insightful.

Total confidentiality

We use the SSL protocol to ensure that all the details of our customers are 100% safe and secure. So, forget about all worries when sharing personal information on our site. We never disclose the details of our clients.

All round service

24/7 customer support. We don’t want you to fail to submit your paper. So, we work 24 hours a day and 7 days a week to provide you with instant feedback.

Original Essays

One of the key principles of our work is to be creative and original. We hire only talented and experienced essay writers that are able to create authentic papers. Each regular essay or term paper is written from scratch in accordance with all your guidelines.

Cheap Service

Compared to our competitors, we offer a relatively cheap service. We allow you the comfort of a cheap paper writing service to improve your grades. If you are facing an academic problem, we’ll solve it by asking for a fair price.

Rocket fast Essay writing service

Don’t worry! We work in a timely manner to deliver orders before the due date. You’ll have enough time to check whether the finished paper corresponds to all your requirements. If not, provide us with feedback and ask for a revision.

Order Your Essay Today From  reliable Essay writing Service.

Order your Assignment today and save 15% with the discount code ESSAYHELP

X