## 8 Discussion  
This work has presented a simulation tool capable of real-time simulating an EM-UWSN whilst running production-stage protocol stacks in each of the virtual nodes. The execution of the exact protocol that will be embedded into HERAKLES project's MINIONs allows an easy evaluation of the expected performance. Furthermore, the developed simulator interacts with the STNAAG 5066 stack at byte level, treating the software piece under evaluation as a black box. This approach has many advantages from a practical viewpoint. For instance, the orchestration of the network simulation is reduced to controlling message delivery, since each real-world STNAAG 5066 stack is carrying out MAC and PHY operations on their own. In addition, the simulated nodes can execute exactly the same routines that will perform under real operation (apart from STNAAG 5066). Finally, the presented framework eliminates the necessity of designing the code taking into account specific API constraints, as it occurs with Click or UnetStack. Figure 13 illustrates a comparison relating the realism and cost of different network simulation approaches. The more realistic both software and hardware are, the more expensive the schemes turn. Hardware-in-loop is closer to an actual deployment as it pretends to use the same hardware with minor modifications, with the purpose of adapting it to the simulation hardware. On the other hand, DES (OMNET++, NS-3, MATLAB, etcetera) needs a protocol implementation compliant with the simulation framework's constraints. Generally, simulating using DES is more unrealistic, but is cheaper and faster. Finally, hybrid simulation (MULE, HTOSSIM) and the use of SCL (such as Click or UnetStack) are more software-realistic, but the development cost is higher since the implementation must fit within the framework's API. Figure 12: Impact of PIR on PLR per node. The simulated network scenario corresponds to a linear deployment in which each node has only visibility with its neighbours. Furthermore, all the nodes generate traffic depending on a network parameter (PIR). Although the scenario's topology is relatively simple and the distance between nodes minimizes PER, the results suggest that there is a significant amount of collisions. As it was commented in Section 3, if after waiting the corresponding initial back-off time a node determines that the channel is idle (from its viewpoint, obviously), it carries out the transmission of all the queued messages up to 60 s. Taking into account the parameters of Table 4, this means that a maximum of 77 queued messages can be transmitted each time. However, since each node is unable the sense transmissions of nodes located above a single-hop distance, collisions are likely to happen. This fact, joint to the long transmission times would make that sometimes a link should be marked as broken. This breakage directly implies that all the buffers are flushed, and hence this information is lost (ultimately increasing PLR). The obtained simulation results suggest that a PLR below 5% for all the network can be assured for PIR values lower than 1.2 packets per second. Regarding packet delivery time, it was observed that the traffic accumulation effect of the linear topology had a significant impact. In general terms, the latency of the i-th node \(D_{i}\) can be expressed in terms of medium access delay (\(D_{i}^{ma}\)), transmission delay (\(D_{i}^{tx}\)), and queueing delay (\(D_{i}^{qu}\)). This relation is shown in Equation (9). \[D_{i}=D_{i}^{tx}+D_{i}^{ma}+D_{i}^{qu}. \tag{9}\]  
The values of each delay component are different for each node. In general terms, messages flow from each node to the sink, whilst ACKs perform in the opposite direction but just from the immediately forward node. Hence, the traffic originated in the farthest node, will be subject to a higher collision probability since it must be forwarded several times before reaching the sink node.