-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.sh
executable file
·56 lines (42 loc) · 1.41 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# main.sh
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
NUMLEECHERS=1
NUMSEEDERS=1
FILESIZE=1024
RUNDURATION=120
LATENCYINTERVALS=50
REPETITIONS=11
FILENAME="test.file"
TORRENTNAME="test.torrent"
RESULTFILE="result.csv"
RESULTPLOT="result.png"
TMPFOLDER="tmp/"
SEEDFOLDER=$TMPFOLDER"seeder/"
LEECHFOLDER=$TMPFOLDER"leecher/"
echo "Removing possible previous folder..."
rm -rf $TMPFOLDER
echo "Creating temporary folder to conduct tests in..."
mkdir $TMPFOLDER
mkdir $SEEDFOLDER
mkdir $LEECHFOLDER
echo "Copying leecher and seeder scripts to the correct folders..."
cp {seeder.conf,leecher.conf} $TMPFOLDER
cp seeder.py $SEEDFOLDER
cp leecher.py $LEECHFOLDER
echo "Creating random file of $FILESIZE MiB and torrent for the seeders to seed... This might take a while."
dd if=/dev/urandom of=$SEEDFOLDER$FILENAME bs=1M count=$FILESIZE status=progress
ctorrent -t -u 127.0.0.1 -s $SEEDFOLDER$TORRENTNAME $SEEDFOLDER$FILENAME
cp $SEEDFOLDER$TORRENTNAME $LEECHFOLDER$TORRENTNAME
echo -e "\n\nRunning container.sh..."
./containers.sh $NUMSEEDERS $RUNDURATION $LATENCYINTERVALS $REPETITIONS $RESULTFILE
echo -e "Done running container.sh.\n\n"
echo "Copying data from temporary folder..."
cp $LEECHFOLDER$RESULTFILE $RESULTFILE
echo "Removing temporary folder..."
rm -rf $TMPFOLDER
echo "Creating plot..."
python3 create_plot.py $RESULTFILE $RUNDURATION $LATENCYINTERVALS $RESULTPLOT