• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OpenThread CLI - SRP (Service Registration Protocol)
2
3## Quick Start
4
5### Start SRP Server
6
7Start the SRP Server node:
8
9```bash
10./output/simulation/bin/ot-cli-ftd 1
11```
12
13Setup a Thread network and start the SRP Server:
14
15```bash
16> dataset init new
17Done
18> dataset
19Active Timestamp: 1
20Channel: 22
21Channel Mask: 0x07fff800
22Ext PAN ID: 8d6ed7a05a28fb3b
23Mesh Local Prefix: fded:5114:8263:1fe1::/64
24Network Key: 7fcbae4153cc2955c28440c15d4d4219
25Network Name: OpenThread-f7af
26PAN ID: 0xf7af
27PSKc: b658e40f174e3a11be149b302ef07a0f
28Security Policy: 672, onrc
29Done
30> dataset commit active
31Done
32> ifconfig up
33Done
34> thread start
35Done
36> state
37leader
38Done
39>ipaddr
40fded:5114:8263:1fe1:0:ff:fe00:fc00
41fded:5114:8263:1fe1:0:ff:fe00:c000
42fded:5114:8263:1fe1:68bc:ec03:c1ad:9325
43fe80:0:0:0:a8cd:6e23:df3d:4193
44Done
45> srp server enable
46Done
47```
48
49### Start SRP Client
50
51Start the SRP Client node:
52
53```bash
54./output/simulation/bin/ot-cli-ftd 2
55```
56
57Join the Thread Network and register a `_ipps._tcp` service:
58
59```bash
60> dataset networkkey 7fcbae4153cc2955c28440c15d4d4219
61Done
62> dataset commit active
63Done
64> ifconfig up
65Done
66> thread start
67Done
68> state
69child
70Done
71> ipaddr
72fded:5114:8263:1fe1:0:ff:fe00:c001
73fded:5114:8263:1fe1:44f9:cc06:4a2d:534
74fe80:0:0:0:38dd:fdf7:5fd:24e
75Done
76> srp client host name my-host
77Done
78> srp client host address fded:5114:8263:1fe1:44f9:cc06:4a2d:534
79Done
80> srp client service add my-service _ipps._tcp 12345
81Done
82> srp client autostart enable
83Done
84```
85
86The last command enables the auto-start mode on the client which then monitors the network data to discover available SRP servers within the Thread network and automatically starts the client.
87
88Alternatively, the client can be started manually using the `srp client start`.
89
90The SRP Server listening UDP port (which is `c002`(`49154`) in the example below) can be found from the Server Data (listed by the `netdata show` command).
91
92Make sure the SRP Server address & port are used for the `srp client start` command.
93
94```bash
95> netdata show
96Prefixes:
97Routes:
98Services:
9944970 5d c002 s 8400
100Done
101srp client start fded:5114:8263:1fe1:68bc:ec03:c1ad:9325 49154
102Done
103```
104
105### Verify the service status
106
107Check if the host and service has been successfully registered on the client node:
108
109```bash
110> srp client host
111name:"my-host", state:Registered, addrs:[fded:5114:8263:1fe1:44f9:cc06:4a2d:534]
112Done
113> srp client service
114instance:"my-service", name:"_ipps._tcp", state:Registered, port:12345, priority:0, weight:0
115Done
116```
117
118Make sure it shows `state:Registered` for both host and service commands.
119
120Check the host & service on the server node:
121
122```bash
123> srp server host
124my-host.default.service.arpa.
125    deleted: false
126    addresses: [fded:5114:8263:1fe1:44f9:cc06:4a2d:534]
127Done
128> srp server service
129my-service._ipps._tcp.default.service.arpa.
130    deleted: false
131    port: 12345
132    priority: 0
133    weight: 0
134    TXT: 00
135    host: my-host.default.service.arpa.
136    addresses: [fded:5114:8263:1fe1:44f9:cc06:4a2d:534]
137Done
138```
139
140Make sure it shows `deleted: false` for both host and service commands.
141
142### Remove the service
143
144A service can be removed through the client node:
145
146```bash
147> srp client service remove my-service _ipps._tcp
148Done
149```
150
151Confirm on the server node that the service has been removed:
152
153```bash
154> srp server service
155my-service._ipps._tcp.default.service.arpa.
156    deleted: true
157Done
158```
159
160The service entry is listed because the name of service is not removed.
161
162### Remove the host and service names
163
164A host and service, along with their names, can be removed through the client node:
165
166```bash
167> srp client host remove 1
168Done
169```
170
171Confirm on the server node that no host or service entries are listed:
172
173```bash
174> srp server host
175Done
176> srp server service
177Done
178>
179```
180
181## CLI Reference
182
183- [SRP Client CLI Reference](README_SRP_CLIENT.md)
184- [SRP Server CLI Reference](README_SRP_SERVER.md)
185