## 3 Model of WSN  
The proposed model of a wireless sensor network is represented by a graph of states and transitions. The necessity to develop the model follows from the need to formalize the WSN functioning processes and, in particular, to obtain a more formal view of the properties of the self-organization and decentralization inherent in such WSNs. One way to implement the decentralization mechanism in a WSN is to introduce a role-functioning mechanism into it. Essentially, the role of a node represents a set of functions of a certain type. According to some initial distribution of the roles among the nodes, a particular node has a few functional duties assigned. However, during the network operation, the distribution of the roles among the nodes can change dynamically. For example, if needed, it is possible to redistribute the functions of a single WSN base station to some other network nodes in order to reduce the negative effect of this node when it leaves the network. Specifically, [PERSON] et al. identify some functions inherent in a base station node and sensor nodes of the network, namely data collection, sending data to a base station, data processing, data aggregation and storage [10]. Consequently, in a network involving a full cycle of the processes for collecting, manipulating and analyzing data from sensors, it is necessary to allocate the following roles: data collector (in fact, this role could be valid for almost every sensor node), data processor, data keeper and data analyzer. At the same time, typically, each role is assigned to at least one of the network nodes, and, if necessary, the role can be reassigned to another one during the operation. Thus, due to the use of the role redistribution mechanism, the runtime decentralization of the WSN operation is ensured. A detailed description of the characteristics of each role in the WSN model we proposed and a description of its functionality are presented in Table 2. The system of the roles is specified as a set  
\[\text{R}=\{\text{r}_{\text{coll}},\,\text{r}_{\text{keep}},\,\text{r}_{\text{ proc}},\,\text{r}_{\text{control}}\}, \tag{1}\]  
where R is a set of roles used to organize the decentralized functioning of the WSN, \(\text{r}_{\text{coll}}\) means the data collector role, \(\text{r}_{\text{keep}}\) is data keeper role, \(\text{r}_{\text{proc}}\) is data processor role, \(\text{r}_{\text{control}}\) is network controller role. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Source** & **Attack** & **Metrics** & **Value** \\ \hline [PERSON] et al. [21] & clone attack & precicion, recall & 0.97 \\ \hline [PERSON] et al. [16] & DDoS (various kinds of flood) & accuracy & 0.997\% \\ \hline  & & energy consumption, throughput, packet delivery ratio (PDR) & 0.8 \\ [PERSON] et al. [20] & & & 0.78-0.93 (depending on the number of nodes) \\  & & & \\ \hline  & & recall & 0.88–0.99 (depending on the number of malicious nodes, the more there are, the lower) \\ [PERSON] et al. [18] & identifying malicious nodes & FPR & more there are, the lower) \\  & & FNR & 0–0.03 \\ \hline [PERSON] et al. [14] & anomalies in WSN (Intel Laboratory dataset) & accuracy & 89.9\% \\ \hline  & & & 0.9 (dalay) \\ [PERSON] et al. [12] & message delay, repetition, wormhole, jamming, data alteration attacks, blackhole, selective forwarding attack & detection effectiveness & 1.0 (jamming) \\  & & (accuracy) & 0.8 (data alteration) \\  & & & 0.96 (blackhole) \\  & & & 0.83 (selective forwarding) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Comparison with state of the art. The initial distribution of roles among WSN nodes is performed at the WSN initialization stage. By default, each node could be assigned the data collector role. Further, during the operation of the network, the assignment of roles can be redistributed in accordance with the conditions described in Table 2. Thus, after a new node appears in the WSN, the network controller makes a decision upon assigning some specific role to this node if it is more profitable for the functioning of this role.