How can i get a matlab code for csma/ca
古いコメントを表示
I am currently working on cognitive Radio and I need a simulation source code for CSMA/CA. Could anyone please assist.
Thanks
5 件のコメント
Liliana Cruz
2021 年 5 月 17 日
Can I find the source code?
clear all
close all
clc
cwmax=1023;
n1.datarate=10;
cw=31;
cw_default=31;
reached=0;
toRetransmit=0;
sumDatarate = 8*n1.datarate;
DataSent = sumDatarate;
next_Sent=0;
bw=0;
nodeenergy = 50;
NWEinitial = nodeenergy * 8;
% % % % % % % % % % % % % % % % EXISTING
for i=1:10
if (DataSent<cw)
% next_Sent = sumDatarate+ toRetransmit
fprintf("\n\nPackets sent in iteration %i is: %i\n",i,DataSent);
fprintf("CW size in %i is: %i\n",i,cw);
reached=DataSent;
fprintf("Packets succeeded in iteration %i is: %i\n",i,reached);
lostPackets=0 ;
fprintf("Packets lost in iteration %i is: %i\n",i,lostPackets);
bw_available = cw;
bw_used = DataSent;
bw_wasted = bw_available - bw_used;
bw_available_E(i)=bw_available;
bw_used_E(i) = bw_used;
bw_wasted_E(i) = bw_wasted;
fprintf("Bandwidth wasted_Existing in %i is: %i\n\n",i,bw_wasted);
Eused_E = sum(bw_available_E)/5;
Re = NWEinitial - Eused_E;
Re_E = Re;
fprintf("Energy utilized_Existing in %i is: %i\n",i,Eused_E);
fprintf("Remaining Energy_Existing in %i is: %i\n\n",i,Re);
cw = cw_default
toRetransmit = 0;
fprintf("Packets to Retransmit in iteration %i is: %i\n\n",i,lostPackets);
lost(i) = lostPackets;
succeeded(i)=reached;
DataSent = toRetransmit + sumDatarate;
else
% next_Sent = sumDatarate+ toRetransmit
fprintf("\n\nPackets sent in iteration %i is: %i\n",i,DataSent);
fprintf("CW size in %i is: %i\n",i,cw);
reached=cw;
fprintf("Packets succeeded in iteration %i is: %i\n",i,reached);
lostPackets=DataSent - cw ;
fprintf("Packets lost in iteration %i is: %i\n",i,lostPackets);
bw_available = cw;
bw_used = cw;
bw_wasted = bw_available - bw_used;
bw_available_E(i)=bw_available;
bw_used_E(i) = bw_used;
bw_wasted_E(i) = bw_wasted;
fprintf("Bandwidth wasted in %i is: %i\n\n",i,bw_wasted);
Eused_E = sum(bw_available_E)/5;
Re = NWEinitial - Eused_E;
Re_E = Re;
fprintf("Energy utilized_Existing in %i is: %i\n",i,Eused_E);
fprintf("Remaining Energy_Existing in %i is: %i\n\n",i,Re);
cw = bitsll(cw,1)+3
toRetransmit = lostPackets;
fprintf("Packets to Retransmit in iteration %i is: %i\n\n",i,lostPackets);
lost(i) = lostPackets;
succeeded(i)=reached;
DataSent = toRetransmit + sumDatarate;
end
end
Hi, can some one please help me to modify the code to enable many number of nodes..that is with many sources and destinations with saturated data..Thanks inn advance
Walter Roberson
2022 年 7 月 13 日
You need more comments, such as what cw means.
Which variable(s) represent nodes in your code?
Is bandwidth shared? Are links completely independent, completely shared, partially shared? Which part of your code is modeling how much of a shared band is being currently used?
neethu subash
2022 年 7 月 14 日
the above code is doing contention window size variations as how it works in csma/ca binary backoff. Only one node is sending in my code..that is one sender..
回答 (1 件)
Walter Roberson
2017 年 7 月 19 日
0 投票
The following have all modeled CSMA/CA in MATLAB. Possibly one of them has made the source code available.
2 件のコメント
neethu subash
2022 年 7 月 13 日
is the code available? could not find one
Walter Roberson
2022 年 7 月 13 日
I do not have code for this purpose; I did a google search to create the list I posted above.
カテゴリ
ヘルプ センター および File Exchange で Wireless Communications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!