## 3 Network Simulations for Fixed and Uniform Random Patterns of Nodes  
The network simulation is an important approach to better anticipate the results of the actual network performance. It also sheds some light on what the network performance would be like in case the actual implementation cannot take place. However, most previous simulation works relied on generating a uniform random node pattern that could significantly deviate from the real-world scenario. This section aims at understanding the effect of node patterns on SF assignment and network performance by comparing fixed and random node patterns using the default ADR scheme. Before constructing the node pattern, the propagation path loss model suitable for the study area was selected for the simulation. In our investigation, we conducted a survey at a considerable number of dairy farms in the Photharam district of Ratchaburi, Thailand. This area has the potential to adopt smart livestock technologies, and some farms have already pursued such technologies. We installed the LoRa gateway at Centermilk Farm and then conducted several drive tests in a 5 km radius, as shown in Figure 2, to measure the LoRa signal strength before creating a map to locate dairy farms within the test area. Photharam district is situated outside urban areas, characterized by small buildings and villages. Although present, these structures are not as numerous or densely populated as in urban areas. Thus, this environment aligns better with the suburban Hata-Okumura path loss model [26], as indicated by Equations (7)-(11). For simplicity, the path loss equation is shortened by using the variables \(A\), \(B\), and \(C\) to represent its three components. Note that the choice of path loss model depends on several factors such as environment type, operating frequency, communication range, propagation conditions, etc. \[L_{c}=A+Blog(d)-a(h_{m})+C, \tag{7}\]  
\[A=69.55+26.16 log(f)-13.82 log(h_{b}), \tag{8}\]\[B=44.9-6.55 log(h_{b}), \tag{9}\]  
\[a(h_{m})=(1.1 log(f)-0.7)h_{m}-(1.56 log(f)-0.8), \tag{10}\]  
\[C=-2(log(\frac{f}{28}))^{2}-5.4, \tag{11}\]  
where  
\(L_{c}\) is the total path loss (in dB);  
\(d\) is the distance of end devices (in meters);  
\(h_{m}\) is the height of end devices (in meters);  
\(f\) is the frequency (in Kilohertz);  
\(h_{b}\) is the height of the gateway (in meters);  
\(a(h_{m})\) is the correction factor for suburban environment (in dB). In our research, we assigned 1500 nodes to represent 1500 connected dairy cows raised on the dairy farms in Photharam district, Ratchaburi. Note that the connected dairy cows are those tagged with the IoT sensors. We introduced node positions in the 2D plane with \(x\) and \(y\) coordinates, as expressed in Equations (12) and (13). Subsequently, we calculated the distance \(D\) from the node to a gateway using the Pythagorean formula, as shown in Equation (14). \[x=K\times D_{max}\text{cos}\bigg{(}\frac{I}{J}\bigg{)}, \tag{12}\]  
\[y=K\times D_{max}\text{ sin}\bigg{(}\frac{I}{J}\bigg{)}, \tag{13}\]  
\[D=\sqrt{x^{2}+y^{2}}, \tag{14}\]  
where  
\(D_{max}\) is the coverage area in meters;  
\(x\) and \(y\) are the positions in the 2-dimensional plane;  
\(D\) is the distance between the node and the gateway in meters;  
\(I\), \(J\), and \(K\) are values between 0 and 1. Figure 2: Location of dairy farms at Photharam district, Ratchaburi, Thailand. First, we utilized the LoRaSim simulator to randomize \(I,J\), and \(K\) constants to generate the uniform random node pattern, as shown in Figure 3. Then, we assigned certain values of \(I\), \(J\), and \(K\) constants using Equations (12)-(14) to reflect the actual locations of dairy farms and, consequently, the connected cows raised on those farms. The actual or fixed pattern shown in Figure 4 clearly exhibits a biased node distribution, where most nodes are confined within a 2 km radius from the center. After the node pattern was constructed, the node's SF values of both patterns were assigned using the default ADR mechanism in LoRaSim.