Projecte

General

Perfil

Ubus » Historial » Versió 16

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

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