Ubus » Historial » Versió 8
Roger Pueyo Centelles, 02-06-2014 14:00
| 1 | 1 | Roger Pueyo Centelles | h1. Ubus |
|---|---|---|---|
| 2 | |||
| 3 | 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. |
||
| 4 | |||
| 5 | h2. NCd ubus namespace and procedures summary |
||
| 6 | |||
| 7 | 4 | Roger Pueyo Centelles | h3. Local node information |
| 8 | 1 | Roger Pueyo Centelles | |
| 9 | 4 | Roger Pueyo Centelles | |_.Path |_.Procedure |_.Signature |_.Description | |
| 10 | 1 | Roger Pueyo Centelles | |\4=. | |
| 11 | 6 | Roger Pueyo Centelles | |ncd.local | [[Ubus#ncd-id|id]] | { } | Get the unique id of the local node. | |
| 12 | |ncd.local | [[Ubus#ncd-board|board]] | { } | Get the system information of the local node (model, CPU, OpenWrt version, hostname, kernel version, etc.) ¹| |
||
| 13 | |ncd.local | [[Ubus#ncd-info|info]] | { } | Get the system status of the local node (uptime, load, memory, etc.) ²| |
||
| 14 | 8 | Roger Pueyo Centelles | |ncd.local | [[Ubus#ncd-neighbours|neighbours]] | { } | List all the neighbours of a specified node using its unique id. | |
| 15 | 7 | Roger Pueyo Centelles | |ncd.local.position | [[Ubus|get]] | { } | Get the position (latitude and longitude) of the nodes. | |
| 16 | 1 | Roger Pueyo Centelles | |ncd.local.position | [[Ubus|set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude) of the node. | |
| 17 | 4 | Roger Pueyo Centelles | |
| 18 | ¹ It is the same information provided by OpenWrt's _system board_ Ubus call |
||
| 19 | ¹ It is the same information provided by OpenWrt's _system info_ Ubus call |
||
| 20 | 1 | Roger Pueyo Centelles | |
| 21 | h3. Link-related information |
||
| 22 | |||
| 23 | |_.Path |_.Procedure |_.Signature |_.Description | |
||
| 24 | |\4=. | |
||
| 25 | |ncd.link | link | { "nodes": [ "id_1", "id_2" ] } | Get the details of the link(s) between nodes id_1 and id_2. | |
||
| 26 | | | | | | |
||
| 27 | |||
| 28 | h2. Usage examples |
||
| 29 | |||
| 30 | 5 | Roger Pueyo Centelles | h3. ncd id |
| 31 | 1 | Roger Pueyo Centelles | |
| 32 | Request: |
||
| 33 | 3 | Roger Pueyo Centelles | |
| 34 | 5 | Roger Pueyo Centelles | @ubus call ncd id { }@ |
| 35 | 1 | Roger Pueyo Centelles | |
| 36 | Response: |
||
| 37 | 3 | Roger Pueyo Centelles | |
| 38 | 1 | Roger Pueyo Centelles | @{ "id" : "node_id" }@ |
| 39 | |||
| 40 | |
||
| 41 | |||
| 42 | |||
| 43 | 5 | Roger Pueyo Centelles | |
| 44 | |||
| 45 | h3. ncd board |
||
| 46 | |||
| 47 | 1 | Roger Pueyo Centelles | Request: |
| 48 | |||
| 49 | 5 | Roger Pueyo Centelles | @ubus call ncd board { }@ |
| 50 | 1 | Roger Pueyo Centelles | |
| 51 | Response: |
||
| 52 | |||
| 53 | 5 | Roger Pueyo Centelles | <pre> |
| 54 | { |
||
| 55 | "kernel": "3.10.36", |
||
| 56 | "hostname": "qMp-6a32", |
||
| 57 | "system": "Qualcomm Atheros QCA9533 rev 1", |
||
| 58 | "model": "TP-Link TL-WR841N\/ND v9", |
||
| 59 | "release": { |
||
| 60 | "distribution": "OpenWrt", |
||
| 61 | "version": "Bleeding Edge", |
||
| 62 | "revision": "r40831", |
||
| 63 | "codename": "barrier_breaker", |
||
| 64 | "target": "ar71xx\/generic", |
||
| 65 | "description": "OpenWrt Barrier Breaker r40831" |
||
| 66 | } |
||
| 67 | } |
||
| 68 | </pre> |
||
| 69 | 1 | Roger Pueyo Centelles | |
| 70 | |
||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | 5 | Roger Pueyo Centelles | h3. ncd info |
| 76 | |||
| 77 | 1 | Roger Pueyo Centelles | Request: |
| 78 | |||
| 79 | 5 | Roger Pueyo Centelles | @ubus call ncd info { }@ |
| 80 | 1 | Roger Pueyo Centelles | |
| 81 | Response: |
||
| 82 | |||
| 83 | 5 | Roger Pueyo Centelles | <pre> |
| 84 | { |
||
| 85 | "uptime": 9425, |
||
| 86 | "localtime": 1401464813, |
||
| 87 | "load": [ |
||
| 88 | 3264, |
||
| 89 | 10592, |
||
| 90 | 7648 |
||
| 91 | ], |
||
| 92 | "memory": { |
||
| 93 | "total": 29741056, |
||
| 94 | "free": 5259264, |
||
| 95 | "shared": 0, |
||
| 96 | "buffered": 2297856 |
||
| 97 | }, |
||
| 98 | "swap": { |
||
| 99 | "total": 0, |
||
| 100 | "free": 0 |
||
| 101 | } |
||
| 102 | } |
||
| 103 | </pre> |
||
| 104 | 1 | Roger Pueyo Centelles | |
| 105 | |
||
| 106 | |||
| 107 | 5 | Roger Pueyo Centelles | h3. ncd.node.neighbours |
| 108 | 1 | Roger Pueyo Centelles | |
| 109 | 5 | Roger Pueyo Centelles | Request: |
| 110 | |||
| 111 | @ncd.node.neighbours { "node" : "id" }@ |
||
| 112 | 1 | Roger Pueyo Centelles | |
| 113 | 5 | Roger Pueyo Centelles | Response: |
| 114 | |||
| 115 | @{ "nodes" : [ "id_1", "id_2", "id_3" ] }@ |
||
| 116 | |||
| 117 | |
||
| 118 | |||
| 119 | |||
| 120 | |||
| 121 | |||
| 122 | |||
| 123 | |||
| 124 | |||
| 125 | 1 | Roger Pueyo Centelles | h3. ncd.node.info |
| 126 | |||
| 127 | Request: |
||
| 128 | |||
| 129 | @ncd.node.info { "node" : "id" }@ |
||
| 130 | |||
| 131 | Response: |
||
| 132 | |||
| 133 | <pre> |
||
| 134 | { |
||
| 135 | "nodeinfo": { |
||
| 136 | "id": "node016", |
||
| 137 | "name": "FT-NarrowStreet1616-NSLM5", |
||
| 138 | "hardware": { |
||
| 139 | "model": "Ubiquiti Nanostation M", |
||
| 140 | "type": "Atheros AR7241 rev 1", |
||
| 141 | "cpu": "MIPS 24Kc V7.4", |
||
| 142 | "ram": "29312" |
||
| 143 | }, |
||
| 144 | "software": { |
||
| 145 | "os": { |
||
| 146 | "name": "OpenWrt", |
||
| 147 | "version": 12.09, |
||
| 148 | "codename": "Attitude Adjustment", |
||
| 149 | "date": "2013-09-06", |
||
| 150 | "revision": "r38347" |
||
| 151 | }, |
||
| 152 | "qMp": { |
||
| 153 | "version": "3.0-rc3", |
||
| 154 | "codename": "Clearance", |
||
| 155 | "date": 20140227, |
||
| 156 | "revision": "d94713e", |
||
| 157 | "branch": "master" |
||
| 158 | }, |
||
| 159 | "bmx6": { |
||
| 160 | "revision": "bae36ab0", |
||
| 161 | "version": 12, |
||
| 162 | "branch": "master" |
||
| 163 | }, |
||
| 164 | "ncd": { |
||
| 165 | "revision": "36aaed94", |
||
| 166 | "version": 0.2, |
||
| 167 | "branch": "dev" |
||
| 168 | } |
||
| 169 | }, |
||
| 170 | "interfaces": { |
||
| 171 | "physical": { |
||
| 172 | "wired": { |
||
| 173 | "eth0": { |
||
| 174 | "mac": "DC:9F:DB:4F:A1:F6", |
||
| 175 | "encap": "Ethernet", |
||
| 176 | "mode": "100baseTX", |
||
| 177 | "mtu": 1500 |
||
| 178 | }, |
||
| 179 | "eth1": { |
||
| 180 | "mac": "DE:9F:DB:4F:A1:F6", |
||
| 181 | "encap": "Ethernet", |
||
| 182 | "mode": "down", |
||
| 183 | "mtu": 1500 |
||
| 184 | } |
||
| 185 | }, |
||
| 186 | "wireless": { |
||
| 187 | "radio0": { |
||
| 188 | "type": "mac80211", |
||
| 189 | "mac": "DC:9F:DB:4E:A1:F6", |
||
| 190 | "hwmode": "auto", |
||
| 191 | "channel": 124, |
||
| 192 | "country": "SP", |
||
| 193 | "txpower": 17, |
||
| 194 | "distance": 5000, |
||
| 195 | "ht": [ |
||
| 196 | "SHORT-GI-40", |
||
| 197 | "RX-STBC1", |
||
| 198 | "DSSS_CCK-40" |
||
| 199 | ], |
||
| 200 | "interfaces": { |
||
| 201 | "wlan0": { |
||
| 202 | "device": "radio0", |
||
| 203 | "mode": "adhoc", |
||
| 204 | "bssid": "02:CA:FF:EE:BA:BE", |
||
| 205 | "ssid": "qMp-HWErmitaBellvitge16", |
||
| 206 | "encryption": "open", |
||
| 207 | "network": "lan", |
||
| 208 | "ifname": "wlan0", |
||
| 209 | "stations": { |
||
| 210 | "dc:9f:db:34:17:b6": { |
||
| 211 | "signal": [ |
||
| 212 | -70, |
||
| 213 | -74, |
||
| 214 | -73 |
||
| 215 | ], |
||
| 216 | "avgsignal": [ |
||
| 217 | -70, |
||
| 218 | -74, |
||
| 219 | -73 |
||
| 220 | ], |
||
| 221 | "txbitrate": "60.0 MBit/s MCS 9 40Mhz short GI", |
||
| 222 | "rxbitrate": "81.0 MBit/s MCS 4 40Mhz" |
||
| 223 | } |
||
| 224 | } |
||
| 225 | } |
||
| 226 | } |
||
| 227 | } |
||
| 228 | } |
||
| 229 | }, |
||
| 230 | "virtual": { |
||
| 231 | "lo": { |
||
| 232 | "type": "loopback", |
||
| 233 | "addressing": { |
||
| 234 | "ipv4": [ |
||
| 235 | { |
||
| 236 | "ipaddr": "127.0.0.1", |
||
| 237 | "netmask": "255.0.0.0" |
||
| 238 | } |
||
| 239 | ], |
||
| 240 | "ipv6": [ |
||
| 241 | { |
||
| 242 | "ipaddr6": "::1/128", |
||
| 243 | "scope": "host" |
||
| 244 | } |
||
| 245 | ] |
||
| 246 | } |
||
| 247 | }, |
||
| 248 | "br-lan": { |
||
| 249 | "type": "bridge", |
||
| 250 | "ifname": [ |
||
| 251 | "eth0" |
||
| 252 | ], |
||
| 253 | "addressing": { |
||
| 254 | "ipv4": [ |
||
| 255 | { |
||
| 256 | "ipaddr": "10.1.32.33", |
||
| 257 | "netmask": "255.255.255.224" |
||
| 258 | }, |
||
| 259 | { |
||
| 260 | "ipaddr": "169.254.246.1", |
||
| 261 | "netmask": "255.255.255.248" |
||
| 262 | } |
||
| 263 | ], |
||
| 264 | "ipv6": [ |
||
| 265 | { |
||
| 266 | "scope": "global", |
||
| 267 | "ipaddr6": "fd00:1714:1714:a1f6::1/64" |
||
| 268 | }, |
||
| 269 | { |
||
| 270 | "scope": "link", |
||
| 271 | "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" |
||
| 272 | } |
||
| 273 | ] |
||
| 274 | } |
||
| 275 | }, |
||
| 276 | "br-lan.12": { |
||
| 277 | "type": "vlan", |
||
| 278 | "ifname": [ |
||
| 279 | "eth0" |
||
| 280 | ], |
||
| 281 | "addressing": { |
||
| 282 | "ipv6": [ |
||
| 283 | { |
||
| 284 | "scope": "global", |
||
| 285 | "ipaddr6": "fd66:66:66:8:de9f:dbff:fe4f:a1f6/64" |
||
| 286 | }, |
||
| 287 | { |
||
| 288 | "scope": "global", |
||
| 289 | "ipaddr6": "fd02::dc9f:db4f:a1f6:0:112/128" |
||
| 290 | }, |
||
| 291 | { |
||
| 292 | "scope": "link", |
||
| 293 | "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" |
||
| 294 | } |
||
| 295 | ] |
||
| 296 | } |
||
| 297 | }, |
||
| 298 | "wlan0": { |
||
| 299 | "type": "wireless", |
||
| 300 | "ifname": "radio0", |
||
| 301 | "addressing": { |
||
| 302 | "ipv4": [ |
||
| 303 | { |
||
| 304 | "ipaddr": "169.254.246.1", |
||
| 305 | "netmask": "255.255.255.248" |
||
| 306 | }, |
||
| 307 | { |
||
| 308 | "ipaddr": "10.1.32.33", |
||
| 309 | "netmask": "255.255.255.224" |
||
| 310 | } |
||
| 311 | ], |
||
| 312 | "ipv6": [ |
||
| 313 | { |
||
| 314 | "scope": "link", |
||
| 315 | "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64" |
||
| 316 | }, |
||
| 317 | { |
||
| 318 | "scope": "global", |
||
| 319 | "ipaddr6": "fd00:1714:1714:a1f6::1/64" |
||
| 320 | }, |
||
| 321 | { |
||
| 322 | "scope": "link", |
||
| 323 | "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" |
||
| 324 | } |
||
| 325 | ] |
||
| 326 | } |
||
| 327 | }, |
||
| 328 | "wlan0.12": { |
||
| 329 | "type": "vlan", |
||
| 330 | "ifname": "radio0", |
||
| 331 | "addressing": { |
||
| 332 | "ipv6": [ |
||
| 333 | { |
||
| 334 | "scope": "link", |
||
| 335 | "ipaddr6": "fd66:66:66:a:de9f:dbff:fe4e:a1f6/64" |
||
| 336 | }, |
||
| 337 | { |
||
| 338 | "scope": "global", |
||
| 339 | "ipaddr6": "fd02::dc9f:db4f:a1f6:0:212/128" |
||
| 340 | }, |
||
| 341 | { |
||
| 342 | "scope": "link", |
||
| 343 | "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64" |
||
| 344 | } |
||
| 345 | ] |
||
| 346 | } |
||
| 347 | }, |
||
| 348 | "bmxtmain": { |
||
| 349 | "type": "tunnel6", |
||
| 350 | "addressing": { |
||
| 351 | "ipv4": [ |
||
| 352 | { |
||
| 353 | "ipaddr": "10.1.32.33", |
||
| 354 | "netmask": "255.255.255.224" |
||
| 355 | } |
||
| 356 | ], |
||
| 357 | "ipv6": [ |
||
| 358 | { |
||
| 359 | "scope": "global", |
||
| 360 | "ipaddr6": "2012:0:0:a1f6::1/128" |
||
| 361 | }, |
||
| 362 | { |
||
| 363 | "scope": "link", |
||
| 364 | "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" |
||
| 365 | } |
||
| 366 | ] |
||
| 367 | } |
||
| 368 | } |
||
| 369 | } |
||
| 370 | } |
||
| 371 | } |
||
| 372 | } |
||
| 373 | </pre> |
||
| 374 | |||
| 375 | |
||
| 376 | |||
| 377 | h2. More examples |
||
| 378 | |||
| 379 | There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]]. |