Projecte

General

Perfil

Ubus » Historial » Versió 19

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

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