2 # Copyright: George Milescu 2010 - george.milescu@gmail.com
4 # R script used to plot the results of a scenario
9 # Read transmitted command line arguments
10 args <- commandArgs(trailingOnly = TRUE)
12 # The data files are located in the target folder. Also, the graph will be saved in the target folder.
13 target_folder <- args[2]
14 campaign_name <- args[3]
17 # read data from the data file
18 seeder=read.table(paste(target_folder, "p2p-next-08-103.log.data", sep="/"), header=T, sep=" ")
19 leecher=read.table(paste(target_folder, "p2p-next-08-105.log.data", sep="/"), header=T, sep=" ")
22 # transform KB/s to Mbit/s
23 leecher$dlspeed <- leecher$dlspeed*8/1000
26 # plot dlspeed-percent data
28 geom_point(aes(x=leecher$percent, y=leecher$dlspeed, label="Leecher"), size=1) +
30 scale_x_continuous("Percent", limits=c(0, 100), breaks=seq(0, 100, 10)) +
31 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, 8), breaks=seq(0, 8, 0.5)) +
33 scale_colour_manual("Legend") +
34 opts(title=paste(campaign_name, "test-scenario-pre-post-nop: a test swarm (1 Seeder, 1 Leecher), all peers have an 8 Mbit/s BW (upload-only)", sep="\n"))
36 # plot data as an eps file
37 postscript(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-percent.eps", sep="/"))
41 # plot data as an png file
42 png(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-percent.png", sep="/"), width = 1280, height = 800)
48 # plot dlspeed-time data
50 geom_point(aes(x=leecher$time, y=leecher$dlspeed, label="Leecher"), size=1) +
52 scale_x_continuous("Time(s)") +
53 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, 8), breaks=seq(0, 8, 0.5)) +
55 scale_colour_manual("Legend") +
56 opts(title=paste(campaign_name, "test-scenario-pre-post-nop: a test swarm (1 Seeder, 1 Leecher), all peers have an 8 Mbit/s BW upload-only", sep="\n"))
58 # plot data as an eps file
59 postscript(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-time.eps", sep="/"))
63 # plot data as an png file
64 png(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-time.png", sep="/"), width = 1280, height = 800)