Ubus » Historial » Revisió 9
Revisió 8 (Roger Pueyo Centelles, 02-06-2014 14:00) → Revisió 9/31 (Roger Pueyo Centelles, 02-06-2014 14:20)
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. h2. NCd ubus namespace and procedures summary h3. Local node information |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.local | [[Ubus#ncd-id|id]] | { } | Get the unique id of the local node node. | |ncd.local | [[Ubus#ncd-board|board]] | { } | Get the system information of the local node (model, CPU, OpenWrt version, hostname, kernel version, etc.) ¹| |ncd.local | [[Ubus#ncd-info|info]] | { } | Get the system status of the local node (uptime, load, memory, etc.) ²| |ncd.local | [[Ubus#ncd-neighbours|neighbours]] | { } | List all the neighbours of the local a specified node using its unique id. | |ncd.local.position | [[Ubus|get]] | { } | Get the position (latitude and longitude) of the nodes nodes. | |ncd.local.position | [[Ubus|set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude) of the node node. | ¹ It is the same information provided by OpenWrt's _system board_ Ubus call ² ¹ It is the same information provided by OpenWrt's _system info_ Ubus call h3. Link-related information |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.link | link | { "nodes": [ "id_1", "id_2" ] } | Get the details of the link(s) between nodes id_1 and id_2 id_2. | | | | | | h3. Remote node information |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.nodeid ³ | [[Ubus#ncd-board|board]] | { } | Get the system information of the node defined by _nodeid_ (model, CPU, OpenWrt version, hostname, kernel version, etc.) ¹ |ncd.nodeid ³ | [[Ubus#ncd-info|info]] | { } | Get the system status of the node defined by _nodeid_ (uptime, load, memory, etc.) ²| |ncd.nodeid ³ | [[Ubus#ncd-neighbours|neighbours]] | { } | List all the neighbours of the node defined by _nodeid_ | |ncd.nodeid.position ³ | [[Ubus|get]] | { } | Get the position (latitude and longitude) of the node defined by _nodeid_ | |ncd.nodeid.position ³ | [[Ubus|set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude) of the node defined by _nodeid_ | ¹ It is the same information provided by OpenWrt's _system board_ Ubus call ² It is the same information provided by OpenWrt's _system info_ Ubus call ³ Replace _nodeid_ by the node's unique id h2. Usage examples h3. ncd id Request: @ubus call ncd id { }@ Response: @{ "id" : "node_id" }@ h3. ncd board Request: @ubus call ncd board { }@ Response: <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 info Request: @ubus call ncd info { }@ Response: <pre> { "uptime": 9425, "localtime": 1401464813, "load": [ 3264, 10592, 7648 ], "memory": { "total": 29741056, "free": 5259264, "shared": 0, "buffered": 2297856 }, "swap": { "total": 0, "free": 0 } } </pre> h3. ncd.node.neighbours Request: @ncd.node.neighbours { "node" : "id" }@ Response: @{ "nodes" : [ "id_1", "id_2", "id_3" ] }@ h3. ncd.node.info Request: @ncd.node.info { "node" : "id" }@ Response: <pre> { "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": [ "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" } ] } }, "br-lan": { "type": "bridge", "ifname": [ "eth0" ], "addressing": { "ipv4": [ { "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> h2. More examples There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].