Projecte

General

Perfil

Ubus » Historial » Versió 12

Roger Pueyo Centelles, 03-06-2014 14:34

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 12 Roger Pueyo Centelles
The NCd can provide local or remote information (i.e. data gathered from other nodes) via the Ubus interface. Some of the 
6
7 1 Roger Pueyo Centelles
h2. NCd ubus namespace and procedures summary
8
9 10 Roger Pueyo Centelles
h3. NC-specific local node information
10 1 Roger Pueyo Centelles
11 10 Roger Pueyo Centelles
The NCd, once registered to the Ubus daemon, provides the following procedures.
12
13
|_.Path                           |_.Procedure                                 |_.Signature                                      |_.Description |
14 1 Roger Pueyo Centelles
|\4=. |
15 11 Roger Pueyo Centelles
|ncd.local                        | [[Ubus#ncd-local-id|id]]                      | { }                                                    | Get the unique id of the local node |
16
|ncd.local                        | [[Ubus#ncd-local-neighbours|neighbours]]      | { }                                                    | List all the neighbours of the local node |
17
|ncd.local                        | [[Ubus#ncd-local-link-devices|linkdevices]]   | { "nodes": ["nodeid1", "nodeid2", ...] }               | List the devices used to link the local node to other nodes ¹|
18
|ncd.local.location.name          | [[Ubus|ncd-local-location-name-get]]          | { }                                                    | Get the position (name or description) where the node is located |
19
|ncd.local.location.name          | [[Ubus|ncd-local-location-name-set]]          | { "location" : "string" }                              | Get the position (name or description) where the node is located |
20
|ncd.local.location.coordinates   | [[Ubus|ncd-local-location-coordinates-get]]   | { }                                                    | Get the position (latitude and longitude coordinates) where the node is located |
21
|ncd.local.location.coordinates   | [[Ubus|ncd-local-location-coordinates-set]]   | { "coordinates" : [ "lat", "lon" ] }                   | Set the position (latitude and longitude coordinates) where the node is located |
22 10 Roger Pueyo Centelles
23 11 Roger Pueyo Centelles
¹ Two nodes can be linked via two different devices (a wired and a wireless device, two wireless devices at different frequencies, etc.)
24 1 Roger Pueyo Centelles
 
25
26 12 Roger Pueyo Centelles
h3. Local Ubus relay via NC
27 1 Roger Pueyo Centelles
28
The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered locally (like netifd, rpcd, etc.).
29
30 10 Roger Pueyo Centelles
|_.Path                       |_.Procedure                                      |_.Signature                                      |_.Description |
31
|\4=. |
32 1 Roger Pueyo Centelles
|ncd.local.relay.daemon.path        | [[Ubus#ncd-local-ubus-relay|procedure]]                              | { "daemon.path procedure signature" }           | Get the unique id of the local node |
33 10 Roger Pueyo Centelles
34 11 Roger Pueyo Centelles
See the example below to get a clear idea of how it works.
35
36 1 Roger Pueyo Centelles
 
37
38
39 11 Roger Pueyo Centelles
40 1 Roger Pueyo Centelles
h3. NC-specific remote node information
41 10 Roger Pueyo Centelles
42
The NCd can provide the following procedures regarding other nodes in the network running the NCd:
43
44 11 Roger Pueyo Centelles
|_.Path                            |_.Procedure                                    |_.Signature                                    |_.Description |
45 1 Roger Pueyo Centelles
|\4=. |
46 11 Roger Pueyo Centelles
|ncd.nodeid ²                      | [[Ubus#ncd-neighbours|neighbours]]            | { }                                                    | List all the neighbours of the node defined by _nodeid_ |
47
|ncd.nodeid                        | [[Ubus#ncd-nodeid-link-devices|linkdevices]]  | { "nodes": ["nodeid1", "nodeid2", ...] }               | List the devices used to link the node defined by _nodeid_ to other nodes |
48
|ncd.nodeid.location.name          | [[Ubus|get]]                                  | { }                                                    | Get the position (name or description) where the node defined by _nodeid_ is located |
49
|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 |
50
|ncd.nodeid.location.coordinates   | [[Ubus|get]]                                  | { }                                                    | Get the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located |
51
|ncd.nodeid.location.coordinates   | [[Ubus|set]]                                  | { "coordinates" : [ "lat", "lon" ] }                   | Set the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located |
52 1 Roger Pueyo Centelles
53 11 Roger Pueyo Centelles
² Replace _nodeid_ by the node's unique id
54 1 Roger Pueyo Centelles
 
55 10 Roger Pueyo Centelles
56
57 1 Roger Pueyo Centelles
58 11 Roger Pueyo Centelles
59 12 Roger Pueyo Centelles
h3. Remote Ubus relay via NC
60 10 Roger Pueyo Centelles
61
The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered remotely (like netifd, rpcd, etc.).
62
63
|_.Path                              |_.Procedure                                      |_.Signature                                      |_.Description |
64
|\4=. |
65 11 Roger Pueyo Centelles
|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_ |
66 10 Roger Pueyo Centelles
67 11 Roger Pueyo Centelles
² Replace _nodeid_ by the node's unique id
68 10 Roger Pueyo Centelles
 
69
70
71
72
73
74 11 Roger Pueyo Centelles
75 5 Roger Pueyo Centelles
h2. Usage examples
76 10 Roger Pueyo Centelles
77 5 Roger Pueyo Centelles
h3. ncd local id
78 1 Roger Pueyo Centelles
79
Request:
80 10 Roger Pueyo Centelles
 
81 1 Roger Pueyo Centelles
 @ubus call ncd.local id { }@
82
83
Response:
84
85
 @{ "id" : "node_id" }@
86
87
 
88
89
90
91
92
h3. ncd local neighbours
93
94
Request:
95
 
96
 @ubus call ncd.local neighbours { }@
97
98
Response:
99
100
 @{ "nodes" : [ "node011", "node400" ] }@
101 11 Roger Pueyo Centelles
102
 
103
104
105
106
107
h3. ncd local link devices
108
109
Request:
110
 
111
 @ubus call ncd.local linkdevices { "nodes" : [ "node011", "node400" ] }@
112
113
Response:
114
115
<pre>
116
{
117
  "links": [
118
    {
119
      "node011": [
120
        "eth0.12",
121
        "wlan0"
122
      ]
123
    },
124
    {
125
      "node400": [
126
        "wlan0"
127
      ]
128
    }
129
  ]
130
}
131
</pre>
132 1 Roger Pueyo Centelles
133
&nbsp;
134
135
136
137
138 10 Roger Pueyo Centelles
139
h3. ncd local location name get
140 1 Roger Pueyo Centelles
141
Request:
142 10 Roger Pueyo Centelles
 
143 1 Roger Pueyo Centelles
 @ubus call ncd.local.location.name get { }@
144
145
Response:
146 10 Roger Pueyo Centelles
147 1 Roger Pueyo Centelles
 @{ "coordinates" : [ "Narrow Street 16, Faketown" ] }@
148
149
&nbsp;
150
151 10 Roger Pueyo Centelles
152
153
154
155
h3. ncd local position coordinates get
156 1 Roger Pueyo Centelles
157
Request:
158 10 Roger Pueyo Centelles
 
159 1 Roger Pueyo Centelles
 @ubus call ncd.local.location.coordinates get { }@
160
161
Response:
162 10 Roger Pueyo Centelles
163 1 Roger Pueyo Centelles
 @{ "coordinates" : [ "42.34796", "3.11036" ] }@
164
165
&nbsp;
166
167
168
169 10 Roger Pueyo Centelles
170 1 Roger Pueyo Centelles
h3. ncd local position name set
171 10 Roger Pueyo Centelles
172
Request:
173
 
174 1 Roger Pueyo Centelles
 @ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@
175 10 Roger Pueyo Centelles
176 1 Roger Pueyo Centelles
Response:
177 10 Roger Pueyo Centelles
178 1 Roger Pueyo Centelles
 @{ ] }@
179 10 Roger Pueyo Centelles
180
&nbsp;
181
182
183
184
185
186
h3. ncd local position coordinates set
187 1 Roger Pueyo Centelles
188
Request:
189 10 Roger Pueyo Centelles
 
190 1 Roger Pueyo Centelles
 @ubus call ncd.local.position.coordinates set { "coordinates" : [ "42.34796", "3.11036" ] }@
191
192
Response:
193 10 Roger Pueyo Centelles
194
 @{ }@
195
196
&nbsp;
197
198
199
200
201
202
h3. ncd local ubus relay
203
204
Request:
205
 
206
 @ubus call ncd.local.relay.iwinfo devices { }@
207
208
Response:
209
210 1 Roger Pueyo Centelles
 <pre>
211 10 Roger Pueyo Centelles
{
212
	"devices": [
213
		"wlan1",
214
		"wlan0",
215
		"wlan0ap"
216 1 Roger Pueyo Centelles
	]
217 10 Roger Pueyo Centelles
}
218 1 Roger Pueyo Centelles
 </pre>
219
220 10 Roger Pueyo Centelles
&nbsp;
221
222
223
224
225
ubus call iwinfo devices
226
227
228 1 Roger Pueyo Centelles
229
230
h2. More examples
231
232
There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].