HDLC 帧 - 八位字节/模 8 疑问
我正在尝试实现 HDLC 帧格式类型 3,但我对帧的八位组/模 8 编码有一些疑问。
- 首先,HDLC帧是否完全以八位字节传输?
- 帧的长度是'n'八位字节是什么意思?请举个例子。
- 我相信八位字节和模数是相同的,因此假设我们有一个字节的帧X,那么它们的编码X意味着什么以 8 为模。
我对这一切感到有点困惑,所以我需要更多澄清。例子和插图将会有很大的帮助。
提前致谢。
谢谢@clifford 和@masoud。你的回答真的很有帮助。但我必须阅读这个八位字节字符串:它是什么?(虽然听起来很有趣因为它解释得很简单),我回来读了你的评论,然后我明白了你解释的一切。尽管如此,祝我编码愉快。
I am trying to implement the HDLC frame format type 3 and I have some doubts as regards Octets/Modulo 8 encoding of frames.
- Firstly, Is the HDLC frame transmitted entirely in Octets?
- What do they mean by a frame is 'n' Octet in length? Please give an example.
- I believe that Octet and Modulo is the same, so assuming that we have a frame X of one byte, what then do they mean by the encoding of X shall be modulo 8.
I am getting a little confused with all this, so i need more clarifications. Example and illustration will be of great help.
Thanks in Advance.
Thanks @clifford and @masoud. Your answer was really helpful. But I have to read this Octet String: What is it? (though it sounds funny because it explained in a simple way), and I came back to read your comments, then I understood all you explained. All the same, wish me a happy coding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 HDLC 中,每个字段的长度必须以 8 为模,例如:
HDLC 的帧如下所示:
[FLAG(8bits)|ADDRESS(8bits)|CONTROL(8/16bits)|INFORMATION(n*8bits)|FCS(8bits)|FLAG(8bits)]
每个字段以 8 为模,长度为偶数INFORMATION 必须以 8 为模。
这意味着如果要发送长度为 1 位的数据,则必须消耗一个字节(8 位)。
如果您正在寻找一些 HDLC 帧示例,请查看此链接:点击我!
并阅读以下内容:点击我
In HDLC every field length must be modulo 8 for example:
A frame of HDLC is like below:
[FLAG(8bits)|ADDRESS(8bits)|CONTROL(8/16bits)|INFORMATION(n*8bits)|FCS(8bits)|FLAG(8bits)]
each field is modulo 8, even length of INFORMATION must be modulo 8.
It means if you want to send a data with length of 1 bit, you must consume a byte(8 bits).
If you are looking for some HDLC frame sample, look at this link: Click me!
and read this: Click me
这仅仅意味着数据长度是 8 位的倍数。是的。
“他们”是谁?引用你的参考资料。八位位组只是一组八位。字节是一个不太含糊的术语(很少用来指长度不是八位的机器字)。术语“八位位组”广泛用于电信领域,并且在英语以外的语言中也用于表示“字节”(当一个字节为八位时)。
完全不一样,modulo 是一个数学术语,在这里使用可能不准确,表示可以被 8 整除(或精确倍数)。
再说一遍,“他们”是谁?如果我们可以看到您在上下文中阅读本文的位置,您可能会得到更好的解释。
编辑:
我没有详细引用 ISO 3309,它是定义 HDLC 帧结构的标准,但至少在 维基百科文章 仅在帧序列号的上下文中使用,它仅表示序列号从 0 递增到 7,然后从 0 重新开始(即,它是帧号模 8 - 或 C 代码中的frame_num/8 或简单的
frame_num % 8
的余数。我想知道您是否混淆了术语 - 再次引用或摘录会有所帮助。That simply means that the data length is a multiple of 8 bits. Yes it is.
Who is "they"? Cite your reference material. An octet is simply a group of eight bits. It is a less ambiguous term that byte (which can rarely be used refer to a machine word of length other than eight bits). The term octet is widely used in telecommunications, and is also used in languages other than English to mean "byte" (when a byte is eight bits).
Not at all, modulo is a mathematical term, used here perhaps inaccurately to mean exactly divisible by (or an exact multiple of) eight.
Again who are "they"? If we can see where you are reading this in context, you may get a better explanation.
Edit:
I have not gone to the length of referencing ISO 3309 which is the standard defining HDLC frame structure, but the term "Modulo 8" in at least the Wikipedia article is used only in the context of frame sequence numbers, where it simply means that a sequence number increments from 0 to 7, then restarts at 0 (i.e. it is the frame number modulo 8 - or the remainder of frame_num/8 or simple
frame_num % 8
in C code. I wonder whether you are confusing terms - again a citation or extract would help.