# # 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 seeder=read.table(paste(target_folder, "p2p-next-01-105.log.data", sep="/"), header=T, sep=" ") leecher01=read.table(paste(target_folder, "p2p-next-03-105.log.data", sep="/"), header=T, sep=" ") leecher02=read.table(paste(target_folder, "p2p-next-04-105.log.data", sep="/"), header=T, sep=" ") leecher03=read.table(paste(target_folder, "p2p-next-05-105.log.data", sep="/"), header=T, sep=" ") leecher04=read.table(paste(target_folder, "p2p-next-06-105.log.data", sep="/"), header=T, sep=" ") leecher05=read.table(paste(target_folder, "p2p-next-07-105.log.data", sep="/"), header=T, sep=" ") leecher06=read.table(paste(target_folder, "p2p-next-08-105.log.data", sep="/"), header=T, sep=" ") leecher07=read.table(paste(target_folder, "p2p-next-09-105.log.data", sep="/"), header=T, sep=" ") leecher08=read.table(paste(target_folder, "p2p-next-10-105.log.data", sep="/"), header=T, sep=" ") # transform KB/s to Mbit/s leecher01$dlspeed <- leecher01$dlspeed*8/1000 leecher02$dlspeed <- leecher02$dlspeed*8/1000 leecher03$dlspeed <- leecher03$dlspeed*8/1000 leecher04$dlspeed <- leecher04$dlspeed*8/1000 leecher05$dlspeed <- leecher05$dlspeed*8/1000 leecher06$dlspeed <- leecher06$dlspeed*8/1000 leecher07$dlspeed <- leecher07$dlspeed*8/1000 leecher08$dlspeed <- leecher08$dlspeed*8/1000 # plot dlspeed-percent data p <- ggplot() + geom_point(aes(x=leecher01$percent, y=leecher01$dlspeed, label="Leecher 01"), size=1) + geom_point(aes(x=leecher02$percent, y=leecher02$dlspeed, label="Leecher 02"), size=1) + geom_point(aes(x=leecher03$percent, y=leecher03$dlspeed, label="Leecher 03"), size=1) + geom_point(aes(x=leecher04$percent, y=leecher04$dlspeed, label="Leecher 04"), size=1) + geom_point(aes(x=leecher05$percent, y=leecher05$dlspeed, label="Leecher 05"), size=1) + geom_point(aes(x=leecher06$percent, y=leecher06$dlspeed, label="Leecher 06"), size=1) + geom_point(aes(x=leecher07$percent, y=leecher07$dlspeed, label="Leecher 07"), size=1) + geom_point(aes(x=leecher08$percent, y=leecher08$dlspeed, label="Leecher 08"), size=1) + theme_bw() + scale_x_continuous("Percent", limits=c(0, 100), breaks=seq(0, 100, 10)) + scale_y_continuous("Download speed (Mbit/s)", limits=c(0, 8), breaks=seq(0, 8, 0.5)) + coord_cartesian() + scale_colour_manual("Legend") + opts(title=paste(campaign_name, "test-scenario-pre-post-nop-many: a test swarm (1 Seeder, 8 Leechers), all peers have an 8 Mbit/s upload BW limitation", sep="\n")) # plot data as an eps file postscript(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-percent.eps", sep="/")) print(p) dev.off() # plot data as an png file png(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-percent.png", sep="/"), width = 1280, height = 800) print(p) dev.off() # plot dlspeed-time data p <- ggplot() + geom_point(aes(x=leecher01$time, y=leecher01$dlspeed, label="Leecher 01"), size=1) + geom_point(aes(x=leecher02$time, y=leecher02$dlspeed, label="Leecher 02"), size=1) + geom_point(aes(x=leecher03$time, y=leecher03$dlspeed, label="Leecher 03"), size=1) + geom_point(aes(x=leecher04$time, y=leecher04$dlspeed, label="Leecher 04"), size=1) + geom_point(aes(x=leecher05$time, y=leecher05$dlspeed, label="Leecher 05"), size=1) + geom_point(aes(x=leecher06$time, y=leecher06$dlspeed, label="Leecher 06"), size=1) + geom_point(aes(x=leecher07$time, y=leecher07$dlspeed, label="Leecher 07"), size=1) + geom_point(aes(x=leecher08$time, y=leecher08$dlspeed, label="Leecher 08"), size=1) + theme_bw() + scale_x_continuous("Time(s)") + scale_y_continuous("Download speed (Mbit/s)", limits=c(0, 8), breaks=seq(0, 8, 0.5)) + coord_cartesian() + scale_colour_manual("Legend") + opts(title=paste(campaign_name, "test-scenario-pre-post-nop-many: a test swarm (1 Seeder, 8 Leechers), all peers have an 8 Mbit/s upload BW limitation", sep="\n")) # plot data as an eps file postscript(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-time.eps", sep="/")) print(p) dev.off() # plot data as an png file png(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-time.png", sep="/"), width = 1280, height = 800) print(p) dev.off()