Projecte

General

Perfil

Ubus » Historial » Versió 31

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

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 31 Roger Pueyo Centelles
h2. [WiP
130 15 Roger Pueyo Centelles
h3. ncd local node neighbours
131 1 Roger Pueyo Centelles
132
Request:
133 15 Roger Pueyo Centelles
 
134
 @ubus call ncd.local neighbours { }@
135
136
or, equivalently if the local node's unique id is "node016":
137 1 Roger Pueyo Centelles
138
 @ubus call ncd.node016 neighbours { }@
139
140 11 Roger Pueyo Centelles
Response:
141
142
 @{ "nodes" : [ "node011", "node400" ] }@
143 1 Roger Pueyo Centelles
144 11 Roger Pueyo Centelles
 
145
146 15 Roger Pueyo Centelles
h3. ncd remote node neighbours
147 1 Roger Pueyo Centelles
148
Request:
149
 
150 15 Roger Pueyo Centelles
 @ubus call ncd.node011 neighbours { }@
151
152
Response:
153
154
 @{ "nodes" : [ "node094", "node400" ] }@
155
156
 
157
158
159
160
161
162
h3. ncd local node link devices
163
164
Request:
165
 
166 1 Roger Pueyo Centelles
 @ubus call ncd.local linkdevices { "nodes" : [ "node011", "node400" ] }@
167
168 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
169
170
 @ubus call ncd.node016 linkdevices { "nodes" : [ "node011", "node400" ] }@
171
172 11 Roger Pueyo Centelles
Response:
173
174
<pre>
175
{
176
  "links": [
177
    {
178
      "node011": [
179
        "eth0.12",
180
        "wlan0"
181
      ]
182
    },
183
    {
184
      "node400": [
185
        "wlan0"
186
      ]
187 1 Roger Pueyo Centelles
    }
188
  ]
189
}
190
</pre>
191 10 Roger Pueyo Centelles
192
&nbsp;
193 1 Roger Pueyo Centelles
194
195
196
197 15 Roger Pueyo Centelles
h3. ncd remote node link devices
198 1 Roger Pueyo Centelles
199 15 Roger Pueyo Centelles
Request:
200
 
201
 @ubus call ncd.node011 linkdevices { "nodes" : [ "node016", "node094", "node400" ] }@
202
203
Response:
204
205
<pre>
206
{
207
  "links": [
208
    {
209
      "node016": [
210
        "wlan0"
211
      ]
212
    },
213
    {
214
      "node094": [
215
        "wlan1"
216
      ]
217
    },
218
    {
219
      "node400": [
220
        "wlan0",
221
        "wlan1"
222
      ]
223
    }
224
  ]
225
}
226
</pre>
227
228
&nbsp;
229
230
231
232 1 Roger Pueyo Centelles
h3. ncd local location name get
233
234 10 Roger Pueyo Centelles
Request:
235 1 Roger Pueyo Centelles
 
236
 @ubus call ncd.local.location.name get { }@
237
238 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
239
240
 @ubus call ncd.node016.location.name get { }@
241
242 10 Roger Pueyo Centelles
Response:
243
244 15 Roger Pueyo Centelles
 @{ "name" : [ "Narrow Street 16, Faketown" ] }@
245 1 Roger Pueyo Centelles
246
&nbsp;
247 10 Roger Pueyo Centelles
248 1 Roger Pueyo Centelles
249
250 15 Roger Pueyo Centelles
h3. ncd local position name set
251 1 Roger Pueyo Centelles
252 10 Roger Pueyo Centelles
Request:
253 1 Roger Pueyo Centelles
 
254 15 Roger Pueyo Centelles
 @ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@
255 1 Roger Pueyo Centelles
256 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
257
258
 @ubus call ncd.node016.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@
259
260 1 Roger Pueyo Centelles
Response:
261
262 15 Roger Pueyo Centelles
 @{ ] }@
263 1 Roger Pueyo Centelles
264
&nbsp;
265
266
267
268
269 10 Roger Pueyo Centelles
270 15 Roger Pueyo Centelles
h3. ncd local position coordinates get
271
272 10 Roger Pueyo Centelles
Request:
273 1 Roger Pueyo Centelles
 
274 15 Roger Pueyo Centelles
 @ubus call ncd.local.location.coordinates get { }@
275 1 Roger Pueyo Centelles
276 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
277
278
 @ubus call ncd.node016.location.coordinates get { }@
279
280 10 Roger Pueyo Centelles
Response:
281 1 Roger Pueyo Centelles
282 15 Roger Pueyo Centelles
 @{ "coordinates" : [ "42.34796", "3.11036" ] }@
283 1 Roger Pueyo Centelles
284
&nbsp;
285
286
287 10 Roger Pueyo Centelles
288
289
290
h3. ncd local position coordinates set
291 1 Roger Pueyo Centelles
292
Request:
293 10 Roger Pueyo Centelles
 
294 15 Roger Pueyo Centelles
 @ubus call ncd.local.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }@
295 1 Roger Pueyo Centelles
296 15 Roger Pueyo Centelles
or, equivalently if the local node's unique id is "node016":
297
298
 @ubus call ncd.node016.position.coordinates set { "coordinates" : [ "43.34796", "4.11036" ] }@
299
300 10 Roger Pueyo Centelles
Response:
301
302
 @{ }@
303
304
&nbsp;
305
306
307
308
309
310
h3. ncd local ubus relay
311
312
Request:
313
 
314 1 Roger Pueyo Centelles
 @ubus call ncd.local.relay.iwinfo devices { }@
315 10 Roger Pueyo Centelles
316
Response:
317
318
 <pre>
319
{
320 1 Roger Pueyo Centelles
	"devices": [
321 10 Roger Pueyo Centelles
		"wlan1",
322 1 Roger Pueyo Centelles
		"wlan0",
323
		"wlan0ap"
324 10 Roger Pueyo Centelles
	]
325
}
326
 </pre>
327
328
&nbsp;
329
330
331
332 1 Roger Pueyo Centelles
333
ubus call iwinfo devices
334
335
h2. More examples
336
337
There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].