This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Decode of libpcap file.

0

I have written a program to decode and use the capture file from wireshark in real time.

It failed when I moved it to a different computer since I had a check for valid header which was actually looking for my IP(I thought it was just a magic number)

Problem is, I read and followed your Global Header second and Record header section in the doc, but you did not outline the format of the actual data packet. Thus I was not aware the first few bytes were destination then source then some other stuff I have no idea about. In total 54 bytes of something from what I can tell. Where can I find the spec on those 54 bytes of the packet?

[email protected]

Many thanks Glen Lalonde www.binarysearchtree.com

asked 24 Jul '11, 19:20

codewarrior's gravatar image

codewarrior
1111
accept rate: 0%


2 Answers:

1

The easiest way to read a libpcap file is, not surprisigly, to use libpcap (or, on Windows, WinPcap).

However, that won't help you understand the format of the data packet. The data packet is just raw packet data, possibly preceded by a pseudo-header; the link-layer type value returned by pcap_datalink() indicates what the pseudo-header, if any, and the link-layer header format for the packet are - see the link-layer header types page on the tcpdump.org Web site for the description of the types. For example, a type value of 1 (DLT_EN10MB as returned by pcap_datalink()) indicates that the packets are Ethernet packets, beginning with an Ethernet header; the link-layer header types page links to a page for the IEEE 802.3 specifications, which describes the Ethernet link-layer header (which has 6 octets of destination address, 6 octets of source address, and 2 octets of a type/length field - that field is in network byte order, and has the value 0x0800 for IPv4 packets, for example).

answered 24 Jul '11, 23:16

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196
accept rate: 19%

Using what you said I found this page which had all the details at the level I needed. Many thanks. Page: http://en.wikipedia.org/wiki/EtherType

(25 Jul '11, 07:43) codewarrior

0

Hi, libpacps file format can be found [here] the development version of Wireshark uses pcapng as the default file format.

answered 24 Jul '11, 21:20

Anders's gravatar image

Anders ♦
4.6k952
accept rate: 17%

http://wiki.wireshark.org/Development/LibpcapFileFormat

(24 Jul '11, 21:21) Anders ♦

That was the document I was already reading, it does not indicate enough detail about the actual packet, it just details the two headers.

(25 Jul '11, 07:10) codewarrior