1# OpenThread CLI Example
2
3This example application exposes OpenThread configuration and management APIs via a simple command-line interface. The steps below take you through the minimal steps required to ping one emulated Thread device from another emulated Thread device.
4
5## 1. Build
6
7```bash
8$ cd <path-to-openthread>
9$ ./script/cmake-build simulation
10```
11
12## 2. Start node 1
13
14Spawn the process:
15
16```bash
17$ cd <path-to-openthread>/build/simulation/examples/apps/cli
18$ ./ot-cli-ftd 1
19```
20
21Generate, view, and commit a new Active Operational Dataset:
22
23```bash
24> dataset init new
25Done
26> dataset
27Active Timestamp: 1
28Channel: 13
29Channel Mask: 0x07fff800
30Ext PAN ID: d63e8e3e495ebbc3
31Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
32Network Key: dfd34f0f05cad978ec4e32b0413038ff
33Network Name: OpenThread-8f28
34PAN ID: 0x8f28
35PSKc: c23a76e98f1a6483639b1ac1271e2e27
36Security Policy: 0, onrc
37Done
38> dataset commit active
39Done
40```
41
42Bring up the IPv6 interface:
43
44```bash
45> ifconfig up
46Done
47```
48
49Start Thread protocol operation:
50
51```bash
52> thread start
53Done
54```
55
56Wait a few seconds and verify that the device has become a Thread Leader:
57
58```bash
59> state
60leader
61Done
62```
63
64View IPv6 addresses assigned to Node 1's Thread interface:
65
66```bash
67> ipaddr
68fd3d:b50b:f96d:722d:0:ff:fe00:fc00
69fd3d:b50b:f96d:722d:0:ff:fe00:c00
70fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
71fe80:0:0:0:6c41:9001:f3d6:4148
72Done
73```
74
75## 2. Start node 2
76
77Spawn the process:
78
79```bash
80$ cd <path-to-openthread>/build/simulation/examples/apps/cli
81$ ./ot-cli-ftd 2
82```
83
84Configure Thread Network Key from Node 1's Active Operational Dataset:
85
86```bash
87> dataset networkkey dfd34f0f05cad978ec4e32b0413038ff
88Done
89> dataset commit active
90Done
91```
92
93Bring up the IPv6 interface:
94
95```bash
96> ifconfig up
97Done
98```
99
100Start Thread protocol operation:
101
102```bash
103> thread start
104Done
105```
106
107Wait a few seconds and verify that the device has become a Thread Child or Router:
108
109```bash
110> state
111child
112Done
113```
114
115## 3. Ping Node 1 from Node 2
116
117```bash
118> ping fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
11916 bytes from fd3d:b50b:f96d:722d:558:f56b:d688:799: icmp_seq=1 hlim=64 time=24ms
120```
121
122## 4. Explore More
123
124See the [OpenThread CLI Reference README.md](../../../src/cli/README.md) to explore more.
125