错误检测(3)校验和

this type of error where you have multiple bit errors in a row is called burst error

除了为每一行添加一个奇偶校验位,还可以为每一列添加

parity bits per row

parity bits per column

in most communication systems burst errors are actually pretty common

and something like a parity bit per column here might be a better choice

但是这样的话,如果一个列中有多个flips错误 你也是抓不到的

下面我来看另外一种错误检测方法- checksum

这些ascii码加在一起是1161(10进制)

看一下对应的二进制的

第一列是 5个1 相加

(结果应该是101)

 

但是对这一位来说相当于是对1的一个奇偶校验

5个1,所以是奇数个1,parity的列校验也是1

继续相加,

加到第三位的时候,这个位就不是奇偶校验位了,而是进位得到的值

想表达的是什么。。

如果是单纯的奇偶校验,一列中两个1变成了两个0,那么这一列是不会被校验出错误的, 但是如果是加和,就能校验出来了,因为到后面会有进位的问题

这就是校验和相比列奇偶校验的一个优势

接着看,这一坨相加完后大于8位了,一般我们就留8位,

要把多余的chop off掉。

that as essentially being equivalent to sending the remainder of a division problem here

用1161/256

余的137 就是右边的8位

chop off掉的位数也会引起不准确的问题,因为进位的一些信息丢失掉了,

所以通常的做法是把chop off掉的位数再加回去,得到结果

this technique of doing this end around carry like this when you are doing addition is referred to as one’s complement addition

接下来我们不除以256,我们除以255

我们会得到 141, 比137 多4,

这正是我们 one’s complement addition 得到的结果

(用8位加上100 (十进制的4))

最后的10001101就是checksum的结果,

我们一般传的是取反的结果

(这个值是十进制的114 也就是上面除式中的255-141)

我们继续刚才的加法,将这个取反的checksum结果带到信息中,

然后相加计算:

左边多余的100 放到下面相加,

得到1111 1111

然后都取反 ,会 得到 0000 0000

到此我们的checksum就结束了,

limitation of this type of checksum:

1.

2.

传输过程中被插入了很多0000 0000  也是检测不出来的

3.

传输的信息中有 0000 0000,但是0000 0000没有按照正确顺序传输

在我们的实验中,我们用导线连接并传输信息,所以并不会出现乱序的问题,

但是在实际的网络中

在A和B点之间,有些数据会通过一条路传播,另一些数据通过另一条路传播

checksum不能检测序列的问题

下面介绍一个 用checksum来检测乱序的实例——ISBN,

在书籍的ISBN-10编码中, 最后一个是6

写出

  0 – 4 6 5 – 0 4 6 7 4

10    9  8 7   6 5 4 3 2

相乘相加得到192,

然后用192/11 …. 余5

之所以用11 是因为 11 不是 0~10之间(上面所有数)的任何的公因数

所以他们计算之后除以11,一定是有一个余数的,

如果上面任何一个数字变化了,那么余数一定也变化

所以我们可以根据余数是否变化来判断这组数是否有变化了

接下来,

用 11 - 5 = 6

即最后一个数是6,也就是check digit 是6 ,其实也就是书上的最后一位6

所以这种计算方法,也可以加上6来计算,

这样得到198,

然后用198除以11 余0

有时候你会看到书的结尾是x ,也就是说里面的数字是0~9 而不是0~10

And we talked about out of order errors and burst errors as potential problems,

Hamming Distance

hamming distance between this two is 2

The hamming distance between validate code words is two bits

that means that you have to change at least two bits in your message

in order to fool the parity detection scheme

在这个情况下 checksum 和 parity 都不太行

in this dimension or this in this measurement of hamming distance, both of them are susceptible

well, there are error detection schemes that have a higher hamming distance

hamming distance for parity it seems in all of these cases is gonna be two

checkout what happened when we combine all of this:

(对行和列都增加了 parity 校验)

假设有一个错误了, one bit error easy to detect just like any other parity scenario

行和列都能检测出来

如果有两个错误了:

行能检测出来

列能检测出来

如果是三个呢

列能检测出来

这样也能检测出来

如果是4个呢?

四个的话就检测不出来了

the minimum is four bits and so we would say that this scheme has a hamming distance of

drawback(缺点):我们添加了一些额外的比特位

checksum虽然很好,但是实现起来可能稍稍有一点复杂, 需要一些软件上的算法,

后面我们会介绍CRC校验,通过纯硬件的方式实现的一种非常robust的校验

and that’s another consideration is how easy it is to implement some of these different algorithms. we’ve been talking about purely in hardware , and so that’s why I’m going to talk about one more algorithm in the next video that turns out to be a really powerful algorithm and that’s the CRC the cyclical redundancy check

and it turns out you’re able to device CRC checks that are able to detect random bit errors in fact have a very hide Hamming distance and they’re also able to detect out of order data and very good at detecting burst errors.

In fact, not much more than we have here and we’ll be able to do an incredibly robust error detection completely in hardware

原文地址:https://www.cnblogs.com/eret9616/p/12253953.html