[Winpcap-users] Packet random access using file seek
pat.marion at kitware.com
Mon Apr 22 03:51:27 PDT 2013
I am using libpcap on macosx/linux and winpcap for Windows targets. My
application reads packets stored in save files using the functions:
I am trying to implement packet random access, for example, open the file
and read packets 100 thru 200. My strategy has been to open the file once
and loop over each packet, and record the file position of certain packets
of interest using ftell. Later, I can skip directly to these packets using
fseek. (actually, my code uses fgetpos/fsetpos for large file support)
I found that my code works on macosx and linux but not Windows. I found
winpcap documentation that says pcap_file() is deprecated in
so I switched to use pcap_fopen_offline() and pass my own file pointer.
This works, but seeking on the file pointer using ftell/fseek does not
work. For example, on linux ftell() will return the offset 24 after
pcap_fopen_offline(), while on Windows the returned file offset is 4096.
So it appears that my plan to use file seeking may not be possible on
Windows. I am using the winpcap 4.1.2 development package and dll.
Gianluca, I found a relevant email thread here:
It seems that you were prepared to go into some more detail, but then the
thread ended before you did so :-) Do you have any advice? Is there a
technique I could use to seek to packets of interest in a save file?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Winpcap-users