IoT is a massive network that interconnects low power and low resources devices rendering them connected or connected to the Internet [
1]. These devices are capable of exchanging data with each other without human intervention. The growth of number of IoT devices that will emerge by 2025 is approximately 75 billion [
2]. Therefore, IoT will lead the development of a smarter world for the future decades in different fields such as smart homes, smart industries, and smart healthcare [
3]. IoT relies on different protocols to exchange information between the devices and the internet. IoT is composed of three layers namely, the perception layer which includes sensors that gathers data from the environment, the network layer which receives data from sensors and processes it accordingly, and finally, the application layer which receives information from the network layer [
4]. In terms of communications protocols, there are different protocols in the application layer which include CoAP, Message Queuing Telemetry Transport (MQTT), and Advanced Message Queuing Protocol (AMQP). Indeed, CoAP prevails among other protocols due to its lightness and it fits lower power and lower resource devices, thus, it can be secured using DTLS [
5]. CoAP works on the REST model and resources can be addressed from the server and accessed by the clients with the help of the standard HTTP methods such as (GET, PUT, POST, and DELETE). CoAP prevails over other application protocols due to its simplicity to developers, lightweight in terms of power consumption and communication, mobility, and portability [
6]. Therefore, CoAP is targeted by DDoS attacks. The DDoS attack is a collection of infected devices (Zombies) that are controlled by the attacker, and once the attacker aims to launch the attack, he or she commands and controls those Zombies, asking them to overwhelm the victim with a high volume of traffics which results in consuming the victim’s resources and make it unavailable to legitimate users. Therefore, securing CoAP against DDoS attacks is significant. DTLS is proposed to secure CoAP, however, DTLS suffers from the communication overhead because it performs six messages for the handshake process which results in consuming the constrained device energy. Moreover, DTLS is not designed for constrained devices [
6]. Likewise, LSPWSN is used to secure messages of CoAP, but this system is working in the network layer while CoAP is working in the application layer. Motivated by the assumption that detection of DDoS attacks is more beneficial to be near the victim whereas mitigation is more effective to be near the attacker [
7], this works aims to propose a method to detect DDoS attacks against CoAP in the application layer. This study uses CIDAD dataset that contains DDoS attacks (interception, modification, and duplication of CoAP messages). The dataset has ~11000 samples where the malware samples are only 288. As a result, we extend the dataset to 100,000 samples with ~50% for each category (benign and malware) using Generative Adversarial Networks (GANs). In addition, four different ML classification models namely Naïve Bayes, Random Forest, SVC, and Decision Tree since these ML methods showed impressive results in classifying IoT attacks [
8]. The proposed model gains an accuracy of 98% with the Decision Tree algorithm which outperform other algorithms. The main contributions of this work are as follows:
1.1. IoT Overview
The Internet of Things inspires the existence of tiny object devices so they can send and receive data with little users’ intervention [
9]. IoT is defined as extending the network connectivity and computing capability to tiny objects such as temperature sensors and blood pressure monitors to allow them to operate independently. The application of the IoT will involve the military, industry, transportation, and even our daily life activities. The significant and powerful data analytic capabilities combined with the revolutionary of IoT devices are promising to change the way we live and behave. As per the anticipation of some research, 75 billion IoT devices will take place in the communication technology environment by 2025 [
2]. IoT consists of three layers (as depicted in
Figure 1): the perception layer that represents the physical sensors and actuators, the network layer that enables device-to-device and device-to-cloud communication, and the application layer that delivers the services to other devices or humans [
2]. IoT architecture can be extended to have two more layers, namely, MAC and adaptation layer resulting in what the so-called five-layer architecture [
10]. To connect IoT devices to other devices or the internet, several communication models are proposed to connect IoT devices to another device, to the cloud, and to a gateway. Due to the heterogeneity aspect of IoT devices that will interact with other devices, and different IoT protocols are developed to enable the interactions between IoT devices. Consequently, the Institute of Electrical and Electronics Engineers (IEEE) and the Internet Engineering Task Force (IETF) are developing standardized protocols.
Figure 2 depicts the layers and protocols deployed for each layer based on the five-layer architecture of the IoT network. After reviewing the IoT architecture, the protocols related to the IoT will be discussed with more focus on the CoAP protocol. CoAP prevails among other protocols in the application layer because it is a lightweight protocol and fits for constrained devices [
5]. However, CoAP and many other protocols are susceptible to DDoS attacks. DDoS attacks target different layers and many protocols rendering the service unavailable for legitimate users. In the next sections, IoT protocols and CoAP architecture will be reviewed, then DDoS attacks against IoT and CoAP specifically will be investigated.
1.2. IoT Protocols
- 1
IEEE 802.15.4 Protocol
Both physical and MAC layers are ruled by IEEE 802.15.4 protocol which emerged in 2003. The physical layer provides some functionalities such as transferring data, detecting the energy of the channel, and indicating the link quality [
11], whereas the MAC layer associates, disassociates, acknowledges frame arrival, and validates frame.
- 2
6LoWPAN protocol
Lower-Power Wireless Personal Area Network 6LoWPAN has emerged in 2007 due to the demand for low-energy IoT protocol [
10]. It allows a direct connection to the internet and defines encapsulation and header compression mechanisms. 6LoWPAN is considered a replacement for IPv6. This protocol supports addresses with different lengths, low bandwidth, and costs.
- 3
Routing – RPL protocol
IETF proposed Routing Protocol Layer (RPL) for Low Power and Lossy Networks (LLNs) that provides IPv6 connectivity to the LLNs [
12]. This protocol is used in multiple networking facilities such as automated homes, automated industry, and automated buildings.
- 4
CoAP Protocol
The Constrained Application Protocol (CoAP) is a proper web transfer protocol for lower resources devices and LLNs [
13]. The nodes often have 8-bit microcontrollers and limited RAM and ROM. The protocol supports M2M applications like an automated smart home. Due to the demand for a proper design of a generic web protocol that fits constrained devices, CoAP has emerged.
1.2.1. CoAP Architecture
CoAP relies on the client/server model like HTTP with the usage of the request-response model for exchanging messages. The communication between two machines inspires a CoAP to interfere and acts as a client or as a server. A CoAP request is similar to an HTTP request which asks for a resource on a server. The resource is identified by URI. Thus, a response code from the server is sent back with the representation of the resource. So, CoAP architecture includes the message layer and the request-response layer as the main layers. The former is responsible for message delivery over UDP for two nodes and it supports optional reliability. As a result, it is in charge of the redundancy and consistency of any message. The latter avoids having outdated messages or having more copies of a message by holding the code of the requesting and responding.
Figure 3.
Layers of the CoAP Protocol.
Figure 3.
Layers of the CoAP Protocol.
1.2.2. Messaging Model
Messaging model of CoAP is based on sending and receiving messages over UDP for two nodes. CoAP has a 4-byte header, then it has options and payload. Each message has a message ID for duplication check and a reliable connection if desired. Four types of messages are supported by CoAP as follows:
- 1
Confirmable Message (CON): in this mode, all messages are marked as confirmable messages (reliable mode). The message is resent using a default timeout till receiving an Acknowledgement from the recipient with the same messageID as the sender. If the recipient failed to process the confirmable message, the recipient will send a reset message (RST) instead of (ACK) to reset the communication.
Figure 4 shows the confirmable mode between the client and the server.
Figure 4.
Confirmable message transmission.
Figure 4.
Confirmable message transmission.
- 2
Non-Confirmable Message (NON): if reliable delivery is not desired, the message can be sent as a non-confirmable message (unreliable mode). For duplication check purposes, the message is not acknowledged but still has a messageID. Besides, the recipient could send a reset message if it failed to respond to the NON-message. Figure5 depicts the NON-message between the client and the server.
Figure 5.
NON-Confirmable message transmission.
Figure 5.
NON-Confirmable message transmission.
1.2.3. Request/Response Model
Request and response semantics which include method/response code is carried by the CoAP message. Some information about the request and response are considered optional such as the URI and payload media type. To check the identity of requests and responses, a token is used to connect responses with their opposite requests independently. Conceptually, Token differs from messageID. There are three types of messages in the request-response model as follows:
Piggybacked message: CON or NON-message carries a request and if instantly enforced, the response carried in a CON message is carried in the resulting ACK message.
Figure 6 shows two examples of a basic GET request with a piggyback response, one for success and the other resulting in a 4.04 (Not Found) response. Hence, the code [0x00] is the message ID.
Empty Message: if the server is not able to respond immediately to a request carried on the CON message, an empty Acknowledgement.
The message is used to respond to the request so the client can stop retransmitting the request. If the response is ready, the server sends it in a new confirmable message as depicted in
Figure 7.
Non-Confirmable Message: if a non-Confirmable mode is used to send a message, then either a new Non-Confirmable or a Confirmable message is used to send the response as illustrated in
Figure 8.
1.2.4. Message Format
CoAP sends/receives messages and employs UDP for transportation. The encoding of CoAP messages is a simple binary format. A fixed-size 4-byte format appears in the header of the message, then it is followed by a Token value that is 0-8 bytes long. After the Token value, CoAP Options in Type-Length-Value (TLV) format appear, or a sequence of zeros for non-option is displayed. Finally, an optional payload appears that takes up the rest of the datagram.
Figure 9 depicts the CoAP message format. The header fields can be elaborated as follows:
- (1)
Version (V): unsigned integer (2-bit) that represents the CoAP version number. This field takes (01 binary), and other values are reserved for future versions. If the message comes with unknown version numbers, it must be ignored.
- (2)
Type (T): unsigned integer (2-bit) that represents 0 for Confirmable, 1 for Non-Confirmable, 2 for Acknowledgement, or 3 for reset as illustrated in the previous section.
- (3)
Token Length (TKL): unsigned integer (4-bit) with a length of 0 to 8 bytes. Lengths 9-15 are specialized for message format errors.
- (4)
Code: unsigned integer (8-bit) that is divided into the most significant bits (3-bit) and the least significant bit (5-bit). It is represented as "c.dd" ("c" can be 0-7 as a digit for the 3-bit, and "dd" can be two digits in the range from 00 to 31 for the 5-bit). The most significant bits view 0 for a request, 2 for a successful response, 4 for a client error response, or 5 for a server error response. The other most significant bits are reserved. The code 0.00 represents an Empty message as a special case.
- (5)
MessageID: unsigned integer (16-bit) used for duplicate vetting purposes. It is also used to match Acknowledgement/Reset messages to messages of type Confirmable or Non-Confirmable, respectively.
- (6)
Token: maybe 0 to 8 bytes based on the length stated in the TKL field. It is used to correlate requests and responses.
- (7)
Options: can be 0, by another option, or by the payload.
- (8)
Payload: if exists, it is prefixed by a (0xFF) marker as a benchmark for payload start. To calculate the length of the payload, it is counted from the end of the marker until the UDP datagram end.
1.2.5. Method Definitions
Like HTTP, CoAP uses methods (GET, POST, PUT and DELETE) to take any action on a URI resource. CoAP message follows RESTful architecture that makes it fit for constrained devices as a lightweight protocol. A request that carries fault method code results in a 4.05 (Unallowed method) piggyback response. We will briefly elaborate on each method.
GET
The GET method retrieves the information's representation that belongs to the resource identified by the request URI. If the GET method succeeds, a 2.05 (Content) is presented, or a 2.03 (Valid) response code appears.
POST
The POST method functionality is to process the representation retrieved by the request. The origin server performs the main functionality of the POST method depending on the target resource. The result of this action is a creation of a new resource, or an updating process is performed on the target resource. In the case of the creation of a new resource, the response should have a 2.01 (Created) code with the corresponding URI of the created source. However, if POST is processed but the creation of a new source on the server fails, so a 2.04 (Changed) response code is generated. If POST is processed and results in a deletion of a resource, the response should have a 2.02 (Deleted) response code.
PUT
The PUT method functionality is confined to creating or updating the resource identified by the request URI. The enclosed representation format is specified by the media type and content coding provided in the Content-Format option (if it is given). In the case of existing resources at the request URI, the enclosed representation is a modification copy, and a 2.04 (Changed) response code is issued. Otherwise, a new resource should be created by the server and aligned to that URI, and then, a 2.01 (Created) response code is issued. In case of modifying or creating failure, then the error response code is returned.
DELETE
The DELETE method requests to drop the resource that the request URI identifies. If the deletion is a success, a 2.02 (Deleted) is issued. The same message is returned if the resource did not show up before the request.
1.2.6. CoAP URIs
The CoAP uses "coap" and "coaps" URI schemes to identify and locate the resources. A CoAP server hierarchically organizes and governs these resources, and it waits to receive CoAP requests on a specified UDP port number. So, the CoAP methods discussed above are used to access the resources on the CoAP server. Therefore, the "coap" and "coaps" URI schemes are similar to that of "HTTP" and "HTTPS" used with the HTTP protocol.