Projecte

General

Perfil

Ubus » Historial » Versió 23

Roger Pueyo Centelles, 03-07-2014 11:55

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