定界二进制序列

编程入门 行业动态 更新时间:2024-10-10 12:25:38
本文介绍了定界二进制序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要能够定界二进制数据流.我当时正在考虑使用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.

更多推荐

定界二进制序列

本文发布于:2023-11-29 08:42:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645902.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:序列   定界

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!