A simple PCAP file writer for node.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
.gitignore
LICENSE
README.md
index.js
package.json

README.md

node-pcap-writer

A simple pcap writer that helps you to create pcap file from captured packet data in Node JS.

Background

There are reader and parser packages available for pcap in Node JS but not writer so decided to write onde that can help others.

Example

Initialize:

var PcapWriter = require('../index');
...
var pcapWriter = new PcapWriter('./test.pcap', 1500, 105);
...

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

...
pcapWriter.writePacket(packetDataBuffer, timestamp)
...

Here packetDataBuffer is Buffer object of Node JS containig data of packet. Timestamp needs to be in seconds. And then finally close it:

...
pcapWriter.close();
...

This will close the file write stream so the file can be usable. Don't forget to close it when you are done writing all packets.

License

MIT