lx_MSE = zeros((gro_num, SNR_num)) CS_MSE = zeros((gro_num, SNR_num)) eva_MSE = zeros((gro_num, SNR_num)) lx_BER = zeros((gro_num, SNR_num)) CS_BER = zeros((gro_num, SNR_num)) eva_BER = zeros((gro_num, SNR_num)) lx_SC = zeros((gro_num, SNR_num)) CS_SC = zeros((gro_num, SNR_num)) for i in range(gro_num): for j in range(SNR_num): print 'Running... Current group: ', i, j ''' 根据RSSI/Phase产生随机导频图样''' pos_A, pos_B, pos_E = agreement(P) ''' 发送端 ''' bits_A, diagram_A, x = sender(N, Ncp, pos_A, modulate_type) ''' 信道传输 ''' h_ab, H_ab, y_b = transmission(x, L, K, N, Ncp, SNR[j]) ''' 理想条件下的信道估计''' # 合法用户确切知道发送端导频 h_lx, H_lx, bits_lx, diagram_lx = receiver(y_b, L, K, N, Ncp, pos_A, modulate_type) ''' 接收端 信道估计''' h_cs, H_cs, bits_cs, diagram_cs = receiver(y_b, L, K, N, Ncp, pos_B, modulate_type) ''' 窃听信道 ''' h_ae, H_ae, y_e = transmission(x, L, K, N, Ncp, SNR[j]) ''' 非法用户 ''' h_eva, H_eva, bits_eva, diagram = receiver(y_e, L, K, N, Ncp, pos_E, modulate_type) ''' 评价性能 '''
lx_MSE = zeros((group_num, right_num)) CS_MSE = zeros((group_num, right_num)) eva_MSE = zeros((group_num, right_num)) lx_BER = zeros((group_num, right_num)) CS_BER = zeros((group_num, right_num)) eva_BER = zeros((group_num, right_num)) lx_SC = zeros((group_num, right_num)) CS_SC = zeros((group_num, right_num)) for i in range(group_num): for j in range(right_num): print 'Running... Current group: ', i, j ''' 根据RSSI/Phase产生随机导频图样''' pos_A, pos_B, pos_E = agreement(P) ''' 发送端 ''' bits_A, diagram_A, x = sender(pos_A) ''' 信道传输 ''' h_ab, H_ab, y_b = transmission(x) ''' 理想条件下的信道估计''' # 合法用户确切知道发送端导频 h_lx, H_lx, bits_lx, diagram_lx = receiver(y_b, pos_A, 'CS', 'from_pos') ''' 接收端 信道估计''' h_cs, H_cs, bits_cs, diagram_cs = receiver(y_b, pos_B, 'CS', 'from_pos') ''' 窃听信道 ''' h_ae, H_ae, y_e = transmission(x) ''' 非法用户 ''' # 非法用户随机猜测导频位置。与发送端的导频图样pos_A相比,非法用户猜对了j个,j取值[0,P) h_eva, H_eva, bits_eva, diagram_eva = receiver(y_e, pos_A, 'CS', '%d' % (j))
from OFDM import sender, transmission, receiver os.system('cls') plt.close('all') ''' 参数 ''' L = 50 # 信道长度 K = 6 # 稀疏度/多径数,满足:K<<L N = 512 # 训练序列长度/载波数,满足:L<=N Ncp = 64 # 循环前缀的长度,Ncp>L modulate = 4 # 星座调制 P = 36 # 导频数,P<N SNR = 20 # AWGN信道信噪比 ''' 根据RSSI/Phase产生随机导频图样''' pos_A, pos_B, pos_E = agreement(P) ''' 发送端 ''' bits_A, diagram_A, x = sender(pos_A, N, Ncp, modulate) ''' 信道传输 ''' h_ab, H_ab, y_b = transmission(x, SNR, L, K, N, Ncp) ''' 理想条件下的信道估计''' # 合法用户确切知道发送端导频 h_lx, H_lx, bits_lx, diagram_lx = receiver(y_b, pos_A, 'CS', 'from_pos', L, K, N, Ncp, modulate) ''' 接收端 信道估计''' h_cs, H_cs, bits_cs, diagram_cs = receiver(y_b, pos_B, 'CS', 'from_pos', L, K, N, Ncp, modulate) ''' 窃听信道 ''' h_ae, H_ae, y_e = transmission(x, SNR, L, K, N, Ncp) ''' 非法用户 ''' h_eva, H_eva, bits_eva, diagram_eva = receiver(y_e, pos_E, 'CS', 'from_pos', L, K, N, Ncp, modulate) ''' 评价性能 '''