LOG_FOLDER=$1
LOG_FILE=$2
DATA_FILE=$LOG_FOLDER/${LOG_FILE}.data
+PEER_DOWNLOAD_FILE=$LOG_FOLDER/${LOG_FILE}.down
+PEER_UPLOAD_FILE=$LOG_FOLDER/${LOG_FILE}.up
# Check if the log folder exists
if [ ! -d $LOG_FOLDER ]; then
if ($1 == "SLEEP")
rel_time = rel_time + $2;
else {
- lspeed = $6 + 0;
+ dlspeed = $6 + 0;
upspeed = $8 + 0;
download = $10 + 0;
size = $14 + 0;
}
}' >> $DATA_FILE
+# convert host_id and veid to veth IP address in 10.0.0.0/8 network
+host_veid_to_eth_ip()
+{
+ host_id=$1
+ veid=$2
+ ip_part1=$(($veid / 100))
+ ip_part2=$(($veid % 100))
+ id=$(echo "$host_id" | awk '{printf "%d", $1;}')
+ echo "10.$ip_part1.$id.$ip_part2"
+}
+
+# convert p2p-next-${host_id}-${veid} hostname to veth IP address
+hostname_to_ip()
+{
+ hostname=$1
+
+ veid=${hostname##*-}
+ tmp=${hostname%-*}
+ host_id=${tmp##*-}
+
+ host_veid_to_eth_ip $host_id $veid
+}
+
+local_ip=$(hostname_to_ip ${LOG_FILE/%.log/})
+
+# Parse the peer log file; output peer download and upload files
+
+grep '^--Peers\|SLEEP' $LOG_FOLDER/$LOG_FILE | awk -v ip=${local_ip} -F '[],() []+' '
+{
+ printf "[%s %s %s]", $2, $3, $4;
+ i = 6;
+ for (i = 6; i < NF; i += 6) {
+ j = i+2;
+ speed = $j + 0;
+ split($i, ip_port, ":");
+ printf " (%s, %s, %s)", ip, ip_port[1], speed;
+ }
+ printf "\n";
+}' > $PEER_DOWNLOAD_FILE
+
+grep '^--Peers\|SLEEP' $LOG_FOLDER/$LOG_FILE | awk -v ip=${local_ip} -F '[],() []+' '
+{
+ printf "[%s %s %s]", $2, $3, $4;
+ i = 6;
+ for (i = 6; i < NF; i += 6) {
+ j = i+4;
+ speed = $j + 0;
+ split($i, ip_port, ":");
+ printf " (%s, %s, %s)", ip, ip_port[1], speed;
+ }
+ printf "\n";
+}' > $PEER_UPLOAD_FILE
+
exit 0