## 3 Simulation Framework
### Modules
#### 3.2.2 Transmitter/Receiver (T/R) and Channel  
The Transmitter/Receiver (T/R) and Channel modules are responsible for transmitting, receiving, processing, and routing data and frame messages. Both modules are instances of the Device Software Component (Device) illustrated in Figure 5 that is introduced in [45]. The Device Software Component is written in C and is designed as a multi-threaded application for the Linux operating system.  
The Device Software Component is composed of several software submodules: File Parser, Logger, Data/Frame Processing Logic, Data Transmitter/Receiver, Frame Transmitter/Receiver and Control Messages Parser. It can be configured to operate as the Transmitter/Receiver module or the Channel module. The configuration process is performed from the HUT module via the control interface during the simulation initialization phase. Figure 6 illustrates the configuration of the T/R and Channel module, as well as the connection between them.  
Figure 4: File parsing and data transmission mechanism.  
When the Device Software Component is configured to operate in Transmitter/Receiver (T/R) mode, all submodules shown in Figure 5 are utilized, except for the File Parser submodule. The primary function of the T/R module is to process Data Messages received from the HUT module at the uplink as well as Frame Messages received from the Channel module at the downlink over the corresponding channel. At the uplink, it encodes Data Messages using appropriate channel modems and encapsulates the payload and header of these messages into a terrestrial or satellite physical layer format, thus producing Frame Messages that are sent to the Channel module. At the downlink, it decodes Frame Messages received from the Channel module and extracts Data Messages that are sent back to the HUT module. When the simulation is started, the Logger submodule sends corresponding messages over the UART interface, which can be used for debugging.  
When the Device Software Component is configured to operate in Channel mode, all submodules shown in Figure 5 are utilized, except for the Data T/R submodule. The primary function of the Channel module is to process Frame Messages received over the uplink, from the T/R module, by applying the appropriate channel model, thus simulating real-life scenarios. One of the key functions of channel processing is to determine whether a Frame Message should pass or should be dropped. If the MODCOD, used in the current Frame Message, is not strong enough to handle the channel SNR, then the frame should be dropped since it cannot be decoded successfully at the receiver's side. Otherwise, the Frame Message should pass to the downlink and almost certainly will be decoded successfully in the T/R module. A dropping mechanism is implemented by comparing the MODCOD used for the current Frame Message encoding with the optimal MODCOD that should be used considering the current channel conditions. The first MODCOD, which is used for Frame Message coding, is a prediction provided by the HUT module, while the latter MODCOD is a value produced by the Channel model and represents the optimal code considering channel conditions. If the first MODCOD, used for encoding, has a larger SNR threshold value than the optimal MODCOD, the Frame Message will be dropped; otherwise, it will pass to the downlink.  
Figure 5: The architecture of the Device Software Component.  
Figure 6: Configuration of the T/R and Channel modules as well as a connection between them.