## 2 Methodology
### An Optimal Energy Resources Allocation Method Based on Clustering Optimization  
The sub-network layer of railway wireless monitoring network is mainly composed of several sensor nodes and a sink node. Sensor nodes are responsible for sensing, processing, and short-distance transmission of data, while sink nodes are responsible for collecting data perceived by all sensor nodes in the monitoring sub-network. Sensor nodes are usually composed of four parts: Data sensing unit, data processing unit, data communication unit, and energy supply unit. Data sensing unit is responsible for perceiving real-time service status data of monitoring objects. Data processing unit is responsible for simple format transformation of perceptual data and other processing work. The data communication unit is responsible for data communication with other sensors or sink nodes, including the process of receiving and transmitting data. The energy supply unit is responsible for energy supply for the remaining three units to ensure the stability of each unit. The energy consumption of wireless sensor nodes is mainly in three stages: Data sensing, data processing, and data transmission. According to the literature [14], the energy consumed by sensors in the process of data sensing is negligible compared with the other two stages. Therefore, the energy consumption of sensor nodes in the process of data processing and communication when establishing the energy consumption model of railway wireless monitoring sub-network. As shown as Figure 3, the energy consumption of sensor nodes in data communication process consists of three parts: Data processing energy consumption, data receiving energy consumption, and data sending energy consumption [15; 16]. Figure 3: Composition structure and energy consumption of wireless sensor nodes. The energy consumption of data processing is mainly determined by the energy consumption rate of data processing and the amount of data processed, as shown in Equation (1):  
\[E_{X}(l)=l\times E_{A} \tag{1}\]  
where \(l\) represents the amount of data processed, \(E_{A}\) represents energy consumption of data processing circuits for processing unit data. The energy consumption of data reception is mainly determined by the amount of data received, as shown in Equation (2):  
\[E_{R}(l)=l\times E_{C} \tag{2}\]  
where \(l\) also represents the amount of data processed, \(E_{C}\) represents energy consumption of transmitting circuit. The energy consumption of data transmission is mainly related to the amount of data sent and the distance sent, as shown in Equation (3):  
\[E_{T}(l,d)=\left\{ \begin{array}{ll}E_{R}(l)+l\times E_{f}\times d^{2},&(d<d_ {0})\\ E_{R}(l)+l\times E_{m}\times d^{4},&(d\geq d_{0})\end{array} \right. \tag{3}\]  
where \(d\) represents the distance between two nodes, \(d_{0}\) is a constant, the selection of its value is related to network environment. When the distance between sending node and receiving node is less than \(d_{0}\) in the network, energy dissipation model in free space [17] is adopted, the energy consumption of sending data is proportional to the square of distance. \(E_{f}\) represents the energy consumption coefficient of free space power amplifier. When the distance between sending node and receiving node is greater than or equal to \(d_{0}\) in the network, multi-channel attenuated energy dissipation model [18] is adopted, the energy consumption of sending data is proportional to the fourth power of distance. \(E_{m}\) represents the energy consumption coefficient of multichannel attenuated power amplifier. The sink node in the subnet is mainly responsible for receiving information, and the energy storage of the sink node is much larger than that of the other sensor nodes. Therefore, in this chapter, it is assumed that the energy of the sink node is infinite. In order to reduce the energy consumption of sensor nodes, a routing protocol based on clustering communication is used to transmit data in the sub-network.