networking - 为什么 DNS 请求中句点的十六进制值不是 0x2E,为什么会发生变化?

标签 networking dns udp

在 wireshark 中查看 www.google.com 的 DNS 请求,它的十六进制是 03 77 77 77 06 67 6f 6f 67 6c 65 03 63 6f 6d 00

有点困惑,为什么第一个句点是 03(以及为什么它在那里),第二个句点是 06,最后一个句点是 03

最佳答案

DNS 协议(protocol)层在RFC 1035 中定义.引用自“3.1. namespace 定义”:

Domain names in messages are expressed in terms of a sequence of labels. Each label is represented as a one octet length field followed by that number of octets. Since every domain name ends with the null label of the root, a domain name is terminated by a length byte of zero.

因此 www.google.com 在 DNS 数据包中被编码为:

03 77 77 77                  length 3, "www"
06 67 6f 6f 67 6c 65         length 6, "google"
03 63 6f 6d                  length 3, "com"
00                           length 0 (end of label)

关于networking - 为什么 DNS 请求中句点的十六进制值不是 0x2E,为什么会发生变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47258547/

相关文章:

c - 哪些绿色线程库可用于 C,可以匹配 Haskell 绿色线程的性能和易用性?

c++ - 将一个 float 分成单个字节

dns - 如何解决 Windows 10 上的 "server DNS address could not be found"错误?

dns - DNSimple 上部分但非全部值的通配符子域

javascript - 如何将UDP收到的数据传输到node.js中的网页

.net - 对象未被垃圾收集

c++ - ipv6 向后兼容 ipv4 吗?

Java 小程序联网

html - 在免费的 heroku dyno 上托管我的多人 HTML5 游戏是否会影响我的网络性能?

docker - 容器之间的链接在我的 Rancher 1.6.21 堆栈中不起作用