Channel Simulation in Wireless Communication, with Python Code
Wireless communications are vital nowadays, since they enable us to be connected. Cell phose, laptos, headphones, wireless communications are available in every device in our modern life. However, the performance of these systems is highly dependent on the environment where they operate. In this article, the main wireless channel effects are described. Furthermore, Python code is provided to simulate these wireless effects.
Additive White Guassian Nosie Channel
In a wireless system, noise is generated by several sources such as electronic components, interference from other communication systems and atmospheric effects. The Additive White Gaussian Noise (AWGN) channel is a model to simplify all this effects and analyze the communication system under all these kind of noise types. This model adds to the signal a random signal which is white, meaning that it has a constant spectral density over the whole frequencies, and Gaussian, it follows a normal distribution whose mean is 0 and variance is σ2.

The channel is defined by the Signal to Noise Ratio (SNR), which is given by:

where S is the signal power, N is the signal power (equal to σ2), No is the noise density function and B is the bandwidth of the channel. The SNR is typically measured in dB, whose expression is:

The following code in Python add AWGN noise to a signal. A sine is considered as a transmitted signal, then, a noise to simulate a SNR = 20 dB is added.
import numpy as np
t_max = 1 # Simulated time
fs = 100 # Sampling frequency
f_c = 10 # Carrier frequency
# Signal
t = np.linspace(0, t_max, t_max*fs)
signal = np.cos(2*np.pi*f_c*t)
# AWGN channel
SNR = 20
S = sum(abs(signal)**2)/len(signal) # Signal power (Natural)
S_db = 10*np.log10(S) # Signal power (dB)
N_db = S_db-SNR # Noise power (dB)
N = 10**(N_db/10) # Noise power (Natural)
mean = 0 # Noise mean
std = np.sqrt(N) # Noise standard deviation
noise = np.random.normal(mean, std, size=len(signal))
rx_signal = signal + noiseThe following Figure shows how the noise (in red) affects a signal (in green) for different SNRs. As it can be seen, the lower the SNR the higher the noise level, and the received signal (in purple) is less recognizible.

Multipath Channel
Multipath is the effect which occurs when a RF signal arrives at the receiver several times due to reflections on objects. Buildings, people, walls or any object can cause reflections which arrive at the receiver at different times and with different power leves. For example, a car driving aroung the city will recieve the signal from the direct path but also reflected signals on the surrounding buildings.

In the multipath channel, the transmitted signal is delayed to get the diferrent paths. Finally, the different path signals are sum up with a different gain for each path. The Python code for a 2 paths channel is shown below.

# Multipath channel
d1 = 1 # Delay of path 1 in samples
d2 = 5 # Delay of path 2 in samples
g1 = 1 # Gain of path 1
g2 = 0.8 # Gain of path 2
# Compute paths
path1 = g1*np.append(np.zeros(d1), signal[:-d1])
path2 = g2*np.append(np.zeros(d2), signal[:-d2])
# Sum up all paths
rx_signal = path1+path2Under the multipath channel, the received signal may have a higher or a lower level than the transmitted signal depending on the delay of the different paths. In a 2 paths channel, if the peaks of both signals are line up, that is both signals are in phase, there is a constructive interference. On the other hand, a destructive interference occurs when the peaks of one signal line up with the zeros of the other signal. Both situations may be seen in the following Figure.

Doppler effect
The Doppler effect or Doppler shift is an effect which happens when a signal source is moving relative to the observer. It’s easy to observe Doppler effect with sound waves, but it also occurs withe electromagnetic waves. Doppler effect provoces a frequency shift which changes the frequency of the signal which the receiver sees.
As it can be seen in the Figure, Doppler effect causes a variable delay in the signal, thus provoking the frequency shift. This may be simulated by a delay line where the delay is variable. Variations in the delay depends on the relative speed between transmitter and receiver and the speed of light. To do so, the interp function from NumPy may be used. To get the signal after the Doppler effect is added, we need to interpolate the signal to the time instants where the relative speed is taken into account. This approach is used in the Python code below.

# Doppler channel
speed = 10000 # Relative speed
c = 3e8 # Light speed
t2 = t+speed/c*np.arange(len(t))
rx_signal = np.interp(t2, t, signal)To show a representable frequency shift, a very big relative speed must be considered, which is due to the speed of light. Therefore, this effect won’t be a problem for most of the communication systems, starting to be a problem in aerospace environments.

Typically, Doppler effect occurs at the same time that multichannel. Furthermore, each channel may have different variations on its delay, so interference varies in this type of channels (including changes from constructive to destructive interferences).
Conclusion
This article explained the most common effects that a wireless channel adds to a wireless signal. Noise, multipath and Doppler effect have been explained. Furthermore, Python simulations have been carried out to explain and display these effects. This Python code may be used to evaluate the effect which these channels have on different kind of telecommunication systems.
References
[1] Theodore S. Rappaport, Wireless Communication Principles and Practise.
[2] Julius O. Smith III, Physical Audio Signal Processing, https://www.dsprelated.com/freebooks/pasp/Doppler_Simulation.html
Have you spent your learning budget for this month, you can join Medium here:
Other articles you may find interesting:






