Designing a scalable and efficient application layer protocols for the Internet of Things (IoT) environment is anongoing problem. The constrained application protocol (CoAP) offering RESTful services for IoT devices implements a simplecongestion control mechanism. This study proposes and analyses the distance-based congestion control CoAP (DCC-CoAP)for the current state of the network and accordingly calculate the future flow rate to handle congestion. The authors’ main idea isto use the combination of distance between nodes and round trip time (RTT) measurements which limits the losses of CoAPmessages, which is an efficient way to predict the network congestion. The user-defined options, i.e. retransmission counter andtimestamp of sent and received CON and ACK messages are introduced for mapping CON to ACK and measure RTT. Thecomparative analysis of the DCC-CoAP with other congestion control mechanism like default CoAP, CoCoA+ is also highlightedin this study. With low additional computations, future RTT can be measured for avoiding congestion, and retransmissiontimeout varies with distance to avoid transaction losses. An algorithm with varying data rate has been used in homogeneousand mixed traffic to calculate the parameters in terms of packet delivery ratios, delay and retransmission count.