layer2

A streaming API for the data link layer


Keywords
wifi, 802.11, ethernet, mac, frame, packet, stream, monitor, capture, injection, pcap, wireshark, tcpdump
License
MIT
Install
npm install layer2@0.2.0

Documentation

Layer2 Build Status

var layer2 = require('layer2');

layer2.createInterfaceSniffer('eth0')
  .on('pdu', function (pdu) {
    var frame = pdu.frame.Ethernet2;
    var src = frame.srcAddr;
    var dst = frame.dstAddr;
    console.log(src + ' -> ' + dst + ' [' + pdu.size + ']');
  });

Installation

You will need a compiler with C++11 support, then if you already have avro>=1.7 and tins>=3.2 installed:

$ npm install layer2

Otherwise, you can build both dependencies along with this package by running:

$ git clone --recursive git@github.com:mtth/layer2.git
$ cd layer2
$ npm run install-all
$ export LD_LIBRARY_PATH="$(pwd)/etc/deps/libtins/build/lib:$(pwd)/etc/deps/avro/lang/c++/build:$LD_LIBRARY_PATH"

Note the last step required to find the libraries at runtime (alternatively you could install both dependencies globally).

Documentation