1. How each frame is made: step 1: start from the user_data and compute checksum step 2: add a FLAG, put in user_data followed by the checksum (doing byte stuffing when necessary), add another FLAG. When you decode, you need to reverse the process. 2. Regarding the checksum calculation. The data bits need to be considered in a non-conventional way as specified in the assignment description. However, both checksum and data bits are not re-arranged physically. 3. An example: Consider the first frame in the 'output' file. Try 'xxd -b output | more'. 0000000: 01100001 01010111 00011100 10110001 01100001 01100001 aW..aa 0000006: 01100101 10010000 01100101 01100001 01100001 01101100 e.eaal ... The first frame is 'aW..a': a is the FLAG; character 'W' is the data which is followed by a two-byte checksum, which is in turn followed by another FLAG. The binary for 'W' is 01010111. With the bit rearrangement described in the assignment description, we need to compute checksum for 00110111. So we have data = 00110111 generator = 10110000100010011 You can compute the checksum by hand and get 0001110010110001. As you can see in the file, the checksum byte follows the 'W' in the frame is 00011100, which is followed by another checksum byte 10110001. So this is a valid frame.