1# OpenThread CLI - Operational Datasets
2
3## Overview
4
5Thread network configuration parameters are managed using Active and Pending Operational Dataset objects.
6
7### WARNING - Restrictions for production use!
8
9The CLI commands to write/change the Active and Pending Operational Datasets may allow setting invalid parameters, or invalid combinations of parameters, for testing purposes. These CLI commands can only be used:
10
11- To configure network parameters for the first device in a newly created Thread network.
12- For testing (not applicable to production devices).
13
14In production Thread networks, the correct method to write/change Operational Datasets is via a [Commissioner](README_COMMISSIONER.md) that performs [commissioning](README_COMMISSIONING.md). Production devices that are not an active Commissioner and are part of a Thread network MUST NOT modify the Operational Datasets in any way.
15
16### Active Operational Dataset
17
18The Active Operational Dataset includes parameters that are currently in use across an entire Thread network. The Active Operational Dataset contains:
19
20- Active Timestamp
21- Channel
22- Wake-up Channel
23- Channel Mask
24- Extended PAN ID
25- Mesh-Local Prefix
26- Network Name
27- PAN ID
28- PSKc
29- Security Policy
30
31### Pending Operational Dataset
32
33The Pending Operational Dataset is used to communicate changes to the Active Operational Dataset before they take effect. The Pending Operational Dataset contains all the parameters from the Active Operational Dataset, with the addition of:
34
35- Delay Timer
36- Pending Timestamp
37
38## Quick Start
39
40### Form Network
41
421. Generate and view new network configuration.
43
44   ```bash
45   > dataset init new
46   Done
47   > dataset
48   Active Timestamp: 1
49   Channel: 15
50   Wake-up Channel: 16
51   Channel Mask: 0x07fff800
52   Ext PAN ID: 39758ec8144b07fb
53   Mesh Local Prefix: fdf1:f1ad:d079:7dc0::/64
54   Network Key: f366cec7a446bab978d90d27abe38f23
55   Network Name: OpenThread-5938
56   PAN ID: 0x5938
57   PSKc: 3ca67c969efb0d0c74a4d8ee923b576c
58   Security Policy: 672 onrc 0
59   Done
60   ```
61
622. Commit new dataset to the Active Operational Dataset in non-volatile storage.
63
64   ```bash
65   dataset commit active
66   Done
67   ```
68
693. Enable Thread interface
70
71   ```bash
72   > ifconfig up
73   Done
74   > thread start
75   Done
76   ```
77
78### Attach to Existing Network
79
80Only the Network Key is required for a device to attach to a Thread network.
81
82While not required, specifying the channel avoids the need to search across multiple channels, improving both latency and efficiency of the attach process.
83
84After the device successfully attaches to a Thread network, the device will retrieve the complete Active Operational Dataset.
85
861. Create a partial Active Operational Dataset.
87
88   ```bash
89   > dataset networkkey dfd34f0f05cad978ec4e32b0413038ff
90   Done
91   > dataset commit active
92   Done
93   ```
94
952. Enable Thread interface.
96
97   ```bash
98   > ifconfig up
99   Done
100   > thread start
101   Done
102   ```
103
1043. After attaching, validate that the device received the complete Active Operational Dataset.
105
106   ```bash
107   > dataset active
108   Active Timestamp: 1
109   Channel: 15
110   Wake-up Channel: 16
111   Channel Mask: 0x07fff800
112   Ext PAN ID: 39758ec8144b07fb
113   Mesh Local Prefix: fdf1:f1ad:d079:7dc0::/64
114   Network Key: f366cec7a446bab978d90d27abe38f23
115   Network Name: OpenThread-5938
116   PAN ID: 0x5938
117   PSKc: 3ca67c969efb0d0c74a4d8ee923b576c
118   Security Policy: 672 onrc 0
119   Done
120   ```
121
122### Using the Dataset Updater to update Operational Dataset
123
124Dataset Updater can be used for a delayed update of network parameters on all devices of a Thread Network.
125
1261. Clear the dataset buffer and add the Dataset fields to update.
127
128   ```bash
129   > dataset clear
130   Done
131
132   > dataset channel 12
133   Done
134   ```
135
1362. Set the delay timer parameter (example uses 5 minutes or 300000 ms). Check the resulting dataset. There is no need to specify active or pending timestamps because the Dataset Updater will handle this. If specified the `dataset updater start` will issue an error.
137
138   ```bash
139   > dataset delay 300000
140
141   > dataset
142   Channel: 12
143   Delay: 30000
144   Done
145   ```
146
1473. Start the Dataset Updater, which will prepare a Pending Operation Dataset and inform the Leader to distribute it to other devices.
148
149   ```bash
150   > dataset updater start
151   Done
152
153   > dataset updater
154   Enabled
155   ```
156
1574. After about 5 minutes, the changes are applied to the Active Operational Dataset on the Leader. This can also be checked at other devices on the network: these should have applied the new Dataset too, at approximately the same time as the Leader has done this.
158
159   ```bash
160   > dataset active
161   Active Timestamp: 10
162   Channel: 12
163   Channel Mask: 0x07fff800
164   Ext PAN ID: 324a71d90cdc8345
165   Mesh Local Prefix: fd7d:da74:df5e:80c::/64
166   Network Key: be768535bac1b8d228960038311d6ca2
167   Network Name: OpenThread-bcaf
168   PAN ID: 0xbcaf
169   PSKc: e79b274ab22414a814ed5cce6a30be67
170   Security Policy: 672 onrc 0
171   Done
172   ```
173
174### Using the Pending Operational Dataset for Delayed Dataset Updates
175
176The Pending Operational Dataset can be used for a delayed update of network parameters on all devices of a Thread Network. If certain Active Operational Dataset parameters need to be changed, but the change would impact the connectivity of the network, delaying the update helps to let all devices receive the new parameters before the update is applied. Examples of such parameters are the channel, PAN ID, certain Security Policy bits, or Network Key.
177
178The delay timer determines the time period after which the Pending Operational Dataset takes effect and becomes the Active Operational Dataset. The following example shows how a Pending Operational Dataset with delay timer can be set at a Leader device. The Leader will initiate the distribution of the Pending Operational Dataset to the rest of the devices in the network.
179
180Normally, an active Commissioner will set a new Pending Operational Dataset. For testing purposes, we will do this in the example directly on the Leader using the CLI - so without using a Commissioner.
181
1821. The main parameter to change is the channel. We can display the current Active Operational Dataset to see that the current channel is 16.
183
184   ```bash
185   > dataset active
186   Active Timestamp: 1691070443
187   Channel: 16
188   Channel Mask: 0x07fff800
189   Ext PAN ID: 324a71d90cdc8345
190   Mesh Local Prefix: fd7d:da74:df5e:80c::/64
191   Network Key: be768535bac1b8d228960038311d6ca2
192   Network Name: OpenThread-bcaf
193   PAN ID: 0xbcaf
194   PSKc: e79b274ab22414a814ed5cce6a30be67
195   Security Policy: 672 onrc 0
196   Done
197   ```
198
1992. Create a new Dataset in the dataset buffer, by copying the Active Operational Dataset. Then change the channel number to 12 and increase the timestamp.
200
201   ```bash
202   > dataset init active
203   Done
204   > dataset activetimestamp 1696177379
205   Done
206   > dataset pendingtimestamp 1696177379
207   Done
208   > dataset channel 12
209   Done
210   ```
211
2123. Set the delay timer parameter to 5 minutes (300000 ms). Show the resulting Dataset that's ready to be used.
213
214   ```bash
215   > dataset delay 300000
216   Done
217   > dataset
218   Pending Timestamp: 1696177379
219   Active Timestamp: 1696177379
220   Channel: 12
221   Channel Mask: 0x07fff800
222   Delay: 300000
223   Ext PAN ID: 324a71d90cdc8345
224   Mesh Local Prefix: fd7d:da74:df5e:80c::/64
225   Network Key: be768535bac1b8d228960038311d6ca2
226   Network Name: OpenThread-bcaf
227   PAN ID: 0xbcaf
228   PSKc: e79b274ab22414a814ed5cce6a30be67
229   Security Policy: 672 onrc 0
230   Done
231   ```
232
2334. Commit the new Dataset as the Pending Operational Dataset. This also starts the delay timer countdown. The Leader then starts the distribution of the Pending Operational Dataset to other devices in the network.
234
235   ```bash
236   > dataset commit pending
237   Done
238   ```
239
2405. To verify that the delay timer is counting down, display the Pending Operational Dataset after a few seconds.
241
242   ```bash
243   > dataset pending
244   Pending Timestamp: 1696177379
245   Active Timestamp: 1696177379
246   Channel: 12
247   Channel Mask: 0x07fff800
248   Delay: 293051
249   Ext PAN ID: 324a71d90cdc8345
250   Mesh Local Prefix: fd7d:da74:df5e:80c::/64
251   Network Key: be768535bac1b8d228960038311d6ca2
252   Network Name: OpenThread-bcaf
253   PAN ID: 0xbcaf
254   PSKc: e79b274ab22414a814ed5cce6a30be67
255   Security Policy: 672 onrc 0
256   Done
257   ```
258
259   This shows that indeed the delay timer has started counting down from its initial value `300000`. The same can be optionally checked on other devices in the network.
260
2616) After about 5 minutes, check that the Pending Operational Dataset has been applied at the Leader. This can also be checked at other devices on the network: these should have applied the new Dataset too, at approximately the same time as the Leader has done this.
262
263   ```bash
264   > dataset active
265   Active Timestamp: 1696177379
266   Channel: 12
267   Channel Mask: 0x07fff800
268   Ext PAN ID: 324a71d90cdc8345
269   Mesh Local Prefix: fd7d:da74:df5e:80c::/64
270   Network Key: be768535bac1b8d228960038311d6ca2
271   Network Name: OpenThread-bcaf
272   PAN ID: 0xbcaf
273   PSKc: e79b274ab22414a814ed5cce6a30be67
274   Security Policy: 672 onrc 0
275   Done
276   ```
277
278   This shows that the Active Operational Dataset has now been updated to use channel 12. And the Pending Operational Dataset is no longer present, as can be seen by this command:
279
280   ```bash
281   > dataset pending
282   Error 23: NotFound
283   ```
284
285## Command List
286
287- [help](#help)
288- [active](#active)
289- [activetimestamp](#activetimestamp)
290- [channel](#channel)
291- [channelmask](#channelmask)
292- [clear](#clear)
293- [commit](#commit)
294- [delay](#delay)
295- [extpanid](#extpanid)
296- [init](#init)
297- [meshlocalprefix](#meshlocalprefix)
298- [mgmtgetcommand](#mgmtgetcommand)
299- [mgmtsetcommand](#mgmtsetcommand)
300- [networkkey](#networkkey)
301- [networkname](#networkname)
302- [panid](#panid)
303- [pending](#pending)
304- [pendingtimestamp](#pendingtimestamp)
305- [pskc](#pskc)
306- [securitypolicy](#securitypolicy)
307- [tlvs](#tlvs)
308- [updater](#updater)
309- [wakeupchannel](#wakeupchannel)
310
311## Command Details
312
313### help
314
315Usage: `dataset help`
316
317Print dataset help menu.
318
319```bash
320> dataset help
321help
322active
323activetimestamp
324channel
325channelmask
326clear
327commit
328delay
329extpanid
330init
331meshlocalprefix
332mgmtgetcommand
333mgmtsetcommand
334networkkey
335networkname
336panid
337pending
338pendingtimestamp
339pskc
340securitypolicy
341set
342tlvs
343wakeupchannel
344Done
345```
346
347### active
348
349Usage: `dataset active [-x]`
350
351Print Active Operational Dataset in human-readable form.
352
353```bash
354> dataset active
355Active Timestamp: 1
356Channel: 15
357Wake-up Channel: 16
358Channel Mask: 0x07fff800
359Ext PAN ID: 39758ec8144b07fb
360Mesh Local Prefix: fdf1:f1ad:d079:7dc0::/64
361Network Key: f366cec7a446bab978d90d27abe38f23
362Network Name: OpenThread-5938
363PAN ID: 0x5938
364PSKc: 3ca67c969efb0d0c74a4d8ee923b576c
365Security Policy: 672 onrc 0
366Done
367```
368
369Print Active Operational Dataset as hex-encoded TLVs.
370
371```bash
372> dataset active -x
3730e08000000000001000000030000164a0300001735060004001fffe00208b182e6a17996cecc0708fd3f363fa8f1b0bc0510ebb6f6a447c96e1542176df3a834ac0e030f4f70656e5468726561642d3663393901026c99041096e9cdfe1eb1363a3676e2b94df0271b0c0402a0f7f8
374Done
375```
376
377### activetimestamp
378
379Usage: `dataset activetimestamp [timestamp]`
380
381Get active timestamp seconds. It represents a "Unix time", in number of seconds since Jan 1st, 1970.
382
383```bash
384> dataset activetimestamp
385123456789
386Done
387```
388
389Set active timestamp seconds.
390
391```bash
392> dataset activetimestamp 123456789
393Done
394```
395
396### channel
397
398Usage: `channel [channel]`
399
400Get channel.
401
402```bash
403> dataset channel
40412
405Done
406```
407
408Set channel.
409
410```bash
411> dataset channel 12
412Done
413```
414
415### channelmask
416
417Usage: `dataset channelmask [channelmask]`
418
419Get channel mask.
420
421```bash
422> dataset channelmask
4230x07fff800
424Done
425```
426
427Set channel mask.
428
429```bash
430> dataset channelmask 0x07fff800
431Done
432```
433
434### clear
435
436Usage: `dataset clear`
437
438Reset operational dataset buffer.
439
440```bash
441> dataset clear
442Done
443```
444
445### commit
446
447Usage: `dataset commit <active|pending>`
448
449Commit operational dataset buffer to active/pending operational dataset.
450
451```bash
452> dataset commit active
453Done
454```
455
456### delay
457
458Usage: `dataset delay [delay]`
459
460Get delay timer value. The timer value is in milliseconds.
461
462```bash
463> dataset delay
4641000
465Done
466```
467
468Set delay timer value.
469
470```bash
471> dataset delay 100000
472Done
473```
474
475### extpanid
476
477Usage: `dataset extpanid [extpanid]`
478
479Get extended panid.
480
481```bash
482> dataset extpanid
483000db80123456789
484Done
485```
486
487Set extended panid.
488
489**NOTE** The commissioning credential in the dataset buffer becomes stale after changing this value. Use [pskc](#pskc) to reset.
490
491```bash
492> dataset extpanid 000db80123456789
493Done
494```
495
496### init
497
498Usage: `dataset init <active|new|pending|tlvs <hex-encoded TLVs>>`
499
500Initialize operational dataset buffer. Use `new` to initialize with randomly selected values:
501
502```bash
503> dataset init new
504Done
505```
506
507Use `active` or `pending` to initialize the dataset buffer with a copy of the current Active Operational Dataset or Pending Operational Dataset, respectively:
508
509```bash
510> dataset init active
511Done
512```
513
514Use the `tlvs` option to initialize the dataset buffer from a string of hex-encoded TLVs:
515
516```bash
517> dataset init tlvs 0e080000000000010000000300001235060004001fffe002088665f03e6e42e7750708fda576e5f9a5bd8c0510506071d8391be671569e080d52870fd5030f4f70656e5468726561642d633538640102c58d04108a926cf8b13275a012ceedeeae40910d0c0402a0f7f8
518Done
519```
520
521### meshlocalprefix
522
523Usage: `dataset meshlocalprefix [prefix]`
524
525Get mesh local prefix.
526
527```bash
528> dataset meshlocalprefix
529fd00:db8:0:0::/64
530Done
531```
532
533Set mesh local prefix.
534
535```bash
536> dataset meshlocalprefix fd00:db8::
537Done
538```
539
540### mgmtgetcommand
541
542Usage: `dataset mgmtgetcommand <active|pending> [address <destination>] [TLV list] [-x]`
543
544Send MGMT_ACTIVE_GET or MGMT_PENDING_GET.
545
546```bash
547> dataset mgmtgetcommand active address fdde:ad00:beef:0:558:f56b:d688:799 activetimestamp securitypolicy
548Done
549```
550
551### mgmtsetcommand
552
553Usage: `dataset mgmtsetcommand <active|pending> [TLV Type list] [-x]`
554
555Send MGMT_ACTIVE_SET or MGMT_PENDING_SET.
556
557```bash
558> dataset mgmtsetcommand active activetimestamp 123 securitypolicy 1 onrc 0
559Done
560```
561
562### networkkey
563
564Usage: `dataset networkkey [key]`
565
566Get network key
567
568```bash
569> dataset networkkey
57000112233445566778899aabbccddeeff
571Done
572```
573
574Set network key.
575
576```bash
577> dataset networkkey 00112233445566778899aabbccddeeff
578Done
579```
580
581### networkname
582
583Usage: `dataset networkname [name]`
584
585Get network name.
586
587```bash
588> dataset networkname
589OpenThread
590Done
591```
592
593Set network name.
594
595**NOTE** The commissioning credential in the dataset buffer becomes stale after changing this value. Use [pskc](#pskc) to reset.
596
597```bash
598> dataset networkname OpenThread
599Done
600```
601
602### panid
603
604Usage: `dataset panid [panid]`
605
606Get panid.
607
608```bash
609> dataset panid
6100x1234
611Done
612```
613
614Set panid.
615
616```bash
617> dataset panid 0x1234
618Done
619```
620
621### pending
622
623Usage: `dataset pending [-x]`
624
625Print Pending Operational Dataset in human-readable form.
626
627```bash
628> dataset pending
629Pending Timestamp: 2
630Active Timestamp: 1
631Channel: 26
632Channel Mask: 0x07fff800
633Delay: 58706
634Ext PAN ID: a74182f4d3f4de41
635Mesh Local Prefix: fd46:c1b9:e159:5574::/64
636Network Key: ed916e454d96fd00184f10a6f5c9e1d3
637Network Name: OpenThread-bff8
638PAN ID: 0xbff8
639PSKc: 264f78414adc683191863d968f72d1b7
640Security Policy: 672 onrc 0
641Done
642```
643
644Print Pending Operational Dataset as hex-encoded TLVs.
645
646```bash
647> dataset pending -x
6480e0800000000000100003308000000000002000034040000b512000300001a35060004001fffe00208a74182f4d3f4de410708fd46c1b9e15955740510ed916e454d96fd00184f10a6f5c9e1d3030f4f70656e5468726561642d626666380102bff80410264f78414adc683191863d968f72d1b70c0402a0f7f8
649Done
650```
651
652### pendingtimestamp
653
654Usage: `dataset pendingtimestamp [timestamp]`
655
656Get pending timestamp seconds. It represents a "Unix time", in number of seconds since Jan 1st, 1970.
657
658```bash
659> dataset pendingtimestamp
660123456789
661Done
662```
663
664Set pending timestamp seconds.
665
666```bash
667> dataset pendingtimestamp 123456789
668Done
669```
670
671### pskc
672
673Usage: `pskc [-p] [<key>|<passphrase>]`
674
675Get PSKc.
676
677```bash
678> dataset pskc
67967c0c203aa0b042bfb5381c47aef4d9e
680Done
681```
682
683Set PSKc.
684
685With `-p`(**only for FTD**) generate PSKc from \<passphrase\> (UTF-8 encoded) together with network name and extended PAN ID in the dataset buffer if set or values in the current stack if not, otherwise set PSKc as \<key\> (hex format).
686
687```bash
688> dataset pskc 67c0c203aa0b042bfb5381c47aef4d9e
689Done
690> dataset pskc -p 123456
691Done
692```
693
694### securitypolicy
695
696Usage: `dataset securitypolicy [<rotationtime> [onrcCepR] [versionthreshold]]`
697
698Get security policy.
699
700```bash
701> dataset securitypolicy
702672 onrc 0
703Done
704```
705
706Set security policy.
707
708- o: Obtaining the Network Key for out-of-band commissioning is enabled.
709- n: Native Commissioning using PSKc is allowed.
710- r: Thread 1.x Routers are enabled.
711- c: External Commissioner authentication is allowed using PSKc.
712- C: Thread 1.2 Commercial Commissioning is enabled.
713- e: Thread 1.2 Autonomous Enrollment is enabled.
714- p: Thread 1.2 Network Key Provisioning is enabled.
715- R: Non-CCM routers are allowed in Thread 1.2 CCM networks.
716
717If the `versionthreshold` parameter is not provided, a default value of zero is assumed.
718
719```bash
720> dataset securitypolicy 672 onrc 0
721Done
722```
723
724### set
725
726Usage: `dataset set <active|pending> <dataset>`
727
728Set the Active Operational Dataset using hex-encoded TLVs.
729
730```bash
731> dataset set active 0e080000000000010000000300000f35060004001fffe0020839758ec8144b07fb0708fdf1f1add0797dc00510f366cec7a446bab978d90d27abe38f23030f4f70656e5468726561642d353933380102593804103ca67c969efb0d0c74a4d8ee923b576c0c0402a0f7f8
732Done
733```
734
735Set the Pending Operational Dataset using hex-encoded TLVs.
736
737```bash
738> dataset set pending 0e0800000000000100003308000000000002000034040000b512000300001a35060004001fffe00208a74182f4d3f4de410708fd46c1b9e15955740510ed916e454d96fd00184f10a6f5c9e1d3030f4f70656e5468726561642d626666380102bff80410264f78414adc683191863d968f72d1b70c0402a0f7f8
739Done
740```
741
742### tlvs
743
744Usage: `dataset tlvs`
745
746Convert the Operational Dataset to hex-encoded TLVs.
747
748```bash
749> dataset
750Active Timestamp: 1
751Channel: 22
752Channel Mask: 0x07fff800
753Ext PAN ID: d196fa2040e973b6
754Mesh Local Prefix: fdbb:c310:c48f:3a39::/64
755Network Key: 9929154dbc363218bcd22f907caf5c15
756Network Name: OpenThread-de2b
757PAN ID: 0xde2b
758PSKc: 15b2c16f7ba92ed4bc7b1ee054f1553f
759Security Policy: 672 onrc 0
760Done
761
762> dataset tlvs
7630e080000000000010000000300001635060004001fffe00208d196fa2040e973b60708fdbbc310c48f3a3905109929154dbc363218bcd22f907caf5c15030f4f70656e5468726561642d646532620102de2b041015b2c16f7ba92ed4bc7b1ee054f1553f0c0402a0f7f8
764Done
765```
766
767### updater
768
769Usage: `dataset updater`
770
771Requires `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE`.
772
773Indicate whether there is an ongoing Operation Dataset update request.
774
775```bash
776> dataset updater
777Enabled
778```
779
780### updater start
781
782Usage: `dataset updater start`
783
784Requires `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE`.
785
786Request network to update its Operation Dataset to the current operational dataset buffer.
787
788The current operational dataset buffer should contain the fields to be updated with their new values. It must not contain Active or Pending Timestamp fields. The Delay field is optional. If not provided, a default value (1000 ms) is used.
789
790```bash
791> channel
79219
793Done
794
795> dataset clear
796Done
797> dataset channel 15
798Done
799> dataset
800Channel: 15
801Done
802
803> dataset updater start
804Done
805> dataset updater
806Enabled
807Done
808
809Dataset update complete: OK
810
811> channel
81215
813Done
814```
815
816### updater cancel
817
818Usage: `dataset updater cancel`
819
820Requires `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE`.
821
822Cancels an ongoing (if any) Operational Dataset update request.
823
824```bash
825> dataset updater start
826Done
827> dataset updater
828Enabled
829Done
830>
831> dataset updater cancel
832Done
833> dataset updater
834Disabled
835Done
836```
837
838### wakeupchannel
839
840Usage: `wakeupchannel [channel]`
841
842Get wake-up channel.
843
844```bash
845> dataset wakeupchannel
84613
847Done
848```
849
850Set wake-up channel.
851
852```bash
853> dataset wakeupchannel 13
854Done
855```
856