Projecte

General

Perfil

Ubus » Historial » Versió 14

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