字节中的位排序有关系吗? [英] Bit ordering in a byte, does it matter?
问题描述
假设我们在网络 MA 和 MB 上有两台计算机,
MA 考虑小端顺序
恰好相反, MB 则按照大字节序排列字节中的位顺序。
Let's say we have two machines on a network MA and MB,
MA considers little endian the order of the bits in a byte,
on the contrary MB cosiders big endian the order of the bits in a byte.
MA 和 MB 如何在通过网络进行
通信期间对字节中的位使用什么终结性?
How do MA and MB agree on what "endianess" to use for the bits in a byte during the communication over the network ?
是否存在标准的网络耐力性?
套接字程序员是否必须采取任何措施以确保正确的通信?
Is there a standard "network endianess" or what ?
Do socket programmers have to take any actions in ensuring a correct communication ?
例如HTTP是一个文本协议,这意味着机器发送和接收表示字符的字节,如果字符的编码在位的字节序方面是不同的呢?
For example HTTP is a text protocol, that means that machines send and receive bytes wich represent characters,what if the encoding of the characters is different in the endianess of the bits ?
谢谢
推荐答案
是的,硬件协议指定了所有网络链路上字节的位顺序。通常,这是由NIC硬件自动处理的。
Yes, the hardware protocols specify the bit order of bytes on all network links. This is generally handled automatically by the NIC hardware.
例如,参见以太网帧格式。
以太网传输很奇怪,因为字节顺序为大端(最左侧的字节先发送),而比特顺序为小端(最先或字节的LSB(最低有效位)发送)。
Ethernet transmission is strange, in that the byte order is big-endian (leftmost byte is sent first), but bit order little-endian (rigthmost, or LSB (Least Significant Bit) of the byte is sent first).
这篇关于字节中的位排序有关系吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!