|
1 #!/usr/bin/perl |
|
2 |
|
3 # |
|
4 # Copyright 2005-2006 Intel Corporation |
|
5 # |
|
6 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
7 # you may not use this file except in compliance with the License. |
|
8 # You may obtain a copy of the License at |
|
9 # |
|
10 # http://www.apache.org/licenses/LICENSE-2.0 |
|
11 # |
|
12 # Unless required by applicable law or agreed to in writing, software |
|
13 # distributed under the License is distributed on an "AS IS" BASIS, |
|
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 # See the License for the specific language governing permissions and |
|
16 # limitations under the License. |
|
17 # |
|
18 |
|
19 |
|
20 use Getopt::Long; |
|
21 |
|
22 my $logscalex = 0; |
|
23 my $logscaley = 0; |
|
24 |
|
25 |
|
26 my $expname=''; |
|
27 my $base=''; |
|
28 |
|
29 |
|
30 my $nodes=4; |
|
31 my $loss=0; |
|
32 my $bandwidth=100; |
|
33 my $size=10; |
|
34 my $num=100; |
|
35 |
|
36 |
|
37 my $stop_at=-1; |
|
38 my $is_mike = 1; |
|
39 my $theoryfile = "theory1.txt"; |
|
40 |
|
41 GetOptions( |
|
42 "exp=s" => \$expname, |
|
43 "base=s" => \$base, |
|
44 "nodes=i" => \$nodes, |
|
45 "num=i" => \$num, |
|
46 "size=i" => \$size, |
|
47 "stop=i" => \$stop_at, |
|
48 ); |
|
49 |
|
50 if($base eq '') |
|
51 { |
|
52 print "base not given\n"; |
|
53 exit; |
|
54 } |
|
55 if($expname eq '') |
|
56 { |
|
57 print "expname not given\n"; |
|
58 exit; |
|
59 } |
|
60 $expbase="$base/$expname"; |
|
61 |
|
62 |
|
63 if ( !(-d $expbase)) |
|
64 { |
|
65 print "$expbase does not exist\n"; |
|
66 exit; |
|
67 } |
|
68 |
|
69 %protos=("5 tcp0" => "SFTP", |
|
70 #" 6 tcp1" => "TCP (HOP)", |
|
71 "4 dtn0" => "DTN (E2E)", |
|
72 "2 dtn1" => "DTN (HOP)", |
|
73 "1 dtn3" => "DTN (40K)", |
|
74 #"7 mail0" => "MAIL (E2E)", |
|
75 "3 mail1" => "MAIL" |
|
76 ); |
|
77 %linestyle=("tcp0" => "6", |
|
78 #"tcp1" => "7", |
|
79 "dtn0" => "5", |
|
80 "dtn1" => "3", |
|
81 "dtn3" => "2", |
|
82 #"mail0" => "8", |
|
83 "mail1" => "4" |
|
84 ); |
|
85 |
|
86 $plotbase="$expbase/gnuplot"; |
|
87 $logbase="$plotbase/log"; |
|
88 $psbase="$plotbase/ps"; |
|
89 |
|
90 mkdir($plotbase); |
|
91 mkdir($logbase); |
|
92 mkdir($psbase); |
|
93 |
|
94 if($expname =~ /rabin/g) |
|
95 { |
|
96 print "Getting info about experiment ..\n"; |
|
97 $expname =~ /([\w]+)-N([1-9])-L([0-9\.]+)-M([0-9]+)-S([0-9]+)-B([0-9]+).*/g; |
|
98 $nodes=$2; |
|
99 $loss=$3; |
|
100 $num=$4; |
|
101 $size=$5; |
|
102 $bandwidth=$6; |
|
103 } |
|
104 print "Name: Nodes:$nodes Loss:$loss Num:$num Size:$size Bandwidth:$bandwidth\n"; |
|
105 |
|
106 $command="maketable.sh $nodes $expname $base"; |
|
107 print "First generating the time table ... : $command\n"; |
|
108 system($command); |
|
109 |
|
110 |
|
111 ### the code below needs a $key ...$costo |
|
112 |
|
113 $vacfile="$plotbase/plot.gnp"; |
|
114 |
|
115 print "\n\nNow starting gnuplot generation stuff ...\n"; |
|
116 |
|
117 open (VACFILE, ">$vacfile") || die ("cannot open:$vacfile\n"); |
|
118 |
|
119 |
|
120 $pointsize="1.5"; |
|
121 #p1(""); |
|
122 #set pointsize 2.0 ; |
|
123 &p1(" |
|
124 set linestyle 1 lt -1 lw 4 ; |
|
125 set linestyle 2 lt 1 lw 7 pt 1 ps $pointsize ; |
|
126 set linestyle 3 lt 3 lw 3 pt 3 ps $pointsize ; |
|
127 set linestyle 4 lt 10 lw 7 pt 2 ps $pointsize ; |
|
128 set linestyle 5 lt 7 lw 3 pt 5 ps $pointsize ; |
|
129 set linestyle 6 lt 10 lw 6 pt 6 ps $pointsize ; |
|
130 set linestyle 7 lt 15 lw 3 pt 17 ps 2 ; |
|
131 set linestyle 8 lt 3 lw 3 pt 15 ps 2 ; |
|
132 "); |
|
133 |
|
134 |
|
135 &p1("set ylabel ", &qs("# of messages received")); |
|
136 &p1("set xlabel ", &qs("Time (s)")); |
|
137 |
|
138 |
|
139 $gx_init = $logscalex; |
|
140 $gy_init = $logscaley; |
|
141 |
|
142 |
|
143 #&p1("set xrange [$gx_init:1.1]"); |
|
144 #&p1("set yrange [$gy_init:1.1]"); |
|
145 &p1("!touch empty ; \n"); |
|
146 &p1("set xrange [$gx_init:500]"); |
|
147 &p1("set yrange [$gx_init:500]"); |
|
148 &p1("set term x11 1 ; ","plot ",&qs("empty"), " title ",&qs("")); |
|
149 |
|
150 |
|
151 |
|
152 #$plottitle="Nodes:$nodes Size:$size Loss=$loss" ; |
|
153 #&p1("set title ",&qs($plottitle)); |
|
154 |
|
155 if($is_mike == 1) |
|
156 { |
|
157 &p1("set xtics 240"); |
|
158 &p1("set ytics border nomirror 0,2"); |
|
159 &p1("set y2tics border nomirror 0,2"); |
|
160 &p1("set grid xtics "); |
|
161 &p1("set key top left"); |
|
162 $lsid = 1; |
|
163 &p1( "replot ",&qs($theoryfile), " using 1:(\$6/($size*8)) title ",&qs("MAX"), " with lines ls $lsid"); |
|
164 } |
|
165 |
|
166 |
|
167 |
|
168 $xrange=100; |
|
169 $yrange=100; |
|
170 foreach $proto_ (sort keys %protos) { |
|
171 @parts = split(/[ \t]+/,$proto_); |
|
172 $proto = $parts[1]; |
|
173 my $timesfile="$expbase/$proto/times.txt"; |
|
174 print "Proto:$proto_:$proto\n"; |
|
175 if ( !(-e $timesfile)) |
|
176 { |
|
177 next; |
|
178 } |
|
179 my $timesfile1="$expbase/$proto/times1.txt"; |
|
180 |
|
181 &add_stair_step($timesfile,$timesfile1); |
|
182 |
|
183 open(FIN,"$timesfile") || die("cannot open file:$timesfile\n"); |
|
184 $lineno=0; |
|
185 $startime=0;$endtime=0; |
|
186 while($line=<FIN>) |
|
187 { |
|
188 @parts=split(/[ \t]+/,$line); |
|
189 if($lineno == 0) { |
|
190 $startime = $parts[1]; |
|
191 } |
|
192 $endtime=$parts[2]; |
|
193 $lineno=$lineno+1; |
|
194 } |
|
195 close(FIN); |
|
196 |
|
197 $diff=$endtime-$startime; |
|
198 if($xrange < $diff) {$xrange=$diff;} |
|
199 |
|
200 print "good: $timesfile start:$startime end:$endtime xrange:$xrange\n"; |
|
201 |
|
202 my $title ="$protos{$proto_}"; |
|
203 |
|
204 #&p1( "replot ",&qs($timesfile), " using 1:(\$3-$startime) title ",&qs($title), " with lines ls $lsid"); |
|
205 $lsid=$linestyle{$proto}; |
|
206 &p1( "replot ",&qs($timesfile1), " using (\$3-$startime):1 title ",&qs($title), " with linespoints ls $lsid"); |
|
207 } |
|
208 |
|
209 |
|
210 |
|
211 if($stop_at != -1 ) |
|
212 { |
|
213 $xrange = $stop_at; |
|
214 } |
|
215 $yrange=$num*1.2; |
|
216 if($is_mike == 1) |
|
217 { |
|
218 $yrange=$yrange*1.2; |
|
219 $yrange=14.5; |
|
220 } |
|
221 |
|
222 &p1("set xrange [$gx_init:$xrange]"); |
|
223 &p1("set yrange [$gy_init:$yrange]"); |
|
224 |
|
225 |
|
226 |
|
227 if($is_mike == 1) |
|
228 { |
|
229 &p1("set xtics 240"); |
|
230 &p1("set ytics border nomirror 0,2,14"); |
|
231 &p1("set y2tics border nomirror 0,2,14"); |
|
232 &p1("set grid xtics "); |
|
233 &p1("set key top left"); |
|
234 } |
|
235 |
|
236 &p1("replot"); |
|
237 |
|
238 &p1("set term postscript noenhanced color dashed 20 ; "," set output ",&qs("$psbase/plot.ps"), " ; replot ; set term x11 ; "); |
|
239 |
|
240 |
|
241 |
|
242 close(VACFILE); |
|
243 print "Run : \ngnuplot $plotbase/plot.gnp\n"; |
|
244 print "psfile: $psbase/plot.ps\n"; |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 system ("gnuplot $plotbase/plot.gnp"); |
|
250 |
|
251 exit; |
|
252 |
|
253 |
|
254 sub qs() { return "\"" . $_[0] ."\"" ;} #print &qs("HELLO ") ; |
|
255 sub p1() { |
|
256 foreach $foo (@_) { |
|
257 print VACFILE $foo; |
|
258 } |
|
259 print VACFILE "\n"; |
|
260 } |
|
261 |
|
262 sub find() { |
|
263 $_key=$_[0]; |
|
264 $_file =$_[1]; |
|
265 open(FILE,$_file) or die " file not found $_file"; |
|
266 while(<FILE>) { |
|
267 $foo=$_; |
|
268 # print $foo; |
|
269 #if (($key,$gap,$val) = ($foo =~ /(.*)($_key)(\s*=\s*)([\d:_\.]*\b)(.*)/)){ |
|
270 # return $4; |
|
271 #} |
|
272 } |
|
273 close(FILE); |
|
274 } |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 sub add_stair_step() |
|
281 { |
|
282 my($file,$file1) = @_; |
|
283 |
|
284 open(FIN,"$file") || die("cannot open file:$file\n"); |
|
285 open(FOUT,">$file1") || die("cannot open file:$file1\n"); |
|
286 |
|
287 |
|
288 $line = <FIN>; |
|
289 print FOUT $line; |
|
290 |
|
291 @parts = split(/[ \t]+/,$line); |
|
292 |
|
293 $start = $parts[1]; |
|
294 $cur_del = $parts[3]; |
|
295 $end = $parts[4]; |
|
296 $rcvlen = $parts[5]; |
|
297 $sentlen = $parts[6]; |
|
298 $index = 0; |
|
299 print FOUT "0 0 0\n"; |
|
300 while($line = <FIN>) |
|
301 { |
|
302 @parts = split(/[ \t]+/,$line); |
|
303 $cur_del = $parts[2]; |
|
304 chomp($cur_del); |
|
305 #if($cur_del - $start > $stop_at) {last;} |
|
306 |
|
307 print FOUT "$index\t$start $cur_del\n"; |
|
308 print FOUT $line; |
|
309 $index=$index+1; |
|
310 } |
|
311 |
|
312 if($rcvlen >= $sentlen) |
|
313 { |
|
314 $diff = $end-$start; |
|
315 $finalend = $end; |
|
316 if($stop_at != -1 and $stop_at > $diff) { |
|
317 $finalend = $start + $stop_at; |
|
318 } |
|
319 print FOUT "$index $start $finalend\n"; |
|
320 } |
|
321 close(FIN); |
|
322 close(FOUT); |
|
323 } |
|
324 |