-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-simul.sh
executable file
·153 lines (143 loc) · 3.49 KB
/
run-simul.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/sh
#======================================================================
#
# INPUT ARGS
#
#======================================================================
# Usage
usage="Usage: run_simul.sh [options]
--nodes: Number of Nodes (1 default) [1]
--min-peers: Mininum number of peers. [1]
--discovery-timer: Time between discovery lookups (in ms) [100]
--min-discovery-timeout: Minimum discovery timeout (in s) [5]
--max-discovery-timeout: Maximum discovery timeout (in s) [12]
--min-idle-timeout Minimum discovery idle timeout (in s) [20]
--max-idle-timeout: Maximum discovery idle timeout (in s) [20]
--sim-duration: Simulation time (in s) [3600]
--first-join-time: Last join time (in s) [0.1]
--last-join-time: Last join time (in s) [1]
--gossip-b-initial: Gossip Algorithm Binitial [1]
--gossip-b: Gossip Algorithm B [1]
--gossip-f: Gossip Algorithm F [1]
--seed: Set Random Seed [1893]
--out-file: Set output file [./out.txt]
--path-to-waf: Set path to waf executable (default: .)
--help: Prompt usage"
# Default values
nodes="1"
min_peers="1"
discovery_timer="100"
min_discovery_timeout="5"
max_discovery_timeout="12"
min_idle_timeout="20"
max_idle_timeout="20"
sim_duration="3600"
first_join_time="0.1"
last_join_time="1"
gossip_b_initial="1"
gossip_b="1"
gossip_f="1"
seed="1893"
out_file="$(pwd -P)/out.txt"
path_to_waf="/home/hyrax/ns-allinone-3.24/ns-3.24/"
#
while [[ $# > 0 ]]
do
key="$1"
case $key in
--nodes)
nodes=$2
shift
;;
--gossip-b)
gossip_b=$2
shift
;;
--gossip-b-initial)
gossip_b_initial=$2
shift
;;
--gossip-f)
gossip_f=$2
shift
;;
--min-peers)
min_peers="$2"
shift
;;
--sim-duration)
sim_duration="$2"
shift
;;
--discovery-timer)
discovery_timer="$2"
shift
;;
--min-idle-timeout)
min_idle_timeout="$2"
shift
;;
--max-idle-timeout)
max_idle_timeout="$2"
shift
;;
--min-discovery-timeout)
min_discovery_timeout="$2"
shift
;;
--max-discovery-timeout)
max_discovery_timeout="$2"
shift
;;
--first-join-time)
first_join_time="$2"
shift
;;
--last-join-time)
last_join_time="$2"
shift
;;
--seed)
seed="$2"
shift
;;
--out-file)
out_file="$2"
shift
;;
--path-to-waf)
if [ -d "$2" ]; then
path_to_waf=$2
else
echo "$2 is not a valid directory."
exit 1
fi
shift
;;
--help)
echo -e "\n${usage}\n"
exit 0
;;
*)
echo "Unknown option: $key"
echo -e "\n${usage}\n"
exit 1
;;
esac
shift # past argument or value
done
#======================================================================
#
# Run
#
#======================================================================
if [ ! -f "${path_to_waf}/waf" ]; then
echo "${path_to_waf}/waf does not exist. Are you sure this is the correct path to ns3/waf?"
exit 1
fi
echo "Running simul with waf.. "
cp -r Piconet ${path_to_waf}
pushd ${path_to_waf}
./waf --run="scratch/Piconet/Piconet --Seed=$RANDOM --Nodes=$nodes --MinPeers=$min_peers --DiscoveryTimer=$discovery_timer --MinDiscoveryTimeout=$min_discovery_timeout --MaxDiscoveryTimeout=$max_discovery_timeout --MinIdleTimeout=$min_idle_timeout --MaxIdleTimeout=$max_idle_timeout --SimDuration=$sim_duration --FirstJoinTime=$first_join_time --LastJoinTime=$last_join_time --GossipBinitial=$gossip_b_initial --GossipB=$gossip_b --GossipF=$gossip_f " > $out_file;
popd
echo "Finished running simul."