Last script for now is the download exercise script.
./download-exercise.bash -r 1.234
Uses a file datamap.list to get datamap addresses to download, one file address per line. This file is generated by the upload-exercise.bash script.
Alternatively the datamap.list file can be obtained from anther person or place. Can be their uploads only of many can be combined from many people’s uploads.
download-exercise.zip (1.7 KB)
Again just extract to the directory created for any of the other scripts above
#
#
# Script to download files using the datamap addresses contained in datamap.list
#
# download-exercise -r 1.234
#
# This is the complementry script to the upload-exercise.bash Script
#
# It uses the datamap.list file to request files from teh network. These should be already uploaded public
# files uploaded by the person or a list obtained from a central source
#
# Uses the ant client to do the download and discards the download after its complete. This is not
# a script to get you files but to exercise the downloading capabilities of the network and provide
# some stresses to the nodes. Not much since the genesis network os doing sod all and 10 million
# nodes at the time of writing.
#
# Just one machine running this script will have little impact, but the more people that run it the
# better stress testing that will occur. It is not a be all end all stress test but one component,
# with another being the quoting of random files and also uploading of random files.
#
# The script will perform downloads at the rate requested by putting into the background the download.
# Thus there will be overlapping downloads occurring at the same time.
#
# This requires the filename used to be different for each download requested and obviously
# needs cleaning up afterwards
#
#
#################
#
# parameters
# -r secs - rate in decimal seconds
# Each download will be issued every (approx) seconds after the previous one
# Downloads are performed as a background task and output sent to /dev/null
#
#
########################################################################################################
# Some declarations and ensure sub directories are there
########################################################################################################
declare -i i j k downloadCnt
datamapFile="datamap.list"
if [[ ! -d tmp ]]; then mkdir tmp; fi
########################################################################################################
# Check for rate of quoting - too fast and system will start falling over itself
########################################################################################################
if [[ ! -z $1 ]] && [[ ${1} == "-r" ]]
then
if [[ ! -z $2 ]] && ( [[ ${2} =~ ^[1-9][0-9]*[.]*[0-9]*$ ]] || [[ ${2} =~ ^0.[0-9]*$ ]] )
then
downloadRate="${2}"
else
echo "ERROR: invalid download rate supplied. Decimal number required" >&2
exit
fi
else
downloadRate="120.0"
fi
########################################################################################################
########################################################################################################
#
# FUNCTION: do download and clean up after itself. Meant to run in the background
#
########################################################################################################
########################################################################################################
#
# parameters
# 1 - downloadNo - Sequiental number supplied to keep runs separated
# 2 - datamap addresses
#
function doDownload {
declare -i i j k
if [[ -z $2 ]] || (( ${#2} != 64 )); then echo "ERROR: error in parameters to download function ($1/$2)" >&2; exit; fi
if [[ -z $1 ]]; then echo "ERROR: error in parameters to download function ($1/$2)" >&2; exit; fi
downloadDir="tmp/${1}.file"
logFile="tmp/${1}download.logs"
# ensure files do not exist from a previos aborted run
rm -f $logFile
rm -f -r $downloadDir
# use client to request a quote and direct all output to temp file
ant --log-output-dest stdout file download $2 $downloadDir > $logFile 2>&1
# cleanup
rm -f $logFile
rm -f -r $downloadDir
# exit background task
exit
}
########################################################################################################
########################################################################################################
#
# MAIN PROGRAM
#
########################################################################################################
########################################################################################################
downloadCnt="0"
while read idataAddr ignore
do
if (( ${#idataAddr} != 64 )); then continue; fi
downloadCnt="$(( downloadCnt + 1 ))"
echo -e -n "\r$downloadCnt: $idataAddr "
doDownload $downloadCnt $idataAddr >/dev/null &
sleep $downloadRate
done < $datamapFile
echo "Finished processing the datamap list."
echo "Delaying 100 seconds finishing up to allow the last download to complete"
echo "Safe to ctrl-c now to exit"
sleep 100