• Nenhum resultado encontrado

Test Purposes Selection and Test Cases Generation 79

No documento Nanxing Chen (páginas 87-93)

4.5 Application to the CoAP Protocol

4.5.2 CoAP Protocol

4.5.2.2 Test Purposes Selection and Test Cases Generation 79

Generally in an interoperability testing event, the organizers will study and dis- cuss together to choose the important properties (ITP) to test. Then for each ITP, an iop test case is derived and must be valided by all the members. Regard- ing the specifications of CoAP [20, 23, 25, 26], the organizers of the plugtest event were agree on focusing on a set of 27 interoperability test purposes concerning the 4 aspects listed below. They represent the most important properties of the protocol. To ensure that the ITPs are correct w.r.t the specifications, the ITPs were chosen and cross-validated by experts from ETSI14, IRISA15 and BUPT16,

12http://www.tinyos.net/

13http://www.sics.se/contiki/

14http://www.etsi.org/WebSite/homepage.aspx

15http://www.irisa.fr/

16http://www.bupt.edu.cn/

and reviewed by IPSO Alliance. The test purposes involve:

• Basic CoAP methods: Similar to HTTP, CoAP uses the Representational State Transfer (REST) architectural style. Applications communicate by exchanging resources using respectively RESTful methods GET, POST, PUT, and DELETE. RESTful methods testing involves verifying that both CoAP client and server react correctly to the received messages according to [20]. Specifically, it requires to verify that each time the client sends a request, it contains the correct method code and correct message type code (CON or NON). Upon the reception of the request, the server sends pig- gybacked reply to the client accordingly: (i)if the request is a confirmable message, the server must send an acknowledgment ACK.(ii) If the request is non-confirmable, the server also sends a nonconfirmable reply. An exam- ple can be found in Fig.4.8-(a).

Sometimes however, a server cannot obtain immediately the resource re- quested by the client. In this case, the server will first send an acknowledg- ment with empty payload, which effectively is a promise that the request will be acted. When the server finally has obtained the resource repre- sentation, it sends the response in a confirmable mode to ensure that this message not be lost. (c.f. an example in Fig. 4.8-(b) )

The interoperability testing of CoAP RESTful methods involves verifying that both CoAP client and server interoperate correctly w.r.t different meth- ods as specified in [20]. Even in lossy context as often encountered by M2M communication. Moreover, as CoAP protocol is designed for constrained networks, where many packet losses will occur, therefore an important as- pect is to show that CoAP application should still interoperate correctly even in lossy context. Especially, they must correctly retransmit the re- quest and response if they are lost.

• Resource discovery. As CoAP applications are considered to be M2M, they must be able to discover each other and their resources. Thus, [26] standard- izes a resource discovery format to discover the list of resources offered by a device, or for a device to advertise or post its resources to a directory ser- vice. In [26], path prefix for CoRE discovery is defined as/.well-known/core.

This description is then accessed with a GET request on that URI. The in- teroperability of resource discovery involves verifying that: when the client requests/.well-known/coreresource, the server sends a response containing the payload indicating all the available links. For example, GET /.well-

known/core?rt=Temperature17 would request only resources with the name Temperature. The interoperability of resource discovery involves verifying that: when the client requests/.well-known/core resource, the server sends a response containing the payload indicating all the available links.

• Block-wise transfer: CoAP is based on datagram transports such as UDP, which limits the maximum size of resource representations that can be trans- ferred. In order to handle large payloads, [25] defines an option Block, in order that large sized resource representation can be divided in several blocks and transferred in multiple request-response pairs. It supports the transmission of larger amounts of data by splitting the data into blocks for sending and manages the reassembly on the application layer upon receipt in order to avoid fragmentation on the lower layers.

Block-wise transfer is in form of stop-and-wait mechanism. If the client knows the large resource that it requires, it sends a GET request containing Block option, indicating block number and desired block size. In return, the server sends a response containing the requested block number and size. The transaction repeats until the client obtains the whole resource. If a response generated by a resource handler exceeds the client’s requested block size, the server automatically divides the response and transfer it in a block-wise manner. Then the client sends further requests until completely receiving the resource and displaying it. Similarly, block options also make it possible for the client to update or create a large size resource on the server, by using PUT and POST request respectively.

The interoperability testing of this property therefore involves in verifying that: when the client requests or creates large payload on the server, the server should react correctly to the requests.An example can be found in Fig.4.8-(c).

• Resource observation: The conventional communication model of REST is that a client always initiate requiring resource representations from the server. However, this model does not work well when a client is inter- ested in having a current representation of a resource over a period of time.

Therefore, [23] extends the CoAP core protocol with a mechanism CoAP Observe. It is an asynchronous approach to support pushing information from servers to clients.

17rt: Resource type attribute. It is a noun describing the resource.

The interoperability testing of Observe consists of the following aspects: If a client is interested in the current state of specific resource, it can register its interest in this resource by issuing a GET request with an empty Observe option to the resource. If the server accepts this option, it keeps track of the client and sends a response whenever the observed resource changes. If the client rejects a notification with a RST message or when it performs a GET request without an Observe option for a currently observed resource, the server will remove the client from the list of observers for this resource.

And the client will no longer receive any updated information about the resource. If a client wants to receive notifications later, it needs to register again. An example can be found in Fig.4.8-(d).

Example 4.1 The following figure demonstrates some typical examples of CoAP transactions:

Figure 4.8: CoAP transaction examples

Fig.4.8-(a) illustrates a confirmable request sent by the client, asking for the

resource of humidity. Upon the reception of the request, the server acknowledges the message, transferring the payload while echoing the Message ID generated by the client.

Fig.4.8-(b) is an example of a separate response: When a CoAP server receives a request which it is not able to handle immediately, it first acknowledges the reception of the message by an acknowledgment with empty payload, and later sends back the response in a separate manner.

Fig.4.8-(c) illustrates a block-wise transfer of a large payload (humidity) re- quested by the client. Upon the reception of the request, the server divides the resource into 4 blocks and transfer them separately to the client. Each response indicates the block number and size, as well as whether there are further blocks (indicated by valuem [25]).

Fig.4.8-(d) illustrates an example of resource observation, including registra- tion and cancellation. At first, the client registers its interest in humidity resource by indicating Observe option. After a period, it cancels its intention by sending another GET request on the resource without Observe option.

Once the set of test purposes are defined, a test case is derived for each test purpose which describes in detail the expected behavior of the CoAP implementa- tions to be observed. In this work, test cases derivation is done manually by care- fully studying the protocol specification document. They are also cross-validated by experts from ETSI, IRSIA, BUPT and IPSO Alliance.

Example 4.2 Fig.4.9 shows an example of an iop test purpose and the corre- sponding iop test case. The test purpose (Fig.4.9-(a)) focuses on the GET method in confirmable transaction mode. i.e., when the client sends a GET request (with parameters: a Message ID, Type=0 for confirmable transaction mode, Code=1 for GET method), the server’s response contains an acknowledgment, echoing the same Message ID, as well as the resource presentation (Code=69(2.05 Content)).

The corresponding test case is illustrated in Fig.4.9-(b). The bold part of the test case represents the expected behavior that leads to Pass verdict. Behavior that is not forbidden by the specifications leads to Inconclusive verdict (for ex- ample, response contains code other than 69. These events are noted bym in the figure). However other behavior leads to Fail verdict (for example non-match of Message ID. These events are labeled by otherwise). The test cases are derived w.r.t the specifications of CoAP and implemented in ttproto.

Moreover, during the test, expected behavior to be observed is provided in text form to the users as test specification document (Fig.4.9-(c)).

Figure 4.9: CoAP request examples

Example 4.3 This example shows a test case implemented in the test tool ttproto.

Figure 4.10: A CoAP test case example

The test case aims to test a request containing several URI-Path options [20].

CoAP uses the URI schemes for identifying CoAP resources and providing a means of locating the resource. The syntax of URI schemes is as follows: coap- URI = "coap:" "//" host [ ":" port ] path-abempty [ "?" query ]. In this scheme, Uri-Host specifies the Internet host of a resource; Uri-Port specifies the port of the host; Uri-Path specifies the resource of the host; Uri-Query indicates additional

options for the request. In this work we focus on the test of Uri-Path and Uri- Query. Particularly in case of a request containing several URI-Path options or URI-Query options, the test system verifies that the server send a response message with the correct message type and code in corresponding to the previous request, as well as the requested resource. The test case implemented in ttproto specifies in detail the events that can lead toPass,Fail or Inconclusive verdicts.

4.5.3 Application in Industrial Context

No documento Nanxing Chen (páginas 87-93)