# # Copyright: George Milescu 2010 - george.milescu@gmail.com # # R script used to plot the results of a scenario # import ggplot2 library(ggplot2) # Read transmitted command line arguments args <- commandArgs(trailingOnly = TRUE) # The data files are located in the target folder. Also, the graph will be saved in the target folder. target_folder <- args[2] campaign_name <- args[3] rm(args) # read data from the data file doe=read.table(paste(target_folder, "p2p-next-01.log.data", sep="/"), header=T, sep=" ") proxy01=read.table(paste(target_folder, "p2p-next-03.log.data", sep="/"), header=T, sep=" ") proxy02=read.table(paste(target_folder, "p2p-next-04.log.data", sep="/"), header=T, sep=" ") # transform KB/s to Mbit/s doe$dlspeed <- doe$dlspeed*8/1000 proxy01$dlspeed <- proxy01$dlspeed*8/1000 proxy02$dlspeed <- proxy02$dlspeed*8/1000 # plot dlspeed-percent data p <- ggplot() + geom_point(aes(x=doe$percent, y=doe$dlspeed, label="Doe", colour="Doe"), size=1) + geom_point(aes(x=proxy01$percent, y=proxy01$dlspeed, label="Proxy 01", colour="Proxy 01"), size=1) + geom_point(aes(x=proxy02$percent, y=proxy02$dlspeed, label="Proxy 02", colour="Proxy 02"), size=1) + theme_bw() + scale_x_continuous("Percent", limits=c(0, 100), breaks=seq(0, 100, 10)) + scale_y_continuous("Download speed (Mbit/s)") + coord_cartesian() + scale_colour_manual("Legend", c("Doe"="red", "Proxy 01"="magenta", "Proxy 02"="cyan")) + opts(title=paste(campaign_name, "Scenario-07: a seeded swarm (6 Seeders, 1 Doe, 2 Proxies),\nthe proxies have an 32 Mbit/s BW, all other peers have an 8 Mbit/s BW", sep="\n")) # plot data as an eps file postscript(paste(target_folder, "scenario07-dlspeed-percent.eps", sep="/")) print(p) dev.off() # plot data as an png file png(paste(target_folder, "scenario07-dlspeed-percent.png", sep="/"), width = 1280, height = 800) print(p) dev.off() # plot dlspeed-time data p <- ggplot() + geom_point(aes(x=doe$time, y=doe$dlspeed, label="Doe", colour="Doe"), size=1) + geom_point(aes(x=proxy01$time, y=proxy01$dlspeed, label="Proxy 01", colour="Proxy 01"), size=1) + geom_point(aes(x=proxy02$time, y=proxy02$dlspeed, label="Proxy 02", colour="Proxy 02"), size=1) + theme_bw() + scale_x_continuous("Time (s)") + scale_y_continuous("Download speed (Mbit/s)") + coord_cartesian() + scale_colour_manual("Legend", c("Doe"="red", "Proxy 01"="magenta", "Proxy 02"="cyan")) + opts(title=paste(campaign_name, "Scenario-07: a seeded swarm (6 Seeders, 1 Doe, 2 Proxies),\nthe proxies have an 32 Mbit/s BW, all other peers have an 8 Mbit/s BW", sep="\n")) # plot data as an eps file postscript(paste(target_folder, "scenario07-dlspeed-time.eps", sep="/")) print(p) dev.off() # plot data as an png file png(paste(target_folder, "scenario07-dlspeed-time.png", sep="/"), width = 1280, height = 800) print(p) dev.off()