# Enhancements and Challenges in CoAP--A Survey
## 2 Constrained Application Protocol (CoAP)  
For the purpose of achieving lightweight packet exchanges between constrained IoT devices, IETF developed a lightweight application layer protocol called CoAP. Similar to HTTP, CoAP is based on REST architecture and uses GET, POST, PUT, and DELETE request methods. The CoAP has a small and fixed header length of 4 bytes which includes optional parameters of token, options, and payload. The CoAP header is shown in Figure 2. CoAP provides request/response model as well as publish/subscribe model for resource observation. A CoAP client sends a request to server in a request/response model using RESTful methods and server responds to it. For resource observation [33] the client subscribes to server resource for some time period and the server updates the client only when there is some change or update in the resource. This is helpful in saving energy in many IoT scenarios as client does not have to request state of server resource constantly. There are four types of messages that are supported by CoAP:  
1. [leftmargin=*]
2. Confirmable (CON)
3. Non-confirmable (NON)
4. Acknowledgement (ACK)
5. Reset  
Moreover, CoAP supports two modes of transmission: reliable and non-reliable. For reliable communication, CON message is sent from one node to another and the sender requires the ACK response. Whereas unreliable communication uses NON messages which do not required any ACK from receiver. In case of reliable transmission, if the sender does not receive ACK response from receiver in a particular period of time known as retransmission timeout (RTO), the sender retransmits the packet. These retransmissions cannot increase the MAX_RETRANSMIT which is usually set to 4. Examples of CON and NON messages are represented in Figure 3.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Scheme Name** & **Performance Metrics** & **Topology** & \begin{tabular}{c} **Traffic** \\ **Scenarios** \\ \end{tabular}  & **Avg Percentage Improvement** \\ \hline CoCo-RED [22] & \begin{tabular}{c} Settling time, response \\ time, packet loss \\ \end{tabular}  & \begin{tabular}{c} Chain, grid, cross, \\ dumbbell, random \\ \end{tabular}  & \begin{tabular}{c} Continuous, \\ burst \\ \end{tabular}  & \begin{tabular}{c} Settling time: 2\%, \\ Response time: 8\% \\ Packet loss: 21\% \\ \end{tabular}  \\ \hline CoCoCoA [6] & \begin{tabular}{c} Throughput, \\ settling time \\ \end{tabular}  & Not mentioned & \ \begin{tabular}{c} Continuous, \\ burst \\ \end{tabular}  & \begin{tabular}{c} Throughput: 19 \\ Settling time: 26.67\% \\ \end{tabular}  \\ \hline  
For congestion control, CoAP has a default congestion control mechanism which is based on BEB. Initially for first transmission the RTO value is set to 2 to 3 secs and this value is doubled on expiration for each retransmission until the sender is out of total number of retransmissions. However, the default congestion control mechanism of CoAP is not very efficient and does not correspond to dynamic network conditions. Therefore, many enhancements in congestion control are developed over time which are discussed in the later sections. The default congestion control mechanism of CoAP is shown in Figure 4.  
Figure 4: CoAP Default Congestion Control. Figure 3: Examples of Confirmable and Non-confirmable CoAP messages. Figure 2: CoAP Message Header. Unlike HTTP, CoAP runs over UDP. This helps in avoiding costly handshakes as in case of TCP. CoAP also allows UDP broadcast and multicast for addressing [34]. Owing to the use of UDP in CoAP, large sized payloads can be transferred using block-wise transfer [35] where the resource is split into smaller pieces and sent over multiple CoAP messages. For transferring data securely in CoAP, it uses Datagram Transport Layer Security (DTLS) on top of UDP protocol [34]. Owing to its lightweight capability along with secure reliable and non-reliable communication modes and resource observation model, CoAP has gained immense popularity in IoT and WSN applications.