Skip to content

Instantly share code, notes, and snippets.

@wldhg
Last active May 12, 2020 09:06
Show Gist options
  • Save wldhg/73b559073d7aae90d311b0345e4c079b to your computer and use it in GitHub Desktop.
Save wldhg/73b559073d7aae90d311b0345e4c079b to your computer and use it in GitHub Desktop.
Performance Anomaly: Customized Simulation Code
% Define conditions
cw_min = 31;
msdu_size = 1500; % in bytes
slot_time = 20; % in microseconds
sifs_time = 10; % in microseconds
n = 10;
mbps_f = [11 11 11 ];
mbps_s = [1 2 5.5 ];
mbps_icon = ['o', 'x', '+' ];
% Calculate (with long preamble)
slot = slot_time * 1e-6;
sifs = sifs_time * 1e-6;
difs = (sifs_time + 2 * slot_time) * 1e-6;
p_c = 1 - (1 - 1 / cw_min)^(n - 1);
t_cont = slot * ((1 + p_c) / (2 * n)) * (cw_min / 2);
s_d = (msdu_size + 34) * 8;
t_pr = 192 * 1e-6;
host11 = 0:1:n; % fast hosts
host01 = n:-1:0; % slow hosts
x_udp = zeros(length(mbps_f), length(host11));
for j = 1:length(mbps_f)
bps_11 = mbps_f(j) * 1e+6; % fast bps
bps_01 = mbps_s(j) * 1e+6; % slow bps
t_ack_11 = 112 / bps_11;
t_ack_01 = 112 / bps_01;
for i = 1:length(host11)
t_ov_11 = difs + t_pr + sifs + t_pr + t_ack_11;
t_ov_01 = difs + t_pr + sifs + t_pr + t_ack_01;
t_tr_11 = t_ov_11 + s_d / bps_11 + t_cont;
t_tr_01 = t_ov_01 + s_d / bps_01 + t_cont;
p_slow = ((host11(i) * host01(i) + (host01(i) * (host01(i) - 1)) / 2)) / ((n * (n - 1)) / 2);
t_jam_udp = p_slow * t_tr_01 + (1 - p_slow) * t_tr_11;
u_11 = t_tr_11 / (host11(i) * t_tr_11 + host01(i) * t_tr_01 + p_c * t_jam_udp * n);
x_11 = u_11 * (s_d / (bps_11 * t_tr_11)) * bps_11;
x_udp(j, i) = x_11 / 1e+6; % Mbps
end
end
% Draw graph
figure;
hold on;
names = string(mbps_s) + " Mbps slow host";
for j = 1:length(mbps_f)
plot(host01, x_udp(j, :), 'Marker', mbps_icon(j));
end
ylabel('Throughput (Mbps)');
xlabel('The number of slow hosts');
legend(names);
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment