# Bindings and RESTlets: A Novel Set of CoAP-Based Application Enablers to Build IoT Applications
## 6 Implementation and Evaluation
### Packet Size  
LLNs have a low Maximum Transmission Unit (MTU). Large packets whose size exceeds the MTU go through a fragmentation/defragmentation cycle from the source all the way to their final destination. This behaviour negatively affects the performance of the network. Therefore, the resulting packet size is a very important parameter when discussing the performance of new solutions. Moreover, fragmentation also comes at the expense of an increased delay. The packet size at the application layer for CoAP based communication can be calculated as:  
\[\text{PacketSize}\;=\;\text{Size of}\;(\text{CoAP}-\text{Header})\;+\;\text{Size of}\;(\text{Token})\;+\;\text{Size of}\;(\text{options})\;+\;\text{Size of}\;(\text{payload})\]  
where:  
\[\text{Size of}\;(\text{CoAP}-\text{Header})\;=\;4\;\text{bytes, Size of}\;(\text{Token})\;=\;0\;\text{to}\;8\;\text{bytes}\]  
Size of (Options) differs from packet to packet depending on the number and type of CoAP options being included in the packet. For example, Observation requests include the Observe Option, which has a maximum length of four bytes. The Uri-Path option and payload greatly vary depending on the resource identifier and the data to be communicated. For the URI path, we assume the simplified IPSO Application Framework [17] resource names. For instance, for a button associated with a light switch (sensor)the URI path becomes /gpio/btn, which will be transmitted as two Uri-Path options  
\begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multirow{2}{*}{**Num. Observers**} & \multicolumn{4}{c}{**Binding Sensor**} & \multicolumn{4}{c}{**Non-Binding Sensor**} \\ \cline{2-9}  & **Text** & **Data** & **BSS** & **Total** & **Text** & **Data** & **BSS** & **Total** \\ \hline
0 & 47,829 & 306 & 5324 & 53,459 & 46,453 & 306 & 5166 & 51,925 \\
1 & 47,829 & 306 & 5580 & 53,715 & 46,453 & 306 & 5384 & 52,143 \\
2 & 47,829 & 306 & 5836 & 53,971 & 46,453 & 306 & 5602 & 52,361 \\
3 & 47,with a total length of nine bytes (one byte for every option plus the length of both segments \"gpio\" and \"btn\" in the URI). Most of these values are common for all types of communication so they do not impact the comparison between the two methods. The real difference between the two solutions can be seen at the relationship initiation packet. In case of the non-binding solution the options that are minimally needed are Observe (one byte) and Uri-Path (nine bytes for /gpio/btn). Including the CoAP header (four bytes) and the token (one byte in this example), the total packet size will be 15 bytes. However, for direct bindings, the initial packet includes four additional binding options containing the information on how to trigger the actuator. Therefore, the number of additional bytes required, \(\text{B}_{\text{Byte}}\) is given by:  
\[\begin{array}{l}\text{B}_{\text{Byte}}\;=\;\text{Size}\;\;\text{of}\; \left(\text{BIND\_URI\_HOST}\right)\;+\;\text{Size}\;\;\text{of}\;\left( \text{BIND\_URI\_PORT}\right)\\ \;\;\;\;\;\;\;\;\;  
For all topologies the latency is computed as the time difference between the occurrence of the event at the sensor and the reception of the PUT packet by the actuator. From the results depicted in Figure 16, we can see that in all cases the gateway/cloud based solution has a significantly higher latency compared to the binding solution. This is expected as all sensor events are sent all the way to the gateway and triggers come down to the actuator in the non-binding solution. This increased number of hops introduces significant delay in the overall notification/trigger cycle. The delay will be even more pronounced for larger networks. For our solution, the number of hops, and hence the delay, depends on the routing protocol. As we mentioned earlier, we used RPL as routing protocol. In RPL, the furthest the packets travel is until the common parent of the sensor and actuator. The closer the sensor and actuator, the less delay is introduced. The Cooja screenshots (Figure 17a,b) confirms this statement.