所需奇偶校验位的数量
我正在阅读有关错误检测的内容,偶然发现了一个我不太理解的声明。该声明说“对于 ak 位字符串,我们需要 lg k 奇偶校验位来检测 2 位错误”。其中 lg 是以 2 为底的对数,
我不太明白为什么这是真的,是否有任何正式的推导可以证实这一点。
这本书的名字是 Gallahager 的《数据网络》。
我并不怀疑这本书所说的内容,但我只是好奇地想看看它的推导。
谢谢, 钱德
I was reading about error detection and stumbled upon a statement which I didn't quite understand. The statement said "for a k bit string we need lg k parity bits to detect 2 bit errors".where lg is log to the base 2
I couldn't quite understand why this is true, is there any formal derivation that confirms this.
The name of the book is Data Networks by Gallahager.
Im not doubting what the book says, but am just curious enough to see a derivation.
Thanks,
Chander
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看维基百科页面的循环冗余检查。严格来说,奇偶校验位是 1 位检查,因此谈论多于 1 个奇偶校验位可能是等效 CRC 的简写。文章“CRC 数学” 提供了有关推导的更多信息。
Have a look at the wikipedia page for Cyclic Redundancy Check. Strictly speaking a parity bit is a 1 bit check so talking about more than 1 parity bit is probably shorthand for the equivalent CRC. The article "Mathematics of CRC" gives more on the derivation.
术语
当接收器重新计算奇偶校验位,并将重新计算的奇偶校验位与接收到的奇偶校验位进行比较时,其差异称为校正子。当没有错误时,综合症为零。
换句话说,syndrome = recalculated_parity XOR receive_parity。
证明
证明需要 n 个奇偶校验位才能检测 2^n 位有效负载数据位帧中的 2 位错误:
当在有效负载数据位中仅存在 1 个错误时整个框架,
当接收器重新计算奇偶校验位时,
有两种情况:
当整个帧恰好有2个错误时,
得到的综合症是由每个孤立错误引起的综合症的异或。
当接收器重新计算奇偶校验位时,有3种情况:
假设,如果存在一些有效负载位,使得翻转它会产生一些综合症 S,
并且还有任何其他有效负载位可以产生完全相同的综合症 S,
那么同时命中这两个位的双位错误将无法检测到。
换句话说,该两位错误将给出
S xor S == 0
的综合症。换句话说,每个奇偶校验要么是情况(a),要么是情况(b),这两种情况都不能检测到这样的错误。
那会很糟糕。
因此,为了检测帧中每一个可能的两位错误,
我们必须设计错误检测代码,使得
每个单位错误都必须产生不同的综合症。
换句话说,对于帧中两个错误位的每种可能情况,必须至少有 1 个类型 (c) 的奇偶校验位。
使用 n 个奇偶校验位给出 n 个校正子位。
对于 n 个校正子位,最多有 2^n 种可能的不同校正子。
因此,为了确保帧中的每个位(当它是唯一的错误时)给出不同的综合症,
帧中最多必须有 2^n 位。
我敢打赌,如果您在 https://math.stackexchange.com/ 上发布这个问题,您会得到一个更短、更优雅的证明:-)。
terminology
When the receiver re-calculates the parity bits, and compares the re-calculated parity bits with the received parity bits, the difference is called the syndrome. When there were no errors, the syndrome is zero.
In other words, syndrome = recalculated_parity XOR recieved_parity.
Proof
A proof that n parity bits are required to detect 2 bit errors in a 2^n bit frame of payload data bits:
When there is only 1 error in the entire frame,
when the receiver re-calculates the parity bits,
there are two cases:
When there is exactly 2 errors in the entire frame,
the resulting syndrome is the XOR of the syndrome caused by each error in isolation.
When the receiver re-calculates the parity bits, there are 3 cases:
If, hypothetically, there existed some payload bit such that flipping it produces some syndrome S,
and there is any other payload bit that produces exactly the same syndrome S,
then a two-bit error that hit both of those bits would be undetectable.
In other words, that two-bit error would give syndrome of
S xor S == zero
.In other words, each parity is either case (a) or case (b), neither of which can detect such an error.
That would be bad.
So in order to detect every possible two-bit error in the frame,
we must design the error-detection code such that
each single-bit error must produce a different syndrome.
In other words, there must be at least 1 parity bit of type (c) for every possible case of two erroneous bits in the frame.
Using n parity bits gives n syndrome bits.
With n syndrome bits, there are at most 2^n possible different syndromes.
So to make sure that each bit in the frame (when it is the only error) gives a different syndrome,
we must have at most 2^n bits in the frame.
I bet if you posted this question on https://math.stackexchange.com/ you'd get a much shorter and more elegant proof :-).