像 Wireshark 这样的应用程序如何工作?
我想知道wireshark 是如何工作的。可以监听给定机器所有端口上的流量的应用程序的设计是什么?这样的应用程序会产生什么样的窃听?编写一个监控流量的应用程序的好方法是什么?
谢谢
Im am wondering how wireshark functions. What would be the design of an application that could listen to the traffic on all ports of a given machine? What is the kind of overheard that such an application generates? What would be a good way to go about writing an app that monitors traffic?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Wireshark 在 Unix 平台上利用 libpcap,在 Windows 上利用其端口 WinPcap。这个库提供了一个API来捕获数据包(Wireshark也能够捕获帧,但我在pcap文档中没有发现pcap能够做到这一点)。
库如何做到这一点是特定于平台的,这就是为什么一个好方法是使用库来为您完成繁重的工作; unix 上的 libpcap 或 tcpdump(取决于您需要的级别有多低)以及 Windows 上的 WinPcap 或 Windows 过滤平台。
文档:
http://www.tcpdump.org/pcap3_man.html
http://www.winpcap.org/docs/docs_412/html/main.html
Wireshark leverages libpcap on unix platforms and its port WinPcap on Windows. This library provides an API to capture packets (Wireshark is also able to capture frames but I haven't found in pcap docs that pcap is able to do that).
How the library does that is platform-specific, that's why a good way would be to use the library to do the heavy lifting for you; libpcap or tcpdump on unix (depending on how low-level you need it to be) and WinPcap or Windows Filtering Platform on Windows.
Documentation:
http://www.tcpdump.org/pcap3_man.html
http://www.winpcap.org/docs/docs_412/html/main.html
一种方法是使用 Windows 过滤平台(适用于 Vista+ ,但 XP 中也可以实现类似的功能 - WFP 只是让事情变得更容易)。 WFP 允许您监听驱动程序中在数据包处理堆栈中的各个点调用代码的“调用”,以便您可以在数据移动时捕获、过滤甚至修改数据。
One way would be to use the Windows Filtering Platform (this is for Vista+, but a similar feature was possible in XP- - the WFP just makes things easier). The WFP lets you listen to "callouts" in the driver that call your code at various points in the packet-processing stack so that you can capture, filter, and even modify the data as it moves around.