carrier_sense.m

来自「一个无线网络仿真程序」· M 代码 · 共 27 行

M
27
字号
function busy = carrier_sense(rv)
% check if the channel is busy

global node;
global white_noise_variance;
global rmodel cs_threshold;

Pr = 0;
I = find(node(:, 3)>0);
for i=1:length(I)
   tx1 = I(i);
   if tx1 == rv, continue; end
   Pr = Pr + recv_power(tx1, rv, rmodel);
end
% N0 = abs(random('norm', 0, white_noise_variance));
N0 = white_noise_variance;

% Pr+N0

if (Pr+N0) > cs_threshold
    busy = 1;
else
    busy = 0;
end

return;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?