comm.channel module¶
Module channel is used to describe a channel model for signal propagation. An abstract
BaseChannel class is the base class for any channel in the simulation.
Each Channel class must implement the following abstract method:
do_propagation(): to modify the given signal to capture the propagated signal. The modified signal should capture the quality, distortion, etc depending on how detail the implementation requires.
Note
Created by: CH Foh (2021)
List of Classes¶
BaseChannel¶
An abstract base class of a channel.
DiscModel¶
A radiation model that uses a disc model. When there is a transmission, the signal will radiate within a disc with the origin of the disc being the transmitting source. The signal will be delivered by the channel to the transceivers within the disc. It uses
comm.signalwave.QualityBasedSignal.
LogDistanceModel¶
A radiation model that uses log-distance model. It uses
comm.signalwave.QualityBasedSignal.
-
class
comm.channel.BaseChannel¶ Bases:
abc.ABCThis is an abstract base class for a channel operation.
Methods
do_propagation(signal)This method derives the received signal after its propagation.
get_range([threshold])This method returns an illustrative range of the channel.
-
abstract
do_propagation(signal)¶ This method derives the received signal after its propagation.
This method is not used by user simulation directly. It is used by Transceiver to detect a signal transmitted by a source.
This is an abstract method to be reimplemented in the subclass. The subclass should implement the logic that modifies the input signal due to signal propagation.
- Parameters
- signal
comm.signalwave.BaseSignalsubclass The transmitted signal. This instance will be modified appropriately within this method. The modification describes how the signal would be attenuated and distorted.
- signal
- Returns
comm.signalwave.BaseSignalsubclassThe received signal instance.
-
abstract
get_range(threshold=None)¶ This method returns an illustrative range of the channel. The main function of illustrative range is to show the illustrative coverage on the animation. The actual range might be slightly difference due to randomness in channel fading at each instance.
- Parameters
- thresholdpositive float, optional, default=None
The pathloss attenuation threshold (in dB) that a signal can be detected. The method will use the threshold to calculate how far a signal can reach before the attenuation becomes higher than the threshold.
- Returns
- float
The illustrative range of the channel.
-
abstract
-
class
comm.channel.DiscModel(radius: float)¶ Bases:
comm.channel.BaseChannelThis is a subclass of BaseChannel implementing a disc model for a wireless channel radiation.
For this channel model, when there is a transmission, the signal will propagate within a disc with the origin of the disc being the transmitting source. The signal will be delivered by the channel to the transceivers within the disc.
The channel uses
comm.signalwave.QualityBasedSignalto record the received signal. The quality of 1 indicates the best quality, near 0 indicates poor signal, and 0 indicates no connection.Methods
do_propagation(signal)This method derives the received signal after its propagation.
get_range([threshold])This method returns the coverage radius.
-
__init__(radius: float)¶ This is the constructor.
- Parameters
- freqfloat
The frequency of this channel.
- radiusfloat
The transmission radius.
-
get_range(threshold=None)¶ This method returns the coverage radius. See also the base class description. For this subclass, the range is given at the construction, and it is fixed. The input parameter will not be used.
-
do_propagation(signal: comm.signalwave.QualityBasedSignal) → comm.signalwave.QualityBasedSignal¶ This method derives the received signal after its propagation.
In this implementation, signal is used as the data structure for inputs and outputs. signal contains distance and LOS_dir class properties for this method to read and derive the propagation. It also contains quality class property for this method to recorded the signal quality after the propagation.
In this class, the quality of the signal is related to the distance between the sender and the receiver, and normalized to 1. When receiver is located at the sender, signal quality is 1 (i.e. the best), and when the receiver is at or outside the edge of the radiation disc, the signal quality is 0 (i.e. no connection).
- Parameters
- signal
comm.signalwave.QualityBasedSignal The transmitted signal. This instance will be modified appropriately within this method. The modification describes how the signal would be attenuated and distorted.
- signal
- Returns
- comm.signalwave.QualityBasedSignal
The received signal instance. The quality property contains a value between 0 and 1 indicating the signal quality. The value is linear to the distance between the transmitter and receiver, 1 being zero distance and 0 being the distance that the signal can no longer reach the receiver.
-
-
class
comm.channel.LogDistanceModel(c0, alpha, sigma)¶ Bases:
comm.channel.BaseChannelThis is a subclass of BaseChannel implementing a log-distance path loss model.
The channel uses
comm.signalwave.QualityBasedSignalto record the received signal power.Path loss gain model (P_r/P_t) = c_0 * F_g * d^(-α)
Pr is the received signal power in W.
Pt is the transmitted signal power in W.
F_g describes the flat fading. It is equal to 10^(-X_g/10) where X_g is the fading. In case of slow fading, it has log-normal distribution with zero mean and σ dB standard deviation.
c_0 is the average multiplicative gain at a reference distance. c_0 = d_0^α 10^(-PL_0/10) where d_0 is the reference distance, α is the pathloss exponent, PL_0 is the pathloss (in dB) at d_0.
d is the distance between the transmitter and receiver.
α is the pathloss exponent.
- Parameters
- c0float
The average multiplicative gain at a reference distance.
- alphafloat
The pathloss exponent.
- sigmafloat
The standard deviation (in dB) of the log-normal fading.
Methods
do_propagation(signal)This method derives the received signal after its propagation.
get_range(threshold)This method returns the coverage radius.
-
__init__(c0, alpha, sigma)¶ This is the constructor.
-
get_range(threshold)¶ This method returns the coverage radius. See also the base class description. For this subclass, the range is decided based on the pathloss threshold.
- Parameters
- thresholdfloat
The pathloss threshold.
-
do_propagation(signal: comm.signalwave.QualityBasedSignal) → comm.signalwave.QualityBasedSignal¶ This method derives the received signal after its propagation.
In this implementation, the quality of the signal is recorded based on the pathloss the sender and the receiver. The quality stores the received signal power in dBm after the pathloss and fading.
Based on this model, the received power (in dBm) after the pathloss and fading is:
P_r_dbm = P_t_dbm + 10 log(c_0) - 10 alpha log(d) - X_g
- Parameters
- signal
comm.signalwave.QualityBasedSignal The transmitted signal. The quality property of the instance will be modified after the execution to record the received signal power (in dBm).
- signal
- Returns
comm.signalwave.QualityBasedSignalThe received signal instance. The quality property contains the received signal power (in dBm).