November 13th, 2008, 06:54 PM
Packets C Programming Question
Any HELP would be greatly appreciated. THANKSSSS
Given the name of a binary file, which contains a series of 256-byte packets (or blocks),
your program will read in and check each block for correct parity at the byte level, for
correct checksum at the word level, and correct checksum at the packet level. Your
program will report which blocks of the file are valid and which are invalid. For the
invalid blocks you will report which bytes and words are invalid, if you can determine
You may assume that the blocks can be numbered starting at 0, and your primary ouput
to the screen will be a table of block #s, and either a PASS or FAIL indication for each,
followed by a description of the which parts within the block failed in a readable format
of your choosing.
After the table, also output to the screen the entire ASCII text version of the file, with the
packet headers, block checksums, and parity bits removed. For those bytes, words or
blocks that failed, you may insert a series of ‘*’ characters in those subsections of the
text. Print it out so that it is easily readable in a format of your choosing.
For our purposes, you may assume that the packets have already been received at the
receiver site and reassembled into a complete binary file.
Now we need you to write a program to check that file to see if it holds valid or invalid
data according to the redundancy scheme described below.
We will assume a fixed size packet of 256 bits (or 64 bytes) of information. The first 4
bytes of the packet will hold the packet header, followed by 60 data bytes. The header
holds a packet level checksum, which is the value of the sum of the 60 data bytes in the
rest of the packet.
At the word level (4 bytes) we will implement a simple word checksum as follows. For
example, the procedure that we will implement for each 4 byte group of data is:
• Given 4 bytes of data, e.g. : 0x25623F52
• Step 1: Adding all the individual bytes together, which gives 0x118.
• Step 2: Drop the carry nibble to give you 0x18.
• Step 3: Take the two's complement of the 0x18 to get 0xE8. This is the checksum
byte that will follow the 4 data bytes above. (e.g. 0x25623F52E8)
• Step 4: To test the checksum byte simply add it to the original group of bytes.
This should give you 0x100.
• Step 5: Drop the carry nibble again giving 0x00. Since it is 0x00, this means no
error was detected in this word (although an undetectable error could have
occurred - E.g. reordering of the bytes in the message, inserting or deleting zerovalued
bytes, or multiple errors which sum to zero).
More sophisticated types of redundancy checks are available to address those weaknesses
by considering not only the value of each byte but also its position. We will not
implement any of these sophisticated features on this assignment.
At the data byte level, your program will use the even-parity scheme discussed in class in
which the left 7 bits of each data byte represents an ASCII character, and the rightmost
bit (least significant bit) of the byte is set so that the number of ‘1’ bits in the byte is an
even number (See lecture notes, #27). This even-parity scheme applies to all data bytes,
but does not apply to the packet header information, or to the word checksum values.
November 13th, 2008, 08:55 PM
Re: Packets C Programming Question
Best suggestion....read the "Why We Dont Do Homework" FAQ,as well as the other information...including "Before you Post".
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
In theory, there is no difference between theory and paractice; in practice there is.
* Join the fight, refuse to respond to posts that contain code
outside of [code] ... [/code]
tags. See here
* How NOT
to post a question here
* Of course you read this
carefully before you posted
* Need homework help? Read this first
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.