## 6 Results
### Reliability  
The reliability of IP based Web communications is traditionally provided by the TCP protocol. However, those application protocols that are bound to UDP should provide reliability by themselves. In fact, providing reliable communications is of paramount importance, especially when using wireless links that are known to be prone to packet loss. The IEEE 802.15.4 standard offers only hop-by-hop reliability by implementing packet retransmission at data-link layer. The lack of end-to-end reliability must therefore be compensated by implementing it at higher layers. As anticipated, CoAP provides end-to-end reliability using CON messages through a simple stop-and-wait retransmission mechanism with exponential backoff. Should the CON message not be acknowledged, the CoAP node that started the communication will retransmit the message. In [11], the value for the initial timeout is fixed to 2 seconds, while the maximum number of retransmission is fixed to 4. Moreover, the CoAP definition allows this value to be changed according to the average Round Trip Time (RTT). Although not suggested in the standard, we recommend fixing a lower bound for the initial timeout. This timeout should not expire before the MAC layer reaches its maximum number of retransmissions. In [2], this number is fixed to 3, while the value of the timeout is not specified. TinyOS fixes this timeout to 512 symbols, which is equivalent to 8.192 ms. In order to ensure a fair comparison, we should use the same values of initial timeout for all the solutions and avoid any randomness in the calculation of the subsequent values. We adopt the initial timeout value specified in the RFC 6298 [46]. This value is fixed to 1 second and is big enough to ensure that the CoAP first retransmission is sent after the last one in the MAC layer. The maximum number of retransmissions is fixed to 4, while the maximum value for the TCP retransmission timer is fixed to 16 seconds. This value corresponds to the maximum retransmission timeout reached in CoAP communications. The evaluation of the mechanisms that each solution offers to provide reliability is performed by considering data transfers in an IEEE 802.15.4 link under a Rayleigh fading model. The basis for the calculations required by this model to determine the packet loss is reported in [47]. In this work, the authors studied the impact of the signal to noise ratio (SNR) on the PHY-level packet loss rate of an 802.15.4 link. As reported in [27], the packet loss rate P is given by:  
\[P=1-(1-S)^{2m} \tag{1}\]  
where S is the symbol error rate and m the length in bytes of the packet. The corresponding packet length in symbol is 2 m. The symbol error rate is strictly related to the bit error rate B. The latter contains the relationship with the SNR:  
\[B=\frac{1}{2}-\left(1-\sqrt{\frac{SNR}{1+SNR}}\right) \tag{2}\]  
In this way, given an SNR, we can easily calculate the related packet error rate. However, this error rate does not correspond to that relative to the application layer, but rather to that of the PHY layer. The calculation of the error rate seen by the application layer requires one more step. The probability C of having an erroneous packet at application layer should take into account retransmissions done at the MAC layer, and is given by:\[C=P^{(r+1)} \tag{3}\]  
where r is the maximum number of retransmissions allowed for the MAC layer. However, the formula in Equation (3) gives the application layer packet error rate only for non-fragmented packets. Should a packet be fragmented, this error rate changes according to the number of fragments. Thus, if f fragments compose a packet, the CoAP packet error rate is given by:  
\[C_{f}=\sum\limits_{j=1}^{f}C\times(1-P)^{j-1} \tag{4}\]  
The maximum number of fragments that Blip allows is fixed to 12. It should be pointed out that all the formulas are valid only for single or fragmented packets that occupy the entire space available in 802.15.4 frames. As regards the presence of the PHY header, the frame can reach a maximum size of 133 bytes.