[Winpcap-users] PacketReceivePacket error?

Charlie Heitzig cheitzig at gmail.com
Sun Jan 23 09:43:18 PST 2011


Looking for some thoughts on trouble-shooting a problem. First though, I'm a
bit of a newbie to Winpcap.

For background, I have a C program that is failing with a
PacketReceivePacket error under Cygwin on Windows 7 x64. To better
illustrate the problem, I built a debug / test harness around one of the
Winpcap code samples-- basic_dump_ex.c (full modified version attached).

I modified the last bit of code to loop and re-run pcap_next_ex() after an
error:

>  while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0){
>
> if(res == 0)
>  /* Timeout elapsed */
> continue;
>
>  /* convert the timestamp to readable format */
> local_tv_sec = header->ts.tv_sec;
>  ltime=localtime(&local_tv_sec);
> strftime( timestr, sizeof timestr, "%H:%M:%S", ltime);
>
> printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len);
> }
>
> if(res == -1){
> printf("Error reading the packets: %s\n", pcap_geterr(adhandle));
>  /* Try the next packet one more time */
> if((res = pcap_next_ex( adhandle, &header, &pkt_data)) == -1)
> printf("Second error reading the packets: %s\n", pcap_geterr(adhandle));
>  return -1;
> }


But res never again returns a non-negative number as far as I can tell (even
if I loop endlessly, continuously trying to get another packet.

So that's my question, I guess-- is any error recovery possible after
receiving a PacketReceivePacket error? Any advice on what
a PacketReceivePacket error means-- bad NIC, bad router, cosmic rays? If I
kill the program and re-start immediately, everything runs again for
somewhere between 2 and 36 hours or so.

Any thoughts would be appreciated!

Best,

--> C
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winpcap.org/pipermail/winpcap-users/attachments/20110123/9e6bdc96/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: basic_dump_ex.cjh.c
Type: text/x-csrc
Size: 3541 bytes
Desc: not available
URL: <http://www.winpcap.org/pipermail/winpcap-users/attachments/20110123/9e6bdc96/attachment.c>


More information about the Winpcap-users mailing list