This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:fall2017:discrete:projects:dcf0 [2017/08/20 23:21] – [Program] wedge | haas:fall2017:discrete:projects:dcf0 [2017/09/06 17:19] (current) – [Decode] wedge | ||
---|---|---|---|
Line 8: | Line 8: | ||
======Project: | ======Project: | ||
+ | =====Errata===== | ||
+ | Any changes that have been made. | ||
+ | |||
+ | * Revision 0.1: Enhanced included ' | ||
+ | * Revision 0.2: Filled out the " | ||
+ | * Revision 0.3: Added a "Check Results" | ||
+ | * Revision 0.4: Further enhanced ' | ||
+ | * Revision 0.5: After some absolutely incredible irc shenanigans in what I've come to call the " | ||
=====Objective===== | =====Objective===== | ||
To apply your skills in implementing an encoding scheme that, in ideal circumstances, | To apply your skills in implementing an encoding scheme that, in ideal circumstances, | ||
Line 232: | Line 240: | ||
<code c> | <code c> | ||
- | if (argc < 2) // if less than 2 arguments have been provided | + | if (argc < 3) // if less than 3 arguments have been provided |
{ | { | ||
fprintf(stderr, | fprintf(stderr, | ||
Line 245: | Line 253: | ||
<cli> | <cli> | ||
- | lab46: | + | lab46: |
input name length: 14 bytes | input name length: 14 bytes | ||
input filename: in/ | input filename: in/ | ||
Line 252: | Line 260: | ||
stride value: 1 byte | stride value: 1 byte | ||
read in: 82 bytes | read in: 82 bytes | ||
- | wrote out: 64 bytes | + | wrote out: 62 bytes |
- | compression rate: 21.95% | + | compression rate: 24.39% |
lab46: | lab46: | ||
</ | </ | ||
Line 260: | Line 268: | ||
<cli> | <cli> | ||
- | lab46: | + | lab46: |
- | input name length: | + | lab46: |
- | input filename: | + | input name length: |
+ | input filename: | ||
output name length: 15 bytes | output name length: 15 bytes | ||
- | | + | |
| | ||
stride value: 1 byte | stride value: 1 byte | ||
- | read in: 64 bytes | + | read in: 62 bytes |
wrote out: 82 bytes | wrote out: 82 bytes | ||
- | inflation rate: 21.95% | + | inflation rate: 32.26% |
lab46: | lab46: | ||
</ | </ | ||
- | A good way to test that both encode and decode are working is to encode data then immediately turn around and decode that same data. If the decoded file is in the same state as the original, pre-encoded file, you know things are working. | ||
=====Check Results===== | =====Check Results===== | ||
- | If you'd like to verify your implementations, | + | |
+ | A good way to test that both encode and decode are working is to encode data then immediately turn around and decode that same data. If the decoded file is in the same state as the original, pre-encoded file, you know things are working. | ||
+ | |||
+ | ====diff compare=== | ||
+ | A quick way to check if two files are identical is to run the **diff(1)** command on them, so assuming the original file in **in/ | ||
+ | |||
+ | < | ||
+ | lab46: | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | Just getting your prompt back indicates no major differences were found. | ||
+ | |||
+ | ====MD5sum compare==== | ||
+ | If you'd like to be REALLY sure, generate MD5sum hashes and compare: | ||
+ | |||
+ | < | ||
+ | lab46: | ||
+ | 10f9bc85023dcf37be2b04638cb45ee2 | ||
+ | 10f9bc85023dcf37be2b04638cb45ee2 | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | As you can see, both hashes match (the MD5sum hashes are analyzing the file contents, NOT the name/ | ||
+ | |||
+ | ====Hex Dump/ | ||
+ | You may want to check and see what exactly your program is generating. | ||
+ | |||
+ | This can be done by performing a hex data dump (or visualization) of the raw data in the output file. | ||
+ | |||
+ | The tool I'd recommend for quick viewing is **xxd(1)**; please see the following example: | ||
+ | |||
+ | < | ||
+ | lab46: | ||
+ | 0000000: 6463 6658 2052 4c45 0001 010e 696e 2f73 dcfX RLE....in/ | ||
+ | 0000010: 616d 706c 6530 2e74 7874 0161 0262 0363 ample0.txt.a.b.c | ||
+ | 0000020: 0464 0565 0666 0767 0868 0969 086a 076b .d.e.f.g.h.i.j.k | ||
+ | 0000030: 066c 056d 046e 036f 0270 0171 010a | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | With this output, we can confirm, byte-by-byte, | ||
+ | |||
+ | * leftmost: byte offset (from start of file) | ||
+ | * middle: hex data (in pairs- big endian by default, so as you expect to read it) | ||
+ | * rightmost: the ASCII-ized representation of the middle data | ||
+ | |||
+ | =====Verify Results===== | ||
+ | If you'd like to verify your implementations, | ||
+ | |||
+ | **NOTE:** As there have been updates to this script since the project was first released, you may want to manually obtain a copy, to ensure you have the latest and greatest: | ||
+ | |||
+ | < | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | To run it, you need a functioning **encode** and **decode** program (although it does its best otherwise). | ||
+ | |||
+ | It runs through four separate tests, storing the results in a corresponding **o#/** directory (sometimes, if applicable, intermediate results in a corresponding **m#/** directory): | ||
+ | |||
+ | * test 0: take the raw data files in **in/** and encodes them (**o0/**) | ||
+ | * test 1: take pre-encoded data files in **in/** and decodes them (**o1/**) | ||
+ | * test 2: take the raw data files in **in/**, encodes them (**m2/**), then decodes them (**o2/**) | ||
+ | * test 3: take pre-encoded data files in **in/**, decodes them (**m3/**), then encodes them (**o3/**) | ||
+ | |||
+ | How it works: | ||
+ | |||
+ | - depending on the test, encodes or decodes a file in the **in/** directory. | ||
+ | * if single step, result is in **o#/** directory | ||
+ | * if multi-step, result is in **m#/** directory, then second operation puts its result into **o#/** | ||
+ | - A checksum is taken of the original file in **in/** | ||
+ | - Another checksum is taken of the new file in **o#/** | ||
+ | - The checksums are compared. If they match, " | ||
+ | |||
+ | ====Successful operation==== | ||
+ | If all goes according to plan, you'll see " | ||
+ | |||
+ | < | ||
+ | lab46: | ||
+ | ================================================= | ||
+ | = PHASE 0: Raw -> Encode data verification test = | ||
+ | ================================================= | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | |||
+ | ================================================= | ||
+ | = PHASE 1: Decode -> Raw data verification test = | ||
+ | ================================================= | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | |||
+ | ================================================ | ||
+ | = PHASE 2: Raw -> Encode -> Decode -> Raw test = | ||
+ | ================================================ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | |||
+ | ============================================= | ||
+ | = PHASE 3: Decode -> Raw -> Encode Raw test = | ||
+ | ============================================= | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====Unsuccessful operation==== | ||
+ | Should something not work correctly, you'll see a " | ||
+ | |||
+ | < | ||
+ | lab46: | ||
+ | ================================================= | ||
+ | = PHASE 0: Raw -> Encode data verification test = | ||
+ | ================================================= | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | |||
+ | ================================================= | ||
+ | = PHASE 1: Decode -> Raw data verification test = | ||
+ | ================================================= | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | |||
+ | ================================================ | ||
+ | = PHASE 2: Raw -> Encode -> Decode -> Raw test = | ||
+ | ================================================ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | |||
+ | ============================================= | ||
+ | = PHASE 3: Decode -> Raw -> Encode Raw test = | ||
+ | ============================================= | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====Incomplete operation==== | ||
+ | Should something not work at all (like a missing or uncompiling decode binary), you'll see a " | ||
+ | |||
+ | < | ||
+ | lab46: | ||
+ | ... | ||
+ | |||
+ | ================================================= | ||
+ | = PHASE 1: Decode -> Raw data verification test = | ||
+ | ================================================= | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | in/ | ||
+ | ... | ||
+ | </ | ||
=====Submission===== | =====Submission===== |