[Winpcap-users] Delay receiving packets - wrong functionality ofpcap_setmintocopy()

Mark Pizzolato - WinPCap-Users winpcap-users-20040408 at subscriptions.pizzolato.net
Mon Feb 21 15:11:08 PST 2011


Hi Anton,

 

I've got an WinPcap application which I don't believe looses packets,
but this may actually be happening and is naturally fixed by higher
level protocol retransmissions (i.e. TCP).  In any case, in our usage of
WinPcap  we do the following:

1)      pcap_open_live() is called with promiscuous set, and a timeout
of -1.

2)      We don't use pcap_setbuf() but you certainly could.

3)      pcap_setmintocopy with a size value of 0 is called.

4)      We set a reasonable BPF filter to select interesting packets.

5)      We use pcap_getevent to get the handle of an event to wait on
for packet arrival

6)      When the event is signaled, we call pcap_dispatch to actually
receive packets.

 

In our application, some of the above is done in different threads, but
the pcap activities are not really thread related.  Our reader thread
queues arriving packets for processing elsewhere in the application.

 

Good Luck.

 

-        Mark Pizzolato

 

From: Anton Tremsin [mailto:ast at ssl.berkeley.edu] 
Sent: Wednesday, February 16, 2011 10:55 AM
To: winpcap-users at winpcap.org
Cc: Mark Pizzolato - WinPCap-Users
Subject: Re: [Winpcap-users] Delay receiving packets - wrong
functionality ofpcap_setmintocopy()

 

Setmintocopy wth 0 does not change anything. There is still delay till
the timeout in receiving the rest of the packets. It decides by itself
when to release data to me, and nothing I can do to change it.

I also verified it on an XP computer, where it behaves the same way, so
it is not Windows 7 related issue.






Have you tried with setmintocopy at 0?

 

From: winpcap-users-bounces at winpcap.org
[mailto:winpcap-users-bounces at winpcap.org] On Behalf Of Anton Tremsin
Sent: Thursday, February 10, 2011 6:59 PM
To: Gianluca Varenni
Cc: winpcap-users at winpcap.org
Subject: Re: [Winpcap-users] Delay receiving packets - wrong
functionality ofpcap_setmintocopy()

 

Exactly, I almost always see the timeout, even with setmintocopy set to
1.

I can send multiple bunches of my packets (my each "frame" consists of
64 packets) in very short time from my detector. Then the winpcap
receives then in small chunks, not a fixed number of packets. Then waits
till timeout, then sends another batch of those packets sent into
Winpicol long time ago, then waits for timeout again, etc. That means
the data is not lost, but for some reason is being sent in small chunks
rather than in packs of 64 packets, the size of these chunks does not
change with value set in setmintocopy. However, it is not as simple as
setmintocopy fails: I know there is data in the PC already, I read part
of it after each timeout and that can continue for a long time if I make
large buffer and fill it with packets from the detector.

I also tested it on another computer , which is Windows XP, not Windows
7. So that is not Windows 7 problem. Must be something else. Asked
Chelsio support - they do not know any reason why it could be caused by
the driver of the card.

Thanks a lot for your help.

Anton 




So, if you put a mintocopy of 1, you still experience a timeout in some
cases?

 

GV

 

PS: please do not remove winpcap-users at winpcap.org from the recipients.

 

From: Anton Tremsin [mailto:ast at ssl.berkeley.edu] 
Sent: Friday, February 04, 2011 10:07 PM
To: Gianluca Varenni
Subject: Re: [Winpcap-users] Delay receiving packets - wrong
functionality ofpcap_setmintocopy()

 

I do use pcap_setmintocopy() functon.

That is exactly the problem: I use value equal to 64 packets
(8234*64=526976), value equal to 1 byte only - behavior seems to be very
similar, packets are delayed till timeout.

Thanks,

Anton





What value do you use for mintocopy? Do you call pcap_setmintocopy?

 

Have a nice day

GV

 

From: Anton Tremsin [mailto:ast at ssl.berkeley.edu] 
Sent: Friday, February 04, 2011 9:39 PM
To: winpcap-users at winpcap.org
Cc: Gianluca Varenni
Subject: Re: [Winpcap-users] Delay receiving packets - wrong
functionality ofpcap_setmintocopy()

 

Gianluca,

Thanks a lot for helping me. I am in a dire situation since my detector
really needs that problem to be solved before our experiments in couple
of months time (need to do a lot of debugging and code writing after
Winpcap issue is solved).

I am not loosing packets. Sorry if I made it confusing.

The packets always arrive into my C code (although Wireshark may loose
them, maybe that was a confusion with packets being lost). I only need
my C code to work right.  The rest of packets come only after the
timeout. 

I varied timeout from 1 ms to 20 sec and the effect is the same. With
timeout 0 - the packets do not arrive until I push more packets into
Chelsio card and these, in turn, push the once which were already in
some buffer. 

I am using Chelsio card, but Winpcap I downloaded from the official
website (version 4.1.2). 

The problem seems to be as if the function setmintocopy() does not work
right and the driver decides by itself how much to buffer before sending
it to me. One strange thing - the number of packets being delivered to
me changes from time to time, however very often number 31 (31 packets,
8234 bytes each) arrive in a single chunk. Sometimes it is 62 packets,
sometimes other numbers, e.g. 57. etc.

I will be very glad if someone ca advise something I can try to resolve
that issue.

Thanks again,

Anton






Anton,

 

You say that you are using a Chelsio board. Are you using the official
version of WinPcap or Chelsio provided you with a custom one? What do
you set as timeout and mintocopy?

 

Have a nice day

GV

 

 

From: winpcap-users-bounces at winpcap.org
[mailto:winpcap-users-bounces at winpcap.org] On Behalf Of Mark Pizzolato -
WinPCap-Users
Sent: Friday, January 28, 2011 11:57 AM
To: winpcap-users at winpcap.org
Subject: Re: [Winpcap-users] Delay receiving packets - wrong
functionality ofpcap_setmintocopy()

 

Ho Anton,

 

My first question to you would be:

 

WHY are you using WinPcap to receive UDP packets?

 

This sounds like a job for a winsock application....

 

Mark Pizzolato

 

From: winpcap-users-bounces at winpcap.org
[mailto:winpcap-users-bounces at winpcap.org] On Behalf Of Anton Tremsin
Sent: Friday, January 28, 2011 11:50 AM
To: winpcap-users at winpcap.org
Subject: [Winpcap-users] Delay receiving packets - wrong functionality
ofpcap_setmintocopy()

 

I hope someone can help my problem receiving packets in Windows7

I am sending data by UDP packets from an FPGA through 10GB card
(Chelsio). Using VC++ 2010 to compile code to receive them. 

All packets arrive, no losses seen, but the problem is with the proper
operation of pcap_setmintocopy() function. 

I send 64 packets with 8234 bytes each. Receiving them through
pcp_next_ex() and I only get 31 packets (sometimes 62, sometimes 47, 50
packets) before the timeout occurs. After timeout the rest of the
packets arrives. 

I set the minimum amount of data in the kernel buffer that causes a read
from the application to return (unless the timeout expires) to be 1 byte
or it to be all 8234x64 bytes, no difference. Looks like the setmintocpy
function has no effect on my kernel buffer to be copied to my
application. If I send another set of 64 packets - data arrives into
pcp_next_ex(), still only in lamp of 31 (62, 47,50) packets 

That is a big problem for my application.

Is there anything I am doing wrong or need to change something in the
system/driver to make setmintocopy function to operate properly?

Thanks a lot for your help, 

Anton Tremsin







-- 
 
Anton S. Tremsin, Ph.D.
Space Sciences Laboratory
University of California at Berkeley
Berkeley, CA 94720
Tel: (510) 642 4554
 
 
_______________________________________________
Winpcap-users mailing list
Winpcap-users at winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
  

 

 

 

 
 
_______________________________________________
Winpcap-users mailing list
Winpcap-users at winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
  

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winpcap.org/pipermail/winpcap-users/attachments/20110221/2950a561/attachment-0001.html>


More information about the Winpcap-users mailing list