Microsoft Word - COP3515 - Homework #2 - Spotting The Hacker.docxSpotting The Hacker Congratulations – you have landed a dream summer internship job: you’re going to be working for the...

Files are linked


Microsoft Word - COP3515 - Homework #2 - Spotting The Hacker.docx Spotting The Hacker Congratulations – you have landed a dream summer internship job: you’re going to be working for the White House. President Joe Biden is in the process of working closely with the U.S. ambassador to the United Nations, Linda Thomas-Greenfield, in order to have additional international sanctions placed against Russia for their invasion of Ukraine. As you can imagine, these talks are very secret and require the U.S. to move very carefully as we try to convince other countries to join us in punishing Russia for their actions. A secure communications link has been established between the White House and the ambassador's office at the United Nations in New York. Since you have mastered the art of creating high quality C programs, the White House team needs your help in monitoring the secure data that is being transmitted on this link. Specifically, the White House team needs to ensure that all of the data that they are receiving is accurate –a small glitch in the data could mean that the Russians have found a way to tap into the link. This means that you need to create a C program that will detect errors in the transmissions from the White House to the United Nations. The White House is highly aware that there are a number of different ways to go about detecting errors in a transmission data stream. They are not yet sure which technique they want to use. That’s why they have asked you to implement three different error detection algorithms so that they can study how they perform and then pick one to move forward with. The three error detection algorithms that the White House has selected are: Parity Check, Checksum, and two-dimensional Parity check. Parity Check Parity check is done by adding an extra bit, called parity bit to the data to make number of 1s either even in case of even parity, or odd in case of odd parity. While creating a frame, the sender counts the number of 1s in it and adds the parity bit in following way: • In case of even parity: If number of 1s is even then parity bit value is 0. If number of 1s is odd then parity bit value is 1. • In case of odd parity: If number of 1s is odd then parity bit value is 0. If number of 1s is even then parity bit value is 1. On receiving a frame, the receiver counts the number of 1s in it. In case of even parity check, if the count of 1s is even, the frame is accepted, otherwise it is rejected. Similar rule is adopted for odd parity check. Parity check is suitable for single bit error detection only. The White House will implement the parity check by sending 8 bytes and then another byte that contains the 8 parity bits for the previous 8 bytes. The White House has implemented even bit parity. Checksum In this error detection scheme, the following procedure is applied: 1. Data is divided into fixed sized frames or segments. 2. The sender adds the segments using 1’s complement arithmetic to get the sum. It then complements the sum to get the checksum and sends it along with the data frames. 3. The receiver adds the incoming segments along with the checksum to get the sum and then complements it. 4. If the result is zero, the received frames are accepted; otherwise they are discarded. Two-dimensional Parity check Parity check bits are calculated for each row, which is equivalent to a simple parity check bit. Parity check bits are also calculated for all columns, then both are sent along with the data. At the receiving end these are compared with the parity bits calculated on the received data. Your job will be to take the data files that the White House will provide you with and submit the data in each file to the appropriate error detecting algorithms. The output from each of the algorithms will have to be displayed. If the data has no errors, you are to report “No errors found”. If an error is found, you are to report “An error has been found”. White House transmission packet size is 8 bytes: 64 bits. Design Notes 1. To detect that you have read in an entire data file, you can use the feof C function. It will return true or false depending on if you have reached the end of the file. 2. When processing transmission data that is only a byte in size, you will probably want to use variables that are unsigned char – that will give you a variable that you can use all of the bits in (the most significant bit will not be used as a sign bit if you do this). 3. In order to calculate the complement of an integer in C, you use the ~ symbol. x = 0101 ~x = 1010 4. If you use the C function pow(x,y) which returns xy, you will need to cast the result as an integer because pow returns a float: (int)pow(x,y). 5. When comparing two numbers using the "and" function, make sure that you use the "&" operator (the binary version) and not the "&&" operator (the logical version). 6. When working on the Two-Dimensional Parity Check problem, clever use of functions will allow you to solve either the vertical or horizontal parity problem and then easily reuse what you have done to solve the other half of this problem. Sample Data Sets: • The parity check data file that you will be provided with will contain the following data: 8 bytes of transmission data, 1 byte of parity bits • The two-dimensional Parity check data file that you will be provided with will contain the following data: 8 rows of 8 bytes of transmission data One line containing 1 byte of horizontal parity bits, 1 byte of vertical parity bits • The checksum data file that you will be provided with will contain the following data: 8 bytes of transmission data, 1 byte of checksum data Assignment Requirements: 1. You are required to electronically submit a working copy of your program via Replit. 2. Your code must contain the following comment header: /* * COP 3515 – Spring Semester 2023 * * Homework #2: Spotting The Hacker * * (Your Name) */ #include #include #include #include Due This homework is due on Tuesday, 02/28/23 at the start of class. Note: You are only permitted to use the C commands that we have covered in class so far. Yes, there are many more, but no, you can't use them in solving this homework! Sample Output [Note: Dr. Anderson has a lot of error checking output in the output from his program that you do not need to include in your program. You are responsible for processing the data transmission streams and determining if the hacker has caused them to become corrupted.] ** Part 1 - Parity Check Processing Transmission line number: 1 Data stream: 1 2 3 4 5 6 7 8 Parity byte: 0 data item = 1 , binary = 00000001 Error in transmission byte 1 data item = 2 , binary = 00000010 Error in transmission byte 2 data item = 3 , binary = 00000011 No error in transmission byte 3 data item = 4 , binary = 00000100 Error in transmission byte 4 data item = 5 , binary = 00000101 No error in transmission byte 5 data item = 6 , binary = 00000110 No error in transmission byte 6 data item = 7 , binary = 00000111 Error in transmission byte 7 data item = 8 , binary = 00001000 Error in transmission byte 8 ** Part 2 - Checksum Processing Data stream: 1 2 3 4 5 6 7 8 Checksum: 219 parityData[i] = 1, binary = 00000001 parityData[i] = 2, binary = 00000010 parityData[i] = 3, binary = 00000011 parityData[i] = 4, binary = 00000100 parityData[i] = 5, binary = 00000101 parityData[i] = 6, binary = 00000110 parityData[i] = 7, binary = 00000111 parityData[i] = 8, binary = 00001000 Sum of data items = 36 , binary = 00100100 Checksum value = 219 , binary = 11011011 Sum after adding checksum = 255, binary = 11111111 Sum after complement = 0, binary = 00000000 Checksum: No errors in transmission ** Part 3 - Two-dimensional Parity check ==> Processing Transmission Block 1 Data streams: 10 20 30 40 50 60 70 80 [V: 0] [H: 48] 11 21 31 41 51 61 71 81 [V: 0] [H: 96] 12 22 32 42 52 62 72 82 [V: 0] [H: 96] 13 23 33 43 53 63 73 83 [V: 0] [H: 96] 14 24 34 44 54 64 74 84 [V: 0] [H: 208] 15 25 35 45 55 65 75 85 [V: 0] [H: 64] 16 26 36 46 56 66 76 86 [V: 0] [H: 160] 17 27 37 47 57 67 77 87 [V: 0] [H: 0] ** Vertical processing transmission line 0 val1 = 10, 00001010 val2 = 11, 00001011 val3 = 12, 00001100 val4 = 13, 00001101 val5 = 14, 00001110 val6 = 15, 00001111 val7 = 16, 00010000 val8 = 17, 00010001 checkParityByte = 0, vertParityByte[0] = 0 Transmission line 0 passed vertical parity ** Vertical processing transmission line 1 val1 = 20, 00010100 val2 = 21, 00010101 val3 = 22, 00010110 val4 = 23, 00010111 val5 = 24, 00011000 val6 = 25, 00011001 val7 = 26, 00011010 val8 = 27, 00011011 checkParityByte = 0, vertParityByte[1] = 0 Transmission line 1 passed vertical parity ** Vertical processing transmission line 2 val1 = 30, 00011110 val2 = 31, 00011111 val3 = 32, 00100000 val4 = 33, 00100001 val5 = 34, 00100010 val6 = 35, 00100011 val7 = 36, 00100100 val8 = 37, 00100101 checkParityByte = 0, vertParityByte[2] = 0 Transmission line 2 passed vertical parity ** Vertical processing transmission line 3 val1 = 40, 00101000 val2 = 41, 00101001 val3 = 42, 00101010 val4 = 43, 00101011 val5 = 44, 00101100 val6 = 45, 00101101 val7 = 46, 00101110 val8 = 47, 00101111 checkParityByte = 0, vertParityByte[3] = 0 Transmission line 3 passed vertical parity ** Vertical processing transmission line 4 val1 = 50, 00110010 val2 = 51, 00110011 val3 = 52, 00110100 val4 = 53, 00110101 val5 = 54, 00110110 val6 = 55, 00110111 val7 = 56, 00111000 val8 = 57, 00111001 checkParityByte = 0, vertParityByte[4] = 0 Transmission line 4 passed vertical parity ** Vertical processing transmission line 5 val1 = 60, 00111100 val2 = 61, 00111101 val3 = 62, 00111110 val4 = 63, 00111111 val5 = 64, 01000000 val6 = 65, 01000001 val7 = 66, 01000010 val8 = 67, 01000011 checkParityByte = 0, vertParityByte[5] = 0 Transmission line 5 passed vertical parity ** Vertical processing transmission line 6 val1 = 70, 01000110 val2 = 71, 01000111 val3 = 72, 01001000 val4 = 73, 01001001
Feb 27, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here