# Improving Performance of Cluster Heads Selection in DEC Protocol Using K-Means Algorithm for WSN
## 1 Introduction  
Wireless sensor networks (WSN) have been considered one of the most significant technological achievements of recent years. Wireless communication and the Internet are constantly used in medicine, technology, agriculture, environmental protection, etc. Small, intelligent sensors enable the construction of portable devices for measuring and recording biomedical signals and monitoring the patient's health outside the medical centre. A newly developing field is textronics, which deals with the design of clothing with built-in microsensors that monitor various parameters of the health or well-being of drivers, firefighters and other people performing dangerous work or responsible for the health of others. In control and measurement systems, WSN and small smart sensors are irreplaceable in hard-to-reach places, or they can be deployed in a physical area on an inaccessible track [1, 2, 3]. All WSNs consist of a base station (BS) connected to the Internet and a set of sensor nodes, which communicate with the base station by a wireless channel (see Figure 1). Sensors are small and complex devices; they can sense, process and transmit the data to other sensors in the same network. Therefore, all nodes consist of four main parts: the power part, which is responsible for battery level and energy consumption of sensors; the communication part, used to send and receive data in the network; the processing part,accountable for processing the data and the sensing part used to read data from neighbour nodes [2]. All nodes in WSN are energy constrained. Therefore, in recent years, researchers have developed and implemented many WSN protocols that decrease the energy depletion in the network. [3]. Wireless sensor network protocols can be classified into three main types depending on the network architecture: hierarchical routing protocols, flat routing protocols, and location routing protocols. The most popular are hierarchal routing protocols. In this protocol type, the network is divided into smaller groups called cluster areas. Every cluster area consists of only one cluster head (CH) and a set of nodes. All cluster heads have the same functions: connect nodes in the same cluster area to collect data, process the data, and send the data to the base station of the network [4], as shown in Figure 1.  
The most commonly used hierarchal routing protocols are LEACH (low-energy adaptive clustering hierarchy) [2; 5], SEP (stable election protocol) [6], TEEN (threshold sensitive energy efficient sensor network) [4], DEEC (distributed energy-efficient clustering) [7], DEC (deterministic energy-efficient clustering) [1; 8] and their modifications [5; 9]. In LEACH [10], cluster heads in the network are selected randomly, and it does not consider the nodes' location in the same cluster area. Because of that, many cluster heads will be near each other or near the edge of the network, leading to higher energy consumption. In SEP [6], the cluster head selection is made randomly, similar to the LEACH protocol, but there are two different types of nodes: normal nodes and advanced nodes, which allows for taking into account the network heterogeneity. In TEEN [11], cluster heads are also selected randomly, and energy consumption is reduced by introducing thresholds, reducing the number of transmissions by allowing the nodes to transmit only when the sensed attribute is in the range of interest. One of the prevalent drawbacks of this protocol is when the hard threshold is not checked correctly. Then, the nodes in the cluster area will not connect, and the user will not obtain information about the dead cluster head in the network. In DEEC, the cluster heads are elected by probability based on the ratio between the residual energy of each node and the average energy of the network. In DEC, the CH election is locally decided based on each node's residual energy (RE). DEEC and DEC are dedicated to heterogeneous environments and improve the lifetime of wireless sensor networks significantly when compared with LEACH and SEP [1; 7].