为什么pcap_dispatch只返回1个包?

2024-10-01 22:34:04 发布

您现在位置:Python中文网/ 问答频道 /正文

为什么pcap_dispatch(其中count=10)只返回1个包?在

如果我什么都不做,它会等待,然后显示1个包,但如果我单击一个链接,它会立即停止并显示1个包。在

我应该有这样一个循环吗?公司名称:

for i in range(0,10):
        p.dispatch(10, savePacket)

这是python,但我在C语言中遇到了同样的问题


Tags: in名称for链接countpcap公司range
1条回答
网友
1楼 · 发布于 2024-10-01 22:34:04

从手册页:

       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 ``savefile''  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 processed. 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 read‐
       ing a ``savefile''.

注意这一位的意思是:“所以可以处理少于cnt的包”—也就是说,它的作用取决于pcap实现。在

关于Python的一个注释:我不知道Python实现做了什么,但是在C语言中,对于每个包调用一次回调。在

相关问题 更多 >

    热门问题