Projecte

General

Perfil

Ubus » Historial » Versió 20

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

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