Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 1 | # Copyright (c) 2012 Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 2 | |
| 3 | # install.packages ('ggplot2') |
| 4 | library (ggplot2) |
| 5 | # install.packages ('scales') |
| 6 | library (scales) |
| 7 | |
| 8 | # install.packages ('doBy') |
| 9 | library (doBy) |
| 10 | |
| 11 | ######################### |
| 12 | # Rate trace processing # |
| 13 | ######################### |
| 14 | data = read.table ("rate-trace.txt", header=T) |
| 15 | data$Node = factor (data$Node) |
| 16 | data$FaceId <- factor(data$FaceId) |
| 17 | data$Kilobits <- data$Kilobytes * 8 |
| 18 | data$Type = factor (data$Type) |
| 19 | |
| 20 | # exlude irrelevant types |
| 21 | data = subset (data, Type %in% c("InInterests", "OutInterests", "InData", "OutData")) |
| 22 | |
| 23 | # combine stats from all faces |
| 24 | data.combined = summaryBy (. ~ Time + Node + Type, data=data, FUN=sum) |
| 25 | |
| 26 | data.root = subset (data.combined, Node == "root") |
| 27 | data.leaves = subset (data.combined, Node %in% c("leaf-1", "leaf-2", "leaf-3", "leaf-4")) |
| 28 | |
| 29 | # graph rates on all nodes in Kilobits |
| 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) |
| 34 | |
| 35 | print (g.all) |
| 36 | |
| 37 | # graph rates on the root nodes in Packets |
| 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]") |
| 42 | |
| 43 | print (g.root) |
| 44 | |
| 45 | png ("root-rates.png", width=500, height=250) |
| 46 | print (g.root) |
| 47 | dev.off () |
| 48 | |
| 49 | ############################### |
| 50 | # Aggreagate trace processing # |
| 51 | ############################### |
| 52 | |
| 53 | data = read.table ("aggregate-trace.txt", header=T) |
| 54 | data$Node = factor (data$Node) |
| 55 | data$FaceId <- factor(data$FaceId) |
| 56 | data$Type = factor (data$Type) |
| 57 | |
| 58 | # exlude irrelevant types |
| 59 | data = subset (data, Type %in% c("InInterests", "OutInterests", "InData", "OutData")) |
| 60 | |
| 61 | # Aggregate packet stats in 5-second intervals |
| 62 | data$Time5Sec = 5 * ceiling (data$Time / 5) |
| 63 | data.combined = summaryBy (. ~ Time5Sec + Node + Type, data=data, FUN=sum) |
| 64 | |
| 65 | data.root = subset (data.combined, Node == "root") |
| 66 | data.leaves = subset (data.combined, Node %in% c("leaf-1", "leaf-2", "leaf-3", "leaf-4")) |
| 67 | |
| 68 | # graph rates on all nodes in Packets |
| 69 | g.all <- ggplot (data.combined) + |
| 70 | geom_point (aes (x=Time5Sec, y=Packets.sum, color=Type), size=2) + |
| 71 | geom_line (aes (x=Time5Sec, y=Packets.sum, color=Type), size=0.5) + |
| 72 | ylab ("Number of transitted packets in 5 secon intervals") + |
| 73 | facet_wrap (~ Node) |
| 74 | |
| 75 | print (g.all) |
| 76 | |
| 77 | # graph rates on the root nodes in Packets |
| 78 | g.root <- ggplot (data.root) + |
| 79 | geom_point (aes (x=Time5Sec, y=Packets.sum, color=Type), size=2) + |
| 80 | geom_line (aes (x=Time5Sec, y=Packets.sum, color=Type), size=0.5) + |
| 81 | ylab ("Number of transitted packets in 5 secon intervals") + |
| 82 | ylim (c(0,2000)) |
| 83 | |
| 84 | print (g.root) |
| 85 | |
| 86 | png ("root-5sec-counts.png", width=500, height=250) |
| 87 | print (g.root) |
| 88 | dev.off () |