Projecte

General

Perfil

Ubus » Historial » Versió 9

Roger Pueyo Centelles, 02-06-2014 14:20

1 1 Roger Pueyo Centelles
h1. Ubus
2
3
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
5
h2. NCd ubus namespace and procedures summary
6
7 4 Roger Pueyo Centelles
h3. Local node information
8 1 Roger Pueyo Centelles
9 4 Roger Pueyo Centelles
|_.Path                       |_.Procedure                                      |_.Signature                                      |_.Description |
10 1 Roger Pueyo Centelles
|\4=. |
11 9 Roger Pueyo Centelles
|ncd.local                          | [[Ubus#ncd-id|id]]                              | { }                                             | Get the unique id of the local node |
12 6 Roger Pueyo Centelles
|ncd.local                          | [[Ubus#ncd-board|board]]                        | { }                                             | Get the system information of the local node (model, CPU, OpenWrt version, hostname, kernel version, etc.) ¹|
13
|ncd.local                          | [[Ubus#ncd-info|info]]                          | { }                                             | Get the system status of the local node (uptime, load, memory, etc.) ²|
14 9 Roger Pueyo Centelles
|ncd.local                          | [[Ubus#ncd-neighbours|neighbours]]              | { }                                             | List all the neighbours of the local node |
15
|ncd.local.position                 | [[Ubus|get]]                                    | { }                                             | Get the position (latitude and longitude) of the nodes |
16
|ncd.local.position                 | [[Ubus|set]]                                    | { "coordinates" : [ "lat", "lon" ] }            | Set the position (latitude and longitude) of the node |
17 4 Roger Pueyo Centelles
18
¹ It is the same information provided by OpenWrt's _system board_ Ubus call
19 9 Roger Pueyo Centelles
² It is the same information provided by OpenWrt's _system info_ Ubus call
20 1 Roger Pueyo Centelles
21
h3. Link-related information
22
23
|_.Path                        |_.Procedure                   |_.Signature                                      |_.Description |
24
|\4=. |
25 9 Roger Pueyo Centelles
|ncd.link                      | link                         | {  "nodes": [ "id_1", "id_2" ] }                | Get the details of the link(s) between nodes id_1 and id_2 |
26 1 Roger Pueyo Centelles
|                              |                              |                                                 |                               |
27 9 Roger Pueyo Centelles
28
h3. Remote node information
29
30
|_.Path                          |_.Procedure                                      |_.Signature                                    |_.Description |
31
|\4=. |
32
|ncd.nodeid ³                    | [[Ubus#ncd-board|board]]                      | { }                                           | Get the system information of the node defined by _nodeid_ (model, CPU, OpenWrt version, hostname, kernel version, etc.) ¹
33
|ncd.nodeid ³                    | [[Ubus#ncd-info|info]]                        | { }                                           | Get the system status of the node defined by _nodeid_ (uptime, load, memory, etc.) ²|
34
|ncd.nodeid ³                    | [[Ubus#ncd-neighbours|neighbours]]            | { }                                           | List all the neighbours of the node defined by  _nodeid_ |
35
|ncd.nodeid.position ³           | [[Ubus|get]]                                  | { }                                           | Get the position (latitude and longitude) of the node defined by _nodeid_ |
36
|ncd.nodeid.position ³           | [[Ubus|set]]                                  | { "coordinates" : [ "lat", "lon" ] }          | Set the position (latitude and longitude) of the node defined by _nodeid_ |
37
38
¹ It is the same information provided by OpenWrt's _system board_ Ubus call
39
² It is the same information provided by OpenWrt's _system info_ Ubus call
40
³ Replace _nodeid_ by the node's unique id
41
42 1 Roger Pueyo Centelles
43
h2. Usage examples
44
45 5 Roger Pueyo Centelles
h3. ncd id
46 1 Roger Pueyo Centelles
47
Request:
48 3 Roger Pueyo Centelles
 
49 5 Roger Pueyo Centelles
 @ubus call ncd id { }@
50 1 Roger Pueyo Centelles
51
Response:
52 3 Roger Pueyo Centelles
53 1 Roger Pueyo Centelles
 @{ "id" : "node_id" }@
54
55
 
56
57
58 5 Roger Pueyo Centelles
59
60
h3. ncd board
61
62 1 Roger Pueyo Centelles
Request:
63
 
64 5 Roger Pueyo Centelles
 @ubus call ncd board { }@
65 1 Roger Pueyo Centelles
66
Response:
67
68 5 Roger Pueyo Centelles
 <pre>
69
	{
70
		"kernel": "3.10.36",
71
		"hostname": "qMp-6a32",
72
		"system": "Qualcomm Atheros QCA9533 rev 1",
73
		"model": "TP-Link TL-WR841N\/ND v9",
74
		"release": {
75
			"distribution": "OpenWrt",
76
			"version": "Bleeding Edge",
77
			"revision": "r40831",
78
			"codename": "barrier_breaker",
79
			"target": "ar71xx\/generic",
80
			"description": "OpenWrt Barrier Breaker r40831"
81
		}
82
	}
83
</pre>
84 1 Roger Pueyo Centelles
85
&nbsp;
86
87
88
89
90 5 Roger Pueyo Centelles
h3. ncd info
91
92 1 Roger Pueyo Centelles
Request:
93
 
94 5 Roger Pueyo Centelles
 @ubus call ncd info { }@
95 1 Roger Pueyo Centelles
96
Response:
97
98 5 Roger Pueyo Centelles
 <pre>
99
	{
100
		"uptime": 9425,
101
		"localtime": 1401464813,
102
		"load": [
103
			3264,
104
			10592,
105
			7648
106
		],
107
		"memory": {
108
			"total": 29741056,
109
			"free": 5259264,
110
			"shared": 0,
111
			"buffered": 2297856
112
		},
113
		"swap": {
114
			"total": 0,
115
			"free": 0
116
		}
117
	}
118
</pre>
119 1 Roger Pueyo Centelles
120
&nbsp;
121
122 5 Roger Pueyo Centelles
h3. ncd.node.neighbours
123 1 Roger Pueyo Centelles
124 5 Roger Pueyo Centelles
Request:
125
 
126
 @ncd.node.neighbours { "node" : "id" }@
127 1 Roger Pueyo Centelles
128 5 Roger Pueyo Centelles
Response:
129
130
 @{ "nodes" : [ "id_1", "id_2", "id_3" ] }@
131
132
&nbsp;
133
134
135
136
137
138
139
140 1 Roger Pueyo Centelles
h3. ncd.node.info
141
142
Request:
143
 
144
 @ncd.node.info { "node" : "id" }@
145
146
Response:
147
148
<pre>
149
{
150
  "nodeinfo": {
151
    "id": "node016",
152
    "name": "FT-NarrowStreet1616-NSLM5",
153
    "hardware": {
154
      "model": "Ubiquiti Nanostation M",
155
      "type": "Atheros AR7241 rev 1",
156
      "cpu": "MIPS 24Kc V7.4",
157
      "ram": "29312"
158
    },
159
    "software": {
160
      "os": {
161
        "name": "OpenWrt",
162
        "version": 12.09,
163
        "codename": "Attitude Adjustment",
164
        "date": "2013-09-06",
165
        "revision": "r38347"
166
      },
167
      "qMp": {
168
        "version": "3.0-rc3",
169
        "codename": "Clearance",
170
        "date": 20140227,
171
        "revision": "d94713e",
172
        "branch": "master"
173
      },
174
      "bmx6": {
175
        "revision": "bae36ab0",
176
        "version": 12,
177
        "branch": "master"
178
      },
179
      "ncd": {
180
        "revision": "36aaed94",
181
        "version": 0.2,
182
        "branch": "dev"
183
      }
184
    },
185
    "interfaces": {
186
      "physical": {
187
        "wired": {
188
          "eth0": {
189
            "mac": "DC:9F:DB:4F:A1:F6",
190
            "encap": "Ethernet",
191
            "mode": "100baseTX",
192
            "mtu": 1500
193
          },
194
          "eth1": {
195
            "mac": "DE:9F:DB:4F:A1:F6",
196
            "encap": "Ethernet",
197
            "mode": "down",
198
            "mtu": 1500
199
          }
200
        },
201
        "wireless": {
202
          "radio0": {
203
            "type": "mac80211",
204
            "mac": "DC:9F:DB:4E:A1:F6",
205
            "hwmode": "auto",
206
            "channel": 124,
207
            "country": "SP",
208
            "txpower": 17,
209
            "distance": 5000,
210
            "ht": [
211
              "SHORT-GI-40",
212
              "RX-STBC1",
213
              "DSSS_CCK-40"
214
            ],
215
            "interfaces": {
216
              "wlan0": {
217
                "device": "radio0",
218
                "mode": "adhoc",
219
                "bssid": "02:CA:FF:EE:BA:BE",
220
                "ssid": "qMp-HWErmitaBellvitge16",
221
                "encryption": "open",
222
                "network": "lan",
223
                "ifname": "wlan0",
224
                "stations": {
225
                  "dc:9f:db:34:17:b6": {
226
                    "signal": [
227
                      -70,
228
                      -74,
229
                      -73
230
                    ],
231
                    "avgsignal": [
232
                      -70,
233
                      -74,
234
                      -73
235
                    ],
236
                    "txbitrate": "60.0 MBit/s MCS 9 40Mhz short GI",
237
                    "rxbitrate": "81.0 MBit/s MCS 4 40Mhz"
238
                  }
239
                }
240
              }
241
            }
242
          }
243
        }
244
      },
245
      "virtual": {
246
        "lo": {
247
          "type": "loopback",
248
          "addressing": {
249
            "ipv4": [
250
              {
251
                "ipaddr": "127.0.0.1",
252
                "netmask": "255.0.0.0"
253
              }
254
            ],
255
            "ipv6": [
256
              {
257
                "ipaddr6": "::1/128",
258
                "scope": "host"
259
              }
260
            ]
261
          }
262
        },
263
        "br-lan": {
264
          "type": "bridge",
265
          "ifname": [
266
            "eth0"
267
          ],
268
          "addressing": {
269
            "ipv4": [
270
              {
271
                "ipaddr": "10.1.32.33",
272
                "netmask": "255.255.255.224"
273
              },
274
              {
275
                "ipaddr": "169.254.246.1",
276
                "netmask": "255.255.255.248"
277
              }
278
            ],
279
            "ipv6": [
280
              {
281
                "scope": "global",
282
                "ipaddr6": "fd00:1714:1714:a1f6::1/64"
283
              },
284
              {
285
                "scope": "link",
286
                "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64"
287
              }
288
            ]
289
          }
290
        },
291
        "br-lan.12": {
292
          "type": "vlan",
293
          "ifname": [
294
            "eth0"
295
          ],
296
          "addressing": {
297
            "ipv6": [
298
              {
299
                "scope": "global",
300
                "ipaddr6": "fd66:66:66:8:de9f:dbff:fe4f:a1f6/64"
301
              },
302
              {
303
                "scope": "global",
304
                "ipaddr6": "fd02::dc9f:db4f:a1f6:0:112/128"
305
              },
306
              {
307
                "scope": "link",
308
                "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64"
309
              }
310
            ]
311
          }
312
        },
313
        "wlan0": {
314
          "type": "wireless",
315
          "ifname": "radio0",
316
          "addressing": {
317
            "ipv4": [
318
              {
319
                "ipaddr": "169.254.246.1",
320
                "netmask": "255.255.255.248"
321
              },
322
              {
323
                "ipaddr": "10.1.32.33",
324
                "netmask": "255.255.255.224"
325
              }
326
            ],
327
            "ipv6": [
328
              {
329
                "scope": "link",
330
                "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64"
331
              },
332
              {
333
                "scope": "global",
334
                "ipaddr6": "fd00:1714:1714:a1f6::1/64"
335
              },
336
              {
337
                "scope": "link",
338
                "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64"
339
              }
340
            ]
341
          }
342
        },
343
        "wlan0.12": {
344
          "type": "vlan",
345
          "ifname": "radio0",
346
          "addressing": {
347
            "ipv6": [
348
              {
349
                "scope": "link",
350
                "ipaddr6": "fd66:66:66:a:de9f:dbff:fe4e:a1f6/64"
351
              },
352
              {
353
                "scope": "global",
354
                "ipaddr6": "fd02::dc9f:db4f:a1f6:0:212/128"
355
              },
356
              {
357
                "scope": "link",
358
                "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64"
359
              }
360
            ]
361
          }
362
        },
363
        "bmxtmain": {
364
          "type": "tunnel6",
365
          "addressing": {
366
            "ipv4": [
367
              {
368
                "ipaddr": "10.1.32.33",
369
                "netmask": "255.255.255.224"
370
              }
371
            ],
372
            "ipv6": [
373
              {
374
                "scope": "global",
375
                "ipaddr6": "2012:0:0:a1f6::1/128"
376
              },
377
              {
378
                "scope": "link",
379
                "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64"
380
              }
381
            ]
382
          }
383
        }
384
      }
385
    }
386
  }
387
}
388
</pre>
389
390
&nbsp;
391
392
h2. More examples
393
394
There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].