我怎样才能解析.NET UDP包? [英] how can I parse a UDP packet in .NET?
问题描述
我怎么能解析报文中的.NET?
how can I parse a UDP packet in .NET?
我用PCap.Net捕获数据包,在这种情况下UDP数据包,我可以从PCap.net对象通过(PcapDotNet.packets.Ethernet.IpV4.Udp)访问。
I'm using PCap.Net to capture packets, in this case UDP packets, which I can access from the PCap.net object via (PcapDotNet.packets.Ethernet.IpV4.Udp).
我怎么能走的结果,UDP包,并解析呢?特别分拆DNS请求和被容纳在UDP分组内所发生的反应。
How can I take the results, the Udp packet, and parse this? In particular to unbundle DNS requests and responses that occur that are housed within a UDP packet.
有一个库,可以帮助这里?
Is there a library that could help here?
修改:为了更具体的我希望能够做的是提取DNS响应的IP地址,并使用Wireshark的将是通过基于检查:
EDIT: To be more specific what I want to be able to do is extract the IP address from the DNS response, and based on examination using Wireshark it would be by:
(一)输入:一个UDP数据包是DNS响应的有效载荷
(a) Input: Payload of a UDP packet that is a DNS response
(二)处理:解析出的UDP数据包的DNS响应部分。找到答案部分,在此找到答案记录,它的类型是A(主机地址)不是一个CNAME记录],然后用这个答案记录获取IP地址。
(b) Processing: Parse out the DNS response portion of the UDP packet. Find the Answers portion, within this find the answer record for which the type is A (Host Address) [not a CNAME record], then with this answer record get the IP address.
(三)返回:从DNS响应的IP地址
(c) Return: The IP address from the DNS response.
推荐答案
我发现下面的项目,有code要做到这一点
I found the following project which had the code to do this
HTTP://www.$c$cproject.com/KB/ IP / dnslookupdotnet.aspx
在特定的Response.cs类。同时注意,在code中的错误,但页面上的亮点在哪里,这是注释。
The Response.cs class in particular. Also note there is a bug in the code but the comments on the page highlight where this is.
这篇关于我怎样才能解析.NET UDP包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!