# A Mechanism for Reliable Mobility Management for Internet of Things Using CoAP
## 3 Reliable Message Transmission Algorithm and Analysis of Handover Delay of CoMP  
In this section, we describe the algorithm of signaling message retransmission for a reliable mobility management algorithm of CoAP-based Mobility Management Protocol (CoMP), and analyze the performance of the handover latency. The CoMP extends the CON message of the CoAP protocol to reliably transmit the signaling message under an unreliable IoT network environment. In particular, the retransmission is instrumented by using a Message ID and CON message of the CoAP protocol, using CoAP PUT message. The Message ID is used to detect duplicates and for transmission reliability, and the CON message is retransmitted using both default timeout and exponential back-off between retransmissions until the recipient sends an ACK with the same Message ID from the corresponding endpoint. Algorithm 1 shows the algorithm for reliable transmission of CoAP message where \(T\), \(Rc\), and \(m\) are timeout, retransmission count, and maximum number of retransmission counts, respectively. The algorithm is self-explanatory, and extends the CoAP retransmission algorithm [15]. In case of packet loss, the PUT messages are retransmitted for binding update and holding. ```
Algorithm Reliable_Signaling_Message_Transmission (\(P\), \(T\), \(Rc\), \(m\)); /* This algorithm describes the reliable transmission of CoAP message by using \(T\), \(Rc\) and \(m\)*/ \(P\): CoAP message with sequence number T: Timeout//T = ACK_TIMEOUT*ACK_RANDOM_FACTOR [13] \(Rc\): Retransmission count//initially \(Rc\) = 0 \(m\): Maximum number of retransmission counts//\(m\) = 4
1 Begin
2 If (\(T\) == 0 OR \(Rc\) == 0) Then {
3 \(T\) = ACK_TIMEOUT*ACK_RANDOM_FACTOR;
4 \(Rc\) = 0; \(m\) = 4;
5 Else {
6 If (\(Rc\) < \(m\)) Then {
7 Send the CoAP message to lower layer;
8 While (\(T\) < Timeout)//wait until \(T\) is expired
9 If (mCSN receives Acknowledgement)
10 Then {\(T\) = 0; \(Rc\) = 0;
11 Call CoAP_Retransmission (\(P\) + 1, \(T\), \(Rc\), \(m\));
12 Else Call CoAP_Retransmission (\(P\), \(T^{*}2\), \(Rc\) + 1, \(m\));
13 Else Discard \(P\); // \(P\) is discarded
14 End
```  
**Algorithm 1**Algorithm of Reliable CoAP Signaling Message Transmission. The packet loss of the signaling message can dramatically increase the handover latency, which may be caused by collision, congestion, and system failure in both wireless and wired communication links. The retransmission of signaling messages in the case of packet loss may greatly reduce the handover latency in constrained IoT networks. To analyze the handover latency of CoMP, we first derive the average number of transmissions and retransmissions considering the CoAP retransmission mechanism. In [17], the probability of CoAP packet error rate by the impact of Signal-to-Noise Ratio (SNR) was investigated for a CoAP message composed of \(f\) fragmented packets. The author [17] studied the impact of the SNR on the physical level packet loss rate of an 802.15.4 link. By [17], the packet loss rate \(P\) is given in Equation (1) below:  
\[P=1-(1-S)^{2m} \tag{1}\]  
where \(S\) is the symbol error rate and m is the length in bytes of the MAC packet. The symbol error rate \(S\) is related to the SNR [17]. The probability A of having an erroneous CoAP packet at the application layer, including the retransmission at the MAC layer, is derived as \(A=P^{(r+1)}\), where \(r\) is the maximum number of retransmissions allowed for the MAC layer (default value is 5). However, the entire IEEE 802.15.4 maximum transmission unit (MTU) is 127 bytes. Hence, the CoAP packet must be fragmented. If a CoAP message is comprised of \(f\) fragments, the probability of CoAP packet error rate \(A_{f}\) is given by:  
\[A_{f}=\sum_{j=0}^{f}A\times(1-P)^{j-1} \tag{2}\]  
where the maximum number of fragments is fixed to 12. In [17], the packet error rate by impact of SNRs (1, 1.5, 2, and 2.5 dB) was investigated.