-
Notifications
You must be signed in to change notification settings - Fork 0
/
in_already_received_cleared.m
102 lines (62 loc) · 1.92 KB
/
in_already_received_cleared.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
% Delete messages and buffered messages already received by any of both
% nodes. This is only used for Epidemic and PRoPHET routing protocol.
% Check if message ID of x already received by y, by comparing all IDs.
if ~isempty(messages_x)
IDs = [];
for msgIndex = 1: length(messages_x)
if sum( ID_received_messages_y == ID_messages_x(msgIndex) ) >= 1
IDs(end+1) = msgIndex;
end
end
% Remove message from source queue
if ~isempty(IDs)
MN_DATA_ROUTING_temp.VS_NODE(MN_INDEX_1).MESSAGE( IDs ) = [];
in_Refresh_ID;
in_refresh_buffers;
end
end
% Check if buffered message ID of x already received by y, by comparing all IDs.
if ~isempty(buffer_x)
IDs = [];
for msgIndex = 1: length(buffer_x)
if sum( ID_received_messages_y == ID_buffer_x(msgIndex) ) >= 1
IDs(end+1) = msgIndex;
end
end
% Remove message from source queue
if ~isempty(IDs)
MN_DATA_ROUTING_temp.VS_NODE(MN_INDEX_1).BUFFER( IDs ) = [];
in_Refresh_ID;
in_refresh_buffers;
end
end
% Check if message ID of x already received by y, by comparing all IDs.
if ~isempty(messages_y)
IDs = [];
for msgIndex = 1: length(messages_y)
if sum( ID_received_messages_x == ID_messages_y(msgIndex) ) >= 1
IDs(end+1) = msgIndex;
end
end
% Remove message from source queue
if ~isempty(IDs)
MN_DATA_ROUTING_temp.VS_NODE(MN_INDEX_2).MESSAGE( IDs ) = [];
in_Refresh_ID;
in_refresh_buffers;
end
end
% Check if buffered message ID of x already received by y, by comparing all IDs.
if ~isempty(buffer_y)
IDs = [];
for msgIndex = 1: length(buffer_y)
if sum( ID_received_messages_x == ID_buffer_y(msgIndex) ) >= 1
IDs(end+1) = msgIndex;
end
end
% Remove message from source queue
if ~isempty(IDs)
MN_DATA_ROUTING_temp.VS_NODE(MN_INDEX_2).BUFFER( IDs ) = [];
in_Refresh_ID;
in_refresh_buffers;
end
end