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