layer2

0.2.0 • Public • Published

Layer2 Build Status

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.

Package Sidebar

Install

npm i layer2

Weekly Downloads

12

Version

0.2.0

License

MIT

Last publish

Collaborators

  • mtth