2.2 · Methods of error detection
2.2 · 差错检测方法
Catching errors after transmission
在传输之后捕捉错误
Five ways a receiver can tell that data arrived corrupted: parity, checksum, echo check, check digit, and the automatic repeat query that ties them together.
接收方可以通过五种方式判断数据是否已损坏:奇偶校验、校验和、回音检验、校验位,以及把它们联系在一起的自动重复请求。
Explainer · 2.2.1
讲解 · 2.2.1
Why errors need checking for
为什么需要检查错误
As data travels, interference on the line can corrupt it. Three things can go wrong:
数据在传输过程中,线路上的干扰可能使其损坏。可能出现三种情况:
| Error | 错误类型 | What it means | 含义 |
|---|---|---|---|
| Data loss | 数据丢失 | some bits do not arrive | 部分位没有到达 |
| Data gain | 数据增加 | extra bits appear that were not sent | 出现了未曾发送的多余位 |
| Data change | 数据改变 | bits flip from 0 to 1 or 1 to 0 | 位从 0 变为 1,或从 1 变为 0 |
A human can often still read a garbled message, but a computer cannot, so every one of these must be caught.
对于被打乱的信息,人类通常仍能读懂,但计算机不能,因此上述每一种情况都必须被检测出来。
Explainer · 2.2.2
讲解 · 2.2.2
Parity check
奇偶校验
A parity check counts the 1-bits in a byte. Sender and receiver first agree on even parity (an even number of 1s) or odd parity (an odd number).
奇偶校验会计算一个字节中 1 的个数。发送方和接收方首先约定采用偶校验(1 的个数为偶数)或奇校验(1 的个数为奇数)。
| Step | 步骤 | What happens | 发生的事情 |
|---|---|---|---|
| 1 | the sender sets a parity bit (an extra bit added to each byte) so the byte has the agreed parity | 发送方设置一个奇偶校验位(附加在每个字节上的额外一位),使该字节符合约定的奇偶性 | |
| 2 | the byte is transmitted | 该字节被传输 | |
| 3 | the receiver recounts the 1-bits. If the parity is now wrong, an error occurred | 接收方重新统计 1 的个数。如果此时奇偶性不对,说明发生了错误 |
Parity has a limit: if two bits in the same byte flip, the parity looks correct again and the error is missed. A parity block check fixes this. Several bytes are sent, each with its own parity bit, plus a parity byte made of the parity bits of each column. An error shows up as a bad row and a bad column, and their intersection is the wrong bit.
奇偶校验有其局限性:如果同一字节中有两个位发生翻转,奇偶性会看起来仍然正确,从而漏检该错误。奇偶校验区块检查可以解决这个问题。发送多个字节,每个字节都带有自己的奇偶校验位,再加上由各列奇偶校验位组成的一个奇偶校验字节。错误会同时表现为一行错误和一列错误,二者的交叉点就是出错的那一位。
Always say which parity: “an even parity check”. Include that a parity bit is added to each byte, and that the parity is recalculated at the receiver and compared. A single parity check cannot spot two flipped bits, or say which bit is wrong.
务必说明是哪一种奇偶校验:"一个偶校验"。要包括奇偶校验位被添加到每个字节上,以及奇偶性会在接收方被重新计算并进行比较这两点。单一的奇偶校验无法发现两个位同时翻转的情况,也无法指出究竟是哪一位出错。
Try it yourself
动手试试
Parity byte and parity block
奇偶校验字节与奇偶校验区块
In byte mode, toggle the data bits and see the parity bit set itself, then send with a fault. In block mode, inject a single-bit error and watch the row and column pinpoint it.
在字节模式下,切换各数据位,观察奇偶校验位自动设置,然后带故障发送。在区块模式下,注入一个单比特错误,观察行与列如何定位它。
Explainer · 2.2.2
讲解 · 2.2.2
Checksum and echo check
校验和与回音检验
| Method | 方法 | Process | 过程 |
|---|---|---|---|
| Checksum | 校验和 | before sending, a value is calculated from the whole block of data using an agreed algorithm and sent after it. The receiver recalculates the checksum from the data it received and compares the two. If they differ, the block is re-sent | 发送前,使用约定的算法从整个数据块中计算出一个数值,并随数据一起发送。接收方根据收到的数据重新计算校验和,并比较两者。若不一致,则重新发送该数据块 |
| Echo check | 回音检验 | the receiver sends the data straight back to the sender, which compares it with the original. If they differ, an error happened, but you cannot tell whether it was on the way out or the way back | 接收方将数据原样送回给发送方,由发送方将其与原始数据进行比较。若不一致,说明发生了错误,但无法判断错误发生在去程还是回程 |
Try it yourself
动手试试
Checksum
校验和
Four bytes are sent with a checksum (their total, kept to one byte). Corrupt one byte in transit and watch the recalculated checksum stop matching.
四个字节连同一个校验和(它们的总和,保留为一个字节)一起被发送。让某个字节在传输途中损坏,观察重新计算出的校验和不再匹配。
Explainer · 2.2.3
讲解 · 2.2.3
Check digit
校验位
A check digit is an extra digit placed at the end of a code and worked out from the other digits using a set formula. It catches mistakes made when a code is typed or scanned:
校验位是附加在代码末尾的一个额外数字,通过一个固定公式由其余数字计算得出。它能捕捉在输入或扫描代码时发生的错误:
| Error caught | 捕捉的错误类型 | Example | 示例 |
|---|---|---|---|
| A wrong digit | 数字错误 | 5327 for 5307 | |
| Two digits swapped (transposition) | 两个数字互换位置(移位错误) | 5037 for 5307 | |
| A missing or extra digit | 数字缺失或多余 | 537 or 53107 for 5307 |
Used on ISBNs and barcodes. On entry, the check digit is recalculated from the other digits and compared with the check digit that was read in. If they differ, the code was mis-entered.
应用于 ISBN 和条形码。在录入时,校验位会根据其余数字重新计算,并与读入的校验位进行比较。若不一致,说明代码录入有误。
A check digit checks data entry, one code at a time. A checksum checks a block of data after transmission. Markers report these two swapped constantly. Also: the two things compared are the read-in check digit and the recalculated check digit, not the check digit against the data.
校验位检查的是数据录入,每次针对一个代码。校验和检查的是传输之后的一整块数据。考官报告显示,考生经常把这两者混淆。另外要注意:被比较的两者是读入的校验位和重新计算出的校验位,而不是校验位与数据本身。
Try it yourself
动手试试
The ISBN-13 verifier
ISBN-13 验证器
Type a 13-digit ISBN. The algorithm (you are given this in the exam, not asked to memorise it) is applied step by step. Try changing one digit or swapping two.
输入一个 13 位的 ISBN。该算法(考试中会提供给你,不要求记忆)会被逐步应用。尝试更改一个数字,或交换其中两个数字的位置。
Explainer · 2.2.4
讲解 · 2.2.4
Automatic repeat query (ARQ)
自动重复请求(ARQ)
An ARQ uses acknowledgements and a timeout to make sure data arrives without error:
ARQ 使用确认信号和超时机制来确保数据无差错地到达:
| Step | 步骤 | What happens | 发生的事情 |
|---|---|---|---|
| 1 | the receiver checks each block using an error-detection method (such as a checksum) | 接收方使用一种差错检测方法(例如校验和)检查每个数据块 | |
| 2 | if it is correct, the receiver sends a positive acknowledgement | 若正确,接收方发送一个正确认 | |
| 3 | if it is wrong, the receiver sends a negative acknowledgement and the block is re-sent | 若有误,接收方发送一个负确认,该数据块随即被重新发送 | |
| 4 | the sender runs a timeout: if no acknowledgement of any kind arrives in time, it re-sends automatically | 发送方启动一个超时计时:若在规定时间内没有收到任何确认信号,便会自动重新发送 | |
| 5 | this repeats until a positive acknowledgement comes back, or a set number of retries is reached | 此过程重复进行,直到收到正确认,或达到预设的重试次数为止 |
Name both acknowledgements and say which is which: positive means received correctly, negative means an error was found. The whole exchange is automatic between the two devices, the user is not involved. The timeout covers the case where a block or its acknowledgement is lost entirely.
要同时说出两种确认信号,并说明各自的含义:正确认表示接收正确,负确认表示发现了错误。整个交互过程是两台设备之间自动进行的,用户不参与其中。超时机制则用于覆盖数据块或其确认信号完全丢失的情况。
Try it yourself
动手试试
ARQ step-through
ARQ 逐步演示
Three cases: the block arrives clean, the block arrives corrupted, or the block is lost. Step through each.
三种情况:数据块正常到达、数据块损坏到达,或数据块丢失。逐一进行演示。
Check your understanding
检验你的理解
What kind of error can a single parity check fail to detect?
哪种类型的错误是单一奇偶校验无法检测出来的?
Check your understanding
检验你的理解
Which method is used to detect a mistake made when typing a product code?
哪种方法用于检测输入产品代码时出现的错误?
Check your understanding
检验你的理解
In an ARQ, which event causes the sender to re-send a block?
在 ARQ 中,哪个事件会导致发送方重新发送一个数据块?
Common mistakes
常见错误
2.2.1 to 2.2.4
考官针对 2.2.1 至 2.2.4 报告了以下模式
RecurringCandidates mix up checksum and check digit. Checksum: a value from a block of transmitted data, recalculated and compared after transmission. Check digit: a single digit on a code, recalculated and compared when the code is typed or scanned in.
反复出现考生常混淆校验和与校验位。校验和:来自已传输数据块的一个数值,在传输后重新计算并比较。校验位:代码上的单个数字,在代码被输入或扫描时重新计算并比较。
Parity answers are generic: “a parity check” without saying even or odd. Common missing details: the parity bit is added to each byte, and the parity is recalculated at the receiver and compared. Few can explain how a parity block pinpoints a bit (bad row and bad column intersect).
关于奇偶校验的答案常常过于笼统:只说"一次奇偶校验",却不说明是偶校验还是奇校验。常见遗漏的细节包括:奇偶校验位被添加到每个字节上,以及奇偶性会在接收方被重新计算并比较。很少有考生能解释奇偶校验区块如何精确定位出错的位(错误行与错误列的交叉点)。
On check digits, candidates describe how a barcode scanner works instead of how the check digit detects an error, and say the check digit is compared “with the data” rather than with the recalculated check digit.
在校验位方面,考生常描述条形码扫描器的工作原理,而不是校验位如何检测错误,并且说校验位是与"数据"进行比较,而不是与重新计算出的校验位进行比较。
On ARQ, candidates describe the positive acknowledgement only, or are vague (“an acknowledgement is sent if correct, and one if incorrect”) without naming positive and negative. Some say the user sends the acknowledgement or re-sends the data, but ARQ is automatic between the devices.
在 ARQ 方面,考生常常只描述正确认,或者说法含糊("如果正确就发送一个确认信号,不正确也发送一个"),而没有明确说出"正确认"和"负确认"这两个名称。有些考生说是用户发送确认信号或重新发送数据,但 ARQ 是设备之间自动进行的。
Swapped: “A checksum is the last digit of a barcode, used to check it was scanned correctly.”
混淆:"校验和是条形码的最后一位数字,用于检查扫描是否正确。"
Right: “A checksum is calculated from a block of data, sent with it, then recalculated by the receiver and compared to detect a transmission error.”
正确:"校验和是从一个数据块计算得出,随数据一起发送,然后由接收方重新计算并比较,以检测传输错误。"
Half the process: “In ARQ the receiver sends an acknowledgement back to the sender.”
只写了一半流程:"在 ARQ 中,接收方会向发送方发回一个确认信号。"
Both, named: “A positive acknowledgement if the block is correct; a negative acknowledgement if an error is found, and the block is re-sent. A timeout re-sends if nothing comes back.”
两者都写明:"数据块正确则发送正确认;发现错误则发送负确认,并重新发送该数据块。若没有收到任何回应,超时机制会触发重新发送。"
Revision questions
复习题
Past-paper style. Write an answer, then reveal the marking points and mark yourself.
采用历年真题风格。写下答案,然后展开评分要点给自己打分。
[2]State two ways that data can be affected by errors during transmission.
[2]陈述数据在传输过程中可能受到错误影响的两种方式。
[5]Describe how an even parity check is used to detect an error in a transmitted byte.
[5]描述如何使用偶校验来检测已传输字节中的错误。
Marking points
评分要点
- Sender and receiver first agree on even parity.
- Before sending, the sender counts the 1s in the byte and sets the parity bit so the total number of 1s is even.
- The byte, including the parity bit, is transmitted.
- The receiver counts the 1s in the received byte.
- If the count is odd, an error has occurred during transmission (if even, it is assumed correct).
- 发送方和接收方先约定偶校验。
- 发送前,发送方统计字节中 1 的个数,并设置奇偶校验位,使 1 的总数为偶数。
- 包含奇偶校验位的字节被发送出去。
- 接收方统计收到字节中 1 的个数。
- 如果个数为奇数,说明传输中出错(若为偶数,则认为正确)。
[4]Explain how a parity block check can locate which bit is wrong.
[4]解释奇偶校验区块检查如何定位出错的位。
Marking points
评分要点
- Several bytes are sent as a block, each with its own (row) parity bit.
- A parity byte is also sent, giving the parity of each column.
- At the receiver, the parity of every row and every column is recalculated.
- One row will fail its parity check and one column will fail; the wrong bit is the one where that faulty row and faulty column cross.
- 若干字节作为一个区块发送,每个字节有自己的(行)奇偶校验位。
- 还发送一个奇偶校验字节,给出每一列的奇偶性。
- 在接收方,每一行和每一列的奇偶性都被重新计算。
- 有一行的校验会不通过,有一列的校验也会不通过;出错的位就在那一行和那一列的交叉处。
[4]Give one difference between a checksum and a check digit, and describe the checksum process.
[4]给出校验和与校验位之间的一个区别,并描述校验和的处理过程。
Marking points
评分要点
- Difference: a checksum is calculated from a block of transmitted data and checked after transmission; a check digit is an extra digit on a code and is checked at data entry.
- Checksum process: the sender calculates a value from the data block and sends it with the data; the receiver recalculates the value from the received data; the two values are compared; if they differ, an error occurred (and the block is re-sent).
- 区别:校验和从一块已传输的数据计算得出,在传输之后检查;校验位是代码上多出的一位数字,在数据录入时检查。
- 校验和的过程:发送方从数据块计算出一个值,随数据一起发送;接收方从收到的数据重新计算该值;比较两个值;若不同,说明出错(并重发该数据块)。
[5]Describe how an automatic repeat query uses acknowledgements and a timeout to ensure data is received without error.
[5]描述自动重复请求如何使用确认信号和超时机制来确保数据无差错地被接收。
Marking points
评分要点
- The sender sends a block and starts a timer.
- If the block arrives without error, the receiver sends a positive acknowledgement.
- If an error is detected, the receiver sends a negative acknowledgement and the sender re-sends the block.
- If no acknowledgement is received before the timeout, the sender re-sends the block.
- This repeats until the block is acknowledged as correct.
- 发送方发送一个数据块并启动计时器。
- 如果数据块无误到达,接收方发送正确认。
- 如果检测到错误,接收方发送负确认,发送方重发该数据块。
- 如果在超时之前没有收到确认,发送方重发该数据块。
- 如此重复,直到该数据块被确认为正确。
Flashcards
记忆卡片
Active recall for this subtopic’s key terms.
针对本子主题关键术语的主动回忆练习。
Keep this subtopic’s practice with you
把这个子主题的练习保存下来
Free account: unlock every revision question and flashcard for 2.2, and every other IGCSE 0478 statement.
免费账户:解锁 2.2 以及所有其他 IGCSE 0478 考纲陈述的全部复习题和记忆卡片。