mirror of
https://github.com/Zenithsiz/ist-ddrs-lab2
synced 2026-02-03 22:23:55 +00:00
47 lines
1.6 KiB
R
47 lines
1.6 KiB
R
source("code/7.R")
|
|
source("code/ppl/ppl.R")
|
|
|
|
arrival_rates1 <- c(80)
|
|
|
|
set.seed(0)
|
|
data <- lapply(arrival_rates1, function(arrival_rate1) {
|
|
cat(sprintf("Arrival rate (1) = %d\n", arrival_rate1))
|
|
|
|
packet_size <- 800
|
|
sim_res <- calc_data(2, c(arrival_rate1, 40), packet_size, c(1, 2))
|
|
|
|
# Then calculate theoretical results
|
|
λ1 <- Flows[[1]]$arrivalrate
|
|
λ2 <- Flows[[2]]$arrivalrate
|
|
μ <- LinkCapacity / packet_size
|
|
p1 <- λ1 / μ
|
|
p2 <- λ2 / μ
|
|
p <- p1 + p2
|
|
avg_wait_delay1 <- (p / (2 * μ)) / (1 - p1) + 1 / μ
|
|
avg_wait_delay2 <- (p / (2 * μ)) / ((1 - p1) * (1 - p1 - p2)) + 1 / μ
|
|
|
|
throughput1 <- Flows[[1]]$arrivalrate * packet_size
|
|
throughput2 <- Flows[[2]]$arrivalrate * packet_size
|
|
|
|
data.frame(
|
|
λ1 = λ1,
|
|
λ2 = λ2,
|
|
μ = μ,
|
|
calc_avg_wait_delay1 = signif(avg_wait_delay1, 4),
|
|
calc_avg_wait_delay2 = signif(avg_wait_delay2, 4),
|
|
calc_throughput1 = signif(throughput1, 4),
|
|
calc_throughput2 = signif(throughput2, 4),
|
|
sim_avg_wait_delay1_min = signif(sim_res$avg_wait_delay1$min, 4),
|
|
sim_avg_wait_delay1_max = signif(sim_res$avg_wait_delay1$max, 4),
|
|
sim_avg_wait_delay2_min = signif(sim_res$avg_wait_delay2$min, 4),
|
|
sim_avg_wait_delay2_max = signif(sim_res$avg_wait_delay2$max, 4),
|
|
sim_throughput1_min = signif(sim_res$throughput1$min, 4),
|
|
sim_throughput1_max = signif(sim_res$throughput1$max, 4),
|
|
sim_throughput2_min = signif(sim_res$throughput2$min, 4),
|
|
sim_throughput2_max = signif(sim_res$throughput2$max, 4)
|
|
)
|
|
})
|
|
data <- do.call(rbind, data)
|
|
|
|
write.table(data, "output/7c.csv", sep = "\t", row.names = FALSE)
|