forked from named-data-ndnSIM/scenario-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrate-graph.R
executable file
·59 lines (47 loc) · 1.65 KB
/
rate-graph.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (c) 2012,2015 Alexander Afanasyev <[email protected]>
# Modified by Akshay Raman
args = commandArgs(trailingOnly=TRUE)
trace_file <- ''
if (length(args)==0) {
stop("Specify the input trace file!")
} else if (length(args)==1) {
trace_file <- args[1]
if(!file.exists(trace_file)){
stop(c("File ", trace_file, " does not exist!"))
}
}
# install.packages('ggplot2')
library(ggplot2)
# install.packages('scales')
library(scales)
# install.packages('doBy')
library(doBy)
#########################
# Rate trace processing #
#########################
data = read.table(trace_file, header=T)
data$Node = factor(data$Node)
data$FaceId <- factor(data$FaceId)
data$Kilobits <- data$Kilobytes * 8
data$Type = factor(data$Type)
# exlude irrelevant types
data = subset(data, Type %in% c("InInterests", "OutInterests", "InData", "OutData"))
# combine stats from all faces
data.combined = summaryBy(. ~ Time + Node + Type, data=data, FUN=sum)
data.root = subset (data.combined, Node == "root")
data.leaves = subset(data.combined, Node %in% c("leaf-1", "leaf-2", "leaf-3", "leaf-4"))
# graph rates on all nodes in Kilobits
g.all <- ggplot(data.combined) +
geom_point(aes (x=Time, y=Kilobits.sum, color=Type), size=1) +
ylab("Rate [Kbits/s]") +
facet_wrap(~ Node)
print(g.all)
# graph rates on the root nodes in Packets
g.root <- ggplot(data.root) +
geom_point(aes (x=Time, y=Kilobits.sum, color=Type), size=2) +
geom_line(aes (x=Time, y=Kilobits.sum, color=Type), size=0.5) +
ylab("Rate [Kbits/s]")
print(g.root)
png("../ns-3/src/ndnSIM/docs/source/_static/root-rates.png", width=500, height=250)
print(g.root)
retval <- dev.off()