layer2 leverages Node.js' built-in streams to provide an intuitive and
efficient interface to the data link layer. It supports frame capture
and injection, and provides decoders for various link types.
var layer2 = ;var capture = 'en0' monitor: true;var decoder = ;capture // Stream of buffers (frames' raw bytes).// Stream of objects (decoded frames).;
$ npm install layer2
layer2 depends on libpcap. Note that you might also need to run live
captures as root.
layer2 is built with both ease of use and performance in mind. This means you
throughput rates of several hundred thousand frames per second (upwards of a
million when streaming raw frames). You can read more about this on the
$ npm test
Some tests require an active internet connection.