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