pcap_loop 和 pcap_dispatch 区别 [英] pcap_loop and pcap_dispatch Difference
本文介绍了pcap_loop 和 pcap_dispatch 区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
pcap_loop 和 pcap_dispatch 到底有什么区别?
What exactly is the difference between pcap_loop and pcap_dispatch?
推荐答案
手册对此进行了非常好的描述(我是板着脸说,保证).来自 man pcap_loop
:
The manual describes this amazingly well (I'm saying that with a straight face, promise). From man pcap_loop
:
pcap_loop() processes packets from a live capture or ``savefile''
until cnt packets are processed, the end of the ``savefile'' is
reached when reading from a ``savefile'', pcap_breakloop() is called,
or an error occurs. It does not return when live read timeouts
occur. A value of -1 or 0 for cnt is equivalent to infinity, so that
packets are processed until another ending condition occurs.
pcap_dispatch() processes packets from a live capture or ``savefile''
until cnt packets are processed, the end of the current bufferful of
packets is reached when doing a live capture, the end of the ``save‐
file'' is reached when reading from a ``savefile'', pcap_breakloop()
is called, or an error occurs. Thus, when doing a live capture, cnt
is the maximum number of packets to process before returning, but is
not a minimum number; when reading a live capture, only one bufferful
of packets is read at a time, so fewer than cnt packets may be pro‐
cessed. A value of -1 or 0 for cnt causes all the packets received in
one buffer to be processed when reading a live capture, and causes
all the packets in the file to be processed when reading a ``save‐
file''.
我知道您并不是真的想阅读和理解所有内容,所以让我们分解一下.
I know you didn't really want to read and understand all that, so let's break it down.
两种功能:
- 处理来自实时捕获或保存文件"的数据包,直到出现以下任何一种情况:
- 达到指定数量
- 到达保存文件"的末尾
- pcap_breakloop() 被调用
- 发生错误
pcap_dispatch() 单独
- 也在当前缓冲的数据包结束后返回,当进行实时捕获时(换句话说,可以更频繁地返回,因为指定的计数不是最小值)
这篇关于pcap_loop 和 pcap_dispatch 区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文