## 7 System Simulation Model  
In this section, we explain in detail a discrete event simulation developed to validate the analytical results. The analytical results obtained from the derived Markov Chains are validated through extensive discrete event simulations to calculate the Throughput, the idle slot probability, and the packet collision probability. Algorithm 1, describes the simulations we generate to analyze the WSN considering that the _On/Off_ times are hyper-exponentially distributed, focusing on the interaction of nodes, their energy consumption, and the efficiency of transmissions. The algorithm takes four inputs: the total number of nodes (\(Total_{Nodes}\)), a matrix with all the valid configurations of the nodes (\(Valid_{Matrix}\)) as described in the previous section, the packet transmission probability (\(\tau\)), and a stratum to analyze (\(Stratum\)). Its output is a set of simulation results determined by the Result variable. As it can be seen, it first determines the energy decrease based on the different operations of the nodes. Namely, in the \(On\) state, nodes activate the sensing, processing, and communication capabilities, while in the \(Off\) mode, nodes consume a small amount of energy-related mainly to minimal electronic systems to allow the node to wake up in the following seconds. Additionally, in the \(On\) mode, when nodes transmit a packet, with probability \(\tau\), nodes consume an extra amount of energy. Hence, \(E_{tx}>E_{On}>E_{Off}\). Initially, the algorithm sets up the simulation environment, initializing parameters like energy levels and slot time, and preparing the initial states of the nodes. It also initializes counters for tracking the number of free slots, successful transmissions, and collisions. When the simulation begins evaluating a system with no nodes, a try-catch sequence is implemented to automatically terminate the program due to the absence of nodes to perform any actions, returning results based on the Result variable. Otherwise, it enters a loop that runs for a predefined number of iterations or until a specified slot count threshold is reached. During each slot, the algorithm calculates the number of transmissions, taking into account the active nodes and the transmission probability \(\tau\). It updates the energy consumption for both transmitting and non-transmitting nodes and adjusts the counters for free slots, successful transmissions, and collisions according to the transmission count. Progress is printed at regular intervals to monitor the simulation. Finally, the algorithm concludes by returning free slots, collisions, and successful transmissions relative to the total number of slots, or the average energy consumption per slot. ``` Input:\(valid\_configurations\), \(\tau\), \(Energy\_tx\), \(Energy\_On\), \(Energy\_Off\) Output: Simulation results \(Total\_Energy,Free\_channel\), \(Success,Collision\gets 0,0,0,0\); for\(i\gets 1\)to\(valid\_configurations\_quantity\)do \(configuration\leftarrowvalid\_configurations[i]\); for\(j\gets 1\)to\(100,000\)do \(transmissions\gets 0\); \(actives\gets nodes\_actives\_in\_that\_configuration\); for\(k\gets 1\)to\(actives\)do \(random\leftarrow random\_number\); if\(random\leq\tau\)then \(transmissions\gets transmissions+1\); \(Total\_Energy\gets Total\_Energy+Energy\_tx\); if\(transmissions=1\)then \(Success\gets Success+1\); elseif\(transmissions>1\)then \(Collision\gets Collision+1\); else \(Free\_channel\gets Free\_channel+1\); \(Total\_Energy\gets Total\_Energy+Energy\_off\); return\(\frac{Total\_Energy}{100,000}\), \(Free\_channel\), \(Success\), \(Collision\



network behavior. In each iteration, it calculates the number of active nodes and randomly determines if each active node transmits based on \(\tau\). Depending on the number of transmissions, it updates the success, collision, or free channel counters and adjusts the total energy consumption accordingly.