我无法在pcap.net中创建这些对象
IpV4Datagram ip = packet.Ethernet.IpV4;
TcpDatagram tcp = ip.Tcp;
HttpDatagram http = tcp.Http;
// HttpResponseDatagram resdat=http.; How can i create them?
// HttpResponseLayer resp;
if (tcp.Http.Body != null && http.IsResponse)
body = resp.Body.ToString();
我试图从tcp数据包中获取HTTP响应正文。如果还有其他方法可以帮助别人吗?
答案 0 :(得分:0)
在Pcap.Net User Guide中,有a section about sending packets。
在该部分中,有一个关于如何创建HttpRequestLayer
的示例,并且创建HttpResponseLayer
非常相似。
HttpRequestLayer httpLayer = new HttpRequestLayer { Version = HttpVersion.Version11, Header = new HttpHeader(new HttpContentLengthField(11)), Body = new Datagram(Encoding.ASCII.GetBytes("hello world")), Method = new HttpRequestMethod(HttpRequestKnownMethod.Get), Uri = @"http://pcapdot.net/", };
HttpResponseDatagram是通过解析HTTP数据包来创建的。 例如,通过执行
packet.Ethernet.IpV4.Tcp.Http
在没有解析数据包的情况下,没有简单的方法可以创建Datagram
。