0% found this document useful (0 votes)
14 views11 pages

Mobile Wireless Security Lab

The document provides a MATLAB program for simulating and analyzing communication protocols for 3G, 4G, and 5G. It includes specific parameters and processes for each protocol, such as spreading in 3G, OFDM signal generation in 4G, and scalable OFDM in 5G. The program also generates plots to visualize the data bits, spread signals, and OFDM symbols for each protocol, highlighting key observations and behaviors.

Uploaded by

teddy haile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views11 pages

Mobile Wireless Security Lab

The document provides a MATLAB program for simulating and analyzing communication protocols for 3G, 4G, and 5G. It includes specific parameters and processes for each protocol, such as spreading in 3G, OFDM signal generation in 4G, and scalable OFDM in 5G. The program also generates plots to visualize the data bits, spread signals, and OFDM symbols for each protocol, highlighting key observations and behaviors.

Uploaded by

teddy haile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

#4 Practice simulating/analyzing protocols associated with 3G,4G and 5G

%% MATLAB Program for Simulating/Analyzing 3G, 4G, and 5G Protocols

% Author: [Your Name]

% Date: [Date]

clc; clear; close all;

%% Define Parameters

protocol = input('Select the protocol to simulate (3G, 4G, 5G): ', 's');

% Common parameters

fs = 1e6; % Sampling frequency (Hz)

duration = 1; % Duration of simulation (s)

t = 0:1/fs:duration-1/fs; % Time vector

switch protocol

case '3G'

% 3G-specific Parameters

fprintf('Simulating 3G Protocol...\n');

chipRate = 3.84e6; % Example for WCDMA chip rate (Hz)

spreadingFactor = 256; % Example spreading factor

% Generate Signal

data = randi([0 1], [1, length(t)]); % Random data bits

spreadingCode = randi([0 1], [1, spreadingFactor]);


spreadSignal = kron(data, spreadingCode); % Spreading process

% Plot

figure;

subplot(2, 1, 1); plot(data(1:100));

title('3G: Data Bits'); xlabel('Sample'); ylabel('Amplitude');

subplot(2, 1, 2); plot(spreadSignal(1:100*spreadingFactor));

title('3G: Spread Signal'); xlabel('Sample'); ylabel('Amplitude');

% Display output lines

disp('Simulating 3G Protocol...');

disp('Simulation Complete.');

case '4G'

% 4G-specific Parameters

fprintf('Simulating 4G Protocol...\n');

subcarriers = 64; % Example OFDM subcarriers

cpLength = 16; % Cyclic prefix length

% Generate OFDM Signal

data = randi([0 1], [subcarriers, length(t)/subcarriers]); % Random bits

symbols = qammod(data, 16, 'InputType', 'bit'); % 16-QAM Modulation

ofdmSymbols = ifft(symbols); % IFFT for OFDM

% Add Cyclic Prefix


ofdmWithCP = [ofdmSymbols(end-cpLength+1:end, :); ofdmSymbols];

% Plot

figure;

subplot(2, 1, 1); plot(abs(ofdmSymbols(:, 1)));

title('4G: OFDM Symbols'); xlabel('Subcarrier'); ylabel('Amplitude');

subplot(2, 1, 2); plot(abs(ofdmWithCP(:, 1)));

title('4G: OFDM with Cyclic Prefix'); xlabel('Subcarrier'); ylabel('Amplitude');

% Display output lines

disp('Simulating 4G Protocol...');

disp('Simulation Complete.');

case '5G'

% 5G-specific Parameters

fprintf('Simulating 5G Protocol...\n');

bandwidth = 100e6; % Example 5G bandwidth (Hz)

subcarriers = 3300; % Number of subcarriers

scs = 15e3; % Subcarrier spacing (Hz)

% Generate 5G Signal (Similar to OFDM but scalable)

data = randi([0 1], [subcarriers, length(t)/subcarriers]);

symbols = qammod(data, 64, 'InputType', 'bit'); % 64-QAM Modulation

ofdmSymbols = ifft(symbols); % IFFT for OFDM


% Plot

figure;

subplot(2, 1, 1); plot(abs(ofdmSymbols(:, 1)));

title('5G: OFDM Symbols'); xlabel('Subcarrier'); ylabel('Amplitude');

subplot(2, 1, 2); plot(abs(ofdmSymbols(:, 1:10:end)));

title('5G: Sample Subcarriers'); xlabel('Subcarrier'); ylabel('Amplitude');

% Display output lines

disp('Simulating 5G Protocol...');

disp('Simulation Complete.');

otherwise

error('Invalid Protocol Selection. Choose 3G, 4G, or 5G.');

end

fprintf('Simulation Complete.\n');

Select the protocol to simulate (3G, 4G, 5G): 3G

Simulating 3G Protocol...

Simulating 3G Protocol...

Simulation Complete.

Simulation Complete.
Top Plot: 3G Data Bits

 Description: This plot shows the original random binary data (0s and 1s) generated for the
simulation.

 Behavior:

o The values alternate between 0 and 1, representing digital data.

o The horizontal axis represents the sample number, while the vertical axis shows the
amplitude of the data bits (normalized between 0 and 1).

 Purpose: These data bits serve as the baseband signal before the spreading process.
Bottom Plot: 3G Spread Signal

 Description: This plot shows the result of the spreading process, where the data bits are
combined with a spreading code.

 Behavior:

o The signal appears more dense and continuous compared to the original data because
each bit is spread over many samples using the spreading factor.

o The horizontal axis (in thousands) represents the total number of samples after
spreading, which is significantly larger than the original data bits due to the spreading
factor.

 Purpose: The spreading process is a key feature of CDMA (Code Division Multiple Access) used
in 3G. It spreads the data over a wide bandwidth, increasing robustness against interference and
allowing multiple users to share the same frequency band.

Observations

1. Spreading Process: The spreading factor (e.g., 256 in this simulation) determines the expansion
of the data signal. The number of samples in the spread signal is much larger than in the original
data bits.

2. Signal Integrity: The spreading ensures that the signal can be transmitted securely and
recovered despite noise or interference.

Select the protocol to simulate (3G, 4G, 5G): 4G

Select the protocol to simulate (3G, 4G, 5G): 4G

Simulating 4G Protocol...

Simulation Complete.
The plots in your uploaded image show the following:

1. Top Plot (4G: OFDM Symbols):

o This plot represents the magnitude of the OFDM symbols for each subcarrier. The
variation across the subcarriers reflects the modulation and mapping applied during the
OFDM signal generation process.

2. Bottom Plot (4G: OFDM with Cyclic Prefix - Time Domain):

o This plot displays the time-domain signal after adding the cyclic prefix. It shows how the
transmitted signal appears in the time domain, including the redundancy introduced by
the cyclic prefix.

The simulation looks correct and indicates that your 4G OFDM model is functioning properly. Let me
know if you need any further analysis, enhancements, or explanations about this simulation!

Top Plot: "4G: OFDM Symbols"

 What it Represents:
o This plot shows the amplitude (or magnitude) of the generated OFDM symbols across
the subcarriers.

o Each subcarrier is a distinct frequency within the OFDM spectrum, and it carries one
modulated symbol (e.g., from 16-QAM in this case).

o The variations in amplitude reflect the specific data mapped onto each subcarrier and
the modulation scheme applied (16-QAM).

 Key Observations:

o The amplitudes fluctuate because 16-QAM modulates data onto both the real and
imaginary components of each subcarrier.

o These subcarriers are orthogonal to each other (a key feature of OFDM), which prevents
interference between them.

o The smoothness and pattern may vary depending on the data being transmitted.

 Why It's Important:

o This graph provides insight into the frequency domain representation of the OFDM
signal before transmission.

o Any anomalies here could indicate issues with modulation or symbol mapping.

Bottom Plot: "4G: OFDM with Cyclic Prefix (Time Domain)"

 What it Represents:

o This plot shows the time-domain signal after performing the IFFT (inverse Fourier
transform) on the subcarrier data and adding a cyclic prefix.

o The cyclic prefix is a short repetition of the end of the OFDM symbol, added at the
beginning to combat inter-symbol interference (ISI) caused by multipath propagation.

 Key Observations:

o The signal appears more random, as it combines contributions from all subcarriers in the
time domain.

o The spikes and fluctuations represent the superposition of the different subcarrier
signals.

o The cyclic prefix introduces a repetitive structure at the start of each symbol, but in this
graph, it's not easily distinguishable since we're viewing continuous samples.
 Why It's Important:

o This time-domain signal is what is transmitted over the wireless channel.

o Analyzing it helps ensure that the signal is correctly modulated and prepared for real-
world conditions, such as multipath effects and noise.

How the Two Graphs Relate

 The top plot shows the frequency-domain view of the OFDM signal, where each subcarrier
carries a specific amplitude based on the data.

 The bottom plot shows the same signal transformed into the time domain, which is ready for
transmission.

 The cyclic prefix in the bottom plot is crucial for maintaining the orthogonality of the subcarriers
in the presence of channel delays.

Select the protocol to simulate (3G, 4G, 5G): 5G

Simulating 5G Protocol...

Simulating 5G Protocol...

Simulation Complete.

Simulation Complete.

You might also like