Projecte

General

Perfil

Ubus » Historial » Versió 15

Roger Pueyo Centelles, 04-06-2014 13:23

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