## 4 Registration and Discovery Scenario  
In this section, the following sequence diagrams illustrate the scenarios of registration and discovery using the elements in the proposed IoT network which are the RD server, IoT device, publishing client, IoT client, and user. The registration process involves the interactions between IoT device and RD server, and between publishing client and RD server. The discovery process is comprised of IoT client, RD server and user.  
Figure 7 shows the sequence diagram for registering the IoT device to the RD server. The IoT device is an OCF entity that runs the OCF server for providing the services based on its resources. For starting the server, the device read and write the data to initialize the application and configuration settings. The device information is written in the RAML file that is used to send the device information to the RD server through the OCF communication network. Firstly, the IoT device reads the RAML file  
Figure 5: Functional architecture of publishing client.  
Figure 6: Functional architecture of IoT client.  
to get the RAML data. Then the IoT device gets name and data from the RAML data. The name and data are included in the payload of the request for the registration. The IoT device sends the message that uses the POST method with URI coap://(RD's IP:5683)/rd and the payload. Once the RD server receives the message, then the server parses the RAML data and inserts them in the DB.  
Figure 8 shows the sequence diagram for registering WSps which are deployed in the Internet to provide the service based on the HTTP. The information is registered by the publishing client through the OCF communication network. The publishing client is also an OCF device that is used send the RAML data to the RD server through the OCF network. Because the RD provides a consistent interface for the registration, the RAML need to be sent by the same publishing scheme with the IoT device. Therefore, the process is same as the process of registering an IoT device. Firstly, the publishing client reads the RAML file to get the RAML data. Then, the publishing client gets the name and data from the RAML data to put in the payload of the OCF request message. The publishing client sends the message that uses the POST method with URI coap://(RD's IP:5683)/rd and the payload. Once the RD server receives the message, the server parses the RAML data and inserts it to the DB.  
Figure 8: Sequence diagram for registering Hypertext Transfer Protocol (HTTP)-based web service provider (WSP).  
Figure 7: Sequence diagram for self-registration of IoT device.  
Figure 9 shows the sequence diagram for discovering the IoT device and WSP through the RD server. The returned payload includes the information of OCF service providers as well as the HTTP service providers from the OCF network and the Internet. The discovery service is used by the IoT client that requests to the/rd/list resource of the RD server with the keyword query parameter using the GET method. Once the resource of RD server is requested, the handler responds registered provider information list. Each item involves the table of provider's information in the response payload. Once the response message is delivered to the IoT client, the client displays the provider information list. The user needs to click an item from the list. Once the item is clicked, the IoT client requests to the/rd resource of the bridge device with id query parameter using GET method. The handler of the resource responds with the provider information in detail. The data includes all information that relates to the provider.