What are error-correcting codes?

Asked

Viewed 778 times

21

What they are and how they work error-correcting codes (error-correcting code)? I’ve seen this concept for example in QR Code (where partially damaged and/or imperfectly captured code is still readable) and I have also heard that it is used in space probes, when transmitting data over long distances with enough interference in the signal. I would like to know more about the concept, and how/where to apply it:

(Clarification: I refer only to codes, not to complete protocols. Like QR Code, once printed it cannot be "resubmitted", so any correction capability needs to be present in the code itself.)

  • What are the principles behind the technique? If it is something very extensive, I am satisfied with just an introduction followed by some references.

  • What are the limitations? Returning to the QR Code example, I saw that it is possible to configure it to tolerate up to 30% error. Is there any point from which codes become excessively long (tending to infinity, of course[1]), what is the best rate that can be expected in practice? And do these codes correct errors at arbitrary positions in the data (e.g., beginning, middle, end, 1 bit every 8, any combination of the above, etc.) or just some specific error types? It is possible to code "fix" to something other than the original data?

  • In what scenarios is this used in practice? There are libraries ready to do this, or you need to implement by hand, case by case (depending on the particularities of each application)?

    • Clarifying: I am not asking for a "list of cases", just know in general lines if it is worth using this kind of thing in day-to-day, or only in exceptional circumstances (I note that in practice if it is communication error, relays, if it is storage error, it is used backups; I don’t see this kind of thing being discussed much, not even mentioned).

Note: I am already familiar with codes detectors of errors (such as parity, checksums, hashes, Macs, etc.), I am interested in codes that allow to recover the original data even in the presence of some degree of error in them. Of course, to correct an error first you have to detect it, but my common sense says that the traditional mechanisms mentioned above are not enough - after all, the tag check can also be transmitted with errors...


[1]: When I say "tending to infinity" I mean the fact that it is impossible to correct 100% wrong code unless it is infinite. My question is whether by increasing the level of error tolerance, whether the code size grows at a high rate (e.g., quadratic, exponential...) or at a lower rate (e.g., linear, logarithmic) - allowing for example to achieve tolerances of 90% or more.

  • You’ve already managed to clear up your doubt?

  • @drmcarvalho It’s been a while since I asked this question, and I’ve forgotten the subject hehe! I have actually had some contact with the theoretical part (although I still have some difficulty understanding it), but I am completely lost with the practical part. I will give a "Bump" in the question, suddenly someone who knows more of the subject manifests...

  • I wrote my own QR encoder, but it made me want to cry when I read the documentation. For the polynomial part I was cutting way in everything that is given place (using pre-calculated tables, and simplifying in some cases with array to index the powers). I knew they had complicated in generation to simplify reading, but exaggerated :) - I hope someone will address the subject in the answers, now that has the Bounty, because despite being a boring thing to implement, it is very rich in details.

  • 2

    On the last question, in general these techniques are used when the communication channel is noisy (radio waves, bar code images, etc.). For non-noisy channels (such as a network connection) it usually is OK to do a simple checksum and resend the data if you have a problem. BTW to wkipédia page about Forward Error Correction has more details than the one linked in the question.

  • Melgibsonbr, kkk, the Computer Network of Tanenbaum, addresses this subject in cap 3, if I understand your question correctly... It’s very interesting, but I’m not in a position to explain... By the way, I’m gonna get a call, see if anybody’s qualified, 'cause it’s more binary math than high-level code... You can get an idea-https://en.wikipedia.org/wiki/Cyclic_redundancy_check

  • @Magichat CRC is much simpler, it’s more for data conferencing. Error-Correction in general has redundancy of information, because the goal is for you to be able to recover 100% of the original information without retransmission, even losing part of the data.

  • @Bacco Crcs are based on the Theory of Cyclic error-correcting codes, this put, I imagine that to delve into something so complex, it is necessary a base... But in the book I mentioned, other terms too... Including data retrieval ... It’s worth taking a, "dig"...

  • @mgibsonbr is a good question, but do not know the subject to give an answer, but I will wait for someone to answer, this will definitely help the community a lot.

  • @mgibsonbr I’ll try, do a 10 ai.... Necessary soundtrack... https://www.youtube.com/watch?v=ZSAsI5pnAbc

  • Here’s a really cool question. : ) Looking forward to seeing it unfold. Meanwhile, in the courtroom: https://www.youtube.com/watch?v=KA8hDldvv0

  • Peri I’m going to need a little more time.... https://www.youtube.com/watch?v=-jyTinxcKDg

  • @mgibsonbr I hope that you or any other user did not interpret the "kkk" of my first comment as being sarcastic to your question... I’m actually laughing at your nick Mel Gibson BR ! x)

  • @Magichat It’s funny that said whose is probably the reason of my nick - but not the way it looks! When I created my email on yahoo.com.br (yes, I am old rsrs) I wanted "Gibson", as my friends call me, but it was already used, so I put "mgibson". When I switched pro gmail.com, this was already used, so without thinking too much (after all when this "Google" will surpass the almighty Yahoo?) I passed the "br" I didn’t have in the domain pro username. Now that everyone knows me like this, I’ve been "cursed" with this bizarre nickname for the rest of my life! : P

  • @mgibsonbr heheh...is part, but the said whose is legal, demonstrates acumen, agility, do not feel cursed..... kkkk

Show 9 more comments

1 answer

14

_(ツ)_/

Error detection and correction (Error Detection and Correction)

  • What are and how error-correcting codes work ?

Definition

They are techniques that allow the delivery of data more reliably through communication channels.

Introducing

Detection and Correction, are terms that walk together being impossible the application of the second without the effectiveness of the first.

Communication channels at the physical level generally are susceptible to sensitive failures, often causing data loss or fragmentation.

"Functioning, what are the principles behind the technique, it is possible to code "correct" for something other than the original data ?"

There are 2 best known methods for error correction:

  1. Repeat request automatic (ARQ - Automatic repeat request):

    Uses "acknowledgements" (confirmations via messages sent by the receiver indicating that it has correctly received a data frame or package ) and "timesout" (time periods preceding a confirmation of receipt) to perform a reliable data transmission. If the sender does not receive a confirmation from the receiver before the "timeout" completes its cycle, the packet is retransmitted until the source receives a confirmation or exceeds a predefined number of attempts.

acknowledgements

ACK

timeout

Timeout

There are 3 main protocols using the ARQ method.

All are based on Sliding window Protocol.

2- The second method is Forward error Correction (Advanced error):

The sender redundantly encodes the code using an error correction code (ECC), through the redundancy added to the code the receiver recovers the original data in general the reconstructed data are considered "most likely" original data. The basis for this method is the work of Richar Hamming, author of hamming code and Hamming code(7,4).

The 2 main methods (ARQ and FEC) when combined fix small errors and avoid retransmission and major errors are fixed through 1 relay request : this process is called (HARQ) Hybrid Automatic repeat request.

The main principles that form part of the basis for implementation are:

The explanation of the logic used goes beyond the scope of this answer, but checking the links, or doing an in-depth research on the above appointments can find the full clarification of the functioning.

  • "What limitations, what is the best rate that can be expected in practice?"

Nowadays, due to the progress in the production of physical media, the tolerance in some media is close to 0 (optical fiber), and can be conquered in some special laboratories. However the diversity of means, makes us consider for example the radio transmissions that depend on a controlled environment, which is not possible on the day, because rains, winds, topology and other natural details or not, interfere directly in communication. For frames encoded by CCSDS Reed-Solomon code, less than 1 in 40,000 wrong frames can escape detection.

  • "Is there any point from which the codes become excessively
    long (tending to infinity, of course)?"

In theory, the algorithmic theory claims to be a sequence finite of instructions. The algorithms of detection and correction, are relatively short, because they act on parts of defined size (packages). However, this assertion is applied to simple commercial means, and taking into account military cryptography, space probes and other applications, I believe that they can really tend towards "infinity", or a few million lines... Although the use of logic serves exactly to inhibit this idea, I think...

  • "And these codes correct errors at arbitrary positions in the data (e.g.: beginning, middle, end, 1 bit every 8, any combination of previous, etc.) or only some specific error types?"

They act on predetermined parts of the packets, that is, the arbitrariness in the case is not the beginning, middle or end, but the error detected in itself.

The Advisory Committee for Data Space Systems ( CCSDS ) defines the protocol used for the transmission of data from spacecraft instruments through the deep space channel. According to this pattern, an image or other data sent from a spacecraft instrument is transmitted using one or more packets, ranging from 7 to 65,542 bytes, including the package header. These in turn are transmitted through tables of up to 2048 bytes.

  • "In which scenarios this is used in practice?"

    • Internet

    • Telecommunications in deep space

    • Satellite broadcasting

    • Data storage

    • Memory with error correction

  • "There are libraries ready to do this, or we need to implement on a case-by-case basis (depending on the particularities of each application)?"

The set of codes and protocols used to construct progress directed to these tasks is called Elementary Data Link Protocols. And the protocol code is in turn a set of classes.

Some definitions used in the presented protocols are stored in the file Protocol. h

#define MAX_PKT 1024  // Packet size in bytes
typedef enum {false,true} boolean;
typedef unsigned int seq_nr // seq or ack numbers
typedef struct {unsigned char data[MAX_PKT];} packet
typedef enum {data, ack,nak} frame_kind

typedef struct{
  frame_kind kind;
  seq_nr seq;
  seq_nr ack;
  packet info;
} frame;

void waif_for_event(event_type *event);
void from_network_layer(packet *p);
void to_network_layer(packet *p);
void from_physical_layer(frame *r);
void to_physical_layer(frame *s);
void start_timer(seq_nr k);
void stop_timer(seq_nr k);
void start_ack_timer(void);
void stop_ack_timer(void);
void enable_network_layer(void);
void disalbe_network_layer(void);
insira o código aqui
#define inc(k) if(k<MAX_SEQ) k++; else k=0

Examples of protocols and codes

Pipelining and error recovery. Effect of an error when (a) the size of the receiving window is 1 and when (b) the size of the receiving window is large

Pipe

Note on clarification:

In practice these protocols are used embedded in the hardware responsible for the transmission and reception of the data, and are abstracted from layers closer to the end user, so it goes unnoticed.

Special thanks to Tanenbaum

  • I’m sorry I didn’t respond earlier, but I left my last comment just before bed and I couldn’t respond properly. Please don’t take it personally. Come on: 1) I’m sorry if my question wasn’t clear. I was referring specifically to forward error Correction, as linked to Wikipedia, and I have no interest [in this specific question] in ARQ. I commented "I notice that in practice if it is communication error, relays" and I thought I had made it clear that the question was not about this type of technique. I’ll try to communicate better next time.

    1. His original response - quoting and explaining Hamming’s distance and things like that - was actually very relevant and straightforward at the point I wanted. But still, it was copying protected content, and that’s serious. I left that comment just to give you the opportunity to correct the problem yourself, before notifying to moderation, but given the time that this happened (1:30 am in my time zone) I could not elaborate more. I appreciate the research effort, and I think the material cited is an excellent reference (as link, not as copy).
  • I’ll take it easy, then give you some feedback. Whether the Hamming technique is sufficient or not, I don’t know, if I knew exactly what the "right" answer was, I wouldn’t have had to ask the rsrs question! Which is why I need the opinion of more experienced people than myself. From what I understand so far, much of what was asked this technique answers (almost everything I asked in the first 2 items). Only as for the practical part that I remain in the dark (because from what I understand of your answer so far, in practice this is used on a minimal scale, giving priority to the ARQ).

  • And since you are asking for opinions to improve your answer, what I think is the following: just citing the technique is not enough, the ideal would be for it to be briefly explained ("I am satisfied with just an introduction followed by some references") and that at least some of the points asked were directly addressed (e.g.: "these codes correct errors in arbitrary positions in the data (...) or only some specific types of errors? Is it possible to code "correct" for something other than the original data?"etc), not necessarily all, of course, is at your discretion.

  • No problem! If someone is willing to give a more didactic answer, this will be prioritized, otherwise I will have no problem in accepting your answer (after all in Sopt each contributes to the extent that can and wants, and every contribution is valid).

  • 1

    "Didactic" is just one of the qualities that an answer has, not necessarily the best. An operations manual is not didactic, a tutorial yes. Sometimes you need one, sometimes another. That said, I’ll stop here, before it turns into a squabble...

  • 3

    @Magichat I find unnecessary comments like this to explain what the didactic is after what is missing from the answer has already been mentioned. If you take a look at the responses of mgibsonbr you will see that they are didactic and well explanatory. I think in this case, if he comments that there are things missing from the answer, it is to take advantage and learn from it. It’s not every day that we have someone with a lot of experience suggesting improvements in what we do. That’s how we improve, with challenges.

  • 1

    Now that the dust has settled, let me try again: when a user asks a question, it is his prerogative which answer to accept, or none at all, if he is not satisfied. The same goes for those who award a reward. Votes, on the other hand, are a reflection of the community, and whether your response is being well received by it - as yours is - is what really matters, not the opinion of a particular user like me. Finally, citing the Help Center, 'if your motivation is "I would like others to explain ______" to me, you are probably in the right place'. If anyone’s willing, I’d be grateful.

  • Otherwise, I suggest you keep your answer as is, there is no need for any change (except a small detail I will suggest myself, please revert if you do not agree to the issue). It is a good, very comprehensive response, whose scope still goes beyond what has been requested. Which is good: the policy of Stack Overflow is to avoid throwing out good answers, so it would be a shame if your excellent response were altered too much because of a "whim" of mine. And you always have the option to give more than one answer if you wish (and if not, your contributions are more than enough).

  • P.S. I saw your latest changes, addressing more of what was requested. Have my upvote, +1.

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.