Ubus » Historial » Versió 18
Roger Pueyo Centelles, 03-07-2014 11:37
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 | 13 | Roger Pueyo Centelles | h3. NC-specific node information |
22 | 11 | Roger Pueyo Centelles | |
23 | 1 | Roger Pueyo Centelles | The NCd can provide the following procedures regarding other nodes in the network running the NCd: |
24 | 10 | Roger Pueyo Centelles | |
25 | |_.Path |_.Procedure |_.Signature |_.Description | |
||
26 | |\4=. | |
||
27 | 14 | Roger Pueyo Centelles | |ncd.nodeid ² | [[Ubus#ncd-local-neighbours|neighbours]] | { } | List all the neighbours of the node defined by _nodeid_ | |
28 | |ncd.nodeid | [[Ubus#ncd-local-node-link-devices|linkdevices]] | { "nodes": ["nodeid1", "nodeid2", ...] } | List the devices used to link the node defined by _nodeid_ to other nodes | |
||
29 | |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 | |
||
30 | 11 | Roger Pueyo Centelles | |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 | |
31 | |ncd.nodeid.location.coordinates | [[Ubus|get]] | { } | Get the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located | |
||
32 | |ncd.nodeid.location.coordinates | [[Ubus|set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located | |
||
33 | |||
34 | 13 | Roger Pueyo Centelles | ² Replace _nodeid_ by the node's unique id or by _local_ to request information about the local node |
35 | 11 | Roger Pueyo Centelles | |
36 | 1 | Roger Pueyo Centelles | |
37 | 10 | Roger Pueyo Centelles | |
38 | |||
39 | 1 | Roger Pueyo Centelles | |
40 | 13 | Roger Pueyo Centelles | h3. Ubus relay via NC |
41 | 12 | Roger Pueyo Centelles | |
42 | 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.). |
43 | |||
44 | |_.Path |_.Procedure |_.Signature |_.Description | |
||
45 | |\4=. | |
||
46 | |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_ | |
||
47 | 11 | Roger Pueyo Centelles | |
48 | 10 | Roger Pueyo Centelles | ² Replace _nodeid_ by the node's unique id |
49 | |
||
50 | |||
51 | See the examples below to get a clear idea of how it works. |
||
52 | 11 | Roger Pueyo Centelles | |
53 | 5 | Roger Pueyo Centelles | h2. Usage examples |
54 | 10 | Roger Pueyo Centelles | |
55 | 5 | Roger Pueyo Centelles | h3. ncd local id |
56 | 1 | Roger Pueyo Centelles | |
57 | Request: |
||
58 | 10 | Roger Pueyo Centelles | |
59 | 18 | Roger Pueyo Centelles | @ubus call ncd local { }@ |
60 | 1 | Roger Pueyo Centelles | |
61 | Response: |
||
62 | |||
63 | 15 | Roger Pueyo Centelles | @{ "id" : "node016" }@ |
64 | 1 | Roger Pueyo Centelles | |
65 | |
||
66 | |||
67 | 15 | Roger Pueyo Centelles | h3. ncd local node neighbours |
68 | 1 | Roger Pueyo Centelles | |
69 | Request: |
||
70 | |||
71 | @ubus call ncd.local neighbours { }@ |
||
72 | |||
73 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
74 | |||
75 | @ubus call ncd.node016 neighbours { }@ |
||
76 | |||
77 | 1 | Roger Pueyo Centelles | Response: |
78 | |||
79 | @{ "nodes" : [ "node011", "node400" ] }@ |
||
80 | 11 | Roger Pueyo Centelles | |
81 | |
||
82 | |||
83 | 1 | Roger Pueyo Centelles | |
84 | 11 | Roger Pueyo Centelles | |
85 | |||
86 | 15 | Roger Pueyo Centelles | h3. ncd remote node neighbours |
87 | 1 | Roger Pueyo Centelles | |
88 | Request: |
||
89 | |||
90 | 15 | Roger Pueyo Centelles | @ubus call ncd.node011 neighbours { }@ |
91 | |||
92 | Response: |
||
93 | |||
94 | @{ "nodes" : [ "node094", "node400" ] }@ |
||
95 | |||
96 | |
||
97 | |||
98 | |||
99 | |||
100 | |||
101 | |||
102 | h3. ncd local node link devices |
||
103 | |||
104 | Request: |
||
105 | |||
106 | 1 | Roger Pueyo Centelles | @ubus call ncd.local linkdevices { "nodes" : [ "node011", "node400" ] }@ |
107 | |||
108 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
109 | |||
110 | @ubus call ncd.node016 linkdevices { "nodes" : [ "node011", "node400" ] }@ |
||
111 | |||
112 | 11 | Roger Pueyo Centelles | Response: |
113 | |||
114 | <pre> |
||
115 | { |
||
116 | "links": [ |
||
117 | { |
||
118 | "node011": [ |
||
119 | "eth0.12", |
||
120 | "wlan0" |
||
121 | ] |
||
122 | }, |
||
123 | { |
||
124 | "node400": [ |
||
125 | "wlan0" |
||
126 | ] |
||
127 | 1 | Roger Pueyo Centelles | } |
128 | ] |
||
129 | } |
||
130 | </pre> |
||
131 | 10 | Roger Pueyo Centelles | |
132 | |
||
133 | 1 | Roger Pueyo Centelles | |
134 | |||
135 | |||
136 | |||
137 | 15 | Roger Pueyo Centelles | h3. ncd remote node link devices |
138 | 1 | Roger Pueyo Centelles | |
139 | 15 | Roger Pueyo Centelles | Request: |
140 | |||
141 | @ubus call ncd.node011 linkdevices { "nodes" : [ "node016", "node094", "node400" ] }@ |
||
142 | |||
143 | Response: |
||
144 | |||
145 | <pre> |
||
146 | { |
||
147 | "links": [ |
||
148 | { |
||
149 | "node016": [ |
||
150 | "wlan0" |
||
151 | ] |
||
152 | }, |
||
153 | { |
||
154 | "node094": [ |
||
155 | "wlan1" |
||
156 | ] |
||
157 | }, |
||
158 | { |
||
159 | "node400": [ |
||
160 | "wlan0", |
||
161 | "wlan1" |
||
162 | ] |
||
163 | } |
||
164 | ] |
||
165 | } |
||
166 | </pre> |
||
167 | |||
168 | |
||
169 | |||
170 | |||
171 | |||
172 | 1 | Roger Pueyo Centelles | h3. ncd local location name get |
173 | |||
174 | 10 | Roger Pueyo Centelles | Request: |
175 | 1 | Roger Pueyo Centelles | |
176 | @ubus call ncd.local.location.name get { }@ |
||
177 | |||
178 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
179 | |||
180 | @ubus call ncd.node016.location.name get { }@ |
||
181 | |||
182 | 10 | Roger Pueyo Centelles | Response: |
183 | |||
184 | 15 | Roger Pueyo Centelles | @{ "name" : [ "Narrow Street 16, Faketown" ] }@ |
185 | 1 | Roger Pueyo Centelles | |
186 | |
||
187 | 10 | Roger Pueyo Centelles | |
188 | 1 | Roger Pueyo Centelles | |
189 | |||
190 | 15 | Roger Pueyo Centelles | h3. ncd local position name set |
191 | 1 | Roger Pueyo Centelles | |
192 | 10 | Roger Pueyo Centelles | Request: |
193 | 1 | Roger Pueyo Centelles | |
194 | 15 | Roger Pueyo Centelles | @ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@ |
195 | 1 | Roger Pueyo Centelles | |
196 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
197 | |||
198 | @ubus call ncd.node016.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@ |
||
199 | |||
200 | 1 | Roger Pueyo Centelles | Response: |
201 | |||
202 | 15 | Roger Pueyo Centelles | @{ ] }@ |
203 | 1 | Roger Pueyo Centelles | |
204 | |
||
205 | |||
206 | |||
207 | |||
208 | |||
209 | 10 | Roger Pueyo Centelles | |
210 | 15 | Roger Pueyo Centelles | h3. ncd local position coordinates get |
211 | |||
212 | 10 | Roger Pueyo Centelles | Request: |
213 | 1 | Roger Pueyo Centelles | |
214 | 15 | Roger Pueyo Centelles | @ubus call ncd.local.location.coordinates get { }@ |
215 | 1 | Roger Pueyo Centelles | |
216 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
217 | |||
218 | @ubus call ncd.node016.location.coordinates get { }@ |
||
219 | |||
220 | 10 | Roger Pueyo Centelles | Response: |
221 | 1 | Roger Pueyo Centelles | |
222 | 15 | Roger Pueyo Centelles | @{ "coordinates" : [ "42.34796", "3.11036" ] }@ |
223 | 1 | Roger Pueyo Centelles | |
224 | |
||
225 | |||
226 | |||
227 | 10 | Roger Pueyo Centelles | |
228 | |||
229 | |||
230 | h3. ncd local position coordinates set |
||
231 | 1 | Roger Pueyo Centelles | |
232 | Request: |
||
233 | 10 | Roger Pueyo Centelles | |
234 | 15 | Roger Pueyo Centelles | @ubus call ncd.local.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }@ |
235 | 1 | Roger Pueyo Centelles | |
236 | 15 | Roger Pueyo Centelles | or, equivalently if the local node's unique id is "node016": |
237 | |||
238 | @ubus call ncd.node016.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }@ |
||
239 | |||
240 | 10 | Roger Pueyo Centelles | Response: |
241 | |||
242 | @{ }@ |
||
243 | |||
244 | |
||
245 | |||
246 | |||
247 | |||
248 | |||
249 | |||
250 | h3. ncd local ubus relay |
||
251 | |||
252 | Request: |
||
253 | |||
254 | 1 | Roger Pueyo Centelles | @ubus call ncd.local.relay.iwinfo devices { }@ |
255 | 10 | Roger Pueyo Centelles | |
256 | Response: |
||
257 | |||
258 | <pre> |
||
259 | { |
||
260 | 1 | Roger Pueyo Centelles | "devices": [ |
261 | 10 | Roger Pueyo Centelles | "wlan1", |
262 | 1 | Roger Pueyo Centelles | "wlan0", |
263 | "wlan0ap" |
||
264 | 10 | Roger Pueyo Centelles | ] |
265 | } |
||
266 | </pre> |
||
267 | |||
268 | |
||
269 | |||
270 | |||
271 | |||
272 | 1 | Roger Pueyo Centelles | |
273 | ubus call iwinfo devices |
||
274 | |||
275 | h2. More examples |
||
276 | |||
277 | There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]]. |