You are on page 1of 36

PROJECT TỔNG HỢP

GROUP MEMBERS
Đinh Hồ Phúc Thiện - 21207102
Cao Nguyễn Hải Đăng - 21207012
Nguyễn Hoàng Bảo - 21207121
Trương Hoàng Bách Hợp - 21207034
Lưu Hoàng Đông Anh - 21207007

BY GROUP 6
PROJECT 1: A-LAW
AND MU-LAW
COMPANDING

2/20
CODE

% 1. Load speech signal % 3. Calculate the average quantization noise power,...


Fs = 4000; % the average power of the sample signal and SNR
[mSpeech,Fs] = audioread("MaleSpeech-16-4-mono-20secs.wav"); e_uni = mSpeech(1:length(t)) - s_q_2; % error between sample
% sound(mSpeech,Fs) signal and quantized signal
% Consider the speech signal in 1.5s pow_noise_uni = 0;
t = 0:1/Fs:1.5; pow_sig = 0;
plot(t,mSpeech(1:length(t)),'LineWidth',2); for i = 1:length(t)
hold on pow_noise_uni = pow_noise_uni + e_uni(i)^2;
% 2. Quantize the sample signal pow_sig = pow_sig + mSpeech(i)^2;
L = 16; %the number of quantization levels end
V_p = 0.5625; %the peak voltage of signal pow_noise_uni = sum(e_uni.^2)/length(t);
% Determine the single quantile interval ?-wide pow_sig = sum(mSpeech(1:length(t)).^2)/length(t);
q = V_p/(L-1); % Use the exact equation SNR_a_uni = pow_sig./pow_noise_uni ;
s_q_2 = quan_uni(mSpeech(1:length(t)),q); % Uniform quantization plot (t, mSpeech(1:length(t)),'LineWidth',2); hold on;
% Plot the sample signal and the quantization signal plot(t,s_q_2,'ro',
plot(t,s_q_2,'ro','MarkerSize',6,'MarkerEdgeColor','r','MarkerFaceCol 'MarkerSize',6,'MarkerEdgeColor','r','MarkerFaceColor','r');
or','r'); legend('mSpeech','sq2');
xlabel('Time(s)');
ylabel('Amplitude');
title('Original Signal vs. Quantized Signal');

3/20
CODE
%--------compression-------------
% 9. Calculate the average quantization noise power,...
% 5. Compress the sample signal ‘mSpeech’
% the average power of the analog signal and SNR
mu = 255; % or A = ???; use the standard value
e_com = mSpeech(1:length(t)) - s_e_7;
y_max = V_p;
pow_noise_com = sum(e_com.^2)/length(t);
x_max = V_p;
SNR_a_com = pow_sig/pow_noise_com ;
% Replace the compress equation for u-law and A-law
function quan_sig = quan_uni(sig,q)
% with x is the 'mSpeech' signal
for i = 1:length(sig)
s_c_5 = sign(mSpeech(1:length(t))).*(log(1 +
quan_sig(i) = quant(sig(i),q);
mu*abs(mSpeech(1:length(t)))/y_max) / log(1 + mu)) * x_max;
d = sig(i) - quan_sig(i);
% Plot the compress signal;
if d == 0
plot(t,s_c_5);
quan_sig(i) = quan_sig(i) + q/2;
% 6. Quantize the compress signal and plot the quantized signal
elseif (d > 0) && (abs(d) < q/2)
s_q_6 = quan_uni(s_c_5,q);
quan_sig(i) = quan_sig(i) + q/2;
plot(t,s_q_6,'b^','MarkerSize',6,'MarkerEdgeColor','b','MarkerFace
elseif (d > 0) && (abs(d) >= q/2)
Color','b');
quan_sig(i) = quan_sig(i) - q/2;
% 7. Expand the quantized signal
elseif (d < 0) && (abs(d) < q/2)
s_e_7 = sign(s_q_6).*(y_max/mu).*( (1 + mu).^abs(s_q_6/x_max)
quan_sig(i) = quan_sig(i) - q/2;
- 1);
elseif (d < 0) && (abs(d) >= q/2)
plot(t,s_e_7,'g*','MarkerSize',6,'MarkerEdgeColor','g','MarkerFace
quan_sig(i) = quan_sig(i) + q/2;
Color','g');
end
legend('Sample signal','Uniform quantized values','Compress
end
signal','Compress quantized values','Nouniform quantized values');
end

4/20
RESULT

5/20
RESULT

5/20
PROJECT 2: CHAPTER 3

2/20
CODE QUESTION 1

clc; clear; close all; for i = 1:Ntry


% ================ Represent s1(t) and s2(t) if Bit(i) == 0
ts = 0.05; % The sample time s = [s s1];
t1 = 0: ts: 0.5 - 0.05; else
t2 = 0.5: ts: 1 - 0.05; s = [s s2];
t_1bit = [t1 t2]; % Time of 1 bit end
L = length(t_1bit); % The number of samples of 1 bit t_ibit = t_1bit + (i-1); % Time of i-bit
s1_t1 = 1.5*ones(1, length(t1)); t = [t t_ibit];
s1_t2 = 0.5 *ones(1, length(t2)); end
s1 = [s1_t1 s1_t2]; % s1(t) % ================= The AWGN channel
s2_t1 = 0*ones(1, length(t1)); N0_2 = 0.05; % The noise power spectrum desity (W/Hz) N0/2
s2_t2 = -2*ones(1, length(t2)); B = 1/ts; % Bandwidth of signals
s2 = [s2_t1 s2_t2]; % s2(t) Power_noise = N0_2 *B; % The power of noise
% ================ The transmitted signal w = sqrt(Power_noise) *randn(1, length(s));
Ntry = 10^1; % The total transmitted bits
Bit = randsrc (1, Ntry, [0 1]) ;% Transmission with P1 = P2 = 0.5
s = []; % The transmitted signal s(t)
t = []; % The time of s(t)

3/20
CODE QUESTION 1

% ================= The received signal text(x_note, y_note, Text);


r = s + w; xlabel('t (s)'); ylabel('w(t)')
figure(1) axis([0 Ntry -4 4])
subplot(5,1,1) subplot(5,1,5)
plot(t_1bit,s1,'b-','linewidth',1.8); hold on; plot(t,r,'m-','linewidth',1.8);
xlabel('t (s)'); ylabel('s_1(t)'); text(x_note, y_note, Text);
axis([0 1.1 -1 1.6]) xlabel('t (s)'); ylabel('s(t)')
subplot(5,1,2) axis([0 Ntry -3.2 3.2])
plot(t_1bit,s2,'r-','linewidth',1.8);
xlabel('t (s)'); ylabel('s_2(t)')
axis([0 1.1 -2.2 1])
x_note = 0.5 :1 :Ntry - 0.5;
y_note = 2.4 *ones(1,Ntry);
Text = string(Bit);
subplot(5,1,3)
plot(t,s,'g-','linewidth',1.8);
text(x_note, y_note, Text);
xlabel('t (s)'); ylabel('s(t)')
axis([0 Ntry -3 3])
subplot(5,1,4)
plot(t,w,'k-','linewidth',1.4);
text(x_note, y_note, Text);

3/20
RESULT QUESTION 1

3/20
CODE QUESTION 2

clc; clear; close all; for i = 1:Ntry


% ================ Represent s1(t) and s2(t) if Bit(i) == 0
ts = 0.1; % The sample time s = [s s1];
t1 = 0: ts: 0.5 - 0.05; else
t2 = 0.5: ts: 1 - 0.05; s = [s s2];
t_1bit = [t1 t2]; % Time of 1 bit end
L = length(t_1bit); % The number of samples of 1 bit t_ibit = t_1bit + (i-1); % Time of i-bit
s1_t1 = 1.5 *ones(1, length(t1)); t = [t t_ibit];
s1_t2 = 0.5 *ones(1, length(t2)); End
s1 = [s1_t1 s1_t2]; % s1(t) % ================= The AWGN channel
s2_t1 = 0*ones(1, length(t1)); B = 1/ts; % Bandwidth of signals
s2_t2 = -2*ones(1, length(t2)); Power_noise = B * N0_2(j); % The power of noise
s2 = [s2_t1 s2_t2]; % s2(t) w = sqrt(Power_noise)*randn(1, length(s));
% ================ The transmitted signal % ================= The received signal
Ntry = 10^4; % The total transmitted bits r = s + w;
N0_2 =0.2:0.2:1.2; % The noise power spectrum desity (W/Hz) N0/2
P_error_simul = zeros(1,length(N0_2));
P_error_theo = zeros(1,length(N0_2));
for j = 1: length(N0_2)
Bit = randsrc (1, Ntry, [0 1]) ; % Transmission with P1 = P2;
s = []; % The transmitted signal s(t)
t = []; % The time of s(t)

3/20
CODE QUESTION 2

% ================= The recovered signal % ================== The bit error probability


h_t1 = -5/sqrt(17)*ones(1, length(t1)); % ------------- Simulation
h_t2 = -3/sqrt(17)*ones(1, length(t2)); [Num, rate] = biterr(Bit, Bit_rec);
h = [h_t1 h_t2]; % The impulse response of the matched filter P_error_simul(j) = rate;
T = 3/(4*sqrt(17)); % The decision threshold % ------------- Theory
Bit_rec = zeros(1,Ntry); s12_mu = -7/(2*sqrt(17));
for i = 1:Ntry s22_mu = 5/sqrt(17);
Frame = r((i-1)*L + 1 : i*L); % Construct 1 Frame with L samples P_error_theo(j) = qfunc((s22_mu - s12_mu)/ (2*sqrt(N0_2(j))));
y = conv(Frame, h)*ts; % The signals pass through the matched filter end
r2_mu = y(L); figure(1)
% --------- Comparator for decision plot(N0_2,P_error_simul,'ko','linewidth',1.6,'markersize',6);
if r2_mu >= T hold on;
Bit_rec(i) = 1; plot(N0_2,P_error_theo,'r-','linewidth',1.8,'markersize',6);
else xlabel('N_0/2'); ylabel('The bit error probability');
Bit_rec(i) = 0; legend('Simulation','Theory');
end
end
Bit_rec;

3/20
RESULT QUESTION 2

3/20
PROJECT 3: CHAPTER 4

2/20
CODE

N0 = 10^-2; Bit = randsrc(1, Ntry, [0 1; 0 1]); % The transmitted bits


EbN0_dB = 0:2:6; EbN0 = 10.^(EbN0_dB / 10); s = [];
Eb = EbN0 * N0; % The energy of one bit t = [];
Ntry = 5 * 10^3; % The number of transmitted bits for i = 1:2:Ntry
P_error_simul = zeros(1, length(EbN0_dB)); if Bit(i) == 0 && Bit(i + 1) == 0
P_error_theo = zeros(1, length(EbN0_dB)); s = [s s1];
for j = 1:length(EbN0_dB) elseif Bit(i) == 0 && Bit(i + 1) == 1
ts = 1/1000; % The sample time s = [s s2];
Tb = 1; % The time of 1 bit elseif Bit(i) == 1 && Bit(i + 1) == 0
Ts = 2 * Tb; % The time of 1 symbol s = [s s3];
V = sqrt(2 * Eb(j) * Tb); % The amplitude of the carrier signal else
Tc = Ts / 10; % The cycle of the carrier s = [s s4];
fc = 1 / Tc; % The frequency of the carrier end
t_1symbol = 0 : ts : Ts - ts; t_isymbol = t_1symbol + (i - 1); % Time of i-bit
s1 = V * cos(2 * pi * fc * t_1symbol); % s1(t) t = [t t_isymbol];
s2 = V * sin(2 * pi * fc * t_1symbol); % s2(t) end
s3 = -V * cos(2 * pi * fc * t_1symbol); % s3(t) % ================= The AWGN channel
s4 = -V * sin(2 * pi * fc * t_1symbol); % s4(t) B = 1 / ts; % Bandwidth of signals
Es = sum(s1.^2 + s2.^2); % The energy of 1 symbol Power_noise = N0 / 2 * B; % The power of noise
L = length(t_1symbol); % The number of samples of 1 symbol w = sqrt(Power_noise) * randn(1, length(s));
% ================= The received signal
r = s + w;

3/20
CODE

% ================= Signal recovery d1 = (r1 - s11)^2 + (r2 - s12)^2; % The squared distance from r to s1
phi1 = s1; d2 = (r1 - s21)^2 + (r2 - s22)^2; % The squared distance from r to s2
d3 = (r1 - s31)^2 + (r2 - s32)^2; % The squared distance from r to s3
phi2 = s2;
d4 = (r1 - s41)^2 + (r2 - s42)^2; % The squared distance from r to s4
phi3 = s3; % --------- Comparator for decision
phi4 = s4; if d1 < d2 && d1 < d3 && d1 < d4
h1 = fliplr(phi1); Bit_rec = [Bit_rec 0 0];
h2 = fliplr(phi2); elseif d2 < d1 && d2 < d3 && d2 < d4
h3 = fliplr(phi3); Bit_rec = [Bit_rec 0 1];
elseif d3 < d1 && d3 < d2 && d3 < d4
h4 = fliplr(phi4); Bit_rec = [Bit_rec 1 0];
s11 = sqrt(Es); s12 = 0; else
s21 = 0; s22 = sqrt(Es); Bit_rec = [Bit_rec 1 1];
s31 = -sqrt(Es); s32 = 0; end
s41 = 0; s42 = -sqrt(Es); end
Bit_rec;
Bit_rec = []; % ================== The bit error probability
for i = 1:Ntry/2 % ------------- Simulation
Frame = r((i - 1) * L + 1:i * L); % Construct 1 Frame with L samples [Num, rate] = biterr(Bit, Bit_rec);
of 1 symbol P_error_simul(j) = rate;
y1 = conv(Frame, h1) * ts; % r(t) passes through the matched filter 1 % ------------- Theory
P_error_theo(j) = qfunc(sqrt(2 * Eb(j) / N0));
r1 = y1(L); end
y2 = conv(Frame, h2) * ts; % r(t) passes through the matched filter 2 P_error_simul;
r2 = y2(L); P_error_theo;
y3 = conv(Frame, h3) * ts; % r(t) passes through the matched filter 3 figure(1)
r3 = y3(L); semilogy(EbN0_dB, P_error_theo, 'r-', 'linewidth', 1.8); hold on;
semilogy(EbN0_dB, P_error_simul, 'k*', 'markersize', 8);
y4 = conv(Frame, h4) * ts; % r(t) passes through the matched filter 4 xlabel('Eb/N0 (dB)'); ylabel('The error probability');
r4 = y4(L); legend('Theory QPSK', 'Simulation') 3/20
RESULT

3/20
PROJECT 4: LDPC

2/20
1. Vẽ giản đồ Tanner của mã hóa trên?

3/20
1. Cho chuỗi bit ở phía phát là: , giả sử bit đầu tiên bị sai. Sử dụng thuật toán lật bit để tìm lại .

3/20
OVERVIEW

CHARACTERISTICS OF DIFFERENT VERSION OF WIRELESS


network protocols 6/20
OVERVIEW

THE OPEN AIR STANDARD THE ETS300 328 STANDARD THE HIPERLAN STANDARD

• The Open Air Standard, established • The 2.4 GHz frequency band, utilized by • HiperLAN encompasses European standards
by the Wireless LAN International various equipment such as microwave for high-speed wireless LANs operating in
Forum, serves as an interoperable ovens, can cause interference and the 5 GHz and 17 GHz frequency bands
standard within the 2.4 GHz degrade performancethe ETS 300 328 • HiperLAN allows direct data exchange
frequency band standard recommends employing the between stations or relay through a third
• Utilizing Frequency Hopping Spread Direct Sequence Spread Spectrum station if direct contact is not possible. It

Spectrum technology, it ensures both (DSSS) technique. offers a high throughput with a raw bit rate
• DSSS utilizes multiple frequencies to of approximately 24 Mbit/s in the MAC
high security and immunity to
spread communication signals, making protocol, supporting multimedia
interference.
eavesdropping virtually impossible communication.

7/20
OVERVIEW

THE NII/SUPERNET STANDARD THE IEEE 802.11 WIRELESS


STANDARD

• The National Information Infrastructure/Shared • The IEEE 802.11 specification, developed by the
Unlicensed Personal Radio Network (NII/SUPERNet) Institute of Electrical and Electronic Engineering
facilitates wireless transmission of digital data and (IEEE), establishes a wireless LAN standard for
multimedia between computers and information communication between wireless clients, base
appliances, both within Local Area Networks (LANs) stations, and access points
and across point-to-point sites • . It consists of two main layers: the Physical (PHY)
• Regulated by the FCC, this standard aims to spur the layer, which defines signal characteristics and
development of new devices and drive growth in measures RF energy, and the Media Access Control
WLAN industries. It defines a low-power SUPERNet (MAC) layer, responsible for managing access to the
service, operating within the 5.15GHz - 5.35GHz wireless medium
frequency bands, with a range of up to 200 meters
and power levels not exceeding -10 dBW

8/16
OVERVIEW

CURRENT STATUS AND STAGES OF EACH WLAN STANDARDS

9/20
OVERVIEW

• "Wi-Fi connection" refers to a specific wireless connection utilized by a


device, whereas WLAN denotes the network as a whole.
TECHOPEDIA • Not all devices labeled as "Wi-Fi" receive certification from the Wi-Fi
EXPLAINS WLAN Alliance, despite the widespread use of Wi-Fi by over 700 million people
across approximately 750,000 internet hotspots. These hotspots
themselves constitute WLANs of a specific type.

• Every component that connects to a WLAN is considered a station, and falls


into one of two categories: access points (APs) and clients.
WLANS AND ACCESS • Access points or APs transmit and receive radio frequency signals with devices
POINTS able to receive transmitted signals; they normally function as routers.
• Clients, on the other hand, may include a variety of devices, such as desktop
computers, workstations, laptop computers, IP phones and other cell phones
and smartphone devices.

10/20
CARRIER SENSE MULTIPLE
ACCESS/COLLISION
AVOIDANCE (CSMA/CA)

11/20
CSMA/CA

In Wireless LANs, the core concept of communicating wirelessly revolves around CSMA/CA. In any shared medium, accessing the channel without
collisions is vital

CSMA is widely regarded as one of the most practical MAC protocols in wireless networks, such as being a fundamental medium access
algorithm in IEEE 802.11.

CSMA maintains a network rule where only one point can transmit data; otherwise, there may be data/frame loss

12/20
FLOW CHART OF CMSA/CA

3/After sending the data frame,


1/ Check the status of the medium
CSMA/CA sets a timer

4/ If positive ACK is received


b e f o r e t h e e x p i r y o f t h e t i m e r,
2/ If the channel is idle, then the
then it is a successful
station waits for an Inter-frame
transmission.
gap (IFG) amount of time and
Otherwise, the station waits for a
then sends the frame.
back-off time period and restarts
the transmission.

13/20
DIFFERENCE BETWEN CSMA/CD AND CSMA/CA

14/20
BASIC OPERATION OF CSMA/CA

OPERATION OF A CSMA/CA DEVICE


15/20
BASIC OPERATION OF CSMA/CA

• First, the stations monitor the transmission • If the network is free, the station initiates
medium. When it comes to WLAN, this means D C F. F i r s t , t h e c h a n n e l i s c h e c k e d m o r e
that carrier sense monitors the radio channel thoroughly for the duration of DIFS. If it
and checks whether other network participants – remains free for this time, a random backoff
as long as they are visible to the respective s t a r t s a n d o n l y t h e n d o e s t h e RT S / C T S e x c h a n g e
device – are currently transmitting. begin – if this additional mechanism is used

• If it turns out that the transmission medium is • If the request to send has successfully arrived
currently occupied, a random backoff is at the receiver and no collision has occurred,
initiated: the station waits a random amount of t h e s e n d er re ce i ve s p e r m i s s i o n fro m t h e CTS
time until a new check starts. frame to occupy the transmission medium.

16/20
COLLISION OF CSMA/CA

If a statin with a frame to The station decremented its


transmit initially sensed a backoff timer until either the
busy channel, it waited until medium became busy again or
the channel became idle the timer reached zero

. If the medium became busy When the timer finally


before the timer reached zero, decremented to zero, the
the station freezed its timer station transmitted its frame.

OPERATION OF A CSMA/CA DEVICE

17/20
HOW TO AVOID COLLISION IN CSMA/CA

CSMA/CA sensed the transmission channel before transmitting a frame and it tried to
avoid collisions by carefully tuning the timers used by CSMA/CA devices. In this way, the
CSMA/CA introduced a small delay, named Short Inter Frame Spacing (SIFS)

The CSMA/CA defined two delays : DIFS and EIFS

To send a frame, a device must first wait until the channel has been idle for at least the DIFS
if the previous frame was received correctly. However, if the previously received frame was
corrupted, this indicated that there were collisions and the device must sense if the channel
was idle for at least the EIFS, with SIFS < DIFS < EIFS.

18/20
HOW TO AVOID COLLISION IN CSMA/CA

AVOID COLLISION IN CSMA/CA


19/20
HOW TO AVOID COLLISION IN CSMA/CA

The CSMA/CA employed an immediate positive acknowledgment scheme to make sure successful reception of packets

If the medium is sensed to be free for a DIFS interval, the transmission may proceed

On the other hand, if the medium is busy, the station must defer its transmission until the end of the current

Then, it will wait for an additional DIFS interval and generate a random backoff delay to initialize the backoff timer before
transmission

The backoff timer is decreased as long as the medium is sensed as idle, and frozen when a transmission is detected on
the channel, and resumed when the medium is sensed as idle again for more than a DIFS interval.

Only when the backoff timer reaches zero, the station transmits its packet.

20/20
THANK YOU

You might also like