From d2925b32194f9e3bbe1043f3e9492a4a00bf8b76 Mon Sep 17 00:00:00 2001 From: P2P-Next Date: Thu, 19 May 2011 15:17:59 +0300 Subject: [PATCH] Infrastructure ready for BitTorrent Transport protocols comparison: integration of swift and transmission (TCP and uTP) is ready. Delay measurement not yet integrated. --- .../clients/swift/start_swift_leecher.sh | 4 +- .../clients/swift/start_swift_seeder.sh | 51 ++++++----- ControlScripts/globalconfig | 2 +- ControlScripts/hook_monitor_pid.sh | 91 +++++++++++++++++++ 4 files changed, 122 insertions(+), 26 deletions(-) create mode 100755 ControlScripts/hook_monitor_pid.sh diff --git a/ControlScripts/clients/swift/start_swift_leecher.sh b/ControlScripts/clients/swift/start_swift_leecher.sh index 0ac6f1a..2c69bff 100755 --- a/ControlScripts/clients/swift/start_swift_leecher.sh +++ b/ControlScripts/clients/swift/start_swift_leecher.sh @@ -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}* diff --git a/ControlScripts/clients/swift/start_swift_seeder.sh b/ControlScripts/clients/swift/start_swift_seeder.sh index 3c2128b..93217c1 100755 --- a/ControlScripts/clients/swift/start_swift_seeder.sh +++ b/ControlScripts/clients/swift/start_swift_seeder.sh @@ -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 diff --git a/ControlScripts/globalconfig b/ControlScripts/globalconfig index 1f6e42c..4ed9c60 100644 --- a/ControlScripts/globalconfig +++ b/ControlScripts/globalconfig @@ -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 index 0000000..e4f7556 --- /dev/null +++ b/ControlScripts/hook_monitor_pid.sh @@ -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 " 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 " 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 -- 2.20.1