framework for analyzing network behavior and performance for kad

Usage no npm install needed!

<script type="module">
  import kadTelemetry from 'https://cdn.skypack.dev/kad-telemetry';


Kad Telemetry

Build Status Coverage Status NPM

Framework for analyzing network behavior and performance for Kad.


npm install kad-telemetry --save

Quick Start

Decorate your transport adapter.

// Import dependencies
var kad = require('kad');
var telemetry = require('kad-telemetry');

// Decorate your transport adapter
var TelemetryTransport = telemetry.TransportDecorator(kad.transports.UDP);

// Create your transport instance
var transport = new TelemetryTransport(contact, {
  telemetry: { filename: 'path/to/telemetry.data' }

You might also like to extend Kad's peer selection by scoring peers based on the collected metrics by decorating your router.

// Decorate the default router
var TelemetryRouter = telemetry.RouterDecorator(kad.Router);

// Create your router instance
var router = new TelemetryRouter({ transport: transport });

Then create your Kad node and party.

// Create your node
var dht = new kad.Node({
  router: router,
  transport: transport,
  storage: kad.storage.FS('...')

Once you have been connected to the network, you can lookup a node's profile.

// Example profile:
// This node has a ping of 54ms and has responded to 5 of 6 requests
//  { metrics: { latency: 54, availability: [6, 5] } }