0

我正在尝试处理以 pdml 格式输出的来自wireshark 的大型数据包捕获。然后使用 lxml 库将这些捕获加载到 python 中以遍历它们。我遇到的问题是我可以提取有关单个 HTTP 响应数据包的信息,然后我需要一种方法将其与它的 HTTP 请求数据包相关联。

我正在考虑实现的当前解决方案是搜索与响应属于同一 TCP 流的 HTTP 请求数据包,但这似乎是解决问题的低效解决方案,必须不断分离出 TCP 流然后搜索它们用于请求数据包。

有没有一种简单的方法可以将响应数据包与我丢失的请求相关联?

4

1 回答 1

0

到目前为止,我想出的最佳解决方案是在每个 TCP 连接仅包含一个请求/响应对的假设下使用 xpath。

#Get the stream index from the packet
streamIndex = packet.xpath('proto/field[@name="tcp.stream"]')[0].attrib['show']
#Use that stream index to get the matching response packet
return packet.xpath('/pdml/packet[proto/field[@name="tcp.stream" and @show="' + streamIndex + '"] and proto/field[@name="http.request.full_uri"]]')[0]
于 2012-07-18T12:31:52.573 回答