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)
26 # parse comment zone in scenario file (description, leechers, seeders etc.)
29 num_leechers=$(grep "^[ \t]*#[ \t]*Number of leechers:" ${scenario_file} | awk -F ":" '{print $2;}')
30 num_seeders=$(grep "^[ \t]*#[ \t]*Number of seeders:" ${scenario_file} | awk -F ":" '{print $2;}')
31 dl_max_limit=$(grep "^[ \t]*#[ \t]*Maximum download:" ${scenario_file} | awk -F ":" '{print $2;}')
32 dl_max_upload=$(grep "^[ \t]*#[ \t]*Maximum upload:" ${scenario_file} | awk -F ":" '{print $2;}')
33 description=$(grep "^[ \t]*#[ \t]*Description:" ${scenario_file} | awk -F ":" '{print $2;}')
36 # test client description for "leecher" string
41 grep "leecher" <<<"${client_type}" &> /dev/null
44 # test client description for "seeder" string
49 grep "seeder" <<<"${client_type}" &> /dev/null
58 # Read transmitted command line arguments
59 args <- commandArgs(trailingOnly = TRUE)
61 # The data files are located in the target folder. Also, the graph will be saved in the target folder.
62 target_folder <- args[2]
63 campaign_name <- args[3]
66 # read data from the data file
70 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
72 if test -z "${new_port}"; then
73 base_log_name=${server%%.*}
75 base_log_name=${server%%.*}-${new_port}
77 if test_is_leecher ${client_type}; then
78 base_client_name="leecher"
79 elif test_is_seeder ${client_type}; then
80 base_client_name="seeder"
82 base_client_name="tracker"
84 if [ ${base_client_name} != "tracker" ]; then
86 ${base_client_name}${index}=read.table(paste(target_folder, "${base_log_name}.log.data", sep="/"), header=T, sep=" ")
90 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
94 # transform KB/s to Mbit/s
98 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
99 if test_is_leecher ${client_type}; then
101 leecher${index}\$dlspeed <- leecher${index}\$dlspeed*8/1000
104 elif test_is_seeder ${client_type}; then
110 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
114 # plot dlspeed-percent data
119 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
120 if test_is_leecher ${client_type}; then
122 geom_point(aes(x=leecher${index}\$percent, y=leecher${index}\$dlspeed, label="Leecher ${index}"), size=1) +
125 elif test_is_seeder ${client_type}; then
131 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
135 scale_x_continuous("Percent", limits=c(0, 100), breaks=seq(0, 100, 10)) +
136 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, ${dl_max_limit}), breaks=seq(0, ${dl_max_limit}, 0.5)) +
138 scale_colour_manual("Legend") +
139 opts(title=paste(campaign_name, "${scenario_name}: a test swarm (${num_seeders} Seeders, ${num_leechers} Leechers), ${description}", sep="\n"))
141 # plot data as an eps file
142 postscript(paste(target_folder, "${scenario_name}-dlspeed-percent.eps", sep="/"))
146 # plot data as an png file
147 png(paste(target_folder, "${scenario_name}-dlspeed-percent.png", sep="/"), width = 1280, height = 800)
152 # plot dlspeed-time data
157 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
158 if test_is_leecher ${client_type}; then
160 geom_point(aes(x=leecher${index}\$time, y=leecher${index}\$dlspeed, label="Leecher ${index}"), size=1) +
163 elif test_is_seeder ${client_type}; then
169 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
173 scale_x_continuous("Time(s)") +
174 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, ${dl_max_limit}), breaks=seq(0, ${dl_max_limit}, 0.5)) +
176 scale_colour_manual("Legend") +
177 opts(title=paste(campaign_name, "${scenario_name}: a test swarm (${num_seeders} Seeders, ${num_leechers} Leechers), ${description}", sep="\n"))
179 # plot data as an eps file
180 postscript(paste(target_folder, "${scenario_name}-dlspeed-time.eps", sep="/"))
184 # plot data as an png file
185 png(paste(target_folder, "${scenario_name}-dlspeed-time.png", sep="/"), width = 1280, height = 800)