Skip to content

Instantly share code, notes, and snippets.

@igrigorik
Created December 10, 2012 07:18
Show Gist options
  • Select an option

  • Save igrigorik/4249003 to your computer and use it in GitHub Desktop.

Select an option

Save igrigorik/4249003 to your computer and use it in GitHub Desktop.
router latency
setwd('Desktop/latency')
l <- read.csv('out.csv')
graph <- function (data, xlabel, color, fname, buckets=20) {
png(filename=fname, width=750, height=350, units="px", pointsize=12, bg="white")
hist(data,
main=NULL,
#freq=FALSE,
las=1,
breaks=buckets,
col=color,
xlab=xlabel,
xaxt='n'
)
axis(side=1, at=pretty(0:max(data), n=buckets))
dev.off()
}
samples <- sapply(l[2], as.numeric)
graph(samples, "latency", "lightblue", "latency.png", 40)
library(xtable)
qtable <- function(c) {
z <- quantile(c, probs=c(0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 1))
y <- data.frame(id=names(z), values=unname(z), stringsAsFactors=FALSE)
print(xtable(y), type="html")
z <- summary(c)
y <- data.frame(id=names(z), values=c(unname(z)), stringsAsFactors=FALSE)
print(xtable(t(y)), type="html")
}
qtable(samples)
#!/bin/bash
while [ 1 ]
do
date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s `ping -c1 192.168.0.1|grep from`"
sleep 1
done

Processing...

$> sh record.sh > log.txt
$> cut -d' ' -f1,8 log.txt | tr = ' ' | cut -d' ' -f1,3 | tr ' ' , | grep ,

Results

Based on 6 hours of 1 second samples between 5-11PM.

Qnt   Latency
25%   2.57
50%   6.22
75%   7.85
90%   13.68
95%   34.87
99%   58.91
100%  150.8

Smaller sample, based on simple ping run:

--- 192.168.0.1 ping statistics ---
7261 packets transmitted, 7244 packets received, 0.2% packet loss
round-trip min/avg/max/stddev = 0.348/7.103/123.144/10.046 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment