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