1# OpenThread CLI - Network Data 2 3## Overview 4 5Thread Network Data contains information about Border Routers and other servers available in the Thread network. Border Routers and devices offering services register their information with the Leader. The Leader collects and structures this information within the Thread Network Data and distributes the information to all devices in the Thread Network. 6 7Border Routers may register prefixes assigned to the Thread Network and prefixes that they offer routes for. Services may register any information relevant to the service itself. 8 9Border Router and service information may be stable or temporary. Stable Thread Network Data is distributed to all devices, including Sleepy End Devices (SEDs). Temporary Network Data is distributed to all nodes except SEDs. 10 11## Quick Start 12 13### Form Network and Configure Prefix 14 151. Generate and view new network configuration. 16 17 ```bash 18 > dataset init new 19 Done 20 > dataset 21 Active Timestamp: 1 22 Channel: 13 23 Channel Mask: 0x07fff800 24 Ext PAN ID: d63e8e3e495ebbc3 25 Mesh Local Prefix: fd3d:b50b:f96d:722d::/64 26 Network Key: dfd34f0f05cad978ec4e32b0413038ff 27 Network Name: OpenThread-8f28 28 PAN ID: 0x8f28 29 PSKc: c23a76e98f1a6483639b1ac1271e2e27 30 Security Policy: 0, onrc 31 Done 32 ``` 33 342. Commit new dataset to the Active Operational Dataset in non-volatile storage. 35 36 ```bash 37 dataset commit active 38 Done 39 ``` 40 413. Enable Thread interface 42 43 ```bash 44 > ifconfig up 45 Done 46 > thread start 47 Done 48 ``` 49 504. Observe IPv6 addresses assigned to the Thread interface. 51 52 ```bash 53 > ipaddr 54 fd3d:b50b:f96d:722d:0:ff:fe00:fc00 55 fd3d:b50b:f96d:722d:0:ff:fe00:dc00 56 fd3d:b50b:f96d:722d:393c:462d:e8d2:db32 57 fe80:0:0:0:a40b:197f:593d:ca61 58 Done 59 ``` 60 615. Register an IPv6 prefix assigned to the Thread network. 62 63 ```bash 64 > prefix add fd00:dead:beef:cafe::/64 paros 65 Done 66 > netdata register 67 Done 68 ``` 69 706. Observe Thread Network Data. 71 72 ```bash 73 > netdata show 74 Prefixes: 75 fd00:dead:beef:cafe::/64 paros med dc00 76 Routes: 77 Services: 78 Done 79 ``` 80 817. Observe IPv6 addresses assigned to the Thread interface. 82 83 ```bash 84 > ipaddr 85 fd00:dead:beef:cafe:4da8:5234:4aa2:4cfa 86 fd3d:b50b:f96d:722d:0:ff:fe00:fc00 87 fd3d:b50b:f96d:722d:0:ff:fe00:dc00 88 fd3d:b50b:f96d:722d:393c:462d:e8d2:db32 89 fe80:0:0:0:a40b:197f:593d:ca61 90 Done 91 ``` 92 93### Attach to Existing Network 94 95Only the Network Key is required for a device to attach to a Thread network. 96 97While not required, specifying the channel avoids the need to search across multiple channels, improving both latency and efficiency of the attach process. 98 99After the device successfully attaches to a Thread network, the device will retrieve the complete Active Operational Dataset. 100 1011. Create a partial Active Operational Dataset. 102 103 ```bash 104 > dataset networkkey dfd34f0f05cad978ec4e32b0413038ff 105 Done 106 > dataset commit active 107 Done 108 ``` 109 1102. Enable Thread interface. 111 112 ```bash 113 > ifconfig up 114 Done 115 > thread start 116 Done 117 ``` 118 1193. After attaching, observe Thread Network Data. 120 121 ```bash 122 > netdata show 123 Prefixes: 124 fd00:dead:beef:cafe::/64 paros med dc00 125 Routes: 126 Services: 127 Done 128 ``` 129 1304. Observe IPv6 addresses assigned to the Thread interface. 131 132 ```bash 133 > ipaddr 134 fd00:dead:beef:cafe:4da8:5234:4aa2:4cfa 135 fd3d:b50b:f96d:722d:0:ff:fe00:fc00 136 fd3d:b50b:f96d:722d:0:ff:fe00:dc00 137 fd3d:b50b:f96d:722d:393c:462d:e8d2:db32 138 fe80:0:0:0:a40b:197f:593d:ca61 139 Done 140 ``` 141 142## Command List 143 144- [help](#help) 145- [full](#full) 146- [length](#length) 147- [maxlength](#maxlength) 148- [publish](#publish) 149- [register](#register) 150- [show](#show) 151- [steeringdata](#steeringdata-check-eui64discerner) 152- [unpublish](#unpublish) 153 154## Command Details 155 156### help 157 158Usage: `netdata help` 159 160Print netdata help menu. 161 162```bash 163> netdata help 164full 165length 166maxlength 167publish 168register 169show 170steeringdata 171unpublish 172Done 173``` 174 175### full 176 177Usage: `netdata full` 178 179Print "yes" or "no" flag tracking whether or not the "net data full" callback has been invoked since start of Thread operation or since the last time `netdata full reset` was used to reset the flag. 180 181This command requires `OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL`. 182 183The "net data full" callback is invoked whenever: 184 185- The device is acting as a leader and receives a Network Data registration from a Border Router (BR) that it cannot add to Network Data (running out of space). 186- The device is acting as a BR and new entries cannot be added to its local Network Data. 187- The device is acting as a BR and tries to register its local Network Data entries with the leader, but determines that its local entries will not fit. 188 189``` 190> netdata full 191no 192Done 193``` 194 195### full reset 196 197Usage: `netdata full reset` 198 199Reset the flag tracking whether "net data full" callback was invoked. 200 201This command requires `OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL`. 202 203``` 204> netdata full reset 205Done 206``` 207 208### length 209 210Usage: `netdata length` 211 212Get the current length of (number of bytes) Partition's Thread Network Data. 213 214```bash 215> netdata length 21623 217Done 218``` 219 220### maxlength 221 222Usage: `netdata maxlength` 223 224Get the maximum observed length of the Thread Network Data since OT stack initialization or since the last call to `netdata maxlength reset`. 225 226```bash 227> netdata maxlength 22840 229Done 230``` 231 232### maxlength reset 233 234Usage: `netdata maxlength reset` 235 236Reset the tracked maximum length of the Thread Network Data. 237 238```bash 239> netdata maxlength reset 240Done 241``` 242 243### publish 244 245The Network Data Publisher provides mechanisms to limit the number of similar Service and/or Prefix (on-mesh prefix or external route) entries in the Thread Network Data by monitoring the Network Data and managing if or when to add or remove entries. 246 247The Publisher requires `OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE`. 248 249### publish dnssrp 250 251Publish DNS/SRP service entry. 252 253This command requires `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE`. 254 255The following formats are available: : 256 257- `netdata publish dnssrp anycast <seq-num>` to publish "DNS/SRP Service Anycast Address" with a given sequence number. 258- `netdata publish dnssrp unicast <address> <port>` to publish "DNS/SRP Service Unicast Address" with given address and port number info. The address/port info is included in Service TLV data. 259- `netdata publish dnssrp unicast <port>` to publish "DNS/SRP Service Unicast Address" with given port number and the device's mesh-local EID for the address. The address and port info is included in Server TLV data. 260 261A new call to `netdata publish dnssrp [anycast|unicast] [...]` command will remove and replace any previous "DNS/SRP Service" entry that was being published (from earlier `netdata publish dnssrp [...]` commands). 262 263```bash 264> netdata publish dnssrp anycast 1 265Done 266 267> netdata publish dnssrp unicast fd00::1234 51525 268Done 269 270> netdata publish dnssrp unicast 50152 271Done 272``` 273 274### publish prefix \<prefix\> [padcrosnD][prf] 275 276Publish an on-mesh prefix entry. 277 278- p: Preferred flag 279- a: Stateless IPv6 Address Autoconfiguration flag 280- d: DHCPv6 IPv6 Address Configuration flag 281- c: DHCPv6 Other Configuration flag 282- r: Default Route flag 283- o: On Mesh flag 284- s: Stable flag 285- n: Nd Dns flag 286- D: Domain Prefix flag (only available for Thread 1.2). 287- prf: Preference, which may be 'high', 'med', or 'low'. 288 289```bash 290> netdata publish prefix fd00:1234:5678::/64 paos med 291Done 292``` 293 294### publish route \<prefix\> [sn][prf] 295 296Publish an external route entry. 297 298- s: Stable flag 299- n: NAT64 flag 300- a: Advertising PIO (AP) flag 301- prf: Preference, which may be: 'high', 'med', or 'low'. 302 303```bash 304> netdata publish route fd00:1234:5678::/64 s high 305Done 306``` 307 308### publish replace \<old prefix\> \<prefix\> [sn][prf] 309 310Replace a previously published external route entry. 311 312If there is no previously published external route matching old prefix, this command behaves similarly to `netdata publish route`. If there is a previously published route entry, it will be replaced with the new prefix. In particular, if the old prefix was already added in the Network Data, the change to the new prefix is immediately reflected in the Network Data (i.e., old prefix is removed and the new prefix is added in the same Network Data registration request to leader). This ensures that route entries in the Network Data are not abruptly removed. 313 314- s: Stable flag 315- n: NAT64 flag 316- a: Advertising PIO (AP) flag 317- prf: Preference, which may be: 'high', 'med', or 'low'. 318 319```bash 320> netdata publish replace ::/0 fd00:1234:5678::/64 s high 321Done 322``` 323 324### register 325 326Usage: `netdata register` 327 328Register configured prefixes, routes, and services with the Leader. 329 330```bash 331> netdata register 332Done 333``` 334 335### show 336 337Usage: `netdata show [local] [-x] [\<rloc16\>]` 338 339Print entries in Network Data, on-mesh prefixes, external routes, services, and 6LoWPAN context information. 340 341If the optional `rloc16` input is specified, prints the entries associated with the given RLOC16 only. The RLOC16 filtering can be used when `-x` or `local` are not used. 342 343On-mesh prefixes are listed under `Prefixes` header: 344 345- The on-mesh prefix 346- Flags 347 - p: Preferred flag 348 - a: Stateless IPv6 Address Autoconfiguration flag 349 - d: DHCPv6 IPv6 Address Configuration flag 350 - c: DHCPv6 Other Configuration flag 351 - r: Default Route flag 352 - o: On Mesh flag 353 - s: Stable flag 354 - n: Nd Dns flag 355 - D: Domain Prefix flag (only available for Thread 1.2). 356- Preference `high`, `med`, or `low` 357- RLOC16 of device which added the on-mesh prefix 358 359External Routes are listed under `Routes` header: 360 361- The route prefix 362- Flags 363 - s: Stable flag 364 - n: NAT64 flag 365 - a: Advertising PIO (AP) flag 366- Preference `high`, `med`, or `low` 367- RLOC16 of device which added the route prefix 368 369Service entries are listed under `Services` header: 370 371- Enterprise number 372- Service data (as hex bytes) 373- Server data (as hex bytes) 374- Flags 375 - s: Stable flag 376- RLOC16 of devices which added the service entry 377- Service ID 378 3796LoWPAN Context IDs are listed under `Contexts` header: 380 381- The prefix 382- Context ID 383- Compress flag (`c` if marked or `-` otherwise). 384 385Commissioning Dataset information is printed under `Commissioning` header: 386 387- Session ID if present in Dataset or `-` otherwise 388- Border Agent RLOC16 (in hex) if present in Dataset or `-` otherwise 389- Joiner UDP port number if present in Dataset or `-` otherwise 390- Steering Data (as hex bytes) if present in Dataset or `-` otherwise 391- Flags: 392 - e: if Dataset contains any extra unknown TLV 393 394Print Network Data received from the Leader. 395 396```bash 397> netdata show 398Prefixes: 399fd00:dead:beef:cafe::/64 paros med a000 400Routes: 401fd00:1234:0:0::/64 s med a000 402fd00:4567:0:0::/64 s med 8000 403Services: 40444970 5d fddead00beef00007bad0069ce45948504d2 s a000 0 405Contexts: 406fd00:dead:beef:cafe::/64 1 c 407Commissioning: 4081248 dc00 9988 00000000000120000000000000000000 e 409Done 410``` 411 412Print Network Data entries from the Leader associated with `0xa00` RLOC16. 413 414```bash 415> netdata show 0xa00 416Prefixes: 417fd00:dead:beef:cafe::/64 paros med a000 418Routes: 419fd00:1234:0:0::/64 s med a000 420Services: 42144970 5d fddead00beef00007bad0069ce45948504d2 s a000 0 422Done 423``` 424 425Print Network Data received from the Leader as hex-encoded TLVs. 426 427```bash 428> netdata show -x 42908040b02174703140040fd00deadbeefcafe0504dc00330007021140 430Done 431``` 432 433Print local Network Data to sync with Leader. 434 435```bash 436> netdata show local 437Prefixes: 438fd00:dead:beef:cafe::/64 paros med dc00 439Routes: 440Services: 441Done 442``` 443 444Print local Network Data to sync with Leader as hex-encoded TLVs. 445 446```bash 447> netdata show local -x 44808040b02174703140040fd00deadbeefcafe0504dc00330007021140 449Done 450``` 451 452### netdata steeringdata check \<eui64\>|\<discerner\> 453 454Check whether the steering data includes a joiner. 455 456- eui64: The IEEE EUI-64 of the Joiner. 457- discerner: The Joiner discerner in format `number/length`. 458 459```bash 460> netdata steeringdata check d45e64fa83f81cf7 461Done 462> netdata steeringdata check 0xabc/12 463Done 464> netdata steeringdata check 0xdef/12 465Error 23: NotFound 466``` 467 468### unpublish 469 470This command unpublishes a previously published Network Data entry. 471 472This command requires `OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE`. 473 474### unpublish dnssrp 475 476Unpublishes DNS/SRP Service entry (available when `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` is enabled): 477 478- `netdata unpublish dnssrp` to unpublish "DNS/SRP Service" entry (anycast or unciast). 479 480```bash 481> netdata unpublish dnssrp 482Done 483``` 484 485### unpublish \<prefix\> 486 487Unpublishes a previously published on-mesh prefix or external route entry. 488 489```bash 490> netdata unpublish fd00:1234:5678::/64 491Done 492``` 493