Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
slotted aloha matlab code
#1

%SIMULATION PARAMETERS
%simulation for slotted Aloha protocol
%total simulation time in seconds
runtime=0.2;
%total number of stations
nstation=10;
%transmission throughput of the media in bits per second
netthrou=10e6;
%frame size in bits
fsize=8000;
%avarage frame arrival rate per second for each station
%frate=10;
for frate=1:5:150
%average frame arrival rate per simulation iteration
trh=frate/10000;
%random wait window
wwind=100;
%EVENTS VARIABLES
%transmit active
tr=zeros(1,nstation);
%transmit queue
tq=zeros(1,nstation);
%transmit progress counter
tcnt=zeros(1,nstation);
%collision keeper
colis=zeros(1,10000*runtime);
%collision station index
colin=zeros(1,nstation);
%random wait after collision
rwait=zeros(1,nstation);
%transmit keeper
trkeep=zeros(nstation,10000*runtime);
%packet arrival keeper
pakeep=0;
for i=1:10000*runtime
for j=1:nstation
%check if the transmitter is active
if tr(j)==1
trkeep(j,i)=1;
end
%check if the packet has been sent
if tcnt(j)>0
tcnt(j)=tcnt(j)-1;
if tcnt(j)==0
tr(j)=0;
%check if the transmission is collision free
if colin(j)==1
rwait(j)=ceil(wwind*rand(1,1));
tq(j)=tq(j)+1;
colin(j)=0;
end
end
else
if tq(j)>0 & rwait(j)==0 & mod(i,8)==0
tr(j)=1;
tcnt(j)=ceil(fsize/netthrou*10000);
tq(j)=tq(j)-1;
end
end
%check if a new packet has arrived
pa=rand(1,1);
if pa<trh
pakeep=pakeep+1;
%if the transmit is ready
if tr(j)==0 & rwait(j)==0 & mod(i,8)==0
tr(j)=1;
tcnt(j)=ceil(fsize/netthrou*10000);
else
tq(j)=tq(j)+1;
end
end
%decreaserandom waiting count
if rwait(j)>0
rwait(j)=rwait(j)-1;
end
end
%check for collision
if sum(tr)>1
colis(i)=1;
for k=1:nstation
if tr(k)==1
colin(k)=1;
end
end
end
end
px2(frate)=(pakeep-sum(tq));
py2(frate)=pakeep;
end
g2=[0:0.01:1.2];
s2=g2.*exp(-g2);
figure(2)
plot(px2*8000/runtime,py2*8000/runtime,'x',s2*1e7,g2*1e7,'-')
grid
xlabel('Throughput (bps)')
ylabel('Arrival Rate (bps)')
Reply

#2

Hi Dear,
i am saifur rahman,i i would like to get details on slotted aloha matlab code if possible successful interference cancellation frame slotted aloha code also.My one cousin 'maizan' told me that slotted aloha code will be availablr here and now i am living at Malaysia and i last studied in 'The institute of engineers,Bangladesh'and now am doing Master in engineering by research in 'SEGI University'.For my further study i am interested to work related 'vehicular ad-hoc network-VANET'.That's why i need help on about this topic.
Reply



[-]
Quick Reply

Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.