kad-telemetry-js
v0.1.9
Published
framework for analyzing network behavior and performance for kad
Downloads
24
Maintainers
Readme
Kad Telemetry
Framework for analyzing network behavior and performance for Kad.
Installation
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.
transport.telemetry.getProfile(contact);
// Example profile:
// This node has a ping of 54ms and has responded to 5 of 6 requests
// { metrics: { latency: 54, availability: [6, 5] } }