layer2
v0.2.0
Published
A streaming API for the data link layer
Downloads
15
Maintainers
Readme
Layer2
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 = require('layer2');
var capture = new layer2.capture.Live('en0', {monitor: true});
var decoder = new layer2.Decoder();
capture // Stream of buffers (frames' raw bytes).
.pipe(decoder) // Stream of objects (decoded frames).
.on('data', function (frame) { console.log(JSON.stringify(frame)); });
Installation
$ npm install layer2
layer2
depends on libpcap. Note that you might also need to run live
captures as root.
Documentation
API docs and several examples are available.
Benchmarks
layer2
is built with both ease of use and performance in mind. This means you
can benefit from the productivity gains of writing JavaScript and still handle
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
benchmarks page.
Tests
$ npm test
Some tests require an active internet connection.