資源簡介
基于無線物理層密鑰生成方法中信道量化和信道估計的算法MATLAB實現(xiàn)
代碼片段和文件信息
%%?密鑰生成前兩步(信道特征提取和量化)示例程序
clc
clear?all
%%?信道特征提取(平坦衰落信道,單發(fā)Alice單發(fā)Bob,單發(fā)竊聽者Eve)
SNR_dB?=?30;
time?=?1:1:512;
hLS?=?(1/sqrt(2))*(?randn(1length(time))?+?1i*randn(1length(time))?);?%合法信道,均值0方差1的復(fù)高斯信道
gAE?=?(1/sqrt(2))*(?randn(1length(time))?+?1i*randn(1length(time))?);?%竊聽者信道
gBE?=?(1/sqrt(2))*(?randn(1length(time))?+?1i*randn(1length(time))?);?%竊聽者信道
sigmal?=?sqrt(0.5*10.^(-SNR_dB/10));?%?SNR=30dB,噪聲標(biāo)準(zhǔn)差
noise1?=?sigmal*(randn(1length(time))+1i*randn(1length(time)));?%a到b信道噪聲
noise2?=?sigmal*(randn(1length(time))+1i*randn(1length(time)));?%b到a信道噪聲
noiseAE?=?sigmal*(randn(1length(time))+1i*randn(1length(time)));?%a到竊聽者信道噪聲
noiseBE?=?sigmal*(randn(1length(time))+1i*randn(1length(time)));?%b到竊聽者信道噪聲
tx1?=?1;?tx2?=?1;?%為了簡化,假設(shè)雙方發(fā)射已知訓(xùn)練序列1(功率歸一化的恒定信號)
%信道估計
for?i=1:length(time)
????rxb(i)?=?hLS(i)*tx1+noise1(i);?%a發(fā)b收
????rxa(i)?=?hLS(i)*tx2+noise2(i);?%b發(fā)a收,信道互易
????hb(i)?=?inv(tx1)*rxb(i);?%信道LS估計:H=X-1Y
????ha(i)?=?inv(tx2)*rxa(i);
????ampt_ab(i)?=?abs(hb(i));?%計算信道參數(shù)的幅度
????ampt_ba(i)?=?abs(ha(i));
????sita_ab(i)?=?angle(hb(i));?%計算信道參數(shù)的相位
????sita_ba(i)?=?angle(ha(i));
????
????rxaE(i)?=?gAE(i)*tx1+noiseAE(i);?%竊聽者考慮最壞情況:竊聽者信道完美。
????haE(i)?=?inv(tx1)*rxaE(i);?%信道LS估計:H=X-1Y
????ampt_aE(i)?=?abs(haE(i));?%計算信道參數(shù)的幅度
????sita_aE(i)?=?angle(haE(i));?%計算信道參數(shù)的相位
end
%%?量化(2?bit?CQ量化)
for?i=1:length(time)
????if(real(hb(i))>=0?&&?imag(hb(i))>=0)???%量化Bob估計的信道特征為密鑰
????????pre_key_vectorCQb(2*i-1:2*i)=[1?1];
????end
????if(real(hb(i))<0?
- 上一篇:STBC 空時編碼程序
- 下一篇:密鑰生成CQG量化
評論
共有 條評論