Skip to content

Instantly share code, notes, and snippets.

@reyjrar
Created July 7, 2011 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reyjrar/1070570 to your computer and use it in GitHub Desktop.
Save reyjrar/1070570 to your computer and use it in GitHub Desktop.
Probability Density of DNS Query/Response times
# Connect to Database
pgDrv <- dbDriver("PostgreSQL")
dbh <- dbConnect(pgDrv, host="", dbname="dnsmonitor", user="dnsmon", password="")
# Retrieve Statistics from DB
stats <- dbGetQuery(dbh, "select * from packet_timing")
# Close the Database Connection and free variables
dbDisconnect(dbh)
rm(dbh)
rm(pgDrv)
stats$zscore = (stats$difference - mean(stats$difference))/sd(stats$difference)
trimmed <- stats[ which(abs(stats$zscore) <= 3 & stats$difference > 0 ),]
outliers <- stats[which(abs(stats$zscore) > 3),]
# All data
hist(stats$difference,breaks=100,prob=TRUE, main="DNS Response Times", xlab="seconds")
d <- density(stats$difference)
lines(d, col="blue")
# Outliers
hist(outliers$difference,breaks=100,prob=TRUE, main="DNS Response Times for Outliers", xlab="seconds")
d <- density(outliers$difference)
lines(d, col="red")
# Normals
hist(trimmed$difference,breaks=200,prob=TRUE, main="DNS Response Times (z <= 3)", xlab="seconds")
d <- density(trimmed$difference)
lines(d, col="green")
@reyjrar
Copy link
Author

reyjrar commented Jul 7, 2011

Sample output is here: http://skit.ch/b1iw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment