/[PAMELA software]/rawreader/src/Read.cpp
ViewVC logotype

Contents of /rawreader/src/Read.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Fri Sep 1 10:56:22 2006 UTC (18 years, 3 months ago) by cafagna
Branch: MAIN
CVS Tags: v1r11
First release in the PAMELA environment, some cleanup in the include
files, module function and Makefile added

1 #include "descript.h"
2
3 void filename(char [], char [], char [], char[], int, char[]);
4 void FindRoute(int[], int*);
5 short int CRC(int []);
6 int restrict(int [], long long int[], int);
7
8 void read(char fni[], char fno[], char INF[],
9 char protocol[], char path[], char name[], char nnnnn_TMP[], float quality[], int real_route[], int &Rcount)
10 {
11 FILE *fo, *fo1, *fout, *foRout, *foMiss, *fo_log_kadr, *fo_route;
12 ifstream fin;
13 ofstream fo_cln1, fokadr_cln1;
14
15 char buf[1024];
16 // char stop1;
17 char ch1,ch2,ch3, ch, file_name_prot[80];
18 char file_route[80]; /*protocol binary filesm mmm_counter_nnnnn_cln1Er.log*/
19 char miss_file[80]; /*protocol files mmm_counter_nnnnn_mis_cln1.dat*/
20 char cln1_file[80]; /*route binary data files mmm_counter_nnnnn_cln1.pam*/
21 char cln1_kadr[80]; /*route binary data files mmm_counter_nnnnn_cln1.bin*/
22 char log_kadr[80]; /*log binary data files mmm_counter_nnnnn_cln1.log*/
23 char log_route[80]; /*log binary file for number of routes*/
24 char Short_Buf[8], Name_Buf[4];
25 short int CalcCheckSum;
26
27 int LenthBuf=1015, flag_help=0;
28 int i, j, k, file_length=0, Hex[3];
29 int N_er=0; /*Number of kadr with name error*/
30 int CRC0_er=0; /*Number of kadr with CRC0 error*/
31 int P_er=0; /*Number of kadr with packet error number*/
32 int M_er=0; /*Number of kadr with rout error number*/
33 int end=0; /*End of last pamela packet*/
34 // Buffers for Kadr analysis
35 int buffer1[1024], buffer2[1024], buffer3[1024];
36 int rr=0;
37
38 int header1, header2, header3, CRC_0[3], CRC_1[3];
39 long long int icount_int;
40 long long int icount_frac, tmpP, numP[3];
41 long int N1=0; /* Number of identified kadrs*/
42 long long int icount=0; /* Number of bytes in identified kadrs*/
43 long long int icount_total=0; /* Total number of bytes*/
44 long long int packet_first[100];/*First kadr number for each route*/
45 long long int packet_last[100]; /*Second kadr number for each route*/
46 long int count_missed[100]; /* Number of missed kadrs in each route*/
47 long int count_sec_missed[100];
48 unsigned long long int count_ident[100]; /* Number of good bytes in each rout*/
49 unsigned long long int count_tot[100]; /* Total number of bytes in each rout*/
50 int NumRout[1000]; /* Number of Route*/
51 long long int Num_kadrs[1000]; /* Number of identified kadrs in each rout*/
52 long int Num_good_kadrs[1000]; /* Number of normal kadrs in each rout*/
53 long long int Num_bad_kadrs[1000]; /* Bad kadrs number in each rout*/
54 // float quality[100]; /* File quality pointer*/
55 int counter=0; /* Last byte position in truncated kadr*/
56 int adr1=0; /* Initial byte of kadr in cln1.bin*/
57 int adr2=0; /* Last byte of kadr in cln2.bin*/
58 int tmp=0;
59 int numPack[4]; /* Number of kadr in given route*/
60 int adress[4];
61 int R_er[100]; /* Rout errors number in given rout*/
62 int R_er_interf1[100]; /* Interface Rout error at begin of rout*/
63 int R_er_interf2[100]; /* Interface Rout error at end of rout*/
64 int Mis_group[1000]; /* Number of missed kadrs group
65 for each rout*/
66 int Pack_Er[1000]; /* Number of packets with packet number
67 error for each rout*/
68 int CRC_bad_kadr[3]; /* Current CRC bad kadr number*/
69 int flag_pack[3]; /* Flag for error in packet number*/
70 int flag_rout[3]; /* Flag for error in rout number*/
71 int flag_name[3]; /* Flag for name error*/
72 int flag_CRC0[3]; /* Flag for CRC0 error*/
73 int flag_CRC[3]; /* Flag for CRC error*/
74 int flag_CRC_cor[3]; /* Flag for CRC error correction*/
75 int flag_tr[3]; /* Truncate flag*/
76 short int flags; /* Number for all errors*/
77
78 for (j=0; j<4; j++) {adress[j]=0; numPack[j]=0;}
79 for (j=0; j<1024; j++)
80 {buffer1[j]=0; buffer2[j]=0; buffer3[j]=0;}
81 for (i=0; i<100; i++)
82 {Num_kadrs[i]=0;
83 NumRout[i]=0;
84 packet_first[i]=0;
85 packet_last[i]=0;
86 count_missed[i]=0;
87 count_sec_missed[i]=0;
88 count_ident[i]=0;
89 count_tot[i]=0;
90 R_er[i]=0;
91 R_er_interf1[i]=0;
92 Num_bad_kadrs[i]=0;
93 Num_good_kadrs[i]=0;
94 quality[i]=0; Mis_group[i]=0; Pack_Er[i]=0;
95 R_er_interf2[i]=0;}
96 for (i=0; i<3; i++)
97 {numP[i]=0; CRC_bad_kadr[i]=0; Hex[i]=0;
98 flag_pack[i]=0; flag_rout[i]=0;
99 flag_name[i]=0; flag_CRC0[i]=0; flag_tr[i]=0;
100 flag_CRC[i]=0; flag_CRC_cor[i]=0;}
101 // open input file "nnnnnmmm.pam"
102 fin.open(fni, ifstream::binary);
103 if(fin.good()==0) {cerr<<"can not open input file"; exit(0);}
104 //open output file "nnnnnmmm_work.dat"
105 fout=fopen(fno, "wb");
106 if(fout==0) {cerr<<"can not open outputfile"; exit(0);}
107 //open output file "nnnnnmmm_protocol.txt"
108 fo=fopen(protocol, "wb");
109 if(fo==0) {cerr<<"can not open protocol file"; exit(0);}
110 //open output file "nnnnnmmm_cln1.inf"
111 fo1=fopen(INF, "wb");
112 if(fo1==0) {cerr<<"can not open inf file"; exit(0);}
113 //open output file "nnnnnmmm_route.log"
114 strncpy(log_route,INF,strlen(INF)-9);
115 log_route[strlen(INF)-9]='\0';
116 strcat(log_route,"_route.log");
117 fo_route=fopen(log_route, "wb");
118 if(fo_route==0) {cerr<<"can not open file for routes number"; exit(0);}
119 /////////////////////////////////////////////////////////////////
120 // cin>>stop1;
121 k=0;
122 while(fin.eof()==0)
123 {
124 counter=0; //pounter for position of kadr truncation
125 N_er=0;
126 M_er=0;
127 P_er=0;
128 CRC0_er=0;
129 if (N1==0) Rcount=1;
130 /**********************data reading********************************/
131 fin.read(Name_Buf,3);
132 if (fin.eof()) break;
133 fin.read(Short_Buf,5);
134 if (fin.eof()) break;
135 ch1=Name_Buf[0];
136 ch2=Name_Buf[1];
137 ch3=Name_Buf[2];
138 tmpP=(long int)(unsigned char)(Short_Buf[1])+
139 256*(long int)(unsigned char)(Short_Buf[2])+
140 256*256*(long int)(unsigned char)(Short_Buf[3]);
141 icount+=8; icount_total+=8;
142 count_ident[Rcount-1]+=8; count_tot[Rcount-1]+=8;
143
144 while((ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&&
145 (N1==0||buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])))
146 ||
147 (ch2!=(char)(CODE2)&&ch3!=(char)(CODE3)&&(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||(numP[2]+1)!=tmpP))
148 ||
149 (ch3!=(char)(CODE3)&&ch1!=(char)(CODE1)&&((numP[2]+1)!=tmpP||buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])))
150 ||
151 (ch1!=(char)(CODE1)&&
152 (buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP))
153 ||
154 (ch2!=(char)(CODE2)&&
155 (buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP))
156 ||
157 (ch3!=(char)(CODE3)&&
158 (buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP))
159 ||
160 (ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&&ch3!=(char)(CODE3)))
161 {fin.get(ch);
162 if (fin.eof()) {/*cerr<<"\n"<<"gopa";*/ break;}
163 ch1=ch2; ch2=ch3; ch3=Short_Buf[0];
164 for (i=0;i<4;i++) Short_Buf[i]=Short_Buf[i+1]; Short_Buf[4]=ch;
165 icount_total+=1; count_tot[Rcount-1]+=1;
166 tmpP=(long int)(unsigned char)(Short_Buf[1])+
167 256*(long int)(unsigned char)(Short_Buf[2])+
168 256*256*(long int)(unsigned char)(Short_Buf[3]);
169 }
170 if ((fin.eof())&&(N1==0))
171 {
172 fclose(fout);
173 remove(fno);
174 fclose(fo);
175 remove(protocol);
176 fclose(fo1);
177 remove(INF);
178 exit(0);
179 }
180 // cout<<"icount_total="<<icount_total<<" "<<N1<<"\n";
181 // printf("%x %x %x \n",(int)(unsigned char)(ch1),(int)(unsigned char)(ch2),(int)(unsigned char)(ch3));
182 // printf("%x %x %x %x %x\n",(int)(unsigned char)(Short_Buf[0]),(int)(unsigned char)(Short_Buf[1]),
183 // (int)(unsigned char)(Short_Buf[2]),(int)(unsigned char)(Short_Buf[3]),
184 // (int)(unsigned char)(Short_Buf[4]));
185 // printf("buffer3[3]= %x\n",(int)(unsigned char)buffer3[3]);
186 // printf("numP[2]+1= %x tmpP= %x\n",numP[2]+1, tmpP);
187 // printf("buffer3[1023]= %x\n",(int)(unsigned char)buffer3[1023], tmpP);
188
189 /*****************************************************************/
190 /*********************data reading********************************/
191 fin.read(buf,LenthBuf);
192 if (fin.eof()) break;
193 icount+=1015; icount_total+=1015;
194 count_ident[Rcount-1]+=1015; count_tot[Rcount-1]+=1015;
195 /****************************************************************/
196 /********************data reading********************************/
197 fin.get(ch);
198 icount+=1; icount_total+=1;
199 count_ident[Rcount-1]+=1; count_tot[Rcount-1]+=1;
200 if (fin.eof()) break;
201 /***************************************************************/
202 N1+=1; Num_kadrs[Rcount-1]+=1;
203
204 /**********************DATA ANALYSIS****************************/
205 /***************************************************************/
206 header1=(unsigned char)(ch1);
207 header2=(unsigned char)(ch2);
208 header3=(unsigned char)(ch3);
209 switch (N1)
210 {
211 case 1:{
212 buffer3[0]=(int)(unsigned char)(ch1);
213 buffer3[1]=(int)(unsigned char)(ch2);
214 buffer3[2]=(int)(unsigned char)(ch3);
215 buffer3[3]=(int)(unsigned char)(Short_Buf[0]);
216 buffer3[4]=(int)(unsigned char)(Short_Buf[1]);
217 buffer3[5]=(int)(unsigned char)(Short_Buf[2]);
218 buffer3[6]=(int)(unsigned char)(Short_Buf[3]);
219 buffer3[7]=(int)(unsigned char)(Short_Buf[4]);
220 for (i=0; i<1015; i++)
221 {buffer3[i+8]=(int)(unsigned char)(buf[i]);}
222 buffer3[1023]=(int)(unsigned char)(ch);
223 for (i=0; i<1024; i++)
224 {buffer1[i]=buffer3[i];buffer2[i]=buffer3[i];}
225
226 NumRout[Rcount-1]=1;
227 numP[2]=(long int)(unsigned char)(Short_Buf[1])+
228 256*(long int)(unsigned char)(Short_Buf[2])+
229 256*256*(long int)(unsigned char)(Short_Buf[3]);
230 CRC_bad_kadr[2]=0;
231 flag_pack[2]=0; flag_rout[2]=0;
232 flag_name[2]=0; flag_CRC0[2]=0; flag_tr[2]=0;
233 flag_CRC[2]=0; flag_CRC_cor[2]=0;
234 for (i=0; i<2; i++)
235 {numP[i]=numP[2];CRC_bad_kadr[i]=CRC_bad_kadr[2];
236 flag_pack[i]=flag_pack[2]; flag_rout[i]=flag_rout[2];
237 flag_name[i]=flag_name[2]; flag_CRC0[i]=flag_CRC0[2];
238 flag_CRC[i]=flag_CRC[2]; flag_tr[i]=flag_tr[2];
239 flag_CRC_cor[i]=flag_CRC_cor[2];}
240 CRC_0[2]=(int)(unsigned char)(Short_Buf[4]);
241 for (i=0; i<2; i++)
242 {CRC_0[i]=CRC_0[2];}
243 CRC_1[2]=(int)(unsigned char)(ch);
244 for (i=0; i<2; i++)
245 {CRC_1[i]=CRC_1[2];}
246 packet_first[Rcount-1]=numP[2];
247 break;
248 }
249 default:{
250 for (i=0; i<1024; i++)
251 {buffer1[i]=buffer2[i];buffer2[i]=buffer3[i];}
252 buffer3[0]=(int)(unsigned char)(ch1);
253 buffer3[1]=(int)(unsigned char)(ch2);
254 buffer3[2]=(int)(unsigned char)(ch3);
255 buffer3[3]=(int)(unsigned char)(Short_Buf[0]);
256 buffer3[4]=(int)(unsigned char)(Short_Buf[1]);
257 buffer3[5]=(int)(unsigned char)(Short_Buf[2]);
258 buffer3[6]=(int)(unsigned char)(Short_Buf[3]);
259 buffer3[7]=(int)(unsigned char)(Short_Buf[4]);
260 for (i=0; i<1015; i++)
261 {buffer3[i+8]=(int)(unsigned char)(buf[i]);}
262 buffer3[1023]=(int)(unsigned char)(ch);
263
264 for (i=0; i<2; i++)
265 {numP[i]=numP[i+1]; CRC_bad_kadr[i]=CRC_bad_kadr[i+1];
266 flag_pack[i]=flag_pack[i+1];
267 flag_rout[i]=flag_rout[i+1];
268 flag_name[i]=flag_name[i+1];
269 flag_CRC0[i]=flag_CRC0[i+1];
270 flag_tr[i]=flag_tr[i+1];
271 flag_CRC[i]=flag_CRC[i+1];
272 flag_CRC_cor[i]=flag_CRC_cor[i+1];}
273 numP[2]=(long int)(unsigned char)(Short_Buf[1])+
274 256*(long int)(unsigned char)(Short_Buf[2])+
275 256*256*(long int)(unsigned char)(Short_Buf[3]);
276 CRC_bad_kadr[2]=0;
277 flag_pack[2]=0; flag_rout[2]=0;
278 flag_name[2]=0; flag_CRC0[2]=0;
279 flag_CRC[2]=0; flag_CRC_cor[2]=0; flag_tr[2]=0;
280 for (i=0; i<2; i++) CRC_0[i]=CRC_0[i+1];
281 CRC_0[2]=(int)(unsigned char)(Short_Buf[4]);
282 for (i=0; i<2; i++) {CRC_1[i]=CRC_1[i+1];}
283 CRC_1[2]=(int)(unsigned char)(ch);
284 }
285 }
286 // if (fmod(N1,10000)==0.) cout<<N1<<"\n";
287 // Caf mod on 31 Aug 2006
288 if ((N1%10000)==0 && N1>0) cout<<N1<<"\n";
289 // end mod
290
291 /******************CRC ERROR ANALYSIS***************************/
292 CalcCheckSum=CRC(buffer3);
293 if (CalcCheckSum!=(short int)(buffer3[1023]))
294 {
295 /*if (numP[2]==1026)
296 {for (i=0;i<8;i++) printf(" %x ",buffer3[i]); printf("\n");
297 for (i=8;i<16;i++) printf(" %x ",buffer3[i]); printf("\n");
298 for (i=1000;i<1008;i++) printf(" %x ",buffer3[i]); printf("\n");
299 printf("%x %x %x %x",buffer3[1020],buffer3[1021],buffer3[1022],buffer3[1023]);
300 cin>>i;}*/
301 fprintf(fout,"CRC = %x (%x) error in kadr %i\n", buffer3[1023],CalcCheckSum,numP[2]); //write in file nnnnn_work.dat
302 // cerr<<"checksum error "<<Rcount<<" Cadre="<<numP[2]<<
303 // " "<<buffer3[3]<<"\n";
304 flag_CRC[2]=1;
305 Num_bad_kadrs[Rcount-1]+=1;
306 CRC_bad_kadr[2]=numP[2];
307 counter=restrict(buffer3,numP,buffer2[3]);
308 if (counter!=0)
309 {fprintf(fout," truncate byte=%i",counter);
310 cout<<" truncate counter="<<counter<<" route="<<buffer2[3]<<" "<<buffer3[3]<<" kadr="<<numP[2]<<" "<<numP[1]<<" "<<numP[0]<<"\n";
311 fin.seekg(-(1024-counter),ios::cur);
312 icount-=1024;
313 count_ident[Rcount-1]-=1024;
314 count_tot[Rcount-1]-=1024-counter;
315 icount_total-=1024-counter;
316 N1-=1;
317 CRC_bad_kadr[2]=0;
318 flag_tr[2]=1;
319 Num_kadrs[Rcount-1]-=1;
320 Num_bad_kadrs[Rcount-1]-=1;}
321 }
322
323 /******************HEADER ANALYSIS*******************************/
324 if ((header1!=(int)(CODE1))||(header2!=(int)(CODE2))||(header3!=(int)(CODE3)))
325 {flag_name[2]=1; N_er=N1;}
326 /****************************************************************/
327
328 /******************CRC0 ANALYSIS*********************************/
329 if ((buffer2[7]!=buffer1[1023])&&
330 ((numP[1]==numP[0]+1)||(numP[1]==numP[2]-1))&&(flag_tr[1]!=1)&&(flag_tr[0]!=1)&&(N1>2))
331 {flag_CRC0[1]=1; CRC0_er=N1-1;}
332 /****************************************************************/
333
334 /******************KADR NUMBER ANALYSIS**************************/
335 if ((numP[1]!=(numP[0]+1))&&(numP[1]!=(numP[2]-1))&&(N1!=1)&&(CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0))
336 {P_er=N1-1; flag_pack[1]=1;
337 //Correct error packet number//
338 tmpP=numP[0]+1;
339 for (i=0;i<3;i++) Hex[i]=0;
340 for (i=0;i<3;i++)
341 {if (tmpP/(long int)(pow(256.,2-i))>=1)
342 {Hex[2-i]=(int)(tmpP/(long int)(pow(256.,2-i)));
343 tmpP=tmpP-(long int)pow(256.,2-i)*(int)(tmpP/(long int)(pow(256.,2-i)));}}
344 for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]);
345 if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
346
347 tmpP=numP[2]-1;
348 for (i=0;i<3;i++) Hex[i]=0;
349 for (i=0;i<3;i++)
350 {if (tmpP/(long int)(pow(256.,2-i))>=1)
351 {Hex[2-i]=(int)(tmpP/(long int)(pow(256.,2-i)));
352 tmpP=tmpP-(long int)pow(256.,2-i)*(int)(tmpP/(long int)(pow(256.,2-i)));}}
353 for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]);
354 if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
355 }
356 /////////////////////////////////////////////////////////////////////
357 if ((numP[2]!=(numP[1]+1))&&(N1!=1)&&(buffer3[3]==buffer2[3])&&(CRC_bad_kadr[2]==numP[2])&&(numP[2]!=0)) flag_pack[2]=1;
358 if (flag_pack[2]!=1) packet_last[Rcount-1]=numP[2];
359 ////////Missing kadr analysis////////////////////////////////////
360 /**route number: 10 (10 19 10) 10 ******************************/
361 /**kadr number: 21 (22 17 18) 19 ******************************/
362 /**missed kadrs: 21 20 19 18 17 ******************************/
363 if ((numP[1]<numP[0])&&(numP[1]==numP[2]-1)&&(buffer1[3]==buffer3[3])&&(flag_tr[1]==0)&&
364 (flag_pack[0]==0)&&(flag_pack[1]==0)&&(flag_pack[2]==0))
365 {Mis_group[Rcount-1]+=1;
366 fprintf(foMiss,"secondary transmitted kadres may be %9i%9i\n",numP[1]+1,numP[0]-1);
367 count_sec_missed[Rcount-1]+=numP[0]-1-numP[1]-1;}
368 /**route number: 10 (10 19 10) 10 ******************************/
369 /**kadr number: 11 (12 15 20) 21 ******************************/
370 /**missed kadrs: 16 17 18 19 ******************************/
371 if ((numP[1]>numP[0]+1)&&(numP[1]<numP[2]-1)&&(buffer1[3]==buffer3[3])&&(flag_tr[1]==0)&&
372 (flag_pack[0]==0)&&(flag_pack[1]==0)&&(flag_pack[2]==0))
373 {Mis_group[Rcount-1]+=1;
374 fprintf(foMiss,"%9i%9i\n",numP[1]+1,numP[2]-1);
375 count_missed[Rcount-1]+=numP[2]-numP[1]-1;}
376 /**route number: (10 10 10) 10 10 ******************************/
377 /**kadr number: (11 12 15) 20 21 ******************************/
378 /**missed kadrs: 13 14 ******************************/
379 else if ((numP[1]>=numP[0]+1)&&(numP[1]<numP[2]-1)&&
380 (buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&&
381 (flag_tr[1]==0)&&(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0))
382 {Mis_group[Rcount-1]+=1;
383 fprintf(foMiss,"%9i%9i\n",numP[0]+2,numP[2]-1);
384 count_missed[Rcount-1]+=numP[2]-numP[0]-1-1;}
385 /**route number: (10 10 10) 10 10 ******************************/
386 /**kadr number: (11 29 15) 14 15 ******************************/
387 /**number of missed kadrs:2 ******************************/
388 else if (((numP[1]<numP[0]+1)||(numP[1]>numP[2]-1))&&(numP[2]-numP[0]>2)&&
389 (buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&&(flag_tr[1]==0)&&
390 (flag_pack[2]==0)&&(flag_pack[1]==1)&&(flag_pack[0]==0))
391 {Mis_group[Rcount-1]+=1;
392 fprintf(foMiss,"%9i%9i -1\n",numP[0]+1,numP[2]-1);
393 count_missed[Rcount-1]+=numP[2]-numP[0]-1-1;}
394 //truncate kadr
395 /**route number: 10 (10 10 10) 10 ******************************/
396 /**kadr number: 11 (12 13 14) 15 ******************************/
397 /**missed truncate kadr:13 ******************************/
398 else if ((numP[0]<numP[2]-1)&&(buffer1[3]==buffer3[3])&&
399 (flag_tr[0]==0)&&(flag_tr[1]==1)&&(flag_tr[2]==0)&&
400 (flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0))
401 {Mis_group[Rcount-1]+=1;
402 fprintf(foMiss,"%9i%9i\n",numP[0]+1,numP[2]-1);
403 count_missed[Rcount-1]+=numP[2]-numP[0]-1;}
404 /***************************************************************/
405
406 /******************ROUTE NUMBER ANALYSIS**************************/
407 if ((buffer2[3]!=buffer1[3])&&(buffer2[3]!=buffer3[3])&&(buffer1[3]!=buffer3[3])&&
408 (flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0))
409 {
410 /******************Interface route error 1***********************/
411 /**route number:7 7 ( 7 4 8) 8 8 **************************/
412 /**kadr number:197 198 (199 200 1) 2 3 **************************/
413 /*if ((numP[1]==numP[0]+1)&&(numP[2]<numP[0]))
414 {Rcount+=1; flag_rout[1]=1;
415 packet_last[Rcount-2]=numP[1];
416 packet_first[Rcount-1]=numP[2];
417 Num_kadrs[Rcount-1]+=1;
418 Num_kadrs[Rcount-2]-=1;
419 R_er[Rcount-2]+=1;
420 R_er_interf2[Rcount-2]+=1;
421 M_er=N1-1;
422 count_ident[Rcount-1]+=1024; count_ident[Rcount-2]-=1024;
423 count_tot[Rcount-1]+=1024; count_tot[Rcount-2]-=1024;
424 NumRout[Rcount-1]=Rcount;
425 cout<<"\n interface1 "<<NumRout[Rcount-1]<<" "<<Rcount;
426 // cin>>stop1;
427 if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0))
428 {
429 //Correct error route number//////////////////////////////////////////
430 buffer2[3]=buffer1[3];
431 if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
432 ////////////////////////////////////////////////////////////////////
433 flags=(short int)(pow((float)(2*flag_name[1]),4)+
434 pow((float)(2*flag_rout[1]),1)+
435 pow((float)(2*flag_pack[1]),2)+
436 pow((float)(2*flag_CRC0[1]),3)+
437 pow((float)(2*flag_CRC[1]),5)+
438 pow((float)(2*flag_CRC_cor[1]),6));
439 fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),
440 (char)(buffer2[5]),(char)(buffer2[6]),(char)(flags));
441 fprintf(fout,"%i Interface route error 1 %i\n",CRC_bad_kadr[1],flags);
442 CRC_bad_kadr[1]=0;
443 }
444 // CREATE FILE NAMES
445 filename(file_route, miss_file, cln1_file, path,
446 NumRout[Rcount-1], name);
447 strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3);
448 cln1_kadr[strlen(cln1_file)-3]='\0';
449 strcat(cln1_kadr,"bin");
450 strncpy(log_kadr,file_route,strlen(file_route)-6);
451 log_kadr[strlen(file_route)-6]='\0';
452 strcat(log_kadr,"_bin.log");
453 fclose(foRout); //Close files
454 fo_cln1.close(); //for old
455 fclose(foMiss); //route
456 fokadr_cln1.close();
457 fclose(fo_log_kadr);
458 //Open files for new route
459 foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log
460 foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat
461 fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam
462 fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin
463 fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log
464 }*/
465 /******************Interface route error 2***********************/
466 /**route number:7 7 ( 7 4 8) 8 ******************************/
467 /**kadr number:198 199 (200 1 2) 3 ******************************/
468 /*if ((numP[1]==numP[2]-1)&&(numP[1]<numP[0])&&(buffer2[3]!=0))
469 {Rcount+=1; flag_rout[1]=1;
470 packet_last[Rcount-2]=numP[0];
471 packet_first[Rcount-1]=numP[1];
472 Num_kadrs[Rcount-1]+=2;
473 Num_kadrs[Rcount-2]-=2;
474 R_er[Rcount-1]+=1;
475 R_er_interf1[Rcount-1]+=1;
476 M_er=N1-1;
477 count_ident[Rcount-1]+=2048; count_ident[Rcount-2]-=2048;
478 count_tot[Rcount-1]+=2048; count_tot[Rcount-2]-=2048;
479 NumRout[Rcount-1]=Rcount;
480 cout<<"\n interface2 "<<NumRout[Rcount-1]<<" "<<Rcount;
481 // cin>>stop1;
482 // CREATE FILE NAMES
483 filename(file_route, miss_file, cln1_file, path,
484 NumRout[Rcount-1], name);
485 strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3);
486 cln1_kadr[strlen(cln1_file)-3]='\0';
487 strcat(cln1_kadr,"bin");
488 strncpy(log_kadr,file_route,strlen(file_route)-6);
489 log_kadr[strlen(file_route)-6]='\0';
490 strcat(log_kadr,"_bin.log");
491 fclose(foRout); //Close files
492 fo_cln1.close(); //for old
493 fclose(foMiss); //route
494 fokadr_cln1.close();
495 fclose(fo_log_kadr);
496 //Open files for new route
497 foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log
498 foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat
499 fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam
500 fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin
501 fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log
502 if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0))
503 {Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1;
504 //Correct error rout number//////////////////////////////////////////
505 buffer2[3]=buffer3[3];
506 if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
507 ////////////////////////////////////////////////////////////////////
508 flags=(short int)(pow((float)(2*flag_name[1]),4)+
509 pow((float)(2*flag_rout[1]),1)+
510 pow((float)(2*flag_pack[1]),2)+
511 pow((float)(2*flag_CRC0[1]),3)+
512 pow((float)(2*flag_CRC[1]),5)+
513 pow((float)(2*flag_CRC_cor[1]),6));
514 fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags));
515 fprintf(fout,"%i Interface route error 2 %i\n",CRC_bad_kadr[1],flags);
516 CRC_bad_kadr[1]=0;}
517 }*/
518 /******************Interface route error 3************************/
519 /**route number:7 7 ( 7 8 4) 8 8******************************/
520 /**kadr number:198 199 (200 1 2) 3 4******************************/
521 /* if ((numP[1]==numP[2]-1)&&(flag_CRC[1]==0)&&(flag_CRC[2]==1))
522 {Rcount+=1;
523 packet_last[Rcount-2]=numP[0];
524 packet_first[Rcount-1]=numP[1];
525 NumRout[Rcount-1]=Rcount;
526 Num_kadrs[Rcount-2]-=2;
527 Num_kadrs[Rcount-1]+=2;
528 count_ident[Rcount-1]+=2048; count_ident[Rcount-2]-=2048;
529 count_tot[Rcount-1]+=2048; count_tot[Rcount-2]-=2048;
530 Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1;
531 cout<<"\n interface3 "<<NumRout[Rcount-1]<<" "<<Rcount;
532 // cin>>stop1;
533 // CREATE FILE NAMES
534 filename(file_route, miss_file, cln1_file, path,
535 NumRout[Rcount-1], name);
536 strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3);
537 cln1_kadr[strlen(cln1_file)-3]='\0';
538 strcat(cln1_kadr,"bin");
539 strncpy(log_kadr,file_route,strlen(file_route)-6);
540 log_kadr[strlen(file_route)-6]='\0';
541 strcat(log_kadr,"_bin.log");
542 fclose(foRout); //Close files
543 fo_cln1.close(); //for old
544 fclose(foMiss); //route
545 fokadr_cln1.close();
546 fclose(fo_log_kadr);
547 //Open files for new route
548 foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log
549 foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat
550 fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam
551 fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin
552 fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log
553 flags=(short int)(pow((float)(2*flag_name[1]),4)+
554 pow((float)(2*flag_rout[1]),1)+
555 pow((float)(2*flag_pack[1]),2)+
556 pow((float)(2*flag_CRC0[1]),3)+
557 pow((float)(2*flag_CRC[1]),5)+
558 pow((float)(2*flag_CRC_cor[1]),6));
559 fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags));
560 fprintf(fout,"%i Interface route error 3 %i\n",CRC_bad_kadr[1],flags);
561 CRC_bad_kadr[1]=0;
562 }*/
563 }
564 /**************Return to old route*******************************/
565 /**route number: 7 (8 4 8) 8*************************************/
566 /*if ((buffer2[3]!=buffer1[3])&&(buffer2[3]!=buffer3[3])&&
567 (buffer1[3]==buffer3[3])&&(buffer2[3]!=0)&&(N1>2))
568 {
569 R_er[Rcount-1]+=1; flag_rout[1]=1;
570 M_er=N1-1;
571 if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0))
572 {
573 //Correct error route number//////////////////////////////////////////
574 buffer2[3]=buffer1[3];
575 if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
576 ////////////////////////////////////////////////////////////////////
577 flags=(short int)(pow((float)(2*flag_name[1]),4)+
578 pow((float)(2*flag_rout[1]),1)+
579 pow((float)(2*flag_pack[1]),2)+
580 pow((float)(2*flag_CRC0[1]),3)+
581 pow((float)(2*flag_CRC[1]),5)+
582 pow((float)(2*flag_CRC_cor[1]),6));
583 fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags));
584 fprintf(fout,"%i Old route error %i\n",CRC_bad_kadr[1],flags);
585 CRC_bad_kadr[1]=0;}
586 cout<<"\n"<<Rcount<<" old "<<NumRout[Rcount-1]<<" "<<buffer1[3]<<" "<<buffer2[3]<<" "<<buffer3[3]<<" N1="<<N1-1<<"\n";
587 }*/
588 /**************First route***************************************/
589 /**route number: (0 4) 4*****************************************/
590 /**kadr number: (0 1) 2*****************************************/
591 if (N1==2)
592 {packet_first[Rcount-1]=numP[1];
593 packet_last[Rcount-1]=numP[2];
594 NumRout[Rcount-1]=1;
595 // CREATE FILE NAMES
596 filename(file_route, miss_file, cln1_file, path,
597 NumRout[Rcount-1], name);
598 strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3);
599 cln1_kadr[strlen(cln1_file)-3]='\0';
600 strcat(cln1_kadr,"bin");
601 strncpy(log_kadr,file_route,strlen(file_route)-6);
602 log_kadr[strlen(file_route)-6]='\0';
603 strcat(log_kadr,"_bin.log");
604 //Open files for new route
605 foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log
606 foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat
607 fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam
608 if (!fo_cln1) cout<<"can not open "<<cln1_file<<"\n";
609 fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin
610 if (!fokadr_cln1) cout<<"can not open "<<cln1_kadr<<"\n";
611 fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log
612 // cout<<"\n"<<Rcount<<" old "<<NumRout[Rcount-1]<<" "<<numP[1]<<" N1="<<N1-1;
613 }
614 /***************New route***************************************/
615 /**route number: 7 ( 7 0 8) 8*********************************/
616 /**kadr number: 199 (200 0 1) 2*********************************/
617 /**route number: 7 ( 7 8 8) 8*********************************/
618 /**kadr number: 199 (200 0 1) 2*********************************/
619 if ( ((buffer1[3]!=buffer3[3])&&(buffer2[3]==0)&&(N1>3)&&(numP[1]!=numP[0]+1)&&(numP[1]<10))||
620 ((buffer1[3]!=buffer2[3])&&(buffer2[3]==buffer3[3])&&(buffer1[3]!=0)&&(numP[1]!=numP[0]+1)&&(numP[1]<10))||
621 ((numP[2]==numP[1]+1)&&(numP[1]==0)&&(Num_kadrs[Rcount-1]>1000000)) )
622 {Rcount+=1;
623 packet_last[Rcount-2]=numP[0];
624 packet_first[Rcount-1]=numP[1];
625 NumRout[Rcount-1]=Rcount;
626 cout<<"New route="<<Rcount<<" "<<buffer1[3]<<" "<<buffer2[3]<<" "<<buffer3[3]<<"\n";
627 cout<<numP[0]<<" "<<numP[1]<<" "<<numP[2]<<"\n";cin>>i;
628 if (flag_tr[1]==0)
629 {Num_kadrs[Rcount-2]-=2;
630 Num_kadrs[Rcount-1]+=2;
631 count_ident[Rcount-1]+=2048; count_ident[Rcount-2]-=2048;
632 count_tot[Rcount-1]+=2048; count_tot[Rcount-2]-=2048;}
633 else
634 {Num_kadrs[Rcount-2]-=1;
635 Num_kadrs[Rcount-1]+=1;
636 count_ident[Rcount-1]+=1024; count_ident[Rcount-2]-=1024;
637 count_tot[Rcount-1]+=1024; count_tot[Rcount-2]-=1024;}
638 // CREATE FILE NAMES
639 filename(file_route, miss_file, cln1_file, path,
640 NumRout[Rcount-1], name);
641 strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3);
642 cln1_kadr[strlen(cln1_file)-3]='\0';
643 strcat(cln1_kadr,"bin");
644 strncpy(log_kadr,file_route,strlen(file_route)-6);
645 log_kadr[strlen(file_route)-6]='\0';
646 strcat(log_kadr,"_bin.log");
647 fclose(foRout); //Close files
648 fo_cln1.close(); //for old
649 fclose(foMiss); //route
650 fokadr_cln1.close();
651 fclose(fo_log_kadr);
652 //Open files for new route
653 foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log
654 foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat
655 fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam
656 fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin
657 fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log
658 if ((CRC_bad_kadr[2]==numP[2])&&(numP[2]!=0)) {Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1;}
659 if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0))
660 {Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1;
661 flags=(short int)(pow((float)(2*flag_name[1]),4)+
662 pow((float)(2*flag_rout[1]),1)+
663 pow((float)(2*flag_pack[1]),2)+
664 pow((float)(2*flag_CRC0[1]),3)+
665 pow((float)(2*flag_CRC[1]),5)+
666 pow((float)(2*flag_CRC_cor[1]),6));
667 fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags));
668 fprintf(fout,"%i New route %i\n",CRC_bad_kadr[1],flags);
669 CRC_bad_kadr[1]=-1;}
670 // cout<<Rcount<<" New "<<NumRout[Rcount-1]<<" "<<numP[1]<<"\n";
671 }
672
673 if ((numP[1]==0)&&(N1>1))
674 {rr=0;
675 FindRoute(buffer2, &rr);
676 if (rr>0)
677 {
678 real_route[Rcount]=rr;
679 }
680 else
681 {
682 real_route[Rcount]=0;
683 }
684 }
685 /***************************************************************/
686 if (CRC_bad_kadr[1]==numP[1])
687 {
688 //Correct CRC0 error/////////////////////////////////////////////////
689 buffer2[7]=buffer1[1023];
690 if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
691 //Correct name error/////////////////////////////////////////////////
692 buffer2[0]=(int)(CODE1);
693 buffer2[1]=(int)(CODE2);
694 buffer2[2]=(int)(CODE3);
695 if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
696 }
697 ////////////////////////////////////////////////////////////////////
698 /*******************************************************************/
699 if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)&&(N1>1))
700 {
701 flags=(short int)(pow((float)(2*flag_name[1]),4)+
702 pow((float)(2*flag_rout[1]),1)+
703 pow((float)(2*flag_pack[1]),2)+
704 pow((float)(2*flag_CRC0[1]),3)+
705 pow((float)(2*flag_CRC[1]),5)+
706 pow((float)(2*flag_CRC_cor[1]),6));
707 fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),
708 (char)(buffer2[5]),(char)(buffer2[6]),(char)(flags));
709 fprintf(fout,"%i flags=%i\n",CRC_bad_kadr[1],flags);}
710
711 /***************************************************************/
712 // cout <<"\nCalcChekSum="<<dec <<right<<CalcCheckSum
713 // <<"\npacket.CheckSum1="<<right<<packet.CheckSum1;
714 // cout <<"\nPacket number="<<packet.Pckt_Num<<" "<<endl;
715 //*Packet analysis**********************************************
716 if (N_er!=0) fprintf(fout,"Name error %i in kadr %i\n",numP[2],N_er);
717 if (M_er!=0) fprintf(fout,"Root number error %i in kadr %i\n",numP[1],M_er);
718 if (P_er!=0) fprintf(fout,"Number packet error %i in kadr %i\n",numP[1], P_er);
719 if (CRC0_er!=0) fprintf(fout,"CRC0 error %i in kadr %i\n",numP[1], CRC0_er);
720
721 /***************PAMELA data extracting for each route***********/
722 // if (N1!=1&&(flag_CRC[1]==0||(flag_rout[1]==0&&flag_pack[1]==0)||
723 // (flag_CRC[1]!=0&&flag_CRC_cor[1]==1)))
724 if (N1!=1)
725 {end=0;
726 if (buffer2[3]!=buffer1[3]||buffer2[3]!=buffer3[3])
727 {for (i=8;i<1020;i++)
728 {
729 // if (fmodf(float((Num_kadrs[Rcount-1]-1)*1015+i-8),float(64))==0.&&buffer2[i]==0&&buffer2[i+1]==0&&
730 // buffer2[i+2]==0&&buffer2[i+3]==0) end=1;
731 if (end!=1) fo_cln1<<(unsigned char)buffer2[i];
732 }
733 if (end!=1) for(i=1020;i<1023;i++) {fo_cln1<<(unsigned char)buffer2[i];}
734 }
735 else {for(i=8;i<1023;i++) fo_cln1<<(unsigned char)buffer2[i];}
736 for (i=0;i<1024;i++) {fokadr_cln1<<(unsigned char)buffer2[i];}
737 //Write in file mmm_counter_nnnnn_cln1_bin.log
738 tmp=numP[1];
739 for (k=0;k<4;k++) numPack[k]=0;
740 for (k=0;k<4;k++)
741 {if (tmp/(long int)(pow(256.,3-k))>=1)
742 {numPack[3-k]=(int)(tmp/(long int)(pow(256.,3-k)));
743 tmp=tmp-(long int)pow(256.,3-k)*(int)(tmp/(long int)(pow(256.,3-k)));}}
744 for (i=0;i<4;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr);
745 adr1=icount-1024*2;
746 for (k=0;k<4;k++) adress[k]=0;
747 for (k=0;k<4;k++)
748 {if (adr1/(long int)(pow(256.,3-k))>=1)
749 {adress[3-k]=(int)(adr1/(long int)(pow(256.,3-k)));
750 adr1=adr1-(long int)pow(256.,3-k)*
751 (int)(adr1/(long int)(pow(256.,3-k)));}}
752 for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr);
753 adr2=icount-1024;
754 for (k=0;k<4;k++) adress[k]=0;
755 for (k=0;k<4;k++)
756 {if (adr2/(long int)(pow(256.,3-k))>=1)
757 {adress[3-k]=(int)(adr2/(long int)(pow(256.,3-k)));
758 adr2=adr2-(long int)pow(256.,3-k)*
759 (int)(adr2/(long int)(pow(256.,3-k)));}}
760 for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr);
761 fputc(flags,fo_log_kadr);
762 }
763 }
764 /***************************************************************/
765 /***************************************************************/
766 if (flag_CRC[2]==0||(flag_rout[2]==0&&flag_pack[2]==0)||
767 (flag_CRC[2]!=0&&flag_CRC_cor[2]==1))
768 {end=0;
769 for (i=0;i<1024;i++) fokadr_cln1<<(unsigned char)buffer3[i];
770 //Write in file mmm_counter_nnnnn_cln1_bin.log
771 tmp=numP[2];
772 for (k=0;k<4;k++) numPack[k]=0;
773 for (k=0;k<4;k++)
774 {if (tmp/(long int)(pow(256.,3-k))>=1)
775 {numPack[3-k]=(int)(tmp/(long int)(pow(256.,3-k)));
776 tmp=tmp-(long int)pow(256.,3-k)*
777 (int)(tmp/(long int)(pow(256.,3-k)));}}
778 for (i=0;i<4;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr);
779 adr1=icount-1024;
780 for (k=0;k<4;k++) adress[k]=0;
781 for (k=0;k<4;k++)
782 {if (adr1/(long int)(pow(256.,3-k))>=1)
783 {adress[3-k]=(int)(adr1/(long int)(pow(256.,3-k)));
784 adr1=adr1-(long int)pow(256.,3-k)*
785 (int)(adr1/(long int)(pow(256.,3-k)));}}
786 for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr);
787 adr2=icount;
788 for (k=0;k<4;k++) adress[k]=0;
789 for (k=0;k<4;k++)
790 {if (adr2/(long int)(pow(256.,3-k))>=1)
791 {adress[3-k]=(int)(adr2/(long int)(pow(256.,3-k)));
792 adr2=adr2-(long int)pow(256.,3-k)*
793 (int)(adr2/(long int)(pow(256.,3-k)));}}
794 for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr);
795 fputc(flags,fo_log_kadr);
796
797 for (i=8;i<1019;i++)
798 {
799 // if (fmodf(float((Num_kadrs[Rcount-1]-1)*1015+i-8),
800 // float(64))==0.&&buffer3[i]==0&&buffer3[i+1]==0&&
801 // buffer3[i+2]==0&&buffer3[i+3]==0&&buffer3[i+4]==0) end=1;
802 if (end!=1) fo_cln1<<(unsigned char)buffer3[i];
803 }
804 if (end!=1) {for(i=1019;i<1023;i++) {fo_cln1<<(unsigned char)buffer3[i];}}
805 }
806
807 icount_int = (int)(icount/1024);
808 icount_frac= icount%1024;
809 // cout<<"\nfile size="<<icount_total<<" Byte "<<N1
810 // <<" identified cadrs Number of routs="<<Rcount<<"\n";
811 // cout<<" size of identified cadrs="<<icount<<" bytes "<<count_ident[0]<<"\n";
812
813 //***protocol file***********************************************
814 strcpy(file_name_prot, path);
815 strcat(file_name_prot, name);
816 file_length=(int)(strlen(name));
817 fprintf(fo,"file name=%s\n",file_name_prot);
818 fprintf(fo,"file size= %i,%i kByte \n", icount_int,
819 icount_frac);
820 for (i=0;i<Rcount;i++)
821 {fprintf(fo,"route=%i;",NumRout[i]);
822 fprintf(fo," size of identified cadrs =%lli bytes;",count_ident[i]);
823 fprintf(fo," total size of route=%lli bytes;\n",count_tot[i]);
824 fprintf(fo,"number of errors=%i;\n",Num_bad_kadrs[i]);
825 }
826
827 //***route's number log file**************************************
828 for (i=0;i<Rcount;i++) {fprintf(fo_route,"%1c",(char)(NumRout[i]));}
829
830 //***cln1.inf file*************************************************
831 fprintf(fo1,"file name=");
832 fprintf(fo1,"%s%s",path,name);
833 fprintf(fo1,"\nfile size= %i,%i kByte \n", icount_int,
834 icount_frac);
835 fprintf(fo1,"number identified kadrs= %i\n", N1);
836 fprintf(fo1,"number of routes= %i\n", Rcount);
837
838 for (i=0;i<Rcount;i++)
839 {
840 Num_good_kadrs[i]=Num_kadrs[i]-Num_bad_kadrs[i];
841 quality[i]=(float)(1.)-(float)(Num_bad_kadrs[i])/(float)(Num_kadrs[i]);
842 fprintf(fo1,"\nRoute number=%i: number of normal kadrs= %i:\n",
843 NumRout[i],Num_good_kadrs[i]);
844 fprintf(fo1,"first kadre number= %lli:", packet_first[i]);
845 fprintf(fo1," last kadre number= %lli:", packet_last[i]);
846 fprintf(fo1," Number of missed kadrs= %i:\n", count_missed[i]);
847 // fprintf(fo1,"Number of double transmitted kadrs= %i:\n", count_sec_missed[i]);
848 fprintf(fo1,"number of identified kadres=%lli: quality index=%f\n", Num_kadrs[i], quality[i]);
849 }
850 //***************************************************************
851 fin.close();
852 fclose(fout);
853 fclose(fo);
854 fclose(fo1);
855 fclose(foRout);
856 fclose(foMiss);
857 fo_cln1.close();
858 fclose(fo_log_kadr);
859 fokadr_cln1.close();
860 fclose(fo_route);
861 }
862

  ViewVC Help
Powered by ViewVC 1.1.23