-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathschedule_tx.m
71 lines (68 loc) · 2.16 KB
/
schedule_tx.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function [current_frame,tend,flag,fretx]=schedule_tx(nextT,ind_user,user,current_frame,current_time_frame,Tb,nRBperUE,Tslot,iter,BLER,Tp,deadtime,N_OS)
fretx=0;
tend=0;
flag=0;
m=find(current_time_frame>=nextT);
for h=1:length(m)
% p=find(current_frame(:,m(h))==0);
currentTime=current_time_frame(m(h));
% if flagDiscardPkts==1
% if length(Tb)>1
% if ind_user<iter && Tb(ind_user+1,user)<=currentTime
% % latency(user,ind_user)=100000;
% % ind_user=ind_user+1;
% % if ind_user>iter
% % return;
% % end
% flag=2;
% break;
% end
% end
% else
% if ind_user<iter && Tb(ind_user+1,user)<=currentTime
% disp('se hubiera descartado');
% end
if length(Tb)>1
if ind_user<iter && currentTime-Tb(ind_user,user)>=deadtime
% latency(user,ind_user)=100000;
% ind_user=ind_user+1;
% if ind_user>iter
% return;
% end
flag=2;
break;
end
end
% end
for k=0:N_OS-1
p=find(current_frame(:,m(h)+k)==0);
if length(p)<nRBperUE
flag=0;
break;
end
flag=1;
end
if flag==1
for k=0:N_OS-1
p=find(current_frame(:,m(h)+k)==0);
current_frame(p(1:nRBperUE),m(h)+k)=1;
end
tend=current_time_frame(m(h))+N_OS*Tslot; %tend is equal to the start
% time of the next symbol or slot based on the corresponding case
perror=rand();
if perror<=BLER % packet is correctly received
fretx=1;
end
break;
end
% if length(p)>=nRBperUE
% current_frame(p(1:nRBperUE),m(h))=1;
% tend=current_time_frame(m(h))+Tslot;
% flag=1;
% perror=rand();
% if perror<=BLER % packet is correctly received
% fretx=1;
% end
% break;
% end
end