mirror of
https://github.com/Zenithsiz/ist-ddrs-lab2
synced 2026-02-03 05:57:11 +00:00
Updated 11.
This commit is contained in:
parent
fd9cd1d4fa
commit
d7d86d2df5
43
code/11.R
43
code/11.R
@ -66,7 +66,7 @@ calc_throughput <- function(arrival_rates, link_capacity, avg_packet_sizes, queu
|
||||
state$served_queue <- NULL
|
||||
|
||||
# Simulation loop
|
||||
state$max_completed <- 500
|
||||
state$max_completed <- 2000
|
||||
while (state$num_sys_completed < state$max_completed) {
|
||||
# Get next event type
|
||||
next_event_type <- which.min(state$event_list)
|
||||
@ -135,10 +135,16 @@ calc_throughput <- function(arrival_rates, link_capacity, avg_packet_sizes, queu
|
||||
lapply(state$accum_bits, \(bits) bits / state$time)
|
||||
}
|
||||
|
||||
values <- seq(1 / 8, 7 / 8, by = 1 / 8)
|
||||
values <- seq(1 / 8, 7 / 8, by = 1 / 64)
|
||||
params_all <- sapply(values, \(avg_packet_size_ratio) {
|
||||
lapply(values, \(quantum_ratio) {
|
||||
list(avg_packet_size_ratio = avg_packet_size_ratio, quantum_ratio = quantum_ratio)
|
||||
sapply(values, \(quantum_ratio) {
|
||||
lapply(c(1 / 4, 2 / 4, 3 / 4), \(arrival_rate_ratio) {
|
||||
list(
|
||||
arrival_rate_ratio = arrival_rate_ratio,
|
||||
avg_packet_size_ratio = avg_packet_size_ratio,
|
||||
quantum_ratio = quantum_ratio
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -146,7 +152,10 @@ set.seed(0)
|
||||
data <- lapply(params_all, \(params) {
|
||||
str(params)
|
||||
|
||||
arrival_rates <- c(1, 1)
|
||||
arrival_rates <- c(
|
||||
params$arrival_rate_ratio * 3,
|
||||
(1 - params$arrival_rate_ratio) * 3
|
||||
)
|
||||
link_capacity <- 1000
|
||||
avg_packet_sizes <- c(
|
||||
params$avg_packet_size_ratio * 4000,
|
||||
@ -159,17 +168,18 @@ data <- lapply(params_all, \(params) {
|
||||
|
||||
throughputs <- calc_throughput(arrival_rates, link_capacity, avg_packet_sizes, queues_quantum)
|
||||
data.frame(
|
||||
arrival_rate_ratio = params$arrival_rate_ratio,
|
||||
avg_packet_sizes1 = avg_packet_sizes[[1]],
|
||||
avg_packet_sizes2 = avg_packet_sizes[[2]],
|
||||
queues_quantum1 = queues_quantum[[1]],
|
||||
queues_quantum2 = queues_quantum[[2]],
|
||||
throughput1 = signif(throughputs[[1]], 4),
|
||||
throughput2 = signif(throughputs[[2]], 4)
|
||||
)
|
||||
})
|
||||
data <- do.call(rbind, data)
|
||||
|
||||
create_plot <- function(throughput, throughput_title) {
|
||||
create_plot <- function(arrival_rate_ratio, throughput, throughput_title) {
|
||||
data <- data[data$arrival_rate_ratio == arrival_rate_ratio, ]
|
||||
|
||||
ggplot(data, aes(.data$avg_packet_sizes1, .data$queues_quantum1)) +
|
||||
geom_raster(aes(fill = .data[[throughput]])) +
|
||||
scale_x_continuous(
|
||||
@ -190,8 +200,15 @@ create_plot <- function(throughput, throughput_title) {
|
||||
ylab("Quantum size %")
|
||||
}
|
||||
|
||||
plot1 <- create_plot("throughput1", "Throughput (1)")
|
||||
ggsave(plot1, file = "output/11_1.svg", device = "svg")
|
||||
|
||||
plot2 <- create_plot("throughput2", "Throughput (2)")
|
||||
ggsave(plot2, file = "output/11_2.svg", device = "svg")
|
||||
plot <- create_plot(1 / 4, "throughput1", "Throughput (1)")
|
||||
ggsave(plot, file = "output/11_1_1.svg", device = "svg")
|
||||
plot <- create_plot(2 / 4, "throughput1", "Throughput (1)")
|
||||
ggsave(plot, file = "output/11_1_2.svg", device = "svg")
|
||||
plot <- create_plot(3 / 4, "throughput1", "Throughput (1)")
|
||||
ggsave(plot, file = "output/11_1_3.svg", device = "svg")
|
||||
plot <- create_plot(1 / 4, "throughput2", "Throughput (2)")
|
||||
ggsave(plot, file = "output/11_2_1.svg", device = "svg")
|
||||
plot <- create_plot(2 / 4, "throughput2", "Throughput (2)")
|
||||
ggsave(plot, file = "output/11_2_2.svg", device = "svg")
|
||||
plot <- create_plot(3 / 4, "throughput2", "Throughput (2)")
|
||||
ggsave(plot, file = "output/11_2_3.svg", device = "svg")
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#indent_par[The following code 9 is our implementation:]
|
||||
|
||||
#code_figure(
|
||||
columns(1, text(size: 0.75em, raw(read("/code/11.R"), lang: "R", block: true))),
|
||||
columns(1, text(size: 0.7em, raw(read("/code/11.R"), lang: "R", block: true))),
|
||||
caption: "Implementation of deficit round robin",
|
||||
)
|
||||
|
||||
@ -18,22 +18,43 @@
|
||||
|
||||
#indent_par[We've chosen to simulate several scenarios in which:]
|
||||
|
||||
- Arrival rates: $0.75$, $1.50$ and $2.25$.
|
||||
- Link capacity: $1000 "bits" dot s^(-1)$
|
||||
- Average packet sizes: $500 $ to $ 3500 "bits"$, such that $"AvgPacketSize"_1 + "AvgPacketSize"_2 = 4000$
|
||||
- Queues quantum: $250 $ to $ 1750 "bits"$, such that $"QueueQuantum"_1 + "QueueQuantum"_2 = 2000$
|
||||
- Queues quantum: $250$ to $1750 "bits"$, such that $"QueueQuantum"_1 + "QueueQuantum"_2 = 2000$
|
||||
|
||||
#indent_par[And obtained the following graphs in figures 15 and 16:]
|
||||
#indent_par[And obtained the following graphs in figures 15 through 20:]
|
||||
|
||||
#grid(
|
||||
columns: (1fr, 1fr),
|
||||
figure(
|
||||
image("/output/11_1.svg", width: 80%),
|
||||
caption: [Throughput for queue 1]
|
||||
),
|
||||
figure(
|
||||
image("/output/11_2.svg", width: 80%),
|
||||
caption: [Throughput for queue 2]
|
||||
),
|
||||
pad(1em, figure(
|
||||
image("/output/11_1_1.svg", width: 100%),
|
||||
caption: [Throughput for queue 1 #linebreak() (Arrival rate 0.75)]
|
||||
)),
|
||||
pad(1em, figure(
|
||||
image("/output/11_2_1.svg", width: 100%),
|
||||
caption: [Throughput for queue 2 #linebreak() (Arrival rate 2.25)]
|
||||
)),
|
||||
pad(1em, figure(
|
||||
image("/output/11_1_2.svg", width: 100%),
|
||||
caption: [Throughput for queue 1 #linebreak() (Arrival rate 1.50)]
|
||||
)),
|
||||
pad(1em, figure(
|
||||
image("/output/11_2_2.svg", width: 100%),
|
||||
caption: [Throughput for queue 2 #linebreak() (Arrival rate 1.50)]
|
||||
)),
|
||||
pad(1em, figure(
|
||||
image("/output/11_1_3.svg", width: 100%),
|
||||
caption: [Throughput for queue 1 #linebreak() (Arrival rate 2.25)]
|
||||
)),
|
||||
pad(1em, figure(
|
||||
image("/output/11_2_3.svg", width: 100%),
|
||||
caption: [Throughput for queue 2 #linebreak() (Arrival rate 0.75)]
|
||||
)),
|
||||
)
|
||||
|
||||
#indent_par[In both images we see a (mostly) vertical gradient, implying that the throughput values don't change much across the x axis (average packet sizes). From this, we conclude that the relative quantum values seem to mostly determine the throughput of each queue, regardless of the queue's relative average packet size. This concept starts to breaks down for very low or high relative quantums, but it is still mostly applicable across the whole spectrum we tested.]
|
||||
#indent_par[In all images we see a (mostly) vertical gradient, implying that the throughput values don't change much across the x axis (average packet sizes). From this, we conclude that the relative quantum values seem to mostly determine the throughput of each queue, regardless of the queue's relative average packet size.]
|
||||
|
||||
#indent_par[When the arrival rates are different, the vertical gradient starts to break at the extremes. However, outside of these parts, the pattern still fits extremely well.]
|
||||
|
||||
#pagebreak()
|
||||
|
||||
@ -257,8 +257,12 @@ rules:
|
||||
# Exercise 11
|
||||
ex11:
|
||||
out:
|
||||
- output/11_1.svg
|
||||
- output/11_2.svg
|
||||
- output/11_1_1.svg
|
||||
- output/11_1_2.svg
|
||||
- output/11_1_3.svg
|
||||
- output/11_2_1.svg
|
||||
- output/11_2_2.svg
|
||||
- output/11_2_3.svg
|
||||
deps:
|
||||
- code/11.R
|
||||
exec:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user