How can i get a matlab code for csma/ca
Mostrar comentarios más antiguos
I am currently working on cognitive Radio and I need a simulation source code for CSMA/CA. Could anyone please assist.
Thanks
5 comentarios
Liliana Cruz
el 17 de Mayo de 2021
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
el 13 de Jul. de 2022
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
el 14 de Jul. de 2022
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..
Respuestas (1)
Walter Roberson
el 19 de Jul. de 2017
0 votos
The following have all modeled CSMA/CA in MATLAB. Possibly one of them has made the source code available.
2 comentarios
neethu subash
el 13 de Jul. de 2022
is the code available? could not find one
Walter Roberson
el 13 de Jul. de 2022
I do not have code for this purpose; I did a google search to create the list I posted above.
Categorías
Más información sobre Wireless Communications en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!