knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Analyze ping log.
Requires R >= 4.1.
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("atusy/pingAnalysis")
library(pingAnalysis)
-
indicates timeout.20200101000001,192.168.1.1/24,1 20200101000002,192.168.1.1/24,- 20200101000003,192.168.1.2/24,1 20200101000004,192.168.1.1/24,- 20200101000005,192.168.1.2/24,-
log_csv <- tempfile(fileext = ".csv") log_df <- tibble::tibble( timestamp = 20200101000000 + seq(5), address = "192.168.1.1/24", ping = c("1", "-", "1", "-", "-") ) readr::write_csv(log_df, log_csv, col_names = FALSE)
View data
cat(readr::read_lines(log_csv), sep = "\n")
measure_all_timeout(read_log(log_csv))
N
-times or more.Data inherits from the previous example.
N = 1L
is equivalent to measure_all_timeout()
measure_timeout(read_log(log_csv), N = 1L)
N = 2L
measure_timeout(read_log(log_csv), N = 2L)
basetime <- 20200101000000 pings <- c( 0, 11, 0, 11, 12, 0, 11, 12, 13, 0, 11, 0, 11, 12, 0, 11, NA, 13 ) |> as.character() |> dplyr::na_if("0") |> dplyr::coalesce("-") N <- length(pings) / 2L log_df <- tibble::tibble( timestamp = rep(basetime + seq(N), 2L), address = paste0("192.168.1.", 1L:2L, "/24") |> rep(each = N), ping = pings ) readr::write_csv(log_df, log_csv, col_names = FALSE)
View data
cat(readr::read_lines(log_csv), sep = "\n")
Read log
log_df <- read_log(log_csv)
Analyze varying parameters:
measure_overload(log_df, m = 1L, t = 10, N = 1L) measure_overload(log_df, m = 2L, t = 10, N = 1L) measure_overload(log_df, m = 1L, t = 10, N = 2L)
N
-times or more.basetime <- 20200101000000 pings <- c( # 1 2 3 4 5 6 7 8 9 10 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1 ) N <- length(pings) / 3L log_df <- tibble::tibble( timestamp = rep(basetime + seq(N), 3L), address = paste0("192.168.1.", 1L:3L, "/24") |> rep(each = N), ping = ifelse(pings == 0, "-", as.character(pings)) ) log_df |> dplyr::mutate( address = stringr::str_replace(address, "^192\\.168\\.1\\.", "192.168.2.") ) |> dplyr::bind_rows(log_df) |> readr::write_csv(log_csv, col_names = FALSE)
View data
cat(readr::read_lines(log_csv), sep = "\n")
Read log.
log_df <- read_log(log_csv)
Assume log contains all the required IP addresses.
address_all <- unique(log_df$address) address_all
Do the analysis varying N
.
measure_subnet_timeout(log_df, N = 1L, address_all = address_all) measure_subnet_timeout(log_df, N = 2L, address_all = address_all)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.