Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bytes vs. Symbols #80

Open
evmanz opened this issue Jun 20, 2024 · 1 comment
Open

Bytes vs. Symbols #80

evmanz opened this issue Jun 20, 2024 · 1 comment

Comments

@evmanz
Copy link

evmanz commented Jun 20, 2024

Hi,

I am a bit confused about the theory vs. the implementation of the reedsolo.
Theoretically, Reed-Solomon code with two ECC symbols should correct one symbol error.

This behavior is not what is happening with reedsolo. When I create single symbol correcting RSCodec for GF(2^16), i.e., two symbols of ECC, encode the message, and then corrupt first two bytes in it, the decoder fails with "Decoding failed: Too many errors to correct". Which is not how it supposed to behave: with 16-bit symbol, any 2-byte symbol-aligned corruption should be corrected (as those two bytes correspond to one 16-bit symbol).

What am I missing here? Is there any parameter I should define?
I am using reedsolo v2.0.13.

Here is the code that I am using to test this behavior:

import reedsolo as rs

# Initialize the tables with a primitive polynomial for GF(65536)
rs.init_tables(prim=0x18BB7, c_exp=16)

ecc_symbols = 2
codeword_length = 2**16 -1
# Create a Reed-Solomon codec with 16-bit symbols (GF(65536)) and 8 error correction symbols
codec = rs.RSCodec(nsym=ecc_symbols, c_exp=16, prim=0x18BB7, nsize=codeword_length)

# Original message (64 bytes or 32 symbols)
message = 'a'*(64)
print(f"len(message): {len(message)}")

# Encode the message
encoded_message = codec.encode(message)
print("Encoded message:", encoded_message)

# Introduce errors (corrupt two bytes, i.e., one symbol error)
corrupted_message = encoded_message
for i in range(2):
    corrupted_message[i] ^= 0x01 

print("Corrupted message:", corrupted_message)
# Decode the corrupted message
try:
    mes, mes_ecc, err_loc = codec.decode(corrupted_message)
    print("Decoded message:", mes)
    print("Error location:", err_loc)
    print("Message w/ ECC:", mes_ecc)
except rs.ReedSolomonError as e:
    print("Decoding failed:", e)

@vzool
Copy link

vzool commented Jul 27, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants