Debian Codegraph @

tcl/edu/rts-cts/rts-cts-data-ack.pl

raw
1 # Script parses the trace file and using the base nam
2 # file, it generates a nam file that sets colors to
3 # nodes and data packets depending on their state.
4 # When a node is doing carrier sense, it turns red.
5 # When a node is sending RTS packets, it turns purple.
6 # RTS packets are purple broadcas packets.
7 # When a node is sending CTS packets, it turns green.
8 # CTS packets are green broadcast packets.
9 # When a node is sending data packets, it turns tan.
10 # Data packets are tan in color.
11 # When a node is sending ACK packets, it turns orange.
12 # ACK packets are orange in color.
13 sub usage {
14 print STDERR "usage: $0 <Base trace file> <Base nam trace file> <output nam trace file>n";
15 exit;
16 }
17
18 #@ARGV[0] - source trace file
19 #@ARGV[1] - source nam trace file
20 #@ARGV[2] - output nam trace file
21
22 open (Nam, $ARGV[1]) or die "Cannot open $ARGV[1] : $!\n";
23 open (Source, $ARGV[0]) or die "Cannot open $ARGV[0] : $!\n";
24 open (Destination, ">$ARGV[2]") or die "Cannot open $ARGV[2]: $!\n";
25
26
27 $line = <Nam>;
28 $tp =0;
29 while (($line) && ($tp ==0)) {
30 if ($line =~ /-i 3 -n green/) {
31 print Destination $line;
32 print Destination 'v -t 0.0 -e set_rate_ext 0.550ms 1', "\n";
33 print Destination 'v -t 0.0 -e sim_annotation 0.0 1 In a Wireless network topology,when not all nodes are within each other\'s range, ',"\n";
34 print Destination 'v -t 0.01 -e sim_annotation 0.001 2 carrier sense only provides information about collisions at the sender,not at ', "\n";
35 print Destination 'v -t 0.015 -e sim_annotation 0.002 3 the receiver. This leads to problems like hidden terminal where two sender ', "\n";
36 print Destination 'v -t 0.02 -e sim_annotation 0.003 4 nodes out of range of each other transmit packets at the same time, ', "\n";
37 print Destination 'v -t 0.025 -e sim_annotation 0.004 5 to the same receiver, resulting in collisions at the receiver. To solve ', "\n";
38 print Destination 'v -t 0.03 -e sim_annotation 0.005 6 such problems, control packets, RTS & CTS are used. When a node wants to ', "\n";
39 print Destination 'v -t 0.035 -e sim_annotation 0.006 7 transmit packets, it first sends a RTS packet to the receiver.All nodes within ', "\n";
40 print Destination 'v -t 0.04 -e sim_annotation 0.007 8 the sender\'s range receive this RTS packet. Every node hearing this RTS packet ', "\n";
41 print Destination 'v -t 0.045 -e sim_annotation 0.008 9 will defer transmission. If receiver is not receiving data from any other node, ', "\n";
42 print Destination 'v -t 0.05 -e sim_annotation 0.009 10 it responds with a CTS packet.This packet is again received by every node ', "\n";
43 print Destination 'v -t 0.055 -e sim_annotation 0.01 11 within range of receiver. So all nodes in this range defer transmission. ', "\n";
44 print Destination 'v -t 0.06 -e sim_annotation 0.02 12 Sender node sends data packet after receiving CTS. If sender node does not ', "\n";
45 print Destination 'v -t 0.065 -e sim_annotation 0.03 13 hear the CTS, it will time-out and schedule retransmission of RTS. On ', "\n";
46 print Destination 'v -t 0.07 -e sim_annotation 0.04 14 receiving data packet, receiver sends an ACK to sender. ', "\n";
47 $tp = 1;
48 }
49 else
50 {
51 print Destination $line;
52 $line = <Nam>;
53 }
54 }
55
56 print Destination 'v -t 0.100 -e sim_annotation 0.100 18 COLOR LEGEND : ', "\n";
57 print Destination 'v -t 0.110 -e sim_annotation 0.110 19 RTS packets : Purple color. Node turns purple while sending an RTS packet ', "\n";
58 print Destination 'v -t 0.120 -e sim_annotation 0.120 20 CTS packets : Green color . Node turns green while sending CTS packets ', "\n";
59 print Destination 'v -t 0.130 -e sim_annotation 0.130 21 Data packets : Tan color . Node turns tan while sending data packets ', "\n";
60 print Destination 'v -t 0.140 -e sim_annotation 0.140 22 ACK packets : Orange color. Node turns orange while sending ACK packets ', "\n";
61 $line = <Source>;
62 @fields = split ' ', $line;
63 my $temp = @fields[1];
64 my $i = 23;
65 my $t = 1;
66 my $dw = 0;
67 my $num_mov = 0;
68 my $come = 0;
69 my $once = 0;
70
71 while($line) {
72 @fields = split ' ', $line;
73 @fields[1] = $temp + 0.005;
74 # This generates movement of node in name file.
75 if ($line =~ /^M/)
76 {
77 @fields[3] =~ m/(\d+\.\d+)/;
78 @fields[3] = $1;
79 @fields[4] =~ m/(\d+\.\d+)/;
80 @fields[4] = $1;
81 @fields[6] =~ m/(\d+\.\d+)/;
82 @fields[6] = $1;
83 $t = (@fields[6] - @fields[3])/@fields[8];
84 print Destination 'n -t ', @fields[1], ' -s ', @fields[2], ' -x ', @fields[3], ' -y ', @fields[4], ' -U ',@fields[8], ' -V 0.00 -T ', $t,"\n";
85 $num_mov ++;
86 if($num_mov == 1)
87 {
88 print Destination 'v -t ', @fields[1], ' -e sim_annotation ', @fields[1], ' ', $i, ' NODE MOVES : Sender nodes can hear both RTS and CTS ', "\n";
89 $i++;
90 }
91 elsif ($num_mov == 2)
92 {
93 print Destination 'v -t ', @fields[1], ' -e sim_annotation ', @fields[1], ' ', $i, ' NODE MOVES : Sender nodes can hear CTS but not RTS', "\n";
94 $i++;
95 }
96 $line = <Source>;
97 $temp = @fields[1];
98 }
99 elsif( # This parses the trace file for RTS packets before node moves.
100 ($line =~ /s/) && ($line =~ /MAC/) && ($line =~ /RTS/) && (@fields[2] !~ /1/) && ($num_mov <= 1)
101 ) {
102 @fields[2] =~ m/(\d)/;
103 @fields[2] = $1;
104 $other_node = 0;
105 if (@fields[2] == 0)
106 {
107 $other_node = 2;
108 }
109 if ($come == 0)
110 {
111 $come = 1;
112 print Destination 'v -t ', @fields[1], ' -e sim_annotation ', @fields[1], ' ', $i, ' CASE 1 : NO CONTENTION. ', "\n";
113 $i++;
114 @fields[1] = @fields[1] + 0.00005;
115 print Destination 'v -t ', @fields[1], ' -e sim_annotation ', @fields[1], ' ', $i, ' Only one node sends data, it does a simple RTS-CTS_DATA-ACK exchange ', "\n";
116 $i++;
117 @fields[1] = @fields[1] + 0.00005;
118 print Destination 'n -t ', @fields[1], ' -s 0 -S COLOR -c red -o black -i red -I black', "\n";
119 print Destination 'n -t ', @fields[1], ' -s 0 -S DLABEL -l "Carrier sense" -L ""', "\n";
120 $duration = @fields[1] + 0.005;
121 print Destination 'n -t ', $duration, ' -s ', @fields[2], ' -S COLOR -c purple -o red -i purple -I red', "\n";
122 print Destination 'n -t ', $duration, ' -s ', @fields[2], ' -S DLABEL -l "Sending RTS packet" -L ""', "\n";
123 print Destination '+ -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
124 print Destination '- -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
125 print Destination 'h -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
126 print Destination 'r -t ', $duration, ' -s ', @fields[2], ' -d -1 p message -e 500 -a 7', "\n";
127 $new_duration = $duration + 0.01;
128 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S COLOR -c black -o purple -i black -I purple', "\n";
129 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S DLABEL -l "" -L ""', "\n";
130 $new_duration = $new_duration + 0.01;
131 print Destination 'n -t ', $new_duration, ' -s 1 -S COLOR -c green -o black -i green -I black', "\n";
132 print Destination 'n -t ', $new_duration, ' -s 1 -S DLABEL -l "Sending CTS packets" -L ""', "\n";
133 print Destination '+ -t ', $new_duration, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
134 print Destination '- -t ', $new_duration, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
135 print Destination 'h -t ', $new_duration, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
136 print Destination 'r -t ', $new_duration, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
137 $new_duration = $new_duration + 0.01;
138 print Destination 'n -t ', $new_duration, ' -s 1 -S COLOR -c black -o green -i black -I green', "\n";
139 print Destination 'n -t ', $new_duration, ' -s 1 -S DLABEL -l "" -L ""', "\n";
140 $new_duration = $new_duration + 0.01;
141 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S COLOR -c tan -o black -i tan -I black', "\n";
142 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S DLABEL -l "Sending Data Packet" -L ""', "\n";
143 print Destination '+ -t ', $new_duration, ' -s ', @fields[2], ' -d 1 -p message -e 2500 -a 6', "\n";
144 print Destination '- -t ', $new_duration, ' -s ', @fields[2], ' -d 1 -p message -e 2500 -a 6', "\n";
145 print Destination 'h -t ', $new_duration, ' -s ', @fields[2], ' -d 1 -p message -e 2500 -a 6', "\n";
146 print Destination 'r -t ', $new_duration, ' -s ', @fields[2], ' -d 1 -p message -e 2500 -a 6', "\n";
147 $new_duration = $new_duration + 0.01;
148 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S COLOR -c black -o tan -i black -I tan', "\n";
149 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S DLABEL -l "" -L ""', "\n";
150 $new_duration = $new_duration + 0.01;
151 print Destination 'n -t ', $new_duration, ' -s 1 -S COLOR -c orange -o black -i orange -I black', "\n";
152 print Destination 'n -t ', $new_duration, ' -s 1 -S DLABEL -l "Sending ACK packet" -L ""', "\n";
153 print Destination '+ -t ', $new_duration, ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
154 print Destination '- -t ', $new_duration, ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
155 print Destination 'h -t ', $new_duration, ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
156 print Destination 'r -t ', $new_duration, ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
157 $new_duration = $new_duration + 0.01;
158 print Destination 'n -t ', $new_duration, ' -s 1 -S COLOR -c black -o orange -i black -I orange', "\n";
159 print Destination 'n -t ', $new_duration, ' -s 1 -S DLABEL -l "" -L ""', "\n";
160 print Destination 'v -t ', $new_duration, ' -e sim_annotation ', $new_duration, ' ', $i, ' CASE 2 : BACKOFF DUE TO RTS', "\n";
161 $i++;
162 $new_duration = $new_duration + 0.005;
163 print Destination 'v -t ', $new_duration , ' -e sim_annotation ', $new_duration, ' ' , $i, ' Nodes are in RTS range of each other but not in CTS range of the receiver ', "\n";
164 $i++;
165 $new_duration = $new_duration + 0.005;
166 print Destination 'v -t ', $new_duration , ' -e sim_annotation ', $new_duration, ' ', $i, ' Node 0 want to send data to Node 1 at the same time that Node 2 wants to send data to Node 0 ', "\n";
167 $i++;
168 $new_duration = $new_duration + 0.005;
169 print Destination 'v -t ', $new_duration, ' -e sim_annotation ', $new_duration, ' ', $i, ' thus Node 2 backsoff when it hears the RTS from Node 0', "\n";
170 $i ++;
171 $temp = $new_duration;
172 @fields[1] = $new_duration + 0.01;
173 }
174 if($num_mov == 1)
175 {
176 print Destination 'v -t ', @fields[1], ' -e sim_annotation ', @fields[1], ' ', $i, ' CASE 3 : BACKOFF AGAIN DUE TO RTS', "\n";
177 $i++;
178 $new_duration = @fields[1] + 0.00005;
179 print Destination 'v -t ', $new_duration, ' -e sim_annotation ', $new_duration, ' ', $i, ' All nodes are in the RTS and CTS range of each other', "\n";
180 $i++;
181 $new_duration = $new_duration + 0.00005;
182 print Destination 'v -t ', $new_duration, ' -e sim_annotation ', $new_duration, ' ' , $i, ' Nodes 0 and 2 are in range of each other and hence can hear the RTS packet of the other node after hearing RTS packet node backs off', "\n";
183 $i ++;
184 @fields[1] = $new_duration + 0.01;
185 }
186 print Destination 'n -t ', @fields[1], ' -s 0 -S COLOR -c red -o black -i red -I black', "\n";
187 print Destination 'n -t ', @fields[1], ' -s 2 -S COLOR -c red -o black -i red -I black', "\n";
188 print Destination 'n -t ', @fields[1], ' -s 0 -S DLABEL -l "Carrier sense" -L ""', "\n";
189 print Destination 'n -t ', @fields[1], ' -s 2 -S DLABEL -l "Carrier sense" -L ""', "\n";
190 $duration = @fields[1] + 0.005;
191 print Destination 'n -t ', $duration, ' -s ', @fields[2], ' -S COLOR -c purple -o red -i purple -I red', "\n";
192 print Destination 'n -t ', $duration, ' -s ', @fields[2], ' -S DLABEL -l "Sending RTS packet" -L ""', "\n";
193 print Destination '+ -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
194 print Destination '- -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
195 print Destination 'h -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
196 print Destination 'r -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
197
198 $new_duration = $duration + 0.01;
199 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S COLOR -c black -o purple -i black -I purple', "\n";
200 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S DLABEL -l "" -L ""', "\n";
201
202 print Destination 'n -t ', $new_duration, ' -s ', $other_node, ' -S COLOR -c DarkOliveGreen -o red -i DarkOliveGreen -I red', "\n";
203 print Destination 'n -t ', $new_duration, ' -s ', $other_node, ' -S DLABEL -l "Data Waiting" -L ""', "\n";
204 $i ++;
205 $line = <Source>;
206 $temp = $new_duration;
207 }
208 elsif( # This parses trace file for RTS packets after node moves
209 ($line =~ /s/) && ($line =~ /MAC/) && ($line =~ /RTS/) && (@fields[2] !~ /1/) && ($num_mov > 1)
210 ) {
211 @fields[2] =~ m/(\d)/;
212 @fields[2] = $1;
213 $other_node = 0;
214 if (@fields[2] == 0)
215 {
216 $other_node = 2;
217 }
218 if ($once == 0) {
219 print Destination 'v -t ', @fields[1], ' -e sim_annotation ', @fields[1], ' ' , $i, ' CASE 4 : BACKOFF DUE TO CTS ', "\n";
220 $i++;
221 @fields[1] = @fields[1] + 0.005;
222 print Destination 'v -t ', @fields[1], ' -e sim_annotation ', @fields[1], ' ', $i, ' Senders are out of range of RTS of each other but are in range of CTS of receiver', "\n";
223 $i ++;
224 @fields[1] = @fields[1] + 0.005;
225 print Destination 'v -t ', @fields[1], ' -e sim_annotation ', @fields[1], ' ', $i, ' Node 0 sends RTS which Node 2 does not hear but it hears the CTS sent by receiver and thus backsoff after hearing CTS, thus avoiding collision at the receiver', "\n";
226 $i ++;
227 @fields[1] = @fields[1] + 0.005;
228
229 $once ++;
230 }
231 if ($dw == 0) {
232 print Destination 'n -t ', @fields[1], ' -s 0 -S COLOR -c red -o black -i red -I black', "\n";
233 print Destination 'n -t ', @fields[1], ' -s 2 -S COLOR -c red -o black -i red -I black', "\n";
234 print Destination 'n -t ', @fields[1], ' -s 0 -S DLABEL -l "Carrier sense" -L ""', "\n";
235 print Destination 'n -t ', @fields[1], ' -s 2 -S DLABEL -l "Carrier sense" -L ""', "\n";
236 }
237 if($dw == 1) {
238 print Destination 'n -t ', @fields[1],' -s ', @fields[2],' -S COLOR -c red -o black -i red -I black', "\n";
239 print Destination 'n -t ', @fields[1],' -s ', @fields[2],' -S DLABEL -l "Carrier sense" -L ""', "\n";
240 }
241
242 $duration = @fields[1] + 0.005;
243 print Destination 'n -t ', $duration, ' -s ', @fields[2], ' -S COLOR -c purple -o red -i purple -I red', "\n";
244 print Destination 'n -t ', $duration, ' -s ', @fields[2], ' -S DLABEL -l "Sending RTS packet" -L ""', "\n";
245 print Destination '+ -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
246 print Destination '- -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
247 print Destination 'h -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
248 print Destination 'r -t ', $duration, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 7', "\n";
249 $new_duration = $duration + 0.005;
250 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S COLOR -c black -o purple -i black -I purple', "\n";
251 print Destination 'n -t ', $new_duration, ' -s ', @fields[2], ' -S DLABEL -l "" -L ""', "\n";
252 $temp = $new_duration;
253 if ($t == 1) {
254 print Destination 'n -t ', $new_duration, ' -s ', $other_node, ' -S COLOR -c purple -o red -i purple -I red', "\n";
255 print Destination 'n -t ', $new_duration, ' -s ', $other_node, ' -S DLABEL -l "Sending RTS packet" -L ""', "\n";
256 print Destination '+ -t ', $new_duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
257 print Destination '- -t ', $new_duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
258 print Destination 'h -t ', $new_duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
259 print Destination 'r -t ', $new_duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
260 $final_duration = $new_duration + 0.005;
261 print Destination 'n -t ', $final_duration, ' -s ', $other_node, ' -S COLOR -c black -o purple -i black -I purple', "\n";
262 print Destination 'n -t ', $final_duration, ' -s ', $other_node, ' -S DLABEL -l "" -L ""', "\n";
263 $t++;
264 $temp = $final_duration;
265 }
266 $line = <Source>;
267 }
268 elsif( # This parses trace file for CTS packets after node moves
269 ($line =~ /s/) && ($line =~ /MAC/) && ($line =~ /CTS/) && (@fields[2] !~ /0/) && (@fields[2] !~ /2/) && ($num_mov >= 1)
270 ) {
271 @fields[2] =~ m/(\d)/;
272 @fields[2] = $1;
273 $jitter = @fields[1] + 0.01;
274 print Destination 'n -t ', $jitter, ' -s 1 -S DLABEL -l "Sending CTS packets" -L ""', "\n";
275 print Destination 'n -t ', $jitter, ' -s 1 -S COLOR -c green -o black -i green -I black', "\n";
276 print Destination '+ -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
277 print Destination '- -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
278 print Destination 'h -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
279 print Destination 'r -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
280 $duration = $jitter + 0.01;
281 print Destination 'n -t ', $duration, ' -s 1 -S COLOR -c black -o green -i black -I green', "\n";
282 print Destination 'n -t ', $duration, ' -s 1 -S DLABEL -l "" -L ""', "\n";
283 $i++;
284 $line = <Source>;
285 $temp = $duration;
286 }
287 elsif( # This parses trace file for CTS packets after node moves
288 ($line =~ /s/) && ($line =~ /MAC/) && ($line =~ /CTS/) && (@fields[2] !~ /0/) && (@fields[2] !~ /2/) && ($num_mov == 0)
289 ) {
290 @fields[2] =~ m/(\d)/;
291 @fields[2] = $1;
292 $jitter = @fields[1] + 0.01;
293
294 print Destination 'n -t ', $jitter, ' -s 1 -S DLABEL -l "Sending CTS packets" -L ""', "\n";
295 print Destination 'n -t ', $jitter, ' -s 1 -S COLOR -c green -o black -i green -I black', "\n";
296 print Destination '+ -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
297 print Destination '- -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
298 print Destination 'h -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
299 print Destination 'r -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
300 $duration = $jitter + 0.01;
301 print Destination 'n -t ', $duration, ' -s 1 -S COLOR -c black -o green -i black -I green', "\n";
302 print Destination 'n -t ', $duration, ' -s 1 -S DLABEL -l "" -L ""', "\n";
303 $i++;
304 $line = <Source>;
305 $temp = $duration;
306 }
307 elsif( # This parses trace file for data packets
308 ($line =~ /s/) && ($line =~ /MAC/) && ($line =~ /message/) && (@fields[2] !~ /1/)
309 ) {
310 @fields[2] =~ m/(\d)/;
311 @fields[2] = $1;
312 $other_node = 0;
313 if(@fields[2] == 0) {
314 $other_node = 2;
315 }
316 @fields[1] = @fields[1] +0.01;
317 print Destination 'n -t ', @fields[1], ' -s ', @fields[2], ' -S DLABEL -l "Sending Data packets" -L ""', "\n";
318 print Destination 'n -t ', @fields[1], ' -s ', @fields[2], ' -S COLOR -c tan -o black -i tan -I black', "\n";
319 if(($num_mov > 1) && ($dw == 0)) {
320 print Destination 'n -t ', @fields[1], ' -s ', $other_node, ' -S COLOR -c DarkOliveGreen -o black -i DarkOliveGreen -I black', "\n";
321 print Destination 'n -t ', @fields[1], ' -s ', $other_node, ' -S DLABEL -l "Data waiting" -L ""', "\n";
322 }
323 print Destination '+ -t ', @fields[1], ' -s ', @fields[2], ' -d 1 -p message -e 2500 -a 6', "\n";
324 print Destination '- -t ', @fields[1], ' -s ', @fields[2], ' -d 1 -p message -e 2500 -a 6', "\n";
325 print Destination 'h -t ', @fields[1], ' -s ', @fields[2], ' -d 1 -p message -e 2500 -a 6', "\n";
326 print Destination 'r -t ', @fields[1], ' -s ', @fields[2], ' -d 1 -p message -e 2500 -a 6', "\n";
327 $duration = @fields[1] + 0.01;
328 print Destination 'n -t ', $duration, ' -s ', @fields[2], ' -S COLOR -c black -o tan -i black -I tan', "\n";
329 print Destination 'n -t ', $duration, ' -s ', @fields[2], ' -S DLABEL -l "" -L "" ', "\n";
330 $i++;
331 $line = <Source>;
332 $temp = $duration;
333 }
334 elsif( # This parses trace file for ACK packets
335 ($line =~ /r/) && ($line =~ /MAC/) && ($line =~ /ACK/) && (@fields[2] !~ /1/) && ($num_mov > 1)
336 ) {
337 $dw ++;
338 @fields[2] =~ m/(\d)/;
339 @fields[2] = $1;
340 print Destination 'n -t ', @fields[1], ' -s 1 -S DLABEL -l "Sending ACK packets" -L ""', "\n";
341 print Destination 'n -t ', @fields[1], ' -s 1 -S COLOR -c orange -o black -i orange -I black', "\n";
342 print Destination '+ -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
343 print Destination '- -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
344 print Destination 'h -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
345 print Destination 'r -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
346 $duration = @fields[1] + 0.01;
347 print Destination 'n -t ', $duration, ' -s 1 -S COLOR -c black -o orange -i black -I orange', "\n";
348 print Destination 'n -t ', $duration, ' -s 1 -S DLABEL -l "" -L ""', "\n";
349 $i++;
350 $line = <Source>;
351 $temp = $duration;
352 }
353 elsif( # This parses trace file for ACK packets.
354 ($line =~ /r/) && ($line =~ /MAC/) && ($line =~ /ACK/) && (@fields[2] !~ /1/) && ($num_mov == 0)
355 ) {
356 @fields[2] =~ m/(\d)/;
357 @fields[2] = $1;
358 $other_node = 0;
359 if(@fields[2] == 0) {
360 $other_node = 2;
361 }
362 print Destination 'n -t ', @fields[1], ' -s 1 -S DLABEL -l "Sending ACK packet" -L ""', "\n";
363 print Destination 'n -t ', @fields[1], ' -s 1 -S COLOR -c orange -o black -i orange -I black', "\n";
364 print Destination '+ -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
365 print Destination '- -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
366 print Destination 'h -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
367 print Destination 'r -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
368 $duration = @fields[1] + 0.01;
369 print Destination 'n -t ', $duration, ' -s 1 -S COLOR -c black -o orange -i black -I orange', "\n";
370 print Destination 'n -t ', $duration, ' -s 1 -S DLABEL -l "" -L ""', "\n";
371 $i++;
372
373
374 print Destination 'n -t ', $duration, ' -s ', $other_node, ' -S COLOR -c purple -o DarkOliveGreen -i purple -I DarkOliveGreen', "\n";
375 print Destination 'n -t ', $duration, ' -s ', $other_node, ' -S DLABEL -l "Sending RTS packet" -L ""', "\n";
376 print Destination '+ -t ', $duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
377 print Destination '- -t ', $duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
378 print Destination 'h -t ', $duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
379 print Destination 'r -t ', $duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
380 $new_duration = $duration + 0.005;
381 print Destination 'n -t ', $new_duration, ' -s ', $other_node, ' -S COLOR -c black -o purple -i black -I purple', "\n";
382 print Destination 'n -t ', $new_duration, ' -s ', $other_node, ' -S DLABEL -l "" -L ""', "\n";
383 $i ++;
384
385 $jitter = $new_duration + 0.01;
386 print Destination 'n -t ', $jitter, ' -s ', @fields[2], ' -S DLABEL -l "Sending CTS packets" -L ""', "\n";
387 print Destination 'n -t ', $jitter, ' -s ', @fields[2], ' -S COLOR -c green -o black -i green -I black', "\n";
388 print Destination '+ -t ', $jitter, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 3', "\n";
389 print Destination '- -t ', $jitter, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 3', "\n";
390 print Destination 'h -t ', $jitter, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 3', "\n";
391 print Destination 'r -t ', $jitter, ' -s ', @fields[2], ' -d -1 -p message -e 500 -a 3', "\n";
392 $n_duration = $jitter + 0.01;
393 print Destination 'n -t ', $n_duration, ' -s ', @fields[2], ' -S COLOR -c black -o green -i black -I green', "\n";
394 print Destination 'n -t ', $n_duration, ' -s ', @fields[2],' -S DLABEL -l "" -L ""', "\n";
395 $i++;
396
397 $n_duration = $n_duration + 0.005;
398 print Destination 'n -t ', $n_duration, ' -s ', $other_node, ' -S DLABEL -l "Sending Data packets" -L ""', "\n";
399 print Destination 'n -t ', $n_duration, ' -s ', $other_node, ' -S COLOR -c tan -o DarkOliveGreen -i tan -I DarkOliveGreen', "\n";
400
401 print Destination '+ -t ', $n_duration, ' -s ', $other_node, ' -d ', @fields[2], ' -p message -e 2500 -a 6', "\n";
402 print Destination '- -t ', $n_duration, ' -s ', $other_node, ' -d ', @fields[2], ' -p message -e 2500 -a 6', "\n";
403 print Destination 'h -t ', $n_duration, ' -s ', $other_node, ' -d ', @fields[2], ' -p message -e 2500 -a 6', "\n";
404 print Destination 'r -t ', $n_duration, ' -s ', $other_node, ' -d ', @fields[2], ' -p message -e 2500 -a 6', "\n";
405 $n_duration = $n_duration + 0.01;
406 print Destination 'n -t ', $n_duration, ' -s ', $other_node, ' -S COLOR -c black -o tan -i black -I tan', "\n";
407 print Destination 'n -t ', $n_duration, ' -s ', $other_node, ' -S DLABEL -l "" -L "" ', "\n";
408 $i++;
409
410 $n_duration = $n_duration + 0.01;
411 print Destination 'n -t ', $n_duration, ' -s ', @fields[2],' -S DLABEL -l "Sending ACK packet" -L ""', "\n";
412 print Destination 'n -t ', $n_duration, ' -s ', @fields[2],' -S COLOR -c orange -o black -i orange -I black', "\n";
413 print Destination '+ -t ', $n_duration, ' -s ', @fields[2],' -d ', $other_node, ' -p message -e 500 -a 2', "\n";
414 print Destination '- -t ', $n_duration, ' -s ', @fields[2],' -d ', $other_node, ' -p message -e 500 -a 2', "\n";
415 print Destination 'h -t ', $n_duration, ' -s ', @fields[2],' -d ', $other_node, ' -p message -e 500 -a 2', "\n";
416 print Destination 'r -t ', $n_duration, ' -s ', @fields[2],' -d ', $other_node, ' -p message -e 500 -a 2', "\n";
417 $duration = $n_duration + 0.01;
418 print Destination 'n -t ', $duration, ' -s ', @fields[2],' -S COLOR -c black -o orange -i black -I orange', "\n";
419 print Destination 'n -t ', $duration, ' -s ', @fields[2],' -S DLABEL -l "" -L ""', "\n";
420 $i++;
421
422
423
424 $line = <Source>;
425 $temp = $duration;
426
427 }
428 elsif(
429 ($line =~ /r/) && ($line =~ /MAC/) && ($line =~ /ACK/) && (@fields[2] !~ /1/) && ($num_mov == 1)
430 ) {
431 @fields[2] =~ m/(\d)/;
432 @fields[2] = $1;
433 $other_node = 0;
434 if(@fields[2] == 0) {
435 $other_node = 2;
436 }
437 print Destination 'n -t ', @fields[1], ' -s 1 -S DLABEL -l "Sending ACK packet" -L ""', "\n";
438 print Destination 'n -t ', @fields[1], ' -s 1 -S COLOR -c orange -o black -i orange -I black', "\n";
439 print Destination '+ -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
440 print Destination '- -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
441 print Destination 'h -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
442 print Destination 'r -t ', @fields[1], ' -s 1 -d ', @fields[2], ' -p message -e 500 -a 2', "\n";
443 $duration = @fields[1] + 0.01;
444 print Destination 'n -t ', $duration, ' -s 1 -S COLOR -c black -o orange -i black -I orange', "\n";
445 print Destination 'n -t ', $duration, ' -s 1 -S DLABEL -l "" -L ""', "\n";
446 $i++;
447
448 print Destination 'n -t ', $duration, ' -s ', $other_node, ' -S COLOR -c purple -o DarkOliveGreen -i purple -I DarkOliveGreen', "\n";
449 print Destination 'n -t ', $duration, ' -s ', $other_node, ' -S DLABEL -l "Sending RTS packet" -L ""', "\n";
450
451 print Destination '+ -t ', $duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
452 print Destination '- -t ', $duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
453 print Destination 'h -t ', $duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
454 print Destination 'r -t ', $duration, ' -s ', $other_node, ' -d -1 -p message -e 500 -a 7', "\n";
455
456 $new_duration = $duration + 0.005;
457 print Destination 'n -t ', $new_duration, ' -s ', $other_node, ' -S COLOR -c black -o purple -i black -I purple', "\n";
458 print Destination 'n -t ', $new_duration, ' -s ', $other_node, ' -S DLABEL -l "" -L ""', "\n";
459 $i ++;
460
461 $jitter = $new_duration + 0.01;
462 print Destination 'n -t ', $jitter, ' -s 1 -S DLABEL -l "Sending CTS packets" -L ""', "\n";
463 print Destination 'n -t ', $jitter, ' -s 1 -S COLOR -c green -o black -i green -I black', "\n";
464 print Destination '+ -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
465 print Destination '- -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
466 print Destination 'h -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
467 print Destination 'r -t ', $jitter, ' -s 1 -d -1 -p message -e 500 -a 3', "\n";
468 $n_duration = $jitter + 0.01;
469 print Destination 'n -t ', $n_duration, ' -s 1 -S COLOR -c black -o green -i black -I green', "\n";
470 print Destination 'n -t ', $n_duration, ' -s 1 -S DLABEL -l "" -L ""', "\n";
471
472 $n_duration = $n_duration + 0.005;
473 print Destination 'n -t ', $n_duration, ' -s ', $other_node, ' -S DLABEL -l "Sending Data packets" -L ""', "\n";
474 print Destination 'n -t ', $n_duration, ' -s ', $other_node, ' -S COLOR -c tan -o DarkOliveGreen -i tan -I DarkOliveGreen', "\n";
475
476 print Destination '+ -t ', $n_duration, ' -s ', $other_node, ' -d 1 -p message -e 2500 -a 6', "\n";
477 print Destination '- -t ', $n_duration, ' -s ', $other_node, ' -d 1 -p message -e 2500 -a 6', "\n";
478 print Destination 'h -t ', $n_duration, ' -s ', $other_node, ' -d 1 -p message -e 2500 -a 6', "\n";
479 print Destination 'r -t ', $n_duration, ' -s ', $other_node, ' -d 1 -p message -e 2500 -a 6', "\n";
480 $n_duration = $n_duration + 0.01;
481 print Destination 'n -t ', $n_duration, ' -s ', $other_node, ' -S COLOR -c black -o tan -i black -I tan', "\n";
482 print Destination 'n -t ', $n_duration, ' -s ', $other_node, ' -S DLABEL -l "" -L "" ', "\n";
483 $i++;
484
485 $n_duration = $n_duration + 0.01;
486 print Destination 'n -t ', $n_duration, ' -s 1 -S DLABEL -l "Sending ACK packet" -L ""', "\n";
487 print Destination 'n -t ', $n_duration, ' -s 1 -S COLOR -c orange -o black -i orange -I black', "\n";
488 print Destination '+ -t ', $n_duration, ' -s 1 -d ', $other_node, ' -p message -e 500 -a 2', "\n";
489 print Destination '- -t ', $n_duration, ' -s 1 -d ', $other_node, ' -p message -e 500 -a 2', "\n";
490 print Destination 'h -t ', $n_duration, ' -s 1 -d ', $other_node, ' -p message -e 500 -a 2', "\n";
491 print Destination 'r -t ', $n_duration, ' -s 1 -d ', $other_node, ' -p message -e 500 -a 2', "\n";
492 $duration = $n_duration + 0.01;
493 print Destination 'n -t ', $duration, ' -s 1 -S COLOR -c black -o orange -i black -I orange', "\n";
494 print Destination 'n -t ', $duration, ' -s 1 -S DLABEL -l "" -L ""', "\n";
495 $i++;
496
497 $line = <Source>;
498 $temp = $duration;
499
500 }
501
502 else {
503 $line = <Source>;
504 $temp = @fields[1];
505 }
506 }
507
508 close Source;
509 close Destination;
510 close Nam;