forked from qiuzhihui/csma_simulation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworking_node.m
More file actions
40 lines (25 loc) · 1.08 KB
/
working_node.m
File metadata and controls
40 lines (25 loc) · 1.08 KB
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
function [status, timer,flag] = working_node(pre_status_matrix, pre_next_status_timer,frame_size,first_frame_flag)
len=size(pre_status_matrix,1);
status=zeros(len,1);
timer=zeros(len,1);
flag=first_frame_flag;
for i=1:len
if(pre_status_matrix(i)==4 && pre_next_status_timer(i)==1) %SIFS sending ack next time slot;
status(i)=5;
timer(i)=2;
end
if(pre_status_matrix(i)==3 && pre_next_status_timer(i)>1) %SIFS sending ack next time slot;
status(i)=3;
timer(i)= pre_next_status_timer(i)-1;
end
if(pre_status_matrix(i)==5 && pre_next_status_timer(i)>1) %SIFS sending ack next time slot;
status(i)=5;
timer(i)= pre_next_status_timer(i)-1;
end
if(pre_status_matrix(i)==2 && pre_next_status_timer(i)==1) %DIFS end start sending data;
status(i)=3;
timer(i) = frame_size(i);
flag(i)=1;
end
end
end