Projecte

General

Perfil

Ubus » Historial » Versió 27

Roger Pueyo Centelles, 03-07-2014 12:03

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
|_.Path                            |_.Procedure                                    |_.Signature                                    |_.Description |
44
|\4=. |
45
|ncd                               | [[Ubus#ncd-version|version]]                  | { }                                                    | Get the version of the NCd |
46
47
 
48
49 1 Roger Pueyo Centelles
h3. NC-specific node information
50 10 Roger Pueyo Centelles
51
The NCd can provide the following procedures regarding other nodes in the network running the NCd:
52
53 11 Roger Pueyo Centelles
|_.Path                            |_.Procedure                                    |_.Signature                                    |_.Description |
54
|\4=. |
55
|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 |
56
|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 |
57 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 |
58 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 |
59 1 Roger Pueyo Centelles
60 10 Roger Pueyo Centelles
² Replace _nodeid_ by the node's unique id or by _local_ to request information about the local node
61
 
62 1 Roger Pueyo Centelles
63 13 Roger Pueyo Centelles
h3. Ubus relay via NC
64 12 Roger Pueyo Centelles
65 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.).
66
67
|_.Path                              |_.Procedure                                      |_.Signature                                      |_.Description |
68
|\4=. |
69
|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_ |
70 11 Roger Pueyo Centelles
71 10 Roger Pueyo Centelles
² Replace _nodeid_ by the node's unique id
72
 
73
74
See the examples below to get a clear idea of how it works.
75 11 Roger Pueyo Centelles
76 5 Roger Pueyo Centelles
h2. Usage examples
77 10 Roger Pueyo Centelles
78 5 Roger Pueyo Centelles
h3. ncd local id
79 1 Roger Pueyo Centelles
80
Request:
81 10 Roger Pueyo Centelles
 
82 18 Roger Pueyo Centelles
 @ubus call ncd local { }@
83 1 Roger Pueyo Centelles
84
Response:
85
86 15 Roger Pueyo Centelles
 @{ "id" : "node016" }@
87 1 Roger Pueyo Centelles
88
 
89
90 19 Roger Pueyo Centelles
h3. ncd listnodes
91
92
Request:
93
 
94
 @ubus call ncd listnodes { }@
95
96
Response:
97
98 22 Roger Pueyo Centelles
 @{ "nodes" : [ "node011", "node016", "node400", "node094", "node017", "node104", "node105", "node106", "node107" ] }@
99 19 Roger Pueyo Centelles
100
 
101
102 23 Roger Pueyo Centelles
h3. ncd neighbours
103
104
Request:
105
 
106
 @ubus call ncd neighbours { }@
107
108
Response:
109
110
 @{ "nodes" : [ "node011", "node400" ] }@
111
112
 
113
114 27 Roger Pueyo Centelles
h3. ncd version
115
116
Request:
117
 
118
 @ubus call ncd version { }@
119
120
Response:
121
122
 @ { "version" : "0.0.1"  }@
123
124
 
125
126 15 Roger Pueyo Centelles
h3. ncd local node neighbours
127 1 Roger Pueyo Centelles
128
Request:
129 15 Roger Pueyo Centelles
 
130
 @ubus call ncd.local neighbours { }@
131
132
or, equivalently if the local node's unique id is "node016":
133 1 Roger Pueyo Centelles
134
 @ubus call ncd.node016 neighbours { }@
135
136 11 Roger Pueyo Centelles
Response:
137
138
 @{ "nodes" : [ "node011", "node400" ] }@
139 1 Roger Pueyo Centelles
140 11 Roger Pueyo Centelles
 
141
142 15 Roger Pueyo Centelles
h3. ncd remote node neighbours
143 1 Roger Pueyo Centelles
144
Request:
145
 
146 15 Roger Pueyo Centelles
 @ubus call ncd.node011 neighbours { }@
147
148
Response:
149
150
 @{ "nodes" : [ "node094", "node400" ] }@
151
152
 
153
154
155
156
157
158
h3. ncd local node link devices
159
160
Request:
161
 
162 1 Roger Pueyo Centelles
 @ubus call ncd.local linkdevices { "nodes" : [ "node011", "node400" ] }@
163
164 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
165
166
 @ubus call ncd.node016 linkdevices { "nodes" : [ "node011", "node400" ] }@
167
168 11 Roger Pueyo Centelles
Response:
169
170
<pre>
171
{
172
  "links": [
173
    {
174
      "node011": [
175
        "eth0.12",
176
        "wlan0"
177
      ]
178
    },
179
    {
180
      "node400": [
181
        "wlan0"
182
      ]
183 1 Roger Pueyo Centelles
    }
184
  ]
185
}
186
</pre>
187 10 Roger Pueyo Centelles
188
&nbsp;
189 1 Roger Pueyo Centelles
190
191
192
193 15 Roger Pueyo Centelles
h3. ncd remote node link devices
194 1 Roger Pueyo Centelles
195 15 Roger Pueyo Centelles
Request:
196
 
197
 @ubus call ncd.node011 linkdevices { "nodes" : [ "node016", "node094", "node400" ] }@
198
199
Response:
200
201
<pre>
202
{
203
  "links": [
204
    {
205
      "node016": [
206
        "wlan0"
207
      ]
208
    },
209
    {
210
      "node094": [
211
        "wlan1"
212
      ]
213
    },
214
    {
215
      "node400": [
216
        "wlan0",
217
        "wlan1"
218
      ]
219
    }
220
  ]
221
}
222
</pre>
223
224
&nbsp;
225
226
227
228 1 Roger Pueyo Centelles
h3. ncd local location name get
229
230 10 Roger Pueyo Centelles
Request:
231 1 Roger Pueyo Centelles
 
232
 @ubus call ncd.local.location.name get { }@
233
234 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
235
236
 @ubus call ncd.node016.location.name get { }@
237
238 10 Roger Pueyo Centelles
Response:
239
240 15 Roger Pueyo Centelles
 @{ "name" : [ "Narrow Street 16, Faketown" ] }@
241 1 Roger Pueyo Centelles
242
&nbsp;
243 10 Roger Pueyo Centelles
244 1 Roger Pueyo Centelles
245
246 15 Roger Pueyo Centelles
h3. ncd local position name set
247 1 Roger Pueyo Centelles
248 10 Roger Pueyo Centelles
Request:
249 1 Roger Pueyo Centelles
 
250 15 Roger Pueyo Centelles
 @ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@
251 1 Roger Pueyo Centelles
252 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
253
254
 @ubus call ncd.node016.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@
255
256 1 Roger Pueyo Centelles
Response:
257
258 15 Roger Pueyo Centelles
 @{ ] }@
259 1 Roger Pueyo Centelles
260
&nbsp;
261
262
263
264
265 10 Roger Pueyo Centelles
266 15 Roger Pueyo Centelles
h3. ncd local position coordinates get
267
268 10 Roger Pueyo Centelles
Request:
269 1 Roger Pueyo Centelles
 
270 15 Roger Pueyo Centelles
 @ubus call ncd.local.location.coordinates get { }@
271 1 Roger Pueyo Centelles
272 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
273
274
 @ubus call ncd.node016.location.coordinates get { }@
275
276 10 Roger Pueyo Centelles
Response:
277 1 Roger Pueyo Centelles
278 15 Roger Pueyo Centelles
 @{ "coordinates" : [ "42.34796", "3.11036" ] }@
279 1 Roger Pueyo Centelles
280
&nbsp;
281
282
283 10 Roger Pueyo Centelles
284
285
286
h3. ncd local position coordinates set
287 1 Roger Pueyo Centelles
288
Request:
289 10 Roger Pueyo Centelles
 
290 15 Roger Pueyo Centelles
 @ubus call ncd.local.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }@
291 1 Roger Pueyo Centelles
292 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
293
294
 @ubus call ncd.node016.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }@
295
296 10 Roger Pueyo Centelles
Response:
297
298
 @{ }@
299
300
&nbsp;
301
302
303
304
305
306
h3. ncd local ubus relay
307
308
Request:
309
 
310 1 Roger Pueyo Centelles
 @ubus call ncd.local.relay.iwinfo devices { }@
311 10 Roger Pueyo Centelles
312
Response:
313
314
 <pre>
315
{
316 1 Roger Pueyo Centelles
	"devices": [
317 10 Roger Pueyo Centelles
		"wlan1",
318 1 Roger Pueyo Centelles
		"wlan0",
319
		"wlan0ap"
320 10 Roger Pueyo Centelles
	]
321
}
322
 </pre>
323
324
&nbsp;
325
326
327
328 1 Roger Pueyo Centelles
329
ubus call iwinfo devices
330
331
h2. More examples
332
333
There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].