Hello, I am building an application to accept output messages(Ethernet packets) from ECU(Electronic Control unit) and display it on a GUI. The GUI is build using QT designer python and the packets from the ECU will be displayed in a Tree Widget. I am using socket program to bind with the ECU. I want to save these output in a .pcap format. Is it possible to save directly in .pcap format ? Are there any library to save the data directly ? Is there already a code implemented for this ? If yes, then how should i proceed further ? asked 10 May '15, 15:19 Praju |
3 Answers:
If your favorite language is a straightforward C derivative (C itself, C++, Objective-C), the library is called libpcap on UN*X and WinPcap on Windows; just use that. The API for writing capture files is a bit clumsy if you're not writing packets from a libpcap/WinPcap live capture or file you're reading with libpcap/WinPcap, you'd want to use NOTE: if the output messages you receive do not have Ethernet headers, you can't use If your favorite language isn't a straightforward C derivative (C#, the "C" at the beginning of the name nonwithstanding, is not a straightforward C derivative in the sense that I'm using it), see, for example, the "Wrapper libraries" section of the Wikipedia page for pcap for information about wrapper libraries for your language. With those languages, much of what I said above still applies, but the way you call those functions may be different than the way you do so from code written in straightforward C derivatives. In the case of Python, the Wikipedia page section lists python-libpcap and pcapy. Neither of them appear to have good online documentation, so I don't know whether either of them do a good job of supporting writing pcap files. answered 11 May '15, 14:06 Guy Harris ♦♦ edited 11 May '15, 14:11 |
The PCAP file format is a rather simple file format. It should be no problem finding a library for your favorite language, and/or file output routines can easily be written by hand as well. answered 11 May '15, 04:16 Jaap ♦ |
If you're using C/C++ and don't want to mess with libpcap/WinPcap API directly you can use a wrapper library that wraps that functionality and provides a more convenient multi-platform object-oriented C++ API. I wrote such a library: PcapPlusPlus answered 07 Jun '15, 21:54 seladb |
@jaap Thanks. I will look into it
If an answer has solved your issue, please accept the answer for the benefit of other users by clicking the checkmark icon next to the answer. Please read the FAQ for more information.
And incorrect file output routines can also be easily written by hand, so I'd suggest looking at using libpcap/WinPcap, or wrappers for them, unless there's a reason why you can't do that.