csma.m
来自「csma模型的仿真」· M 代码 · 共 43 行
M
43 行
function out=csma_depart(lambda,beta,q_r)
%***********************************************************************************
% lambda: total arrival rate of all stations
% beta: normalized duration of an idle slot
%***********************************************************************************
i=1;
g=i*q_r+lambda*beta;
while g<2, % i is the number of backlogged nodes
a=g*exp(-g);
b=exp(-g);
Departure_csma(i)=a/(beta+1-b);
Departure_csma_cd(i)=a/(beta + a + beta*(1 - b - a));
arrival_rate(i)=lambda;
i=i+1;
g=i*q_r+lambda*beta; % Expected number of attempted transmissions
% Note: impact of retransmission rate q_r and the number of backlogged node
% are captured in
end
figure;
plot([1:i-1],Departure_csma,'k-');
hold on;
plot([1:i-1],Departure_csma_cd,'k-o');
hold on;
plot([1:i-1],arrival_rate,'k--');
hold off;
set(gca,'FontSize',18);
%Title('Departure rate, in packets per unit time');
xlabel('N, the number of backlogged nodes');
legend('Departure rate of slotted CSMA','Departure rate of slotted CSMA/CD','Arrival rate',0);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?