File: modelCDF

package info (click to toggle)
ns2 2.35%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,864 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 818; awk: 525; csh: 355
file content (208 lines) | stat: -rwxr-xr-x 4,053 bytes parent folder | download | duplicates (8)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/usr/bin/perl -w

open(IDLEI,"> idle.in.dat");
open(IDLEO,"> idle.out.dat");
open(REQI,"> request.in.dat");
open(REQO,"> request.out.dat");
open(NUMPAGEI,"> numpage.in.dat");
open(NUMPAGEO,"> numpage.out.dat");
open(PAGESIZEI,"> pagesize.in.dat");
open(PAGESIZEO,"> pagesize.out.dat");
open(SESSINTERI,"> sessinter.in.dat");
open(SESSINTERO,"> sessinter.out.dat");
open(SERVER,"> server.dat");
open(SERVERCDF,"> server.dat.cdf");


$numServer = 0;
$oldtimeI = 0;
$oldtimeO = 0;
$oldT = 0;
$oldclnt = "";

print "start processing model output\n";
while (<>) {
        ($type,$fld1,$fld2,$fld3,$fld4,$fld5,$fld6,$fld7,$fld8,$fld9) = split(' ',$_);

	$fld3="";
	$fld7="";

        if ($type eq "req") {
	   if ($fld2 eq $oldclnt) {
	     $idle = $fld5 - $oldT; 
             if ($fld4 eq "7") {
               print IDLEI "$idle\n";
             } else {
               print IDLEO "$idle\n";
	     }
	   }
           if ($fld4 eq "7") {
               print REQI "$fld8\n";
               print PAGESIZEI "$fld9\n";
           } else {
               print REQO "$fld8\n";
               print PAGESIZEO "$fld9\n";
               $server[$numServer] = $fld4;
               $numServer++;
	   }
	   $oldclnt = $fld2;
	   $oldT = $fld5;
        }
        if ($type eq "Session") {
           if ($fld1 eq "Inbound") {
              print NUMPAGEI "$fld4\n";
	      $inter = $fld6 - $oldtimeI;
	      print SESSINTERI "$inter\n";
	      $oldtimeI = $fld6;
	   }
           if ($fld1 eq "Outbound") {
              print NUMPAGEO "$fld4\n";
	      $inter = $fld6 - $oldtimeO;
	      print SESSINTERO "$inter\n";
	      $oldtimeO = $fld6;
	   }
	}
}

print "sort array\n";
@serverSorted = sort @server;
print "done sorting\n";

$old = "";
$serverCnt = 1;
$ns = 0;
$nsSum = 0;
foreach $j (0 .. $#serverSorted) {
  if ($serverSorted[$j] ne $old) {
     if ($old ne "") {
        print SERVER "$serverCnt\n";
        $svr[$ns] = $serverCnt;
        $ns++;
        $nsSum = $nsSum + $serverCnt;
        $serverCnt = 1;
     }
  }
  else {
    $serverCnt++;
  }
  $old = $serverSorted[$j];
}
print SERVER "$serverCnt\n";
$svr[$ns] = $serverCnt;
$nsSum = $nsSum + $serverCnt;

@svrS = sort numerically @svr;

$tmp = 0;
foreach $j (0 .. $#svrS) {
  $tmp = $tmp + $svrS[$j];
  $prob = $tmp/$nsSum;
  $j1 = $j+1;
  print SERVERCDF "$j1 $tmp $prob\n";
}

close(IDLEI);
close(IDLEO);
close(REQI);
close(REQO);
close(NUMPAGEI);
close(NUMPAGEO);
close(PAGESIZEI);
close(PAGESIZEO);
close(SESSINTERI);
close(SESSINTERO);
close(SERVER);
close(SERVERCDF);

#compute CDF
&outputCDF(1,1,1,"request.in.dat");
&outputCDF(1,1,1,"request.out.dat");
&outputCDF(1,1,1,"numpage.in.dat");
&outputCDF(1,1,1,"numpage.out.dat");
&outputCDF(1,1,1,"pagesize.in.dat");
&outputCDF(1,1,1,"pagesize.out.dat");
&outputCDF(0,0.01,1,"sessinter.in.dat");
&outputCDF(0,0.01,1,"sessinter.out.dat");
&outputCDF(1,0.1,1,"idle.in.dat");
&outputCDF(1,0.1,1,"idle.out.dat");

sub numerically { $a <=> $b; }


sub outputCDF {

local($cur_epoch,$incr,$dividend,$tfile) = @_;

local(@data);
local(@dataS);
local(@epoch);
local(@cum);

open(ORIG,$tfile);
$tfileS = join('.',$tfile,"cdf");
$newtfile = join(' ',">",$tfileS);
open(CDF,$newtfile);

$count = 0;
$cur_time = 0;

$i = 0;
while ($line = <ORIG>) {
  chop $line;
  $data[$i] = $line;
  $i++;
}

close(ORIG);

if ($i eq 0) { exit; }


@dataS = sort numerically @data;

$i = 0;
$sum = 0;

foreach $j (0 .. $#dataS) {

$cur_time = $dataS[$j];

if ($cur_time > $cur_epoch) {
   while ($cur_epoch < $cur_time) {

     $epoch[$i] = $cur_epoch;
     $sum = $sum + $count;
     $cum[$i] = $sum;
     $i++;

     $cur_epoch = $cur_epoch + $incr;
     $count=0;
   }
   if ($cur_time <= $cur_epoch) {
      $count = 1;
   } else {
      $count = 0;
   }
} else {
   $count++;
}

}

$epoch[$i] = $cur_epoch;
$sum = $sum + $count;
$cum[$i] = $sum;

$oldcum = 0;
foreach $j (0 .. $#epoch) {
  $prob = $cum[$j]/$cum[$#cum];
  $e = $epoch[$j]/$dividend;
  if ($cum[$j] ne $oldcum) {
     print CDF "$e $cum[$j] $prob\n";
  }
  $oldcum = $cum[$j];
}

close(CDF);
}