From: Razvan Deaconescu Date: Sun, 19 Sep 2010 12:08:43 +0000 (+0300) Subject: ControlScripts/clients: add next-share X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=5d67714ba0931c67d856710c948257f47ea0d09a;p=p2p-testing-infrastructure.git ControlScripts/clients: add next-share add basic script (use tribler scripts for start) --- diff --git a/ControlScripts/clients/next-share/detect_complete_nextshare.sh b/ControlScripts/clients/next-share/detect_complete_nextshare.sh new file mode 100755 index 0000000..e828197 --- /dev/null +++ b/ControlScripts/clients/next-share/detect_complete_nextshare.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Copyright: George Milescu 2010 - george.milescu@gmail.com +# +# Bash script used to detect when a regular client (a leecher) finished downloading a torrent +# The script +# * monitors a log file provided as an argument +# * as long as the doe is not finished the script keeps running +# * when the doe is finished it returns 0 +# * blocks the caller - the script exits only when the doe has completed the download +# +# Script arguments: +# * log file + +if [ ! $# -eq 1 ]; then + echo "usage: $0 log-file" + exit 1 +fi + +LOG_FILE=$1 + +while true; do + if cat $LOG_FILE | grep DLSTATUS_SEEDING &> /dev/null; then + exit 0 + fi + + # Don't do continuous polling + sleep 5 +done diff --git a/ControlScripts/clients/next-share/parse_nextshare.sh b/ControlScripts/clients/next-share/parse_nextshare.sh new file mode 100755 index 0000000..2adfe09 --- /dev/null +++ b/ControlScripts/clients/next-share/parse_nextshare.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Copyright: George Milescu 2010 - george.milescu@gmail.com +# +# Bash script used to parse the log file generated by a tribler client and to generate a data file +# +# Script arguments: +# * a folder where the log and data files are stored +# * the name of a log file in that folder + + +if [ ! $# -eq 2 ]; then + echo "usage: $0 log-folder log-file" + exit 1 +fi + +LOG_FOLDER=$1 +LOG_FILE=$2 +DATA_FILE=$LOG_FOLDER/${LOG_FILE}.data + +# Check if the log folder exists +if [ ! -d $LOG_FOLDER ]; then + echo "Error: The folder $LOG_FOLDER does not exist." + exit 1 +fi + +# Check if the log file exists +if [ ! -e $LOG_FOLDER/$LOG_FILE ]; then + echo "Error: The log file $LOG_FOLDER/$LOG_FILE does not exist." + exit 1 +fi + +# Check if the log file is a regular file +if [ ! -f $LOG_FOLDER/$LOG_FILE ]; then + echo "Error: The log file $LOG_FOLDER/$LOG_FILE is not a regular file." + exit 1 +fi + +# Write the header to the data file +echo "time percent upspeed dlspeed" > $DATA_FILE + +# Clean and parse the log file +cat $LOG_FOLDER/$LOG_FILE | grep "DLSTATUS\|SLEEP" | grep -v "HASHCHECKING" | tr '\t' ' ' | tr -s ' ' | sed -e s/"%"/""/g -e s/"KB\/s"/""/g >> $DATA_FILE.tmp + +# Current relative time is=0 (we are at the beginning of the test) +rel_time=0 + +# Read all log lines and process the information for the plotting component +while read FILE_NAME STATUS PERCENT UNKNOWN UP UP_SPEED DOWN DOWN_SPEED; do + if [ " $FILE_NAME" = " SLEEP" ]; then + rel_time=$(($rel_time + $STATUS)) + else + echo "$rel_time $PERCENT $UP_SPEED $DOWN_SPEED" >>$DATA_FILE + rel_time=$(($rel_time + 1)) + fi +done <$DATA_FILE.tmp + +rm -f $DATA_FILE.tmp +exit 0 diff --git a/ControlScripts/clients/next-share/start_nextshare_leecher.sh b/ControlScripts/clients/next-share/start_nextshare_leecher.sh new file mode 100755 index 0000000..36bcd05 --- /dev/null +++ b/ControlScripts/clients/next-share/start_nextshare_leecher.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Copyright: George Milescu 2010 - george.milescu@gmail.com +# +# Bash script used to start a regular (non doe, non proxy) instance of tribler cmd-line +# The script +# * changes current working directory to proxyservice-m32 +# * starts a tribler cmd-line instance with the supplied .torrent file. The .torrent file must be located in the TorrentsAndData folder +# * at the end deletes the downloaded data +# +# If you run this script manually, you must run it from the P2P-Testing-Infrastructure/ControlScripts folder and use one argument: the torrent file name that will be loaded from the TorrentsAndData folder +# + +# 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 + +# Read the node-specific configuration file (TORRENT_FILE) +# Check if the node-specific configuration file exists +if [ ! -e ../ClientWorkingFolders/TmpLogs/node_config ]; then + echo "Warning: The global config file ../ClientWorkingFolders/TmpLogs/node_config does not exist." +else + source ../ClientWorkingFolders/TmpLogs/node_config +fi + +if [ " $TORRENT_FILE" = " " ]; then + TORRENT_FILE=$1 +fi + +export PYTHONPATH=$PYTHONPATH:. + +cd $TRIBLER_REL_PATH + +python2.6 Tribler/Tools/proxy-cmdline.py --proxymode off --test-mode off --port 25124 --state-dir $WORKING_FOLDER_REL_PATH/Regular/statedir --output-dir $WORKING_FOLDER_REL_PATH/Regular/ $WORKING_FOLDER_REL_PATH/TorrentsAndData/$TORRENT_FILE + +rm -rf $WORKING_FOLDER_REL_PATH/Regular/* diff --git a/ControlScripts/clients/next-share/start_nextshare_seeder.sh b/ControlScripts/clients/next-share/start_nextshare_seeder.sh new file mode 100755 index 0000000..3d4d097 --- /dev/null +++ b/ControlScripts/clients/next-share/start_nextshare_seeder.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Copyright: George Milescu 2010 - george.milescu@gmail.com +# +# Bash script used to start a seeder instance for the testing topology +# The script +# * changes current working directory to proxyservice-m32 +# * starts a command line BT client seeding the supplied .torrent file. The .torrent file must be located in the TorrentsAndData folder +# +# If you run this script manually, you must run it from the P2P-Testing-Infrastructure/ControlScripts folder and use one argument: the torrent file name that will be loaded from the TorrentsAndData folder +# + +# 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 + +# Read the node-specific configuration file (TORRENT_FILE) +# Check if the node-specific configuration file exists +if [ ! -e ../ClientWorkingFolders/TmpLogs/node_config ]; then + echo "Warning: The global config file ../ClientWorkingFolders/TmpLogs/node_config does not exist." +else + source ../ClientWorkingFolders/TmpLogs/node_config +fi + +if [ " $TORRENT_FILE" = " " ]; then + TORRENT_FILE=$1 +fi + +export PYTHONPATH=$PYTHONPATH:. + +cd $TRIBLER_REL_PATH + +python2.6 Tribler/Tools/proxy-cmdline.py --port 25125 --state-dir $WORKING_FOLDER_REL_PATH/Seeder/statedir --output-dir $WORKING_FOLDER_REL_PATH/TorrentsAndData/ $WORKING_FOLDER_REL_PATH/TorrentsAndData/$TORRENT_FILE + +rm -rf $WORKING_FOLDER_REL_PATH/Seeder/* diff --git a/ControlScripts/clients/next-share/stop_nextshare.sh b/ControlScripts/clients/next-share/stop_nextshare.sh new file mode 100755 index 0000000..65229ec --- /dev/null +++ b/ControlScripts/clients/next-share/stop_nextshare.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Copyright: George Milescu 2010 - george.milescu@gmail.com +# +# Bash script used to stop all tribler instances +# The script +# * stops all the tribler instances + +if [ ! $# -eq 0 ]; then + echo "usage: $0" + exit 1 +fi + +pkill python2.6