Ubus » Historial » Versió 30
Roger Pueyo Centelles, 03-07-2014 12:14
1 | 1 | Roger Pueyo Centelles | h1. Ubus |
---|---|---|---|
2 | |||
3 | 10 | Roger Pueyo Centelles | 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 | 1 | Roger Pueyo Centelles | |
5 | 13 | Roger Pueyo Centelles | The NCd can provide information about the local node or about remote nodes. Some of the data are specific to the NCd, while others can be obtained from other local Ubus interfaces (netifd, rpcd, etc.). The NCd acts as a relay to the local Ubus, but also to remote Ubus instances. By doing so, most of the data processing is left on the NCui side, which is run on Javascript code by the user's browser. This strategy reduces the load on the network nodes, usually low-end embedded devices with limited memory and processing resources. |
6 | 12 | Roger Pueyo Centelles | |
7 | 1 | Roger Pueyo Centelles | h2. NCd ubus namespace and procedures summary |
8 | |||
9 | 13 | Roger Pueyo Centelles | The NCd, once registered to the Ubus daemon, provides the following procedures: |
10 | 1 | Roger Pueyo Centelles | |
11 | 17 | Roger Pueyo Centelles | h3. Local node ID |
12 | 1 | Roger Pueyo Centelles | |
13 | 13 | Roger Pueyo Centelles | Each node running the NC has its unique ID that identifies it on the network. |
14 | |||
15 | 11 | Roger Pueyo Centelles | |_.Path |_.Procedure |_.Signature |_.Description | |
16 | |\4=. | |
||
17 | 16 | Roger Pueyo Centelles | |ncd | [[Ubus#ncd-local-id|local]] | { } | Get the unique id of the local node | |
18 | 1 | Roger Pueyo Centelles | |
19 | |
||
20 | |||
21 | 24 | Roger Pueyo Centelles | h3. List all nodes |
22 | 20 | Roger Pueyo Centelles | |
23 | List all the known or discovered nodes in the network. |
||
24 | |||
25 | |_.Path |_.Procedure |_.Signature |_.Description | |
||
26 | |\4=. | |
||
27 | |ncd | [[Ubus#ncd-listnodes|listnodes]] | { } | Get a list with all the nodes in the network | |
||
28 | |||
29 | |
||
30 | |||
31 | 21 | Roger Pueyo Centelles | h3. Neighbour nodes list |
32 | |||
33 | List the neighbours of the local node (i.e.: directly connected either via wire or wireless). |
||
34 | |||
35 | |_.Path |_.Procedure |_.Signature |_.Description | |
||
36 | |\4=. | |
||
37 | |ncd | [[Ubus#ncd-neighbours|neighbours]] | { } | Get a list with the neighbours of the local node | |
||
38 | |||
39 | |
||
40 | |||
41 | 25 | Roger Pueyo Centelles | h3. NCd-specific information |
42 | |||
43 | 28 | Roger Pueyo Centelles | Provide information related to the NCd/NCui themselves. |
44 | |||
45 | 25 | Roger Pueyo Centelles | |_.Path |_.Procedure |_.Signature |_.Description | |
46 | |\4=. | |
||
47 | |ncd | [[Ubus#ncd-version|version]] | { } | Get the version of the NCd | |
||
48 | |||
49 | |
||
50 | |||
51 | 30 | Roger Pueyo Centelles | h2. [WiP] |
52 | h3. NC-specific node information |
||
53 | 10 | Roger Pueyo Centelles | |
54 | 30 | Roger Pueyo Centelles | The NCd can provide the following procedures regarding other nodes in the network running the NCd. |
55 | 10 | Roger Pueyo Centelles | |
56 | 11 | Roger Pueyo Centelles | |_.Path |_.Procedure |_.Signature |_.Description | |
57 | |\4=. | |
||
58 | |ncd.nodeid.location.name | [[Ubus#ncd-local-location-name-get|get]] | { } | Get the position (name or description) where the node defined by _nodeid_ is located | |
||
59 | |ncd.nodeid.location.name | [[Ubus|get]] | { "location" : "Location name or description" } | Get the position (name or description) where the node defined by _nodeid_ is located | |
||
60 | 13 | Roger Pueyo Centelles | |ncd.nodeid.location.coordinates | [[Ubus|get]] | { } | Get the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located | |
61 | 11 | Roger Pueyo Centelles | |ncd.nodeid.location.coordinates | [[Ubus|set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located | |
62 | 1 | Roger Pueyo Centelles | |
63 | 10 | Roger Pueyo Centelles | ² Replace _nodeid_ by the node's unique id or by _local_ to request information about the local node |
64 | |
||
65 | 1 | Roger Pueyo Centelles | |
66 | 13 | Roger Pueyo Centelles | h3. Ubus relay via NC |
67 | 12 | Roger Pueyo Centelles | |
68 | 10 | Roger Pueyo Centelles | The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered remotely (like netifd, rpcd, etc.). |
69 | |||
70 | |_.Path |_.Procedure |_.Signature |_.Description | |
||
71 | |\4=. | |
||
72 | |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_ | |
||
73 | 11 | Roger Pueyo Centelles | |
74 | 10 | Roger Pueyo Centelles | ² Replace _nodeid_ by the node's unique id |
75 | |
||
76 | |||
77 | See the examples below to get a clear idea of how it works. |
||
78 | 11 | Roger Pueyo Centelles | |
79 | 5 | Roger Pueyo Centelles | h2. Usage examples |
80 | 10 | Roger Pueyo Centelles | |
81 | 5 | Roger Pueyo Centelles | h3. ncd local id |
82 | 1 | Roger Pueyo Centelles | |
83 | Request: |
||
84 | 10 | Roger Pueyo Centelles | |
85 | 18 | Roger Pueyo Centelles | @ubus call ncd local { }@ |
86 | 1 | Roger Pueyo Centelles | |
87 | Response: |
||
88 | |||
89 | 15 | Roger Pueyo Centelles | @{ "id" : "node016" }@ |
90 | 1 | Roger Pueyo Centelles | |
91 | |
||
92 | |||
93 | 19 | Roger Pueyo Centelles | h3. ncd listnodes |
94 | |||
95 | Request: |
||
96 | |||
97 | @ubus call ncd listnodes { }@ |
||
98 | |||
99 | Response: |
||
100 | |||
101 | 22 | Roger Pueyo Centelles | @{ "nodes" : [ "node011", "node016", "node400", "node094", "node017", "node104", "node105", "node106", "node107" ] }@ |
102 | 19 | Roger Pueyo Centelles | |
103 | |
||
104 | |||
105 | 23 | Roger Pueyo Centelles | h3. ncd neighbours |
106 | |||
107 | Request: |
||
108 | |||
109 | @ubus call ncd neighbours { }@ |
||
110 | |||
111 | Response: |
||
112 | |||
113 | @{ "nodes" : [ "node011", "node400" ] }@ |
||
114 | |||
115 | |
||
116 | |||
117 | 27 | Roger Pueyo Centelles | h3. ncd version |
118 | |||
119 | Request: |
||
120 | |||
121 | @ubus call ncd version { }@ |
||
122 | |||
123 | Response: |
||
124 | |||
125 | @ { "version" : "0.0.1" }@ |
||
126 | |||
127 | |
||
128 | |||
129 | 15 | Roger Pueyo Centelles | h3. ncd local node neighbours |
130 | 1 | Roger Pueyo Centelles | |
131 | Request: |
||
132 | 15 | Roger Pueyo Centelles | |
133 | @ubus call ncd.local neighbours { }@ |
||
134 | |||
135 | or, equivalently if the local node's unique id is "node016": |
||
136 | 1 | Roger Pueyo Centelles | |
137 | @ubus call ncd.node016 neighbours { }@ |
||
138 | |||
139 | 11 | Roger Pueyo Centelles | Response: |
140 | |||
141 | @{ "nodes" : [ "node011", "node400" ] }@ |
||
142 | 1 | Roger Pueyo Centelles | |
143 | 11 | Roger Pueyo Centelles | |
144 | |||
145 | 15 | Roger Pueyo Centelles | h3. ncd remote node neighbours |
146 | 1 | Roger Pueyo Centelles | |
147 | Request: |
||
148 | |||
149 | 15 | Roger Pueyo Centelles | @ubus call ncd.node011 neighbours { }@ |
150 | |||
151 | Response: |
||
152 | |||
153 | @{ "nodes" : [ "node094", "node400" ] }@ |
||
154 | |||
155 | |
||
156 | |||
157 | |||
158 | |||
159 | |||
160 | |||
161 | h3. ncd local node link devices |
||
162 | |||
163 | Request: |
||
164 | |||
165 | 1 | Roger Pueyo Centelles | @ubus call ncd.local linkdevices { "nodes" : [ "node011", "node400" ] }@ |
166 | |||
167 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
168 | |||
169 | @ubus call ncd.node016 linkdevices { "nodes" : [ "node011", "node400" ] }@ |
||
170 | |||
171 | 11 | Roger Pueyo Centelles | Response: |
172 | |||
173 | <pre> |
||
174 | { |
||
175 | "links": [ |
||
176 | { |
||
177 | "node011": [ |
||
178 | "eth0.12", |
||
179 | "wlan0" |
||
180 | ] |
||
181 | }, |
||
182 | { |
||
183 | "node400": [ |
||
184 | "wlan0" |
||
185 | ] |
||
186 | 1 | Roger Pueyo Centelles | } |
187 | ] |
||
188 | } |
||
189 | </pre> |
||
190 | 10 | Roger Pueyo Centelles | |
191 | |
||
192 | 1 | Roger Pueyo Centelles | |
193 | |||
194 | |||
195 | |||
196 | 15 | Roger Pueyo Centelles | h3. ncd remote node link devices |
197 | 1 | Roger Pueyo Centelles | |
198 | 15 | Roger Pueyo Centelles | Request: |
199 | |||
200 | @ubus call ncd.node011 linkdevices { "nodes" : [ "node016", "node094", "node400" ] }@ |
||
201 | |||
202 | Response: |
||
203 | |||
204 | <pre> |
||
205 | { |
||
206 | "links": [ |
||
207 | { |
||
208 | "node016": [ |
||
209 | "wlan0" |
||
210 | ] |
||
211 | }, |
||
212 | { |
||
213 | "node094": [ |
||
214 | "wlan1" |
||
215 | ] |
||
216 | }, |
||
217 | { |
||
218 | "node400": [ |
||
219 | "wlan0", |
||
220 | "wlan1" |
||
221 | ] |
||
222 | } |
||
223 | ] |
||
224 | } |
||
225 | </pre> |
||
226 | |||
227 | |
||
228 | |||
229 | |||
230 | |||
231 | 1 | Roger Pueyo Centelles | h3. ncd local location name get |
232 | |||
233 | 10 | Roger Pueyo Centelles | Request: |
234 | 1 | Roger Pueyo Centelles | |
235 | @ubus call ncd.local.location.name get { }@ |
||
236 | |||
237 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
238 | |||
239 | @ubus call ncd.node016.location.name get { }@ |
||
240 | |||
241 | 10 | Roger Pueyo Centelles | Response: |
242 | |||
243 | 15 | Roger Pueyo Centelles | @{ "name" : [ "Narrow Street 16, Faketown" ] }@ |
244 | 1 | Roger Pueyo Centelles | |
245 | |
||
246 | 10 | Roger Pueyo Centelles | |
247 | 1 | Roger Pueyo Centelles | |
248 | |||
249 | 15 | Roger Pueyo Centelles | h3. ncd local position name set |
250 | 1 | Roger Pueyo Centelles | |
251 | 10 | Roger Pueyo Centelles | Request: |
252 | 1 | Roger Pueyo Centelles | |
253 | 15 | Roger Pueyo Centelles | @ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@ |
254 | 1 | Roger Pueyo Centelles | |
255 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
256 | |||
257 | @ubus call ncd.node016.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@ |
||
258 | |||
259 | 1 | Roger Pueyo Centelles | Response: |
260 | |||
261 | 15 | Roger Pueyo Centelles | @{ ] }@ |
262 | 1 | Roger Pueyo Centelles | |
263 | |
||
264 | |||
265 | |||
266 | |||
267 | |||
268 | 10 | Roger Pueyo Centelles | |
269 | 15 | Roger Pueyo Centelles | h3. ncd local position coordinates get |
270 | |||
271 | 10 | Roger Pueyo Centelles | Request: |
272 | 1 | Roger Pueyo Centelles | |
273 | 15 | Roger Pueyo Centelles | @ubus call ncd.local.location.coordinates get { }@ |
274 | 1 | Roger Pueyo Centelles | |
275 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
276 | |||
277 | @ubus call ncd.node016.location.coordinates get { }@ |
||
278 | |||
279 | 10 | Roger Pueyo Centelles | Response: |
280 | 1 | Roger Pueyo Centelles | |
281 | 15 | Roger Pueyo Centelles | @{ "coordinates" : [ "42.34796", "3.11036" ] }@ |
282 | 1 | Roger Pueyo Centelles | |
283 | |
||
284 | |||
285 | |||
286 | 10 | Roger Pueyo Centelles | |
287 | |||
288 | |||
289 | h3. ncd local position coordinates set |
||
290 | 1 | Roger Pueyo Centelles | |
291 | Request: |
||
292 | 10 | Roger Pueyo Centelles | |
293 | 15 | Roger Pueyo Centelles | @ubus call ncd.local.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }@ |
294 | 1 | Roger Pueyo Centelles | |
295 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
296 | |||
297 | @ubus call ncd.node016.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }@ |
||
298 | |||
299 | 10 | Roger Pueyo Centelles | Response: |
300 | |||
301 | @{ }@ |
||
302 | |||
303 | |
||
304 | |||
305 | |||
306 | |||
307 | |||
308 | |||
309 | h3. ncd local ubus relay |
||
310 | |||
311 | Request: |
||
312 | |||
313 | 1 | Roger Pueyo Centelles | @ubus call ncd.local.relay.iwinfo devices { }@ |
314 | 10 | Roger Pueyo Centelles | |
315 | Response: |
||
316 | |||
317 | <pre> |
||
318 | { |
||
319 | 1 | Roger Pueyo Centelles | "devices": [ |
320 | 10 | Roger Pueyo Centelles | "wlan1", |
321 | 1 | Roger Pueyo Centelles | "wlan0", |
322 | "wlan0ap" |
||
323 | 10 | Roger Pueyo Centelles | ] |
324 | } |
||
325 | </pre> |
||
326 | |||
327 | |
||
328 | |||
329 | |||
330 | |||
331 | 1 | Roger Pueyo Centelles | |
332 | ubus call iwinfo devices |
||
333 | |||
334 | h2. More examples |
||
335 | |||
336 | There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]]. |