格式错误的DNS请求数据包

时间:2015-06-04 16:00:18

标签: tcp dns wireshark

我一直致力于一个项目,该项目涉及在问题(其中2个)中发送包含信息(非实际域名)的Add()个请求。我一直用DNS跟踪数据包。

这是创建的数据包的wireshark转储。

  <00> 00000000 00 02 01 00 00 02 00 00 00 00 00 00 01 32 03 65

     

00000010 6e 64 03 63 6f 6d 00 00 01 00 01 01 32 04 73 61

     

00000020 76 65 03 63 6f 6d 00 00 01 00 01

     

........ ..... 2.e

     

nd.com .. .... 2.sa

     

ve.com .. ...

tcpi.d.应为2,需要递归,并且显示的域名是正确的。 qdcount表示它是格式错误的Wireshark数据包。知道数据包有什么问题吗?

1 个答案:

答案 0 :(得分:3)

好的,所以:

  • 如果您自己进行传输层网络连接,则代码将通过指定创建发送数据包的套接字来确定它是通过UDP还是TCP,无论是UDP还是TCP套接字; < / LI>
  • 如果数据包不适合最大大小的UDP数据包,则使用TCP;
  • 如果您通过TCP发送,则需要在其前面加上标题,如RFC 1035中第4.2.2节“TCP使用”中所述。

“最大尺寸”有点模糊。 IPv4规范RFC 791在第3.1节“Internet标头格式”中说:

Total Length:  16 bits

  Total Length is the length of the datagram, measured in octets,
  including internet header and data.  This field allows the length of
  a datagram to be up to 65,535 octets.  Such long datagrams are
  impractical for most hosts and networks.  All hosts must be prepared
  to accept datagrams of up to 576 octets (whether they arrive whole
  or in fragments).  It is recommended that hosts only send datagrams
  larger than 576 octets if they have assurance that the destination
  is prepared to accept the larger datagrams.

  The number 576 is selected to allow a reasonable sized data block to
  be transmitted in addition to the required header information.  For
  example, this size allows a data block of 512 octets plus 64 header
  octets to fit in a datagram.  The maximal internet header is 60
  octets, and a typical internet header is 20 octets, allowing a
  margin for headers of higher level protocols.

然而,现在,将最大数据包大小限制低至576字节的旧网络硬件大部分如果没有完全消失,并且真实世界的“最大数据包大小”通常是以太网数据包大小 - 总长度为1518字节,带有14字节的以太网报头和4字节的FCS,剩余1500字节的有效载荷。对于UDP,典型的IPv4报头长度为20个字节,UDP报头长度为8个字节,这是1472个字节的数据,因此对于大于1472字节的DNS消息使用TCP而不是UDP可能就足够了(IP分段和重组如果网络路由中的任何一跳不能处理1500字节的IPv4数据包,就会发生这种情况;这会增加数据包无法通过的可能性,因为如果一个片段通过但另一个片段没有通过,则整个数据包不会不通过。