定界二进制序列 [英] Delimiting binary sequences

查看:80
本文介绍了定界二进制序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够定界二进制数据流.我当时正在考虑使用ASCII EOT(传输结束)字符之类的方法来完成此操作.

I need to be able to delimit a stream of binary data. I was thinking of using something like the ASCII EOT (End of Transmission) character to do this.

但是我有点担心-我怎么能确定用于此(0b00000100)的特定二进制序列不会出现在我自己的二进制序列中,从而对定界给出错误的肯定?

However I'm a bit concerned -- how can I know for sure that the particular binary sequence used for this (0b00000100) won't appear in my own binary sequences, thus giving a false positive on delimitation?

换句话说,如何最好地处理二进制定界?

In other words, how is binary delimiting best handled?

...不使用长度标题.抱歉,以前应该提到这一点.

...Without using a length header. Sorry guys, should have mentioned this before.

推荐答案

通常,您以一种众所周知的格式包装二进制数据,例如,使用描述后续数据的固定标头包装.如果要在未知数据流中查找分度符,通常需要转义序列.例如,类似HDLC的东西,其中0x7E是帧宽度.必须对数据进行编码,以便如果数据内部有0x7E,则将其替换为0x7D,然后是原始数据的XOR.数据流中的0x7D同样被转义.

Usually, you wrap your binary data in a well known format, for example with a fixed header that describes the subsequent data. If you are trying to find delimeters in an unknown stream of data, usually you need an escape sequence. For example, something like HDLC, where 0x7E is the frame delimeter. Data must be encoded such that if there is 0x7E inside the data, it is replaced with 0x7D followed by an XOR of the original data. 0x7D in the data stream is similarly escaped.

这篇关于定界二进制序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆