npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pcap-scribe

v1.2.2

Published

pcap writer using libpcap

Downloads

11

Readme

Capturing packets live into file using nodejs and libpcap

pcap-scribe

Build Status Coverage Status

Installation

You will need libpcap installed. Most OSX machines seem to have it. All major Linux distributions have it available either by default or with a package like libpcap-dev.

The easiest way to get pcap-scribe and its tools is with npm:

npm install pcap-scribe

If you want to hack on the source code, you can get it from github. Clone the repo like this:

git clone https://github.com/harrydevnull/pcap-scribe

To compile the native code bindings, do this:

cd pcap-scribe
npm install 

Assuming it built without errors, you should be able to run the examples and then write your own packet capture programs.

Starting a capture session

To start a capture session, call pcap.PcapDumpSession with an interface name and a pcap filter string:

var pcap = require("pcap-scribe"); 
    pcap_dump = new pcap.PcapDumpSession(interface, filter,bufferSize,pcap file name ,false,Number of packets to be captured);
    
    pcap_dump.on('pcap_write_complete_async',function(message){
            console.log("done.....",message);
    });

    pcap_dump.on('pcap_write_error',function(message){
            console.log("pcap_write_error.....",message);
    });

    pcap_dump.startAsyncCapture();

    //eg: pcap_dump = new pcap.PcapDumpSession('en0', "ip proto \\tcp",10*1024*1024,"tmp95.pcap",false,5);

interface is the name of the interface on which to capture packets. If passed an empty string, libpcap will try to pick a "default" interface, which is often just the first one in some list and not what you want.

filter is a pcap filter expression, see pcap-filter(7) for more information. An empty string will capture all packets visible on the interface.

Note that pcap-scribe always opens the interface in promiscuous mode, which generally requires running as root.

PcapDumpSession is an EventEmitter that emits a packet event. The only argument to the callback will be a Buffer object with the raw bytes returned by libpcap. It emits two more events pcap_write_complete_async when the write to file is complete and pcap_write_error in case there is an error.