1*cfb92d14SAndroid Build Coastguard Worker# OpenThread CLI - SRP (Service Registration Protocol) 2*cfb92d14SAndroid Build Coastguard Worker 3*cfb92d14SAndroid Build Coastguard Worker## Quick Start 4*cfb92d14SAndroid Build Coastguard Worker 5*cfb92d14SAndroid Build Coastguard Worker### Start SRP Server 6*cfb92d14SAndroid Build Coastguard Worker 7*cfb92d14SAndroid Build Coastguard WorkerStart the SRP Server node: 8*cfb92d14SAndroid Build Coastguard Worker 9*cfb92d14SAndroid Build Coastguard Worker```bash 10*cfb92d14SAndroid Build Coastguard Worker./output/simulation/bin/ot-cli-ftd 1 11*cfb92d14SAndroid Build Coastguard Worker``` 12*cfb92d14SAndroid Build Coastguard Worker 13*cfb92d14SAndroid Build Coastguard WorkerSetup a Thread network and start the SRP Server: 14*cfb92d14SAndroid Build Coastguard Worker 15*cfb92d14SAndroid Build Coastguard Worker```bash 16*cfb92d14SAndroid Build Coastguard Worker> dataset init new 17*cfb92d14SAndroid Build Coastguard WorkerDone 18*cfb92d14SAndroid Build Coastguard Worker> dataset 19*cfb92d14SAndroid Build Coastguard WorkerActive Timestamp: 1 20*cfb92d14SAndroid Build Coastguard WorkerChannel: 22 21*cfb92d14SAndroid Build Coastguard WorkerChannel Mask: 0x07fff800 22*cfb92d14SAndroid Build Coastguard WorkerExt PAN ID: 8d6ed7a05a28fb3b 23*cfb92d14SAndroid Build Coastguard WorkerMesh Local Prefix: fded:5114:8263:1fe1::/64 24*cfb92d14SAndroid Build Coastguard WorkerNetwork Key: 7fcbae4153cc2955c28440c15d4d4219 25*cfb92d14SAndroid Build Coastguard WorkerNetwork Name: OpenThread-f7af 26*cfb92d14SAndroid Build Coastguard WorkerPAN ID: 0xf7af 27*cfb92d14SAndroid Build Coastguard WorkerPSKc: b658e40f174e3a11be149b302ef07a0f 28*cfb92d14SAndroid Build Coastguard WorkerSecurity Policy: 672, onrc 29*cfb92d14SAndroid Build Coastguard WorkerDone 30*cfb92d14SAndroid Build Coastguard Worker> dataset commit active 31*cfb92d14SAndroid Build Coastguard WorkerDone 32*cfb92d14SAndroid Build Coastguard Worker> ifconfig up 33*cfb92d14SAndroid Build Coastguard WorkerDone 34*cfb92d14SAndroid Build Coastguard Worker> thread start 35*cfb92d14SAndroid Build Coastguard WorkerDone 36*cfb92d14SAndroid Build Coastguard Worker> state 37*cfb92d14SAndroid Build Coastguard Workerleader 38*cfb92d14SAndroid Build Coastguard WorkerDone 39*cfb92d14SAndroid Build Coastguard Worker>ipaddr 40*cfb92d14SAndroid Build Coastguard Workerfded:5114:8263:1fe1:0:ff:fe00:fc00 41*cfb92d14SAndroid Build Coastguard Workerfded:5114:8263:1fe1:0:ff:fe00:c000 42*cfb92d14SAndroid Build Coastguard Workerfded:5114:8263:1fe1:68bc:ec03:c1ad:9325 43*cfb92d14SAndroid Build Coastguard Workerfe80:0:0:0:a8cd:6e23:df3d:4193 44*cfb92d14SAndroid Build Coastguard WorkerDone 45*cfb92d14SAndroid Build Coastguard Worker> srp server enable 46*cfb92d14SAndroid Build Coastguard WorkerDone 47*cfb92d14SAndroid Build Coastguard Worker``` 48*cfb92d14SAndroid Build Coastguard Worker 49*cfb92d14SAndroid Build Coastguard Worker### Start SRP Client 50*cfb92d14SAndroid Build Coastguard Worker 51*cfb92d14SAndroid Build Coastguard WorkerStart the SRP Client node: 52*cfb92d14SAndroid Build Coastguard Worker 53*cfb92d14SAndroid Build Coastguard Worker```bash 54*cfb92d14SAndroid Build Coastguard Worker./output/simulation/bin/ot-cli-ftd 2 55*cfb92d14SAndroid Build Coastguard Worker``` 56*cfb92d14SAndroid Build Coastguard Worker 57*cfb92d14SAndroid Build Coastguard WorkerJoin the Thread Network and register a `_ipps._tcp` service: 58*cfb92d14SAndroid Build Coastguard Worker 59*cfb92d14SAndroid Build Coastguard Worker```bash 60*cfb92d14SAndroid Build Coastguard Worker> dataset networkkey 7fcbae4153cc2955c28440c15d4d4219 61*cfb92d14SAndroid Build Coastguard WorkerDone 62*cfb92d14SAndroid Build Coastguard Worker> dataset commit active 63*cfb92d14SAndroid Build Coastguard WorkerDone 64*cfb92d14SAndroid Build Coastguard Worker> ifconfig up 65*cfb92d14SAndroid Build Coastguard WorkerDone 66*cfb92d14SAndroid Build Coastguard Worker> thread start 67*cfb92d14SAndroid Build Coastguard WorkerDone 68*cfb92d14SAndroid Build Coastguard Worker> state 69*cfb92d14SAndroid Build Coastguard Workerchild 70*cfb92d14SAndroid Build Coastguard WorkerDone 71*cfb92d14SAndroid Build Coastguard Worker> ipaddr 72*cfb92d14SAndroid Build Coastguard Workerfded:5114:8263:1fe1:0:ff:fe00:c001 73*cfb92d14SAndroid Build Coastguard Workerfded:5114:8263:1fe1:44f9:cc06:4a2d:534 74*cfb92d14SAndroid Build Coastguard Workerfe80:0:0:0:38dd:fdf7:5fd:24e 75*cfb92d14SAndroid Build Coastguard WorkerDone 76*cfb92d14SAndroid Build Coastguard Worker> srp client host name my-host 77*cfb92d14SAndroid Build Coastguard WorkerDone 78*cfb92d14SAndroid Build Coastguard Worker> srp client host address fded:5114:8263:1fe1:44f9:cc06:4a2d:534 79*cfb92d14SAndroid Build Coastguard WorkerDone 80*cfb92d14SAndroid Build Coastguard Worker> srp client service add my-service _ipps._tcp 12345 81*cfb92d14SAndroid Build Coastguard WorkerDone 82*cfb92d14SAndroid Build Coastguard Worker> srp client autostart enable 83*cfb92d14SAndroid Build Coastguard WorkerDone 84*cfb92d14SAndroid Build Coastguard Worker``` 85*cfb92d14SAndroid Build Coastguard Worker 86*cfb92d14SAndroid Build Coastguard WorkerThe 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*cfb92d14SAndroid Build Coastguard Worker 88*cfb92d14SAndroid Build Coastguard WorkerAlternatively, the client can be started manually using the `srp client start`. 89*cfb92d14SAndroid Build Coastguard Worker 90*cfb92d14SAndroid Build Coastguard WorkerThe 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*cfb92d14SAndroid Build Coastguard Worker 92*cfb92d14SAndroid Build Coastguard WorkerMake sure the SRP Server address & port are used for the `srp client start` command. 93*cfb92d14SAndroid Build Coastguard Worker 94*cfb92d14SAndroid Build Coastguard Worker```bash 95*cfb92d14SAndroid Build Coastguard Worker> netdata show 96*cfb92d14SAndroid Build Coastguard WorkerPrefixes: 97*cfb92d14SAndroid Build Coastguard WorkerRoutes: 98*cfb92d14SAndroid Build Coastguard WorkerServices: 99*cfb92d14SAndroid Build Coastguard Worker44970 5d c002 s 8400 100*cfb92d14SAndroid Build Coastguard WorkerDone 101*cfb92d14SAndroid Build Coastguard Worker> srp client start fded:5114:8263:1fe1:68bc:ec03:c1ad:9325 49154 102*cfb92d14SAndroid Build Coastguard WorkerDone 103*cfb92d14SAndroid Build Coastguard Worker``` 104*cfb92d14SAndroid Build Coastguard Worker 105*cfb92d14SAndroid Build Coastguard Worker### Verify the service status 106*cfb92d14SAndroid Build Coastguard Worker 107*cfb92d14SAndroid Build Coastguard WorkerCheck if the host and service has been successfully registered on the client node: 108*cfb92d14SAndroid Build Coastguard Worker 109*cfb92d14SAndroid Build Coastguard Worker```bash 110*cfb92d14SAndroid Build Coastguard Worker> srp client host 111*cfb92d14SAndroid Build Coastguard Workername:"my-host", state:Registered, addrs:[fded:5114:8263:1fe1:44f9:cc06:4a2d:534] 112*cfb92d14SAndroid Build Coastguard WorkerDone 113*cfb92d14SAndroid Build Coastguard Worker> srp client service 114*cfb92d14SAndroid Build Coastguard Workerinstance:"my-service", name:"_ipps._tcp", state:Registered, port:12345, priority:0, weight:0 115*cfb92d14SAndroid Build Coastguard WorkerDone 116*cfb92d14SAndroid Build Coastguard Worker``` 117*cfb92d14SAndroid Build Coastguard Worker 118*cfb92d14SAndroid Build Coastguard WorkerMake sure it shows `state:Registered` for both host and service commands. 119*cfb92d14SAndroid Build Coastguard Worker 120*cfb92d14SAndroid Build Coastguard WorkerCheck the host & service on the server node: 121*cfb92d14SAndroid Build Coastguard Worker 122*cfb92d14SAndroid Build Coastguard Worker```bash 123*cfb92d14SAndroid Build Coastguard Worker> srp server host 124*cfb92d14SAndroid Build Coastguard Workermy-host.default.service.arpa. 125*cfb92d14SAndroid Build Coastguard Worker deleted: false 126*cfb92d14SAndroid Build Coastguard Worker addresses: [fded:5114:8263:1fe1:44f9:cc06:4a2d:534] 127*cfb92d14SAndroid Build Coastguard WorkerDone 128*cfb92d14SAndroid Build Coastguard Worker> srp server service 129*cfb92d14SAndroid Build Coastguard Workermy-service._ipps._tcp.default.service.arpa. 130*cfb92d14SAndroid Build Coastguard Worker deleted: false 131*cfb92d14SAndroid Build Coastguard Worker port: 12345 132*cfb92d14SAndroid Build Coastguard Worker priority: 0 133*cfb92d14SAndroid Build Coastguard Worker weight: 0 134*cfb92d14SAndroid Build Coastguard Worker ttl: 7200 135*cfb92d14SAndroid Build Coastguard Worker lease: 7200 136*cfb92d14SAndroid Build Coastguard Worker key-lease: 1209600 137*cfb92d14SAndroid Build Coastguard Worker TXT: [] 138*cfb92d14SAndroid Build Coastguard Worker host: my-host.default.service.arpa. 139*cfb92d14SAndroid Build Coastguard Worker addresses: [fded:5114:8263:1fe1:44f9:cc06:4a2d:534] 140*cfb92d14SAndroid Build Coastguard WorkerDone 141*cfb92d14SAndroid Build Coastguard Worker``` 142*cfb92d14SAndroid Build Coastguard Worker 143*cfb92d14SAndroid Build Coastguard WorkerMake sure it shows `deleted: false` for both host and service commands. 144*cfb92d14SAndroid Build Coastguard Worker 145*cfb92d14SAndroid Build Coastguard Worker### Remove the service 146*cfb92d14SAndroid Build Coastguard Worker 147*cfb92d14SAndroid Build Coastguard WorkerA service can be removed through the client node: 148*cfb92d14SAndroid Build Coastguard Worker 149*cfb92d14SAndroid Build Coastguard Worker```bash 150*cfb92d14SAndroid Build Coastguard Worker> srp client service remove my-service _ipps._tcp 151*cfb92d14SAndroid Build Coastguard WorkerDone 152*cfb92d14SAndroid Build Coastguard Worker``` 153*cfb92d14SAndroid Build Coastguard Worker 154*cfb92d14SAndroid Build Coastguard WorkerConfirm on the server node that the service has been removed: 155*cfb92d14SAndroid Build Coastguard Worker 156*cfb92d14SAndroid Build Coastguard Worker```bash 157*cfb92d14SAndroid Build Coastguard Worker> srp server service 158*cfb92d14SAndroid Build Coastguard Workermy-service._ipps._tcp.default.service.arpa. 159*cfb92d14SAndroid Build Coastguard Worker deleted: true 160*cfb92d14SAndroid Build Coastguard WorkerDone 161*cfb92d14SAndroid Build Coastguard Worker``` 162*cfb92d14SAndroid Build Coastguard Worker 163*cfb92d14SAndroid Build Coastguard WorkerThe service entry is listed because the name of service is not removed. 164*cfb92d14SAndroid Build Coastguard Worker 165*cfb92d14SAndroid Build Coastguard Worker### Remove the host and service names 166*cfb92d14SAndroid Build Coastguard Worker 167*cfb92d14SAndroid Build Coastguard WorkerA host and service, along with their names, can be removed through the client node: 168*cfb92d14SAndroid Build Coastguard Worker 169*cfb92d14SAndroid Build Coastguard Worker```bash 170*cfb92d14SAndroid Build Coastguard Worker> srp client host remove 1 171*cfb92d14SAndroid Build Coastguard WorkerDone 172*cfb92d14SAndroid Build Coastguard Worker``` 173*cfb92d14SAndroid Build Coastguard Worker 174*cfb92d14SAndroid Build Coastguard WorkerConfirm on the server node that no host or service entries are listed: 175*cfb92d14SAndroid Build Coastguard Worker 176*cfb92d14SAndroid Build Coastguard Worker```bash 177*cfb92d14SAndroid Build Coastguard Worker> srp server host 178*cfb92d14SAndroid Build Coastguard WorkerDone 179*cfb92d14SAndroid Build Coastguard Worker> srp server service 180*cfb92d14SAndroid Build Coastguard WorkerDone 181*cfb92d14SAndroid Build Coastguard Worker> 182*cfb92d14SAndroid Build Coastguard Worker``` 183*cfb92d14SAndroid Build Coastguard Worker 184*cfb92d14SAndroid Build Coastguard Worker## CLI Reference 185*cfb92d14SAndroid Build Coastguard Worker 186*cfb92d14SAndroid Build Coastguard Worker- [SRP Client CLI Reference](README_SRP_CLIENT.md) 187*cfb92d14SAndroid Build Coastguard Worker- [SRP Server CLI Reference](README_SRP_SERVER.md) 188