Projecte

General

Perfil

Ubus » Historial » Versió 28

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

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