blob: cbacf490b6c3355768826125999a4eafcd66ec3d [file] [log] [blame]
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -08001# Copyright (c) 2012,2015 Alexander Afanasyev <alexander.afanasyev@ucla.edu>
Alexander Afanasyev59314802012-11-26 14:56:04 -08002
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -08003# install.packages('ggplot2')
4library(ggplot2)
5# install.packages('scales')
6library(scales)
Alexander Afanasyev59314802012-11-26 14:56:04 -08007
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -08008# install.packages('doBy')
9library(doBy)
Alexander Afanasyev59314802012-11-26 14:56:04 -080010
11#########################
12# Rate trace processing #
13#########################
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080014data = read.table("rate-trace.txt", header=T)
15data$Node = factor(data$Node)
Alexander Afanasyev59314802012-11-26 14:56:04 -080016data$FaceId <- factor(data$FaceId)
17data$Kilobits <- data$Kilobytes * 8
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080018data$Type = factor(data$Type)
Alexander Afanasyev59314802012-11-26 14:56:04 -080019
20# exlude irrelevant types
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080021data = subset(data, Type %in% c("InInterests", "OutInterests", "InData", "OutData"))
Alexander Afanasyev59314802012-11-26 14:56:04 -080022
23# combine stats from all faces
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080024data.combined = summaryBy(. ~ Time + Node + Type, data=data, FUN=sum)
25
Alexander Afanasyev59314802012-11-26 14:56:04 -080026data.root = subset (data.combined, Node == "root")
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080027data.leaves = subset(data.combined, Node %in% c("leaf-1", "leaf-2", "leaf-3", "leaf-4"))
Alexander Afanasyev59314802012-11-26 14:56:04 -080028
29# graph rates on all nodes in Kilobits
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080030g.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 Afanasyev59314802012-11-26 14:56:04 -080034
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080035print(g.all)
36
Alexander Afanasyev59314802012-11-26 14:56:04 -080037# graph rates on the root nodes in Packets
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080038g.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 Afanasyev59314802012-11-26 14:56:04 -080042
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080043print(g.root)
Alexander Afanasyev59314802012-11-26 14:56:04 -080044
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080045png("src/ndnSIM/docs/source/_static/root-rates.png", width=500, height=250)
46print(g.root)
47retval <- dev.off()