Ubus » Historial » Revisió 10
Revisió 9 (Roger Pueyo Centelles, 02-06-2014 14:20) → Revisió 10/31 (Roger Pueyo Centelles, 02-06-2014 17:36)
h1. Ubus The [[NCd|Network Characterization daemon]] (NCd) uses "Ubus":http://wiki.openwrt.org/doc/techref/ubus "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. h2. NCd ubus namespace and procedures summary h3. NC-specific local Local node information The NCd, once registered to the Ubus daemon, provides the following procedures. |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.local | [[Ubus#ncd-local-id|id]] [[Ubus#ncd-id|id]] | { } | Get the unique id of the local node | |ncd.local | [[Ubus#ncd-board|board]] | [[Ubus#ncd-local-neighbours|neighbours]] | { } | List all Get the neighbours system information of the local node | (model, CPU, OpenWrt version, hostname, kernel version, etc.) ¹| |ncd.local.location.name |ncd.local | [[Ubus|ncd-local-location-name-get]] [[Ubus#ncd-info|info]] | { } | Get the position (name or description) where system status of the local node is located | (uptime, load, memory, etc.) ²| |ncd.local.location.name |ncd.local | [[Ubus|ncd-local-location-name-set]] [[Ubus#ncd-neighbours|neighbours]] | { "location" : "string" } | Get List all the position (name or description) where neighbours of the local node is located | |ncd.local.location.coordinates |ncd.local.position | [[Ubus|ncd-local-location-coordinates-get]] [[Ubus|get]] | { } | Get the position (latitude and longitude coordinates) where longitude) of the node is located nodes | |ncd.local.location.coordinates |ncd.local.position | [[Ubus|ncd-local-location-coordinates-set]] [[Ubus|set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude coordinates) where longitude) of the node is located | h3. ¹ It is the same information provided by OpenWrt's _system board_ Ubus local relay The NCd call ² It is able to relay Ubus calls from the NCui to other same information provided by OpenWrt's _system info_ Ubus instances registered locally (like netifd, rpcd, etc.). call h3. Link-related information |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.local.relay.daemon.path |ncd.link | [[Ubus#ncd-local-ubus-relay|procedure]] link | { "daemon.path procedure signature" "nodes": [ "id_1", "id_2" ] } | Get the unique id details of the local node link(s) between nodes id_1 and id_2 | | | | | | See the example below to get a clear idea of how it works. h3. NC-specific remote Remote 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-neighbours|neighbours]] [[Ubus#ncd-board|board]] | { } | List all Get the neighbours system information of the node defined by _nodeid_ | (model, CPU, OpenWrt version, hostname, kernel version, etc.) ¹ |ncd.local.location.name |ncd.nodeid ³ | [[Ubus|get]] [[Ubus#ncd-info|info]] | { } | Get the position (name or description) where system status of the node defined by _nodeid_ is located | (uptime, load, memory, etc.) ²| |ncd.local.location.name |ncd.nodeid ³ | [[Ubus|get]] [[Ubus#ncd-neighbours|neighbours]] | { "location" : "Location name or description" } | Get List all the position (name or description) where neighbours of the node defined by _nodeid_ is located | |ncd.local.location.coordinates |ncd.nodeid.position ³ | [[Ubus|get]] | { } | Get the position (latitude and longitude coordinates) where longitude) of the node defined by _nodeid_ is located | |ncd.local.location.coordinates |ncd.nodeid.position ³ | [[Ubus|set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude coordinates) where longitude) of the node defined by _nodeid_ is located | ¹ Replace _nodeid_ It is the same information provided by the node's unique id h3. OpenWrt's _system board_ Ubus remote relay The NCd call ² It is able to relay Ubus calls from the NCui to other same information provided by OpenWrt's _system info_ Ubus instances registered remotely (like netifd, rpcd, etc.). |_.Path |_.Procedure |_.Signature |_.Description | call |\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 h2. Usage examples h3. ncd local id Request: @ubus call ncd.local ncd id { }@ Response: @{ "id" : "node_id" }@ h3. ncd local neighbours board Request: @ubus call ncd.local neighbours ncd board { }@ Response: @{ "nodes" : [ "node011", "node400" ] }@ <pre> { "kernel": "3.10.36", "hostname": "qMp-6a32", "system": "Qualcomm Atheros QCA9533 rev 1", "model": "TP-Link TL-WR841N\/ND v9", "release": { "distribution": "OpenWrt", "version": "Bleeding Edge", "revision": "r40831", "codename": "barrier_breaker", "target": "ar71xx\/generic", "description": "OpenWrt Barrier Breaker r40831" } } </pre> h3. ncd local location name get info Request: @ubus call ncd.local.location.name get ncd info { }@ Response: @{ "coordinates" : <pre> { "uptime": 9425, "localtime": 1401464813, "load": [ "Narrow Street 16, Faketown" ] }@ 3264, 10592, 7648 ], "memory": { "total": 29741056, "free": 5259264, "shared": 0, "buffered": 2297856 }, "swap": { "total": 0, "free": 0 } } </pre> h3. ncd local position coordinates get ncd.node.neighbours Request: @ubus call ncd.local.location.coordinates get @ncd.node.neighbours { "node" : "id" }@ Response: @{ "coordinates" "nodes" : [ "42.34796", "3.11036" "id_1", "id_2", "id_3" ] }@ h3. ncd local position name set ncd.node.info Request: @ubus call ncd.local.location.name set @ncd.node.info { "name" "node" : [ "Narrow Street 16, Faketown (rooftop)" "id" }@ Response: @{ ] }@ h3. ncd local position coordinates set Request: @ubus call ncd.local.position.coordinates set <pre> { "coordinates" : "nodeinfo": { "id": "node016", "name": "FT-NarrowStreet1616-NSLM5", "hardware": { "model": "Ubiquiti Nanostation M", "type": "Atheros AR7241 rev 1", "cpu": "MIPS 24Kc V7.4", "ram": "29312" }, "software": { "os": { "name": "OpenWrt", "version": 12.09, "codename": "Attitude Adjustment", "date": "2013-09-06", "revision": "r38347" }, "qMp": { "version": "3.0-rc3", "codename": "Clearance", "date": 20140227, "revision": "d94713e", "branch": "master" }, "bmx6": { "revision": "bae36ab0", "version": 12, "branch": "master" }, "ncd": { "revision": "36aaed94", "version": 0.2, "branch": "dev" } }, "interfaces": { "physical": { "wired": { "eth0": { "mac": "DC:9F:DB:4F:A1:F6", "encap": "Ethernet", "mode": "100baseTX", "mtu": 1500 }, "eth1": { "mac": "DE:9F:DB:4F:A1:F6", "encap": "Ethernet", "mode": "down", "mtu": 1500 } }, "wireless": { "radio0": { "type": "mac80211", "mac": "DC:9F:DB:4E:A1:F6", "hwmode": "auto", "channel": 124, "country": "SP", "txpower": 17, "distance": 5000, "ht": [ "42.34796", "3.11036" "SHORT-GI-40", "RX-STBC1", "DSSS_CCK-40" ], "interfaces": { "wlan0": { "device": "radio0", "mode": "adhoc", "bssid": "02:CA:FF:EE:BA:BE", "ssid": "qMp-HWErmitaBellvitge16", "encryption": "open", "network": "lan", "ifname": "wlan0", "stations": { "dc:9f:db:34:17:b6": { "signal": [ -70, -74, -73 ], "avgsignal": [ -70, -74, -73 ], "txbitrate": "60.0 MBit/s MCS 9 40Mhz short GI", "rxbitrate": "81.0 MBit/s MCS 4 40Mhz" } } } } } } }, "virtual": { "lo": { "type": "loopback", "addressing": { "ipv4": [ { "ipaddr": "127.0.0.1", "netmask": "255.0.0.0" } ], "ipv6": [ { "ipaddr6": "::1/128", "scope": "host" } ] }@ Response: @{ }@ h3. ncd local ubus relay Request: @ubus call ncd.local.relay.iwinfo devices } }, "br-lan": { }@ Response: <pre> "type": "bridge", "ifname": [ "eth0" ], "addressing": { "devices": "ipv4": [ "wlan1", "wlan0", "wlan0ap" { "ipaddr": "10.1.32.33", "netmask": "255.255.255.224" }, { "ipaddr": "169.254.246.1", "netmask": "255.255.255.248" } ], "ipv6": [ { "scope": "global", "ipaddr6": "fd00:1714:1714:a1f6::1/64" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" } ] } }, "br-lan.12": { "type": "vlan", "ifname": [ "eth0" ], "addressing": { "ipv6": [ { "scope": "global", "ipaddr6": "fd66:66:66:8:de9f:dbff:fe4f:a1f6/64" }, { "scope": "global", "ipaddr6": "fd02::dc9f:db4f:a1f6:0:112/128" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" } ] } }, "wlan0": { "type": "wireless", "ifname": "radio0", "addressing": { "ipv4": [ { "ipaddr": "169.254.246.1", "netmask": "255.255.255.248" }, { "ipaddr": "10.1.32.33", "netmask": "255.255.255.224" } ], "ipv6": [ { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64" }, { "scope": "global", "ipaddr6": "fd00:1714:1714:a1f6::1/64" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" } ] } }, "wlan0.12": { "type": "vlan", "ifname": "radio0", "addressing": { "ipv6": [ { "scope": "link", "ipaddr6": "fd66:66:66:a:de9f:dbff:fe4e:a1f6/64" }, { "scope": "global", "ipaddr6": "fd02::dc9f:db4f:a1f6:0:212/128" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64" } ] } }, "bmxtmain": { "type": "tunnel6", "addressing": { "ipv4": [ { "ipaddr": "10.1.32.33", "netmask": "255.255.255.224" } ], "ipv6": [ { "scope": "global", "ipaddr6": "2012:0:0:a1f6::1/128" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" } ] } } } } } } </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]].