1.0.1 • Published 4 years ago

pcap-writer v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

pcap-writer

A simple pcap writer based on the core of node-pcap-writer, from Harsh Raval.

Example

Initialize:

const pcapw = require('pcpa-writer');

const pcapWriter = pcapw.createPcapWriter('file.pcap', 1500, 105);

This will also write global header. Then for writing data packets:

pcapWriter.writePacket(packet, timestamp);

Here packet is a Buffer object of Node JS containig data of packet. Timestamp needs to be in usec, if not set the packet will be written with the current relative timestamp.

And then finally close it:

pcapWriter.close();

This will close the file write stream so the file can be usable.

If you like, you can also add a callback function, to be called as soon as the writer finishes writing the last packet:

pcapWriter.close( (filename, elapsedTime) => {
    
    //your code here

} );

License

MIT