Projecte

General

Perfil

Ubus » Historial » Versió 26

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