Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
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")

This comment has been minimized.

Copy link
Owner Author

reyjrar commented Jul 7, 2011

Sample output is here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.