Projecte

General

Perfil

Ubus » Historial » Versió 25

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

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