为什么IP头variables声明是根据字节顺序进行交换的

我的Ubuntu发行版上的ip.h文件在下面复制了以下的struct iphdr。 任何人都可以解释为什么variablesihl和版本的顺序根据字节顺序而变化。 根据我的理解,如果有多于一个字节,“endianess”将会很重要,但在这种情况下,这两个(ihl和version)结合起来形成一个字节。 因此,小字节或大字节不应影响字节内的位的sorting。

struct iphdr { #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int ihl:4; unsigned int version:4; #elif __BYTE_ORDER == __BIG_ENDIAN unsigned int version:4; unsigned int ihl:4; #else # error "Please fix <bits/endian.h>" #endif u_int8_t tos; u_int16_t tot_len; u_int16_t id; u_int16_t frag_off; u_int8_t ttl; u_int8_t protocol; u_int16_t check; u_int32_t saddr; u_int32_t daddr; /*The options start here. */ }; 

这是特定的实现(psABI-),但是实际上在相关实现中,字节或字内的位字节的位顺序与字内字节的字节顺序相匹配。 因此,为了使这些成员占据与正在使用哪种类型的系统无关的相同比特位置,它们的顺序基于字节顺序来交换。