4 # Generate R script for plot processing from campaign and scenario
8 # ./rgen performance-experiments-3.01.cfg > out.R
11 if test $# -ne 1; then
12 echo "Usage: $0 scenario-config-file" 1>&2
18 scenario_name=$(basename ${scenario_file} .cfg)
27 # parse comment zone in scenario file (description, leechers, seeders etc.)
30 num_trackers=$(grep "^[ \t]*#[ \t]*Number of trackers:" ${scenario_file} | awk -F ":" '{print $2;}')
31 num_leechers=$(grep "^[ \t]*#[ \t]*Number of leechers:" ${scenario_file} | awk -F ":" '{print $2;}')
32 num_seeders=$(grep "^[ \t]*#[ \t]*Number of seeders:" ${scenario_file} | awk -F ":" '{print $2;}')
33 dl_max_limit=$(grep "^[ \t]*#[ \t]*Maximum download:" ${scenario_file} | awk -F ":" '{print $2;}')
34 dl_max_upload=$(grep "^[ \t]*#[ \t]*Maximum upload:" ${scenario_file} | awk -F ":" '{print $2;}')
35 description=$(grep "^[ \t]*#[ \t]*Description:" ${scenario_file} | awk -F ":" '{print $2;}')
38 # test client description for "leecher" string
43 grep "leecher" <<<"${client_type}" &> /dev/null
46 # test client description for "seeder" string
51 grep "seeder" <<<"${client_type}" &> /dev/null
60 # Read transmitted command line arguments
61 args <- commandArgs(trailingOnly = TRUE)
63 # The data files are located in the target folder. Also, the graph will be saved in the target folder.
64 target_folder <- args[2]
65 campaign_name <- args[3]
68 # read data from the data file
72 while read server port user remote_path remote_if dl_bw dl_burst ul_bw ul_burst num_conn pre_run_script post_run_script client_type torrent_file periods; do
74 if test -z "${new_port}"; then
75 base_log_name=${server%%.*}
77 base_log_name=${server%%.*}-${new_port}
79 if test_is_leecher ${client_type}; then
80 base_client_name="leecher"
81 elif test_is_seeder ${client_type}; then
82 base_client_name="seeder"
84 base_client_name="tracker"
86 if [ ${base_client_name} != "tracker" ]; then
88 ${base_client_name}${index}=read.table(paste(target_folder, "${base_log_name}.log.data", sep="/"), header=T, sep=" ")
92 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
96 # transform KB/s to Mbit/s
100 while read server port user remote_path remote_if dl_bw dl_burst ul_bw ul_burst num_conn pre_run_script post_run_script client_type torrent_file periods; do
101 if ! test_is_leecher ${client_type}; then
106 leecher${index}\$dlspeed <- leecher${index}\$dlspeed*8/1000
109 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
113 # plot dlspeed-percent data
118 while read server port user remote_path remote_if dl_bw dl_burst ul_bw ul_burst num_conn pre_run_script post_run_script client_type torrent_file periods; do
119 if ! test_is_leecher ${client_type}; then
124 geom_point(aes(x=leecher${index}\$percent, y=leecher${index}\$dlspeed, label="Leecher ${index}"), size=1) +
127 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
131 scale_x_continuous("Percent", limits=c(0, 100), breaks=seq(0, 100, 10)) +
132 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, ${dl_max_limit}), breaks=seq(0, ${dl_max_limit}, 0.5)) +
134 scale_colour_manual("Legend") +
135 opts(title=paste(campaign_name, "${scenario_name}: a test swarm (${num_seeders} Seeders, ${num_leechers} Leechers, ${num_trackers} Trackers), ${description}", sep="\n"))
137 # plot data as an eps file
138 postscript(paste(target_folder, "${scenario_name}-dlspeed-percent.eps", sep="/"))
142 # plot data as an png file
143 png(paste(target_folder, "${scenario_name}-dlspeed-percent.png", sep="/"), width = 1280, height = 800)
148 # plot dlspeed-time data
153 while read server port user remote_path remote_if dl_bw dl_burst ul_bw ul_burst num_conn pre_run_script post_run_script client_type torrent_file periods; do
154 if ! test_is_leecher ${client_type}; then
159 geom_point(aes(x=leecher${index}\$time, y=leecher${index}\$dlspeed, label="Leecher ${index}"), size=1) +
162 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
166 scale_x_continuous("Time(s)") +
167 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, ${dl_max_limit}), breaks=seq(0, ${dl_max_limit}, 0.5)) +
169 scale_colour_manual("Legend") +
170 opts(title=paste(campaign_name, "${scenario_name}: a test swarm (${num_seeders} Seeders, ${num_leechers} Leechers, ${num_trackers} Trackers), ${description}", sep="\n"))
172 # plot data as an eps file
173 postscript(paste(target_folder, "${scenario_name}-dlspeed-time.eps", sep="/"))
177 # plot data as an png file
178 png(paste(target_folder, "${scenario_name}-dlspeed-time.png", sep="/"), width = 1280, height = 800)