# mplane

> mPlane nodeJS implementation

Latest version **0.7.9** (published 2015-09-18) · BSD license · 0 weekly downloads

## Install

```sh
npm install mplane
pnpm add mplane
yarn add mplane
bun add mplane
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.9 |
| Published | 2015-09-18 |
| First published | 2014-04-15 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | fabrizio.invernizzi@telecomitalia.it |
| Maintainers | finvernizzi |
| Keywords | mPlane, measurement |

## Links

- npm: https://www.npmjs.com/package/mplane
- Repository: https://github.com/finvernizzi/mplane
- Issues: https://github.com/finvernizzi/mplane/issues
- npm.io page: https://npm.io/package/mplane

## Dependencies (7)

- [fs](https://npm.io/package/fs.md) >=0.0.0
- [url](https://npm.io/package/url.md) >=0.7.9
- [cron](https://npm.io/package/cron.md) >=1.0.4
- [sha1](https://npm.io/package/sha1.md) >=0.1.1
- [util](https://npm.io/package/util.md) >=0.10.0
- [lodash](https://npm.io/package/lodash.md) >=2.4.0
- [sync-request](https://npm.io/package/sync-request.md) >=2.0.1

## Recent versions

- 0.7.9 (latest) — 2015-09-18
- 0.7.8 — 2015-08-04
- 0.7.7 — 2015-08-03
- 0.7.6 — 2015-07-31
- 0.7.4 — 2015-07-31
- 0.7.3 — 2015-07-31
- 0.7.2 — 2015-07-31
- 0.7.1 — 2015-05-19
- 0.6.14 — 2015-05-19
- 0.6.13 — 2015-05-19
- 0.6.12 — 2015-05-19
- 0.6.11 — 2015-05-19
- 0.6.10 — 2015-05-19
- 0.6.9 — 2015-05-19
- 0.6.8 — 2015-05-19
- … 20 more at https://npm.io/package/mplane/versions

## README

[![mPlane](http://www.ict-mplane.eu/sites/default/files//public/mplane_final_256x_0.png)](http://www.ict-mplane.eu/)

#mPlane nodeJS reference library 
[![](https://travis-ci.org/finvernizzi/mplane.svg)](https://travis-ci.org/finvernizzi/mplane)


This is the [mPlane](http://www.ict-mplane.eu/) nodejs library. 
The architecture and software structure is freely inspired by [mPlane reference implementation](http://fp7mplane.github.io/protocol-ri/) written in python by Brian Trammell <brian@trammell.ch>.


#Installation

`npm install mplane`

#Usage example
In this example we set a capability for a probe. 

```javascript
var mplane = require('mplane');

var MY_IP="192.168.0.1";

// Initialize available primitives from a registry
// Can be any valid URL or local file
mplane.Element.initialize_registry("ict-mplane.eu/registry/demo");

// Create a new Capability object
var probeCapability = new mplane.Capability();
// Set time constraints
probeCapability.set_when("now ... future / 1s");

// Add parameters with constraints
probeCapability.add_parameter({
    type:"destination.ip4",
    constraints: "192.168.0.0/16"
}).add_parameter({
        type:"source.ip4",
        constraints:MY_IP
});

// Results
probeCapability.add_result_column("delay.twoway");

// Some metadata
probeCapability.set_metadata_value("System_type","Just a TEST")
    .set_metadata_value("System_version","0.1a")
    .set_metadata_value("System_ID","Pinger").update_token();
// A label to identify the capability
probeCapability.set_label("This_is_a_pinger");


```

#Interaction with the RI
The mPlane Reference Implementation, written in python, can be find [here](http://fp7mplane.github.io/protocol-ri/).
In order to correctly interact with any component using the RI messages formats, two method have been exposed in the library, to decode messages generated by the RI and to send messages to a RI component.

##from_dict
This is a global method exposed in the mplane library. It sould be used to import any raw message received from an mPlane RI component.
It will generate an mplane object of the type contained in the message.
In the following example the data received as a body of an HTTP communication is imported in an mPlane object.

```javascript
var result = mplane.from_dict(body);
```

## to_dict
This method, defined for any mPlane information element, should be used before sending data to a RI component.
The following example, shows how the pinger capability defined in the above probe example be transformed in a standard mPlane message. 

```javascript
/* serialize the capability in an mPlane RI message*/
var RIprobeCapability = probeCapability.to_dict();

/* Shows the serialized capability*/
console.log(RIprobeCapability);
```

This is the output of the above example

```json
{
    "capability": "measure",
    "label": "This_is_a_pinger",
    "metadata": {
        "System_type": "Just a TEST",
        "System_version": "0.1a",
        "System_ID": "Pinger"
    },
    "link": "",
    "token": "ead75d3d198ce8f45ae371246da15fd89d05de24",
    "when": "now ... future / 1s",
    "resultvalues": [],
    "results": [
        "delay.twoway"
    ],
    "parameters": {
        "destination.ip4": "192.168.0.0/16",
        "source.ip4": "192.168.0.1"
    }
}
```


#Transport

The base mPlane library implements the mPlane Information Model elements that can be used to build messages to be carried on top of any protocol of choice (SSH, HTTP,...).
A nodejs HTTPS API has been implemented for basic usage (create and read elements) and can be find [here](https://github.com/finvernizzi/mplane_http_transport.git).

#EXAMPLES

## Supervisor
A complete supervisor implementation written in javascript is available [here](https://github.com/finvernizzi/supervisor).


## Reasoner
A reasoner written for DEMO purpouses is available [here](https://github.com/finvernizzi/reasoner)

## Probe
A probe implementing ping, traceroute and HTTP download delay is available [here](https://github.com/finvernizzi/mplane_probe)

#Documentation
Please refer to the API reference [mPlane nodejs API](http://finvernizzi.github.io/mplane/)

#Release Notes

You can find release notes [here](https://github.com/finvernizzi/mplane/blob/master/release_notes.md)

#LICENSE
This software is released under the [BSD](https://en.wikipedia.org/wiki/BSD_licenses#2-clause_license_.28.22Simplified_BSD_License.22_or_.22FreeBSD_License.22.29) license.

---
_Source: https://npm.io/package/mplane · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
