-
Notifications
You must be signed in to change notification settings - Fork 0
/
unbuffered_theoritical_analysis.m
75 lines (56 loc) · 4.59 KB
/
unbuffered_theoritical_analysis.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
%%========================================================================================================================================================================
%% OUTPUT FOR UNBUFFERED ALOHA: ANALYSIS OF THROUGHPUT (S) AND TRANSMITTED LOAD (T) V/S OFFERED LOAD (G)
%%========================================================================================================================================================================
N = 2; %% Number of nodes - needs to be parameterised in the future versions; Concretely ==> N = 2, 5, 10 and INF
T = 0.5; %% Initial value
dutyCycle = T/N; %% Setting some value initially
d = 2; %% Packet duration
omega = 10; %% Packet generation rate
S_unbuff_list = []; %% Array to store the throuput info ====> useful info for later processing
%%================ ARRAYS USED FOR PLOTTING G VERSUS T ============================================================================================================
%%=========================================================================================================================================================================
%% FOR 2 ACTIVE NODES
%%=========================================================================================================================================================================
T_history_2 = [];
G_history_2 = [];
for G=0:10 %% G is the Offered Load
T = G/(1 + G/N); %% G = T / (1 - dutyCycle)
G_history_2 = [G_history_2, G]; %% Transmitted Load ======> Useful for plotting the graph between G and T
T_history_2 = [T_history_2, T];
collision1 = 1 - power((1 - dutyCycle), N - 1); %% probability of type-1 collision
P_t = exp(-omega * d);
collision2 = 1 - power(P_t, N - 1); %% Throughoput for unbuffered ALOHA ===> S_unbuff
S_unbuff_tmp = T*(1 - collision1)*(1 - collision2); %% Calculate this value for different values of the parameters and store it in an array
S_unbuff_list = [S_unbuff_list, S_unbuff_tmp]; %% Appending the newest value, for plotting purposes
end
%%=========================================================================================================================================================================
%% FOR 5 ACTIVE NODES
%%=========================================================================================================================================================================
N = 5;
T_history_5 = [];
G_history_5 = [];
for G=0:10 %% G is the Offered Load
T = G/(1 + G/N); %% G = T / (1 - dutyCycle)
G_history_5 = [G_history_5, G];
T_history_5 = [T_history_5, T];
end
%%=========================================================================================================================================================================
%% FOR 10 ACTIVE NODES
%%=========================================================================================================================================================================
N = 10;
T_history_10 = [];
G_history_10 = [];
for G=0:10 %% G is the Offered Load
T = G/(1 + G/N);
G_history_10 = [G_history_10, G];
T_history_10 = [T_history_10, T];
end
%%=========================================================================================================================================================================
%% PLOTTING THE GRAPH
%%=========================================================================================================================================================================
plot(G_history_2, T_history_2, G_history_5, T_history_5, G_history_10, T_history_10);
title('Unbuffered ALOHA: Transmitted Load(T) versus Offered Load(G), N = No. of Active Nodes');
xlabel('Offered Load(G)') %% x-axis label; G = Average number of frames generated by the system during one frame transmission time (Unitless)
ylabel('Transmitted Load(T)') %% y-axis label; T = Transmitted Load
legend('N = 2', 'N = 5', 'N = 10');
%%=========================================================================================================================================================================