Wireless Network Simulator
Communications Toolbox Wireless Network Simulation Library offers a wireless network simulator object, wirelessNetworkSimulator
, to simulate different wireless network scenarios
with different types of wireless nodes. This topic outlines the process of the
wirelessNetworkSimulator
object, explaining how the simulator
interacts with nodes, triggers scheduled actions, and runs simulations.
Interaction Between Network Simulator and Wireless Nodes
This block diagram illustrates the interaction between the network simulator and the nodes. The interaction consists of these stages:
Run the protocol stack of nodes.
Obtain the generated packet from the transmit buffer of a node.
Check the relevance of the packet to other nodes.
Apply channel impairments to the obtained packet and distribute it the interested nodes in the network.
Run the Protocol Stack of Nodes
Each node in the network contains a protocol stack. A protocol stack consists of layered protocols, such as the application layer, the medium access control layer, and the physical layer. A node runs its protocol stack when the simulator provides the node with the current simulation time and asks it to run.
Initially, the simulator asks all the nodes to run their protocol stacks. After running its protocol stack, each node returns the time of the next run of the protocol stack to the simulator. The simulator records the times of future runs of the protocol stacks of all the nodes. Based on this record, it asks the nodes to rerun their protocol stacks.
Obtain the Generated Packet
The simulator asks each node in the network whether the transmit buffer of the node contains any generated packets for transmission. If a packet exists, the node provides the simulator with the packet to distribute to other nodes in the network.
Apply Channel Impairments to the Obtained Packet and Distribute the Packet
The simulator distributes the obtained packets differently, depending on whether they must pass through a channel or travel directly to their destinations.
Packet must pass through a channel — In this case, the simulator performs these steps.
Check whether the obtained packet is relevant to other nodes in the network — All other nodes in the network might not be interested in every packet generated during the simulation. For each packet, the simulator asks all other nodes whether the packet is relevant to them. Here, a relevant packet means a packet of interest to the node or an interfering packet. The nodes acknowledge the query from the simulator by confirming whether the packet is relevant or not. Additionally, the nodes provide the simulator with the information required for modeling the channel (such as the position of the receiver node, the velocity of the receiver node, the number of receiving antennas at the receiver node, and the unique node identifier).
Apply channel impairments — If a generated packet is relevant to a receiver node, the simulator applies channel impairments to the packet before pushing it to the receiver node. You can apply a custom channel model to the simulator, but the simulator otherwise applies the free-space path loss (FSPL) impairment to the packets. For more information about applying a custom channel, see the Plug Custom Channel into Wireless Network Simulator example.
Packet must travel directly to the destination, bypassing the channel — In this case, the simulator identifies the destination nodes for the packet based on the destination ID in the generated packet.
After identifying the receiver nodes for each packet, the simulator pushes the packet to the receive buffers of the receiver nodes. The simulator then asks the nodes to run their protocol stacks for processing the packet at the current simulation time.
Trigger and Perform Scheduled Actions
After running the protocol stack of the nodes and distributing the packets, the simulator triggers the actions if scheduled for the current simulation time, as shown in this figure.
You can create custom functions to carry out actions during the simulation. Examples of such actions include refreshing the visualization and logging statistics. The simulator enables you to schedule such actions in three different ways: a one-time action, a periodic action, or an action when the simulator advances the simulation clock. For more information about this, see the Schedule Action to Perform During Network Simulation example.
One-Time Action
The simulator triggers the defined action only once during the simulation. For example, this figure shows that the simulator triggers the action Z only at the instant Tn.
Periodic Action
The simulator triggers the defined action periodically during the simulation. For example, this figure shows that the simulator triggers the first execution of the action X at the instant Ts, and repeats it after every Tp seconds.
Action When Simulator Advances the Simulation Clock
The simulator triggers the defined action when the simulator advances the simulator clock to the next event time. For example, this figure shows that whenever the simulator advances the clock to the next event time, it triggers the action D.
The simulator maintains a list containing the times of future events. Based on this list, the simulator advances the clock to the next event, skipping the periods of inactivity.
Summary of Simulator Process
The simulation consists of these steps.
Check whether the current simulation time is less than or equal to the simulation end time. If yes, ask the nodes that must run at that current simulation time to run. Record the time values (when to rerun the node) returned by each node.
Obtain the generated packet from the transmit buffer, check the relevance of the packet to nodes (if required), apply the channel to the packet, and distribute the packet to the interested nodes.
Trigger the actions scheduled (one-time action, periodic action, or action when the simulator advances the simulator clock) for the current simulation time.
Calculate the earliest time for the next run of a node or action.
Advance the simulator clock to the next event time based on the calculated earliest time.
Repeat steps 1–5 for entire simulation duration.
Note that the simulator only schedules the running of the nodes and actions. A node schedules the processing activities related to its protocol stack independently. Also, the simulator does not guarantee the order in which the nodes run or the scheduled actions execute.
This flowchart summarizes the series of actions executed by the simulator.
See Also
Objects
Related Topics
- Plug Custom Channel into Wireless Network Simulator
- Composition of NR Nodes (5G Toolbox)
- Communication Between gNB and UE Nodes (5G Toolbox)
- Create, Configure, and Simulate an 802.11ax Mesh Network (WLAN Toolbox)
- Create, Configure, and Simulate Bluetooth LE Network With Custom Channel (Bluetooth Toolbox)