Projecte

General

Perfil

Ubus » Historial » Versió 13

Roger Pueyo Centelles, 03-06-2014 15:28

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 11 Roger Pueyo Centelles
|ncd.nodeid ²                      | [[Ubus#ncd-neighbours|neighbours]]            | { }                                                    | List all the neighbours of the node defined by _nodeid_ |
31 1 Roger Pueyo Centelles
|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 |
32 11 Roger Pueyo Centelles
|ncd.nodeid.location.name          | [[Ubus|get]]                                  | { }                                                    | Get the position (name or description) where the node defined by _nodeid_ is located |
33
|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 11 Roger Pueyo Centelles
 
53 10 Roger Pueyo Centelles
54 13 Roger Pueyo Centelles
See the examples below to get a clear idea of how it works.
55 10 Roger Pueyo Centelles
56
57
58
59 11 Roger Pueyo Centelles
60 5 Roger Pueyo Centelles
h2. Usage examples
61 10 Roger Pueyo Centelles
62 5 Roger Pueyo Centelles
h3. ncd local id
63 1 Roger Pueyo Centelles
64
Request:
65 10 Roger Pueyo Centelles
 
66 1 Roger Pueyo Centelles
 @ubus call ncd.local id { }@
67
68
Response:
69
70
 @{ "id" : "node_id" }@
71
72
 
73
74
75
76
77
h3. ncd local neighbours
78
79
Request:
80
 
81
 @ubus call ncd.local neighbours { }@
82
83
Response:
84
85
 @{ "nodes" : [ "node011", "node400" ] }@
86 11 Roger Pueyo Centelles
87
 
88
89
90
91
92
h3. ncd local link devices
93
94
Request:
95
 
96
 @ubus call ncd.local linkdevices { "nodes" : [ "node011", "node400" ] }@
97
98
Response:
99
100
<pre>
101
{
102
  "links": [
103
    {
104
      "node011": [
105
        "eth0.12",
106
        "wlan0"
107
      ]
108
    },
109
    {
110
      "node400": [
111
        "wlan0"
112
      ]
113
    }
114
  ]
115
}
116
</pre>
117 1 Roger Pueyo Centelles
118
&nbsp;
119
120
121
122
123 10 Roger Pueyo Centelles
124
h3. ncd local location name get
125 1 Roger Pueyo Centelles
126
Request:
127 10 Roger Pueyo Centelles
 
128 1 Roger Pueyo Centelles
 @ubus call ncd.local.location.name get { }@
129
130
Response:
131 10 Roger Pueyo Centelles
132 1 Roger Pueyo Centelles
 @{ "coordinates" : [ "Narrow Street 16, Faketown" ] }@
133
134
&nbsp;
135
136 10 Roger Pueyo Centelles
137
138
139
140
h3. ncd local position coordinates get
141 1 Roger Pueyo Centelles
142
Request:
143 10 Roger Pueyo Centelles
 
144 1 Roger Pueyo Centelles
 @ubus call ncd.local.location.coordinates get { }@
145
146
Response:
147 10 Roger Pueyo Centelles
148 1 Roger Pueyo Centelles
 @{ "coordinates" : [ "42.34796", "3.11036" ] }@
149
150
&nbsp;
151
152
153
154 10 Roger Pueyo Centelles
155 1 Roger Pueyo Centelles
h3. ncd local position name set
156 10 Roger Pueyo Centelles
157
Request:
158
 
159 1 Roger Pueyo Centelles
 @ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@
160 10 Roger Pueyo Centelles
161 1 Roger Pueyo Centelles
Response:
162 10 Roger Pueyo Centelles
163 1 Roger Pueyo Centelles
 @{ ] }@
164 10 Roger Pueyo Centelles
165
&nbsp;
166
167
168
169
170
171
h3. ncd local position coordinates set
172 1 Roger Pueyo Centelles
173
Request:
174 10 Roger Pueyo Centelles
 
175 1 Roger Pueyo Centelles
 @ubus call ncd.local.position.coordinates set { "coordinates" : [ "42.34796", "3.11036" ] }@
176
177
Response:
178 10 Roger Pueyo Centelles
179
 @{ }@
180
181
&nbsp;
182
183
184
185
186
187
h3. ncd local ubus relay
188
189
Request:
190
 
191
 @ubus call ncd.local.relay.iwinfo devices { }@
192
193
Response:
194
195 1 Roger Pueyo Centelles
 <pre>
196 10 Roger Pueyo Centelles
{
197
	"devices": [
198
		"wlan1",
199
		"wlan0",
200
		"wlan0ap"
201 1 Roger Pueyo Centelles
	]
202 10 Roger Pueyo Centelles
}
203 1 Roger Pueyo Centelles
 </pre>
204
205 10 Roger Pueyo Centelles
&nbsp;
206
207
208
209
210
ubus call iwinfo devices
211
212
213 1 Roger Pueyo Centelles
214
215
h2. More examples
216
217
There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].