Ubus » Historial » Revisió 17
Revisió 16 (Roger Pueyo Centelles, 03-07-2014 11:33) → Revisió 17/31 (Roger Pueyo Centelles, 03-07-2014 11:33)
h1. Ubus The [[NCd|Network Characterization daemon]] (NCd) uses "Ubus":http://wiki.openwrt.org/doc/techref/ubus (the "OpenWrt":http://www.openwrt.org micro bus architecture) to communicate with the [[NCui|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. h2. NCd ubus namespace and procedures summary The NCd, once registered to the Ubus daemon, provides the following procedures: h3. Local Local-only node ID information Each node running the NC has its unique ID that identifies it on the network. |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd | [[Ubus#ncd-local-id|local]] | { } | Get the unique id of the local node | h3. NC-specific node information The NCd can provide the following procedures regarding other nodes in the network running the NCd: |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.nodeid ² | [[Ubus#ncd-local-neighbours|neighbours]] | { } | List all the neighbours of the node defined by _nodeid_ | |ncd.nodeid | [[Ubus#ncd-local-node-link-devices|linkdevices]] | { "nodes": ["nodeid1", "nodeid2", ...] } | List the devices used to link the node defined by _nodeid_ to other nodes | |ncd.nodeid.location.name | [[Ubus#ncd-local-location-name-get|get]] | { } | Get the position (name or description) where the node defined by _nodeid_ is located | |ncd.nodeid.location.name | [[Ubus|get]] | { "location" : "Location name or description" } | Get the position (name or description) where the node defined by _nodeid_ is located | |ncd.nodeid.location.coordinates | [[Ubus|get]] | { } | Get the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located | |ncd.nodeid.location.coordinates | [[Ubus|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 h3. 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 | |\4=. | |ncd.nodeid.relay.daemon.path ² | [[Ubus#ncd-remote-ubus-relay|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. h2. Usage examples h3. ncd local id Request: @ubus call ncd.local id { }@ Response: @{ "id" : "node016" }@ h3. 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" ] }@ h3. ncd remote node neighbours Request: @ubus call ncd.node011 neighbours { }@ Response: @{ "nodes" : [ "node094", "node400" ] }@ h3. 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: <pre> { "links": [ { "node011": [ "eth0.12", "wlan0" ] }, { "node400": [ "wlan0" ] } ] } </pre> h3. ncd remote node link devices Request: @ubus call ncd.node011 linkdevices { "nodes" : [ "node016", "node094", "node400" ] }@ Response: <pre> { "links": [ { "node016": [ "wlan0" ] }, { "node094": [ "wlan1" ] }, { "node400": [ "wlan0", "wlan1" ] } ] } </pre> h3. 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" ] }@ h3. 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: @{ ] }@ h3. 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" ] }@ h3. 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: @{ }@ h3. ncd local ubus relay Request: @ubus call ncd.local.relay.iwinfo devices { }@ Response: <pre> { "devices": [ "wlan1", "wlan0", "wlan0ap" ] } </pre> ubus call iwinfo devices h2. More examples There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].