在哪里可以找到 tcpdump() 文件的文件/结构布局?
我们使用 tcpdump() 将数据包捕获到文件中。我需要编写一个程序来解析它,有谁知道在哪里可以找到此工具创建的转储文件的文件布局?
We are capturing packets to a file using tcpdump(). I need to write a program to parse it, does anyone know where I could find a file layout for a dump file created by this tool?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解析文件最简单的方法是使用 libpcap 读取它; libpcap 可以直接在 C 和 C++ 中使用,并且还有许多其他语言的包装器。这样您就不必知道文件布局是什么(如果您的程序使用 libpcap 1.1 或更高版本,您还可以至少读取一些 pcap-ng 文件)。
The easiest way to parse the file is to read it with libpcap; libpcap can be used directly from C and C++, and there are wrappers for a number of other languages. That way you don't have to know what the file layout is (and you will also be able to read at least some pcap-ng files if your program is using libpcap 1.1 or later).
tcpdump 使用 libpcap;有描述 libpcap 文件格式 的文档,它应该可以满足您的需求。
tcpdump uses libpcap; there are docs describing the libpcap file format which should give you what you need.