Skip to content

Commit

Permalink
Updated to correct for some errors with plotting and to adjust ggplot…
Browse files Browse the repository at this point in the history
… theme.
  • Loading branch information
brianhigh committed Jan 6, 2016
1 parent 725357b commit e42872c
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 40 deletions.
18 changes: 9 additions & 9 deletions data/www_gov_bb/ipinfo.csv
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"ip","country_code","country_name","region_code","region_name","city","zip_code","time_zone","latitude","longitude","metro_code","mean_rtt"
"128.95.230.102","US","United States","WA","Washington","Seattle","98105","America/Los_Angeles",47.6606,-122.2919,"819",1.06866666666667
"209.124.188.134","US","United States","WA","Washington","Seattle","98105","America/Los_Angeles",47.6606,-122.2919,"819",1.415
"206.81.80.84","US","United States","WA","Washington","Seattle","98101","America/Los_Angeles",47.6103,-122.3341,"819",0.763666666666667
"206.81.80.13","US","United States","WA","Washington","Seattle","98101","America/Los_Angeles",47.6103,-122.3341,"819",1.73066666666667
"63.218.112.218","US","United States","VA","Virginia","Herndon","20170","America/New_York",38.9841,-77.3827,"511",97.657
"63.217.112.26","US","United States","VA","Virginia","Herndon","20170","America/New_York",38.9841,-77.3827,"511",97.709
"63.245.106.184","US","United States","FL","Florida","Miami","33162","America/New_York",25.9274,-80.1801,"528",94.2756666666667
"63.245.70.98","US","United States","FL","Florida","Miami","33162","America/New_York",25.9274,-80.1801,"528",149.132333333333
"162.246.104.182","BB","Barbados","08","Saint Michael","Warrens","","America/Barbados",13.15,-59.6,"0",149.240666666667
"128.95.230.102","US","United States","WA","Washington","Seattle","98105","America/Los_Angeles",47.6606,-122.2919,"819",8.012
"209.124.188.134","US","United States","WA","Washington","Seattle","98105","America/Los_Angeles",47.6606,-122.2919,"819",2.71266666666667
"206.81.80.84","US","United States","WA","Washington","Seattle","98101","America/Los_Angeles",47.6103,-122.3341,"819",0
"206.81.80.13","US","United States","WA","Washington","Seattle","98101","America/Los_Angeles",47.6103,-122.3341,"819",0
"63.218.112.218","US","United States","VA","Virginia","Herndon","20170","America/New_York",38.9841,-77.3827,"511",95.952
"63.217.112.26","US","United States","VA","Virginia","Herndon","20170","America/New_York",38.9841,-77.3827,"511",95.952
"63.245.106.184","US","United States","FL","Florida","Miami","33162","America/New_York",25.9274,-80.1801,"528",103.954
"63.245.70.98","US","United States","FL","Florida","Miami","33162","America/New_York",25.9274,-80.1801,"528",147.959
"162.246.104.182","BB","Barbados","08","Saint Michael","Warrens","","America/Barbados",13.15,-59.6,"0",147.979
22 changes: 11 additions & 11 deletions data/www_gov_bb/route.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"addr","mean_rtt","rtt.1","rtt.2","rtt.3"
"128.95.230.102",1.06866666666667,1.045,1.07,1.091
"10.132.1.73",1.578,1.56,1.584,1.59
"10.132.1.75",1.35533333333333,1.344,1.358,1.364
"209.124.188.134",1.415,1.751,1.759,0.735
"206.81.80.84",0.763666666666667,0.694,0.715,0.882
"206.81.80.13",1.73066666666667,1.473,1.886,1.833
"63.218.112.218",97.657,97.625,97.67,97.676
"63.217.112.26",97.709,97.505,97.786,97.836
"63.245.106.184",94.2756666666667,94.257,94.282,94.288
"63.245.70.98",149.132333333333,149.159,149.202,149.036
"162.246.104.182",149.240666666667,149.35,149.275,149.097
"128.95.230.102",8.012,8.012,8.012,8.012
"10.132.1.73",4.048,4.048,4.048,4.048
"10.132.1.75",4.048,4.048,4.048,4.048
"209.124.188.134",2.71266666666667,4.048,4.048,0.042
"206.81.80.84",0,0,0,0
"206.81.80.13",0,0,0,0
"63.218.112.218",95.952,95.952,95.952,95.952
"63.217.112.26",95.952,95.952,95.952,95.952
"63.245.106.184",103.954,103.954,103.954,103.954
"63.245.70.98",147.959,147.959,147.959,147.959
"162.246.104.182",147.979,147.959,147.989,147.989
22 changes: 11 additions & 11 deletions data/www_gov_bb/route.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
traceroute to www.gov.bb (204.212.244.57), 30 hops max, 60 byte packets
1 128.95.230.102 1.045 ms 1.070 ms 1.091 ms
2 10.132.1.73 1.560 ms 1.584 ms 1.590 ms
3 10.132.1.75 1.344 ms 1.358 ms 1.364 ms
4 209.124.188.134 1.751 ms 1.759 ms 0.735 ms
5 206.81.80.84 0.694 ms 0.715 ms 0.882 ms
6 206.81.80.13 1.473 ms 1.886 ms 1.833 ms
7 63.218.112.218 97.625 ms 97.670 ms 97.676 ms
8 63.217.112.26 97.505 ms 97.786 ms 97.836 ms
9 63.245.106.184 94.257 ms 94.282 ms 94.288 ms
10 63.245.70.98 149.159 ms 149.202 ms 149.036 ms
11 162.246.104.182 149.350 ms 149.275 ms 149.097 ms
1 128.95.230.102 8.012 ms 8.012 ms 8.012 ms
2 10.132.1.73 4.048 ms 4.048 ms 4.048 ms
3 10.132.1.75 4.048 ms 4.048 ms 4.048 ms
4 209.124.188.134 4.048 ms 4.048 ms 0.042 ms
5 206.81.80.84 0.000 ms 0.000 ms 0.000 ms
6 206.81.80.13 0.000 ms 0.000 ms 0.000 ms
7 63.218.112.218 95.952 ms 95.952 ms 95.952 ms
8 63.217.112.26 95.952 ms 95.952 ms 95.952 ms
9 63.245.106.184 103.954 ms 103.954 ms 103.954 ms
10 63.245.70.98 147.959 ms 147.959 ms 147.959 ms
11 162.246.104.182 147.959 ms 147.989 ms 147.989 ms
12 * * *
13 * * *
14 * * *
Expand Down
Binary file added images/www_gov_bb/ggmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/www_gov_bb/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 31 additions & 7 deletions plot_route.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# Plot network hops to reach hosts by round-trip time (rtt) with error bars.
# --------------------------------------------------------------------------
# title: plot_route.R
# descr: Plot hops to reach hosts by round-trip time (rtt) with error bars.
# author: Brian High
# date: 06 Jan. 2016
# --------------------------------------------------------------------------
#
# Note: Only those hops with rtt data will be plotted; others are ignored.
#
# Copyright (C) 2016 Brian High (https://github.com/brianhigh)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# --------------------------------------------------------------------------

# Function to install packages as needed then load them into R.
load_packages <- function(pkgs) {
Expand All @@ -23,11 +47,11 @@ import.route <- function(fname, host) {
if (file.exists(fname) == TRUE) {
route <- read.table(fname, sep=",", header=T, stringsAsFactors=F)
route$hop <- row.names(route)
route$mean_rtt <- NULL
#route$mean_rtt <- NULL
route$hop <- sprintf("%02d", as.numeric(route$hop))
route$hop <- as.factor(route$hop)
route.long <- melt(route, id=c("hop","addr"))
names(route.long) <- c("hop", "addr", "query", "rtt")
route.long <- melt(route, id=c("hop", "addr", "mean_rtt"))
names(route.long) <- c("hop", "addr", "mean_rtt", "query", "rtt")
route.long$host <- rep(host, nrow(route.long))
route.long$query <- as.factor(gsub("rtt.", "", route.long$query,
fixed = TRUE))
Expand All @@ -49,7 +73,7 @@ routes <- rbindlist(lapply(1:length(files),
function(n) import.route(files[n], hosts[n])))

# Combine all route data into a singe data table.
route.summary <- summarySE(routes, measurevar="rtt", groupvars=c("host", "hop"))
route.summary <- summarySE(routes, measurevar="rtt", groupvars=c("host", "hop", "mean_rtt"))

# Make a basic line and point graph with error bars.

Expand All @@ -60,7 +84,7 @@ route.summary <- summarySE(routes, measurevar="rtt", groupvars=c("host", "hop"))
g <- ggplot(route.summary, aes(x=hop, y=rtt, colour=host)) +
geom_errorbar(aes(ymin=rtt-ci, ymax=rtt+ci), width=.1, size=2) +
geom_line(aes(group=host), size=2) +
theme_bw() +
xlab("network hop") + ylab("round-trip time (ms)") +
theme_grey(base_size = 20) +
xlab("Network hop") + ylab("Round-trip time (ms)") +
ggtitle("Round-trip time (ms) per network hop")
plot(g)
8 changes: 6 additions & 2 deletions visual-traceroute.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# title: visual-tracerouter
# descr: Plot a map of the route of internet traffic to a remote host
# author: Brian High
# date: 11 Dec. 2015
# date: 06 Jan. 2016
# --------------------------------------------------------------------------
#
# Copyright (C) 2015 Brian High (https://github.com/brianhigh)
# Copyright (C) 2016 Brian High (https://github.com/brianhigh)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -294,6 +294,10 @@ plot_ggmap <- function(ipinfo) {
# Only load these packages if this function is called.
load_packages(c("ggmap"))

# Set .all_aesthetics to avoid error: "object '.all_aesthetics' not found"
.all_aesthetics <- unlist(getAnywhere(.all_aesthetics)[1:42])

# Create the plot
p <- qmplot(longitude, latitude, data = ipinfo, source="stamen",
maptype = "toner-lite", mapcolor="bw", color = I("red"),
geom = "segment", xend=next_longitude, yend=next_latitude)
Expand Down

0 comments on commit e42872c

Please sign in to comment.