add generation script for tracker experiment
authorCalin Burloiu <calin.burloiu@gmail.com>
Tue, 19 Oct 2010 07:26:21 +0000 (10:26 +0300)
committerCalin Burloiu <calin.burloiu@gmail.com>
Tue, 19 Oct 2010 07:26:21 +0000 (10:26 +0300)
TestSpecs/gen/tracker-tgen [new file with mode: 0755]

diff --git a/TestSpecs/gen/tracker-tgen b/TestSpecs/gen/tracker-tgen
new file mode 100755 (executable)
index 0000000..75a25f9
--- /dev/null
@@ -0,0 +1,148 @@
+#!/bin/bash
+
+#
+# Test scenario generators - generates *.cfg files
+#
+# 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
+#
+# Sample run:
+#   ./tgen gogu P2P_Experimente_Swarm-metrics.csv
+#
+
+if test $# -ne 2; then
+       echo "Usage: $0 campaign-name test-description-file" 1>&2
+       exit 1
+fi
+
+campaign_name=$1
+input=$2
+
+parse_conn()
+{
+       echo "" | awk -v var="$1" '{print var + 0;}'
+}
+
+parse_bw()
+{
+       echo "" | awk -v var="$1" '{print var + 0;}'
+}
+
+parse_file()
+{
+       size=$(echo "" | awk -v var="$1" '{print var + 0;}')
+       echo "Data.${size}M.ct.torrent"
+}
+
+generate_scenario()
+{
+       exp_no=$1
+       num_seeders=$2
+       num_leechers=$3
+       num_conn=$4
+       down_bw=$5
+       up_bw=$6
+       seed_torrent=$7
+       description=$8
+
+       echo -e "#\n# Campaign $campaign_name; scenario $exp_no\n#"
+       echo "### BEGIN SCENARIO INFO"
+       echo "# Campaign: $campaign_name"
+       echo "# Id: $exp_no"
+       echo "# Description: $description"
+       echo "# Number of seeders: $num_seeders"
+       echo "# Number of leechers: $num_leechers"
+       echo "# Maximum download: $down_bw"
+       echo "# Maximum upload: $down_bw"
+       echo "# Client type: hrktorrent (libtorrent-rasterbar)"
+       echo "### END SCENARIO INFO"
+       echo ""
+
+       echo -e "# Hostname\t\t\tSSHport\t\tUser\t\tRemoteFolder\t\tNetInterface\t\tDownload(Mbps)\tDownloadBurst(K)\tUpload(Mbps)\tUploadBurst(K)\tOverallNoOfConnections\tPreRunScript\t\tPostRunScript\t\tClientType\t\t\tTorrentFile\t\tPeriods"
+       index=0
+       for sys_index in 01 03 04 05 06 07 08 09 10; do
+               for ce_index in 1 2 3 4 5 6 7 8 9 10; do
+                       echo -en "p2p-next-$sys_index.grid.pub.ro\t\t"
+                       echo -en "1$(printf %02g $ce_index)22\t\t"
+                       echo -en "p2p\t\t"
+                       echo -en "/home/p2p/george\t"
+                       echo -en "eth0\t\t\t"
+                       echo -en "$down_bw\t\t"
+                       echo -en "100\t\t\t"
+                       echo -en "$up_bw\t\t"
+                       echo -en "100\t\t"
+                       echo -en "$num_conn\t\t\t"
+                       echo -en "pre-run_nop.sh\t\t"
+                       echo -en "post-run_nop.sh\t\t"
+
+                       if test $index -lt $num_seeders; then
+                               echo -en "hrktorrent_seeder_limit\t\t"
+                       elif test $index -lt $(($num_seeders+$num_leechers)); then
+                               echo -en "hrktorrent_leecher_limit\t"
+                       fi
+
+                       echo -en "$seed_torrent\t"
+                       echo "(0,-)"
+
+                       index=$((index+1))
+
+                       if test $index -ge $(($num_seeders+$num_leechers)); then
+                               return
+                       fi
+               done
+       done
+}
+
+campaign_file=${campaign_name}.cfg
+
+> "${campaign_file}" cat <<END
+#
+# ${campaign_name}
+#
+# Scenario description         R script for plotting
+END
+
+html_file=${campaign_name}.html
+cat start.html > ${html_file}
+cat >> ${html_file} <<END
+        <table id="box-table-a" summary="${campaign_name} results">
+          <thead>
+            <tr>
+              <th scope="col">Name</th>
+              <th scope="col">No. of Seeders</th>
+              <th scope="col">No. of Leechers</th>
+              <th scope="col">Bandwidth Rectrictions</th>
+              <th scope="col">Graphs</th>
+            </tr>
+          </thead>
+          <tbody>
+END
+
+while IFS="," read no_trackers data_size down_bw up_bw; do
+       this_down_bw=${down_bw}
+       this_up_bw=${up_bw}
+       this_seed_torrent=$(parse_file $data_size)
+
+       # generate test scenario
+       generate_scenario "$exp_no" "$num_seeders" "$num_leechers" "$this_conn" "$this_down_bw" "$this_up_bw" "$this_seed_torrent" "$description" > "${campaign_name}-${exp_no}".cfg
+
+       # update campaign configuration file
+       echo -e "${campaign_name}-${exp_no}.cfg\t${campaign_name}-${exp_no}.R" >> "${campaign_file}"
+
+       # update campaign HTML file
+       cat >> ${html_file} <<END
+            <tr>
+              <td>${campaign_name}-${exp_no}</td>
+              <td>${num_seeders}</td>
+              <td>${num_leechers}</td>
+              <td>TODO</td>
+              <td><a href="${campaign_name}-${exp_no}/${campaign_name}-${exp_no}-dlspeed-percent.png">dlspeed vs percent</a>; <a href="${campaign_name}-${exp_no}/${campaign_name}-${exp_no}-dlspeed-time.png">dlspeed vs time</a></td>
+            </tr>
+END
+done < $input
+
+cat >> ${html_file} <<END
+          </tbody>
+        </table>
+END
+
+cat end.html >> ${html_file}