Projecte

General

Perfil

Actions

Ubus » Historial » Revisió 26

« Anterior | Revisió 26/31 (diferencies) | Següent »
Roger Pueyo Centelles, 03-07-2014 12:01


Ubus

The Network Characterization daemon (NCd) uses Ubus (the OpenWrt micro bus architecture) to communicate with the Network Characterization user interface and with other daemons and applications. This page documents the ubus namespace of the NC, with the available procedures and several examples.

The NCd can provide information about the local node or about remote nodes. Some of the data are specific to the NCd, while others can be obtained from other local Ubus interfaces (netifd, rpcd, etc.). The NCd acts as a relay to the local Ubus, but also to remote Ubus instances. By doing so, most of the data processing is left on the NCui side, which is run on Javascript code by the user's browser. This strategy reduces the load on the network nodes, usually low-end embedded devices with limited memory and processing resources.

NCd ubus namespace and procedures summary

The NCd, once registered to the Ubus daemon, provides the following procedures:

Local node ID

Each node running the NC has its unique ID that identifies it on the network.

Path Procedure Signature Description
ncd local { } Get the unique id of the local node

 

List all nodes

List all the known or discovered nodes in the network.

Path Procedure Signature Description
ncd listnodes { } Get a list with all the nodes in the network

 

Neighbour nodes list

List the neighbours of the local node (i.e.: directly connected either via wire or wireless).

Path Procedure Signature Description
ncd neighbours { } Get a list with the neighbours of the local node

 

NCd-specific information

Path Procedure Signature Description
ncd version { } Get the version of the NCd

 

NC-specific node information

The NCd can provide the following procedures regarding other nodes in the network running the NCd:

Path Procedure Signature Description
ncd.nodeid.location.name get { } Get the position (name or description) where the node defined by nodeid is located
ncd.nodeid.location.name get { "location" : "Location name or description" } Get the position (name or description) where the node defined by nodeid is located
ncd.nodeid.location.coordinates get { } Get the position (latitude and longitude coordinates) where the node defined by nodeid is located
ncd.nodeid.location.coordinates set { "coordinates" : [ "lat", "lon" ] } Set the position (latitude and longitude coordinates) where the node defined by nodeid is located

² Replace nodeid by the node's unique id or by local to request information about the local node
 

Ubus relay via NC

The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered remotely (like netifd, rpcd, etc.).

Path Procedure Signature Description
ncd.nodeid.relay.daemon.path ² procedure { "daemon.path procedure signature" } Get the unique id of the node defined by nodeid

² Replace nodeid by the node's unique id
 

See the examples below to get a clear idea of how it works.

Usage examples

ncd local id

Request:

ubus call ncd local { }

Response:

{ "id" : "node016" }

 

ncd listnodes

Request:

ubus call ncd listnodes { }

Response:

{ "nodes" : [ "node011", "node016", "node400", "node094", "node017", "node104", "node105", "node106", "node107" ] }

 

ncd neighbours

Request:

ubus call ncd neighbours { }

Response:

{ "nodes" : [ "node011", "node400" ] }

 

ncd local node neighbours

Request:

ubus call ncd.local neighbours { }

or, equivalently if the local node's unique id is "node016":

ubus call ncd.node016 neighbours { }

Response:

{ "nodes" : [ "node011", "node400" ] }

 

ncd remote node neighbours

Request:

ubus call ncd.node011 neighbours { }

Response:

{ "nodes" : [ "node094", "node400" ] }

 

ncd local node link devices

Request:

ubus call ncd.local linkdevices { "nodes" : [ "node011", "node400" ] }

or, equivalently if the local node's unique id is "node016":

ubus call ncd.node016 linkdevices { "nodes" : [ "node011", "node400" ] }

Response:

{
  "links": [
    {
      "node011": [
        "eth0.12",
        "wlan0" 
      ]
    },
    {
      "node400": [
        "wlan0" 
      ]
    }
  ]
}

 

ncd remote node link devices

Request:

ubus call ncd.node011 linkdevices { "nodes" : [ "node016", "node094", "node400" ] }

Response:

{
  "links": [
    {
      "node016": [
        "wlan0" 
      ]
    },
    {
      "node094": [
        "wlan1" 
      ]
    },
    {
      "node400": [
        "wlan0",
        "wlan1" 
      ]
    }
  ]
}

 

ncd local location name get

Request:

ubus call ncd.local.location.name get { }

or, equivalently if the local node's unique id is "node016":

ubus call ncd.node016.location.name get { }

Response:

{ "name" : [ "Narrow Street 16, Faketown" ] }

 

ncd local position name set

Request:

ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }

or, equivalently if the local node's unique id is "node016":

ubus call ncd.node016.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }

Response:

{ ] }

 

ncd local position coordinates get

Request:

ubus call ncd.local.location.coordinates get { }

or, equivalently if the local node's unique id is "node016":

ubus call ncd.node016.location.coordinates get { }

Response:

{ "coordinates" : [ "42.34796", "3.11036" ] }

 

ncd local position coordinates set

Request:

ubus call ncd.local.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }

or, equivalently if the local node's unique id is "node016":

ubus call ncd.node016.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }

Response:

{ }

 

ncd local ubus relay

Request:

ubus call ncd.local.relay.iwinfo devices { }

Response:

{
    "devices": [
        "wlan1",
        "wlan0",
        "wlan0ap" 
    ]
}
 

 

ubus call iwinfo devices

More examples

There is an example of the communication process between the CNAd and the CNAui via ubus here.

Actualitzat per Roger Pueyo Centelles fa més de 10 anys · 26 revisions