Infrastructure ready for BitTorrent Transport protocols comparison: integration of...
authorP2P-Next <p2p@p2p-next.grid.pub.ro>
Thu, 19 May 2011 12:17:59 +0000 (15:17 +0300)
committerP2P-Next <p2p@p2p-next.grid.pub.ro>
Thu, 19 May 2011 12:17:59 +0000 (15:17 +0300)
ControlScripts/clients/swift/start_swift_leecher.sh
ControlScripts/clients/swift/start_swift_seeder.sh
ControlScripts/globalconfig
ControlScripts/hook_monitor_pid.sh [new file with mode: 0755]

index 0ac6f1a..2c69bff 100755 (executable)
@@ -39,6 +39,8 @@ echo "" > ~/deb
 echo $SCHEDULE_CLIENT_PID  >> ~/deb
 ps -ef | grep schedule_client >> ~/deb
 
-./swift -h "$HASH" -t "${TRACKER_IP}:6881" -p 
+echo "***!#"
+echo ./swift -h "$HASH" -t "${TRACKER_IP}:6882" -p 
+./swift -h "$HASH" -t "${TRACKER_IP}:6882" -p 
 
 rm -f ${HASH}*
index 3c2128b..93217c1 100755 (executable)
@@ -28,33 +28,36 @@ else
 fi
 
 # 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
-}
-
-OWN_IP=$(hostname_to_ip $(hostname))
+#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
+#}
+#
+#OWN_IP=$(hostname_to_ip $(hostname))
+OWN_IP="0.0.0.0" #"10.42.5.225"
 cd "$WORKING_FOLDER_REL_PATH"/TorrentsAndData
 DATA_PATH=$(pwd)
 
 cd $SWIFT_ABS_PATH
 
 #echo ./swift -f "${DATA_PATH}"/"${TORRENT_FILE}" -l ${OWN_IP}:6881 -p > ~/deb
-./swift -f "${DATA_PATH}"/"${TORRENT_FILE}" -l ${OWN_IP}:6881 -p
+echo "***!@"
+echo ./swift -f "${DATA_PATH}"/"${TORRENT_FILE}" -l ${OWN_IP}:6882 -p
+./swift -f "${DATA_PATH}"/"${TORRENT_FILE}" -l ${OWN_IP}:6882 -p
index 1f6e42c..4ed9c60 100644 (file)
@@ -41,7 +41,7 @@ XBTUT_ABS_PATH="/home/p2p/export/unified-tracker/trunk/xbt/Tracker"
 XBT_ABS_PATH="/home/p2p/export/xbt_tracker/xbt/Tracker" 
 
 # SWIFT_PATH
-SWIFT_ABS_PATH="/home/p2p/swift-vs-utp/swift"
+SWIFT_ABS_PATH="/home/p2p/p2p-clients/swift"
 
 # WORKING_FOLDER_REL_PATH is relative to TRIBLER_ABS_PATH folder
 WORKING_FOLDER_REL_PATH="../../P2P-Testing-Infrastructure/ClientWorkingFolders"
diff --git a/ControlScripts/hook_monitor_pid.sh b/ControlScripts/hook_monitor_pid.sh
new file mode 100755 (executable)
index 0000000..e4f7556
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+#
+# monitor process resources using systat (/proc), free, iptables and /sys
+#
+# 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
+#
+
+# command line argument must be a process id
+if test $# -ne 1; then
+       echo "Usage: $0 <pid>" 1>&2
+       exit 1
+fi
+
+pid=$1
+
+# check if pid exists
+kill -0 $pid > /dev/null 2>&1
+if test $? -ne 0; then
+       ps -ef
+       echo -e "PID $pid does not exists.\nUsage: $0 <pid>" 1>&2
+       exit 1
+fi
+
+# use _DEBUG="off" to turn off debug printing
+_DEBUG="off"
+
+# Read the global configuration file
+# Check if the global configuration file exists
+if [ ! -e globalconfig ]; then
+       echo "Warning: The global config file globalconfig does not exist."
+else
+       source globalconfig
+fi
+
+# cleanup code (run as signal handler)
+cleanup()
+{
+       kill -TERM $pidstat_pid
+       kill -TERM $iostat_pid
+       kill -TERM $free_pid
+       kill -TERM $timer_callback_pid
+}
+
+# function acting like a periodic callback
+timer_callback()
+{
+       while true; do
+               date +%F-%X
+               sudo iptables -t filter -L -n -v
+               cat /sys/class/net/eth0/statistics/rx_bytes /sys/class/net/eth0/statistics/tx_bytes
+               sleep 1
+       done
+}
+
+# run cleanup on signal receive
+trap cleanup 0 1 2 3 15
+
+# per-process processor (-u), disk (-d) and memory usage (-r)
+pidstat -u -d -r -p $pid 1 &
+pidstat_pid=$!
+
+# per-system (iostat and free)
+iostat -d -c 1 &
+iostat_pid=$!
+free -s 1 &
+free_pid=$!
+
+# per-process network bandwidth usage (iptables)
+# /sys/class/net/$iface/statistics/{tx,rx}_bytes (per system)
+
+# remove old iptables rules/chains
+sudo iptables -t filter -F cout > /dev/null 2>&1
+sudo iptables -t filter -F cin > /dev/null 2>&1
+sudo iptables -t filter -X cout > /dev/null 2>&1
+sudo iptables -t filter -X cin > /dev/null 2>&1
+sudo iptables -t filter -F OUTPUT > /dev/null 2>&1
+
+# add iptables rule
+sudo iptables -t filter -N cout
+sudo iptables -t filter -N cin
+sudo iptables -t filter -A OUTPUT -j cout
+sudo iptables -t filter -A cout -j ACCEPT
+sudo iptables -t filter -A OUTPUT -j cin
+sudo iptables -t filter -A cin -j ACCEPT
+
+timer_callback &
+timer_callback_pid=$!
+
+# wait for child processes to end (shouldn't happen)
+wait