How to use with pcap file
Since there is no documentation about how to parse a pcap file with this, I have to ask. The following code what I made from intuition is not working (runs but produces not output with a populated pcap file) obviously
const pcap = require('pcap');
const session = pcap.createOfflineSession('test.pcap','');
session.on('packet', (rawPacket) => console.log(pcap.decode.packet(rawPacket)));
Hi Silur,
Your intuition is correct. I was able to see decoded packets from a sample pcap file I have here using your code.
May be try with some other capture file? Not sure the decoder works on all formats yet.
I only got the JSON representation of the session object, even when my callback does not contain a decode function:
session.on('packet', (rawPacket) => console.log('HEY I GOT SOMETHING')));
Output:
PcapSession { is_live: false, device_name: '/home/silur/Desktop/test.pcap', filter: '', buffer_size: 0, outfile: '', is_monitor: false, link_type: 'LINKTYPE_ETHERNET', fd: 14, opened: true, buf: <Buffer 00 25 22 f0 05 a3 54 64 d9 d8 3c 34 08 00 45 20 01 45 9a 0c 40 00 33 11 fb c6 9f 99 50 64 c0 a8 00 0f 63 ac 0e 4b 01 31 40 28 00 00 db 88 50 f5 87 47 ... >, header: <Buffer e7 a7 44 57 6b 57 0a 00 53 01 00 00 53 01 00 00>, read_watcher: null, empty_reads: 0, packets_read: null, session: PcapSession {}, domain: Domain { domain: null, _events: { error: [Function] }, _eventsCount: 1, _maxListeners: undefined, members: [] }, _events: { packet: [ [Function] ] }, _eventsCount: 1, _maxListeners: undefined }