-
Notifications
You must be signed in to change notification settings - Fork 1
/
PDCP_RLC_migration_V1.m
104 lines (82 loc) · 3.5 KB
/
PDCP_RLC_migration_V1.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
103
104
% MB = 1024; %1MB = 1024 Bytes
% Traffic = 1500*MB; %Bytes/s (=5MBps)
IP = 1500; %IP packet size in Bytes
PDCP_Hdr = 32;
RLC_Buffer_CU = [ones(145,1); 0; 0; 0; 0; 0]; %ones(150,1);
RLC_Buffer_DU = zeros(150,1);
% Pck_tti = (Traffic/IP)/1000;
pck_loss = 0;
migration = "hard";
split = 1;
%To debug
inc_aft_mig = 0;
out_aft_mig = 0;
for tti = 1:1e4
incoming_pck = poissrnd(1);
PDCP_trf = incoming_pck*IP;
RLC_trf = incoming_pck*(IP+PDCP_Hdr);
pop_buffer = poissrnd(1);
switch split
case 1
rear = find(~RLC_Buffer_CU, 1);
if (incoming_pck>0)
if(isempty(rear))
pck_loss = pck_loss+incoming_pck;
elseif(incoming_pck>(150-rear+1))
pck_loss = pck_loss + (incoming_pck-(150-rear));
RLC_Buffer_CU(rear:end) = 1;
elseif(rear+incoming_pck<=150)
RLC_Buffer_CU(rear:rear+incoming_pck-1) = 1;
end
end
front = find(~RLC_Buffer_CU, 1);
if(pop_buffer>0)
if(isempty(front))
RLC_Buffer_CU(end-pop_buffer+1:end) = 0;
elseif(front-1<=pop_buffer)
RLC_Buffer_CU(1:front) = 0;
elseif(front-1>pop_buffer)
RLC_Buffer_CU(front-pop_buffer:front) = 0;
end
end
if(tti==1000)
split = 2; %given some condition split has changed
pckt_loss_mig = find(~RLC_Buffer_CU, 1);
if(isempty(pckt_loss_mig))
pckt_loss_mig = 150;
else
pckt_loss_mig = pckt_loss_mig-1;
end
pck_loss = pck_loss + pckt_loss_mig;
RLC_Buffer_CU(1:end) = 0;
end
case 2
switch migration
case "hard"
%hard migration
inc_aft_mig = inc_aft_mig + incoming_pck;
out_aft_mig = out_aft_mig + pop_buffer;
rear = find(~RLC_Buffer_DU, 1);
if (incoming_pck>0)
if(isempty(rear))
pck_loss = pck_loss+incoming_pck;
elseif(incoming_pck>(150-rear+1))
pck_loss = pck_loss + (incoming_pck-(150-rear));
RLC_Buffer_DU(rear:end) = 1;
elseif(rear+incoming_pck<=150)
RLC_Buffer_DU(rear:rear+incoming_pck-1) = 1;
end
end
front = find(~RLC_Buffer_DU, 1);
if(pop_buffer>0)
if(isempty(front))
RLC_Buffer_DU(end-pop_buffer+1:end) = 0;
elseif(front-1<=pop_buffer)
RLC_Buffer_DU(1:front) = 0;
elseif(front-1>pop_buffer)
RLC_Buffer_DU(front-pop_buffer:front) = 0;
end
end
end
end
end