# An Enhanced Distributed Data Aggregation Method in the Internet of Things
## 3 Proposed Method (LA-RPL)
### Data Aggregation Scheme Based on Learning Automata
Otherwise, the node is given a penalty. If a reward is received by the node, \(P_{Agg}\) varies as \[P_{Agg}=P_{Agg}+\alpha\times R\times\left(1-P_{Agg}\right)\] (6) And if a bonus is received by the node, \(P_{Agg}\) will be as \[P_{Agg}=(1-\beta(1-R))P_{Agg},\] (7)where \(\beta\) is the penalty coefficient, \(T\) is the reward to penalty ratio, and the impact of coefficients for the total number of (plain or aggregated) received packets in node \(j\) during time duration \(t\) is  
\[N_{AP_{j}}=\sum i=1\textit{degree}\ N_{PK_{i}} \tag{8}\]  
where \(N_{PK_{i}}\) is the number of aggregated data packets in \(i\) for node \(j\), and the impact of coefficients (reward/penalty) is as  
\[T=1-\frac{1}{N_{AP_{j}}} \tag{9}\]  
In Figure 9, the status of a node in the network is displayed with the RPL structure. In this figure, depending on the role of the node on the network, either the child node or the parent, one or both types of input can be adopted. For example, for a leaf node, there is only a data sensing unit and packet formation, and in the parent node, in addition to the sensor segment, there is also a unit of message reception from the children. Therefore, the parent node in the proposed method, depending on whether the package received from its child has already been aggregated, can be done with the functions of the automata to create and manage the Transmission Queue. Finally, the outgoing packets from each parent node are packets that once have been aggregated. In Figure 10, the internal communication diagram of each node is displayed in the RPL network. In this form, the Data Generator unit has the task of sensing the physical environment and data generation that transmits its output to the aggregation node in the node. The control unit for collecting information from the child nodes manages the information received from the parent and acts on the child to send the message to the data sending unit aggregated to the parent or to send the Ack message. It should be noted that all the units mentioned use their internal timer. In Figure 11, a general diagram of the proposed method is presented. As shown earlier, the root node uses two objective functions, one to two, to send a DIO message and form a network graph. In the second step, network nodes send the root node after receiving the DIO message to send the DAO message requesting a root subscription. At the first level, there is no limit to the number of children for root nodes. The parent nodes that are rooted are forwarding the DIO message received from the unit by updating the open rank. At this point, each parent node can accept k child numbers and will not respond to requests that exceed the threshold. This process is done to the extent that the network graph is complete. In the aggregation phase, each label has a label (zero). Given that the parent node closed recently? Retrieved with a learning automata system and will wait for t seconds. This will have a greater chance of getting future packs. Otherwise, he will receive a fine and send the packet directly to his parent. The parent node, in the event of expiration, t submits to the aggregation of the data received and its production data, if any, and sends the packet to the parent. In order to avoid multiple  
Figure 9: The diagram of data aggregation mechanism in each parent node. aggregations of a packet at different levels of the network graph after the package is first combined, the label will change to 1.