--- /dev/null
+#!/usr/bin/awk -f
+# Calculates the average value of 2 columns. Lines with the first column 0 are not taken into account.
+
+BEGIN {
+ n_items = 0
+ sum1 = 0.0
+ sum2 = 0.0
+ FS = "[ \t]+"
+}
+
+/^[0-9]+/ {
+ if($1 != 0)
+ {
+ n_items++
+ sum1 += $1
+ sum2 += $2
+ }
+}
+
+END {
+ printf "%f %f\n", sum1 / n_items, sum2 / n_items
+}
--- /dev/null
+#!/usr/bin/awk -f
+# Calculates the download time and the average download speed in this time for a peer, printed in this order. The input is the *.log.data file content of the peer.
+
+BEGIN {
+ n_items = 0
+ dl_speed_sum = 0.0
+ done = 0
+ FS = "[ \t]+"
+}
+
+/^[0-9]+/ {
+ if($2 != 100 || $2 == 100 && done == 0)
+ {
+ n_items++
+ dl_speed_sum += $4
+ }
+ if($2 == 100)
+ done = 1
+}
+
+END {
+ printf "%d %f\n", n_items-1, dl_speed_sum / n_items
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright: Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script calculates the download time and the average download speed for an entire swarm, printed in this order and taking as input the directory where the peers' *.log.data file are located. Requires script avg2 and get_time_dl_speed_avg.
+
+path=.
+
+if [ $# -gt 0 ]; then
+ path=$1
+fi
+
+rm -f temp1987
+touch temp1987
+
+for i in $(find $path -mindepth 1 -mindepth 1 -name '*.log.data'); do
+ (./get_time_dl_speed_avg < "$i") >> temp1987
+done
+
+./avg2 < temp1987
+
+rm -f temp1987
--- /dev/null
+for i in $(find ../Results/tsup-1t-2-2010.11.11-08.20.53/ -mindepth 1 -mindepth 1 -type d); do ./get_time_dl_speed_avg_for_swarm $i > $i/time_dl_speed_avg.data; done