Пример #1
0
                            taps=15,
                            width=100)
print(packets)
count = 0
acc = 0
print("ended decoding")
print(c.isDone(), len(packets))
while not c.isDone() and count < len(packets):
    received = packets[count]
    s = ""
    for b in received:
        s += str(b)
    if len(s) != 8 + 16 + 8:
        count += 1
        continue
    check = Pack(s, sent=True)
    if check.check_checksum():
        acc += 1
        temp = check.get_received_packet()
        temp = bytearray(temp, 'utf8')
        print("received packet", temp)
        c.receive_packet(temp)
    else:
        print("rejected packet")
    count += 1
de = c.decoded_chunks

final = c.blocks_write()
print(final)
a.decompress(final, "out.txt")
Пример #2
0
c = Receiver()
count = 0
packet == packet[::-1]
while not c.isDone() and count<len(packet):
    received=final_packet[count]
    print(received)
    check=Packet(received, sent = True)
    print(check.check_checksum())
    if check.check_checksum():

        temp=check.get_received_packet()
        temp=bytearray(temp,'utf8')
        c.receive_packet(temp)
    count+=1
de=c.decoded_chunks

# #check chunks
# for i in range(len(chunks)):
#     assert len(chunks[i])==len(de[i])
#     for j in range(len(chunks[i])):
#         assert chunks[i][j]==de[i][j]

huffman=c.blocks_write()

# # check huffman code
# assert  len(huffman)==len(encode)
# for i in range(len(huffman)):
#     assert huffman[i]==encode[i]

a.decompress(huffman,"huffman.txt")