Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 1 | # Copyright (c) 2012,2015 Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 2 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 3 | # install.packages('ggplot2') |
| 4 | library(ggplot2) |
| 5 | # install.packages('scales') |
| 6 | library(scales) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 7 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 8 | # install.packages('doBy') |
| 9 | library(doBy) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 10 | |
| 11 | ######################### |
| 12 | # Rate trace processing # |
| 13 | ######################### |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 14 | data = read.table("rate-trace.txt", header=T) |
| 15 | data$Node = factor(data$Node) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 16 | data$FaceId <- factor(data$FaceId) |
| 17 | data$Kilobits <- data$Kilobytes * 8 |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 18 | data$Type = factor(data$Type) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 19 | |
| 20 | # exlude irrelevant types |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 21 | data = subset(data, Type %in% c("InInterests", "OutInterests", "InData", "OutData")) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 22 | |
| 23 | # combine stats from all faces |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 24 | data.combined = summaryBy(. ~ Time + Node + Type, data=data, FUN=sum) |
| 25 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 26 | data.root = subset (data.combined, Node == "root") |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 27 | data.leaves = subset(data.combined, Node %in% c("leaf-1", "leaf-2", "leaf-3", "leaf-4")) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 28 | |
| 29 | # graph rates on all nodes in Kilobits |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 30 | g.all <- ggplot(data.combined) + |
| 31 | geom_point(aes (x=Time, y=Kilobits.sum, color=Type), size=1) + |
| 32 | ylab("Rate [Kbits/s]") + |
| 33 | facet_wrap(~ Node) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 34 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 35 | print(g.all) |
| 36 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 37 | # graph rates on the root nodes in Packets |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 38 | g.root <- ggplot(data.root) + |
| 39 | geom_point(aes (x=Time, y=Kilobits.sum, color=Type), size=2) + |
| 40 | geom_line(aes (x=Time, y=Kilobits.sum, color=Type), size=0.5) + |
| 41 | ylab("Rate [Kbits/s]") |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 42 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 43 | print(g.root) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 44 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 45 | png("src/ndnSIM/docs/source/_static/root-rates.png", width=500, height=250) |
| 46 | print(g.root) |
| 47 | retval <- dev.off() |