Projecte

General

Perfil

Ubus » Historial » Versió 21

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

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