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
104 leecher${index}\$dlspeed <- leecher${index}\$dlspeed*8/1000
107 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
111 # plot dlspeed-percent data
116 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
117 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 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
129 scale_x_continuous("Percent", limits=c(0, 100), breaks=seq(0, 100, 10)) +
130 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, ${dl_max_limit}), breaks=seq(0, ${dl_max_limit}, 0.5)) +
132 scale_colour_manual("Legend") +
133 opts(title=paste(campaign_name, "${scenario_name}: a test swarm (${num_seeders} Seeders, ${num_leechers} Leechers), ${description}", sep="\n"))
135 # plot data as an eps file
136 postscript(paste(target_folder, "${scenario_name}-dlspeed-percent.eps", sep="/"))
140 # plot data as an png file
141 png(paste(target_folder, "${scenario_name}-dlspeed-percent.png", sep="/"), width = 1280, height = 800)
146 # plot dlspeed-time data
151 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
152 if ! test_is_leecher ${client_type}; then
157 geom_point(aes(x=leecher${index}\$time, y=leecher${index}\$dlspeed, label="Leecher ${index}"), size=1) +
160 done < <(grep -v '^#\|^[ \t]*$' ${scenario_file})
164 scale_x_continuous("Time(s)") +
165 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, ${dl_max_limit}), breaks=seq(0, ${dl_max_limit}, 0.5)) +
167 scale_colour_manual("Legend") +
168 opts(title=paste(campaign_name, "${scenario_name}: a test swarm (${num_seeders} Seeders, ${num_leechers} Leechers), ${description}", sep="\n"))
170 # plot data as an eps file
171 postscript(paste(target_folder, "${scenario_name}-dlspeed-time.eps", sep="/"))
175 # plot data as an png file
176 png(paste(target_folder, "${scenario_name}-dlspeed-time.png", sep="/"), width = 1280, height = 800)