1 |
#include "descript.h" |
#include "descript.h" |
2 |
|
#include "flag.h" |
3 |
|
|
4 |
void filename(char [], char [], char [], char[], int, char[]); |
void filename(char [], char [], char [], char[], int, char[]); |
5 |
void FindRoute(int[], int*); |
void FindRoute(int[], int*); |
6 |
short int CRC(int []); |
short int CRC(int []); |
7 |
int restrict(int [], long long int[], int); |
int restrict(int [], long long int[], int); |
8 |
|
|
9 |
|
extern char database[120]; |
10 |
|
extern char MYSQL[120]; |
11 |
|
extern int print_flag; |
12 |
|
|
13 |
|
int route_good1=0, route_good2=0, route_good3=0; |
14 |
|
int pack_good1=0, pack_good2=0, pack_good3=0; |
15 |
|
int number_good1=0, number_good2=0, number_good3=0; |
16 |
|
|
17 |
void read(char fni[], char fno[], char INF[], |
void read(char fni[], char fno[], char INF[], |
18 |
char protocol[], char path[], char name[], char nnnnn_TMP[], float quality[], int real_route[], int &Rcount) |
char protocol[], char path[], char name[], char nnnnn_TMP[], float quality[], int real_route[], int &Rcount) |
19 |
{ |
{ |
20 |
FILE *fo, *fo1, *fout, *foRout, *foMiss, *fo_log_kadr, *fo_route; |
FILE *fo, *fout, *foRout, *foMiss, *fo_log_kadr, *fo_route, *fo_tmp; |
21 |
ifstream fin; |
ifstream fin; |
22 |
ofstream fo_cln1, fokadr_cln1; |
ofstream fo_cln1, fokadr_cln1, fo_info; |
23 |
|
|
24 |
char buf[1024]; |
char buf[1024]; |
25 |
// char stop1; |
// char stop1; |
26 |
char ch1,ch2,ch3, ch, file_name_prot[80]; |
char ch1,ch2,ch3,ch, ch4[80], ch5[5]; |
27 |
char file_route[80]; /*protocol binary filesm mmm_counter_nnnnn_cln1Er.log*/ |
char file_route[100]; /*protocol binary filesm nnnnn_mmm_xxx_cln1Er.log*/ |
28 |
char miss_file[80]; /*protocol files mmm_counter_nnnnn_mis_cln1.dat*/ |
char miss_file[100]; /*protocol files nnnnn_mmm_xxx_mis_cln1.dat*/ |
29 |
char cln1_file[80]; /*route binary data files mmm_counter_nnnnn_cln1.pam*/ |
char cln1_file[100]; /*route binary data files nnnnn_mmm_xxx_cln1.pam*/ |
30 |
char cln1_kadr[80]; /*route binary data files mmm_counter_nnnnn_cln1.bin*/ |
char cln1_kadr[100]; /*route binary data files nnnnn_mmm_xxx_cln1.bin*/ |
31 |
char log_kadr[80]; /*log binary data files mmm_counter_nnnnn_cln1.log*/ |
char log_kadr[100]; /*log binary data files nnnnn_mmm_xxx_cln1.log*/ |
32 |
char log_route[80]; /*log binary file for number of routes*/ |
char log_route[100]; /*log binary file for number of routes*/ |
33 |
char Short_Buf[8], Name_Buf[4]; |
char Short_Buf[8], Name_Buf[4]; |
34 |
|
char temp[10], temp1[80], connection[120], command[80], name11[80]; |
35 |
short int CalcCheckSum; |
short int CalcCheckSum; |
36 |
|
|
37 |
int LenthBuf=1015, flag_help=0; |
int LenthBuf=1015, flag_help=0; |
38 |
int i, j, k, file_length=0, Hex[3]; |
int i, j, k, file_length=0, Hex[3]; |
39 |
int N_er=0; /*Number of kadr with name error*/ |
int N_er=0; /*Number of cadre with name error*/ |
40 |
int CRC0_er=0; /*Number of kadr with CRC0 error*/ |
int CRC0_er=0; /*Number of cadre with CRC0 error*/ |
41 |
int P_er=0; /*Number of kadr with packet error number*/ |
int P_er=0; /*Number of cadre with packet error number*/ |
|
int M_er=0; /*Number of kadr with rout error number*/ |
|
42 |
int end=0; /*End of last pamela packet*/ |
int end=0; /*End of last pamela packet*/ |
43 |
// Buffers for Kadr analysis |
// Buffers for Cadre analysis |
44 |
int buffer1[1024], buffer2[1024], buffer3[1024]; |
int buffer1[1024], buffer2[1024], buffer3[1024]; |
45 |
int rr=0; |
int rr=0; |
46 |
|
int cirquit_no=0, route=0; |
47 |
|
|
48 |
int header1, header2, header3, CRC_0[3], CRC_1[3]; |
int header1, header2, header3, CRC_0[3], CRC_1[3]; |
49 |
long long int icount_int; |
long long int icount_int; |
50 |
long long int icount_frac, tmpP, numP[3]; |
long long int icount_frac, tmpP, numP[3]; |
51 |
long int N1=0; /* Number of identified kadrs*/ |
long int N1=0; /* Number of identified cadres*/ |
52 |
long long int icount=0; /* Number of bytes in identified kadrs*/ |
long long int icount=0; /* Number of bytes in identified cadres*/ |
53 |
long long int icount_total=0; /* Total number of bytes*/ |
long long int icount_total=0; /* Total number of bytes*/ |
54 |
long long int packet_first[100];/*First kadr number for each route*/ |
long long int packet_first[100];/* First cadre number for each route*/ |
55 |
long long int packet_last[100]; /*Second kadr number for each route*/ |
long long int packet_last[100]; /* Second cadre number for each route*/ |
56 |
long int count_missed[100]; /* Number of missed kadrs in each route*/ |
long long int count_missed[100];/* Number of missed cadres in each route*/ |
57 |
long int count_sec_missed[100]; |
long long int count_sec_missed[100]; |
58 |
unsigned long long int count_ident[100]; /* Number of good bytes in each rout*/ |
unsigned long long int count_ident[100]; /* Number of good bytes in each route*/ |
59 |
unsigned long long int count_tot[100]; /* Total number of bytes in each rout*/ |
unsigned long long int count_tot[100]; /* Total number of bytes in each route*/ |
60 |
int NumRout[1000]; /* Number of Route*/ |
int NumRout[1000]; /* Number of route*/ |
61 |
long long int Num_kadrs[1000]; /* Number of identified kadrs in each rout*/ |
long long int Num_kadrs[1000]; /* Number of identified cadres in each route*/ |
62 |
long int Num_good_kadrs[1000]; /* Number of normal kadrs in each rout*/ |
long int Num_good_kadrs[1000]; /* Number of normal cadres in each route*/ |
63 |
long long int Num_bad_kadrs[1000]; /* Bad kadrs number in each rout*/ |
long long int Num_bad_kadrs[1000]; /* Bad cadres number in each route*/ |
64 |
// float quality[100]; /* File quality pointer*/ |
|
65 |
int counter=0; /* Last byte position in truncated kadr*/ |
int counter=0; /* Last byte position in truncated cadre*/ |
66 |
int adr1=0; /* Initial byte of kadr in cln1.bin*/ |
int adr1=0; /* Initial byte of cadre in cln1.bin*/ |
67 |
int adr2=0; /* Last byte of kadr in cln2.bin*/ |
int adr2=0; /* Last byte of cadre in cln2.bin*/ |
68 |
int tmp=0; |
int tmp=0; |
69 |
int numPack[4]; /* Number of kadr in given route*/ |
int numPack[4]; /* Number of cadre in given route*/ |
70 |
|
|
71 |
int adress[4]; |
int adress[4]; |
72 |
int R_er[100]; /* Rout errors number in given rout*/ |
int R_er[100]; /* Route errors number in given route*/ |
73 |
int R_er_interf1[100]; /* Interface Rout error at begin of rout*/ |
int R_er_interf1[100]; /* Interface Route error at the begining of the route*/ |
74 |
int R_er_interf2[100]; /* Interface Rout error at end of rout*/ |
int R_er_interf2[100]; /* Interface Route error at end of route*/ |
75 |
int Mis_group[1000]; /* Number of missed kadrs group |
int Mis_group[1000]; /* Number of missed cadres group |
76 |
for each rout*/ |
for each route*/ |
77 |
|
float first_missed[100]; |
78 |
int Pack_Er[1000]; /* Number of packets with packet number |
int Pack_Er[1000]; /* Number of packets with packet number |
79 |
error for each rout*/ |
error for each route*/ |
80 |
int CRC_bad_kadr[3]; /* Current CRC bad kadr number*/ |
int CRC_bad_kadr[3]; /* Current CRC bad cadre number*/ |
81 |
int flag_pack[3]; /* Flag for error in packet number*/ |
int flag_pack[3]; /* Flag for error in packet number*/ |
82 |
int flag_rout[3]; /* Flag for error in rout number*/ |
int flag_rout[3]; /* Flag for error in route number*/ |
83 |
int flag_name[3]; /* Flag for name error*/ |
int flag_name[3]; /* Flag for name error*/ |
84 |
int flag_CRC0[3]; /* Flag for CRC0 error*/ |
int flag_CRC0[3]; /* Flag for CRC0 error*/ |
85 |
int flag_CRC[3]; /* Flag for CRC error*/ |
int flag_CRC[3]; /* Flag for CRC error*/ |
86 |
int flag_CRC_cor[3]; /* Flag for CRC error correction*/ |
int flag_CRC_cor[3]; /* Flag for CRC error correction*/ |
87 |
int flag_tr[3]; /* Truncate flag*/ |
int flag_tr[3]; /* Truncate flag*/ |
88 |
short int flags; /* Number for all errors*/ |
short int flags; /* Number for all errors*/ |
89 |
|
int num_rows=0; |
90 |
|
int control[1]; |
91 |
|
control[0]=0; |
92 |
|
control[1]=0; |
93 |
for (j=0; j<4; j++) {adress[j]=0; numPack[j]=0;} |
for (j=0; j<4; j++) {adress[j]=0; numPack[j]=0;} |
94 |
for (j=0; j<1024; j++) |
for (j=0; j<1024; j++) |
95 |
{buffer1[j]=0; buffer2[j]=0; buffer3[j]=0;} |
{buffer1[j]=0; buffer2[j]=0; buffer3[j]=0;} |
100 |
packet_last[i]=0; |
packet_last[i]=0; |
101 |
count_missed[i]=0; |
count_missed[i]=0; |
102 |
count_sec_missed[i]=0; |
count_sec_missed[i]=0; |
103 |
|
first_missed[i]=0; |
104 |
count_ident[i]=0; |
count_ident[i]=0; |
105 |
count_tot[i]=0; |
count_tot[i]=0; |
106 |
R_er[i]=0; |
R_er[i]=0; |
114 |
flag_pack[i]=0; flag_rout[i]=0; |
flag_pack[i]=0; flag_rout[i]=0; |
115 |
flag_name[i]=0; flag_CRC0[i]=0; flag_tr[i]=0; |
flag_name[i]=0; flag_CRC0[i]=0; flag_tr[i]=0; |
116 |
flag_CRC[i]=0; flag_CRC_cor[i]=0;} |
flag_CRC[i]=0; flag_CRC_cor[i]=0;} |
117 |
|
|
118 |
|
stringstream oss; |
119 |
|
|
120 |
|
strcpy(connection,MYSQL); |
121 |
|
strcat(connection,database); |
122 |
|
TSQLServer *sqlServer = TSQLServer::Connect(connection,"pamelaprod","rawprod"); |
123 |
|
if (sqlServer==0) {cerr<<"can not connect with MYSQL sever\n"; exit(1);} |
124 |
// open input file "nnnnnmmm.pam" |
// open input file "nnnnnmmm.pam" |
125 |
fin.open(fni, ifstream::binary); |
fin.open(fni, ifstream::binary); |
126 |
if(fin.good()==0) {cerr<<"can not open input file"; exit(0);} |
if(fin.good()==0) {cerr<<"can not open input file"; exit(1);} |
127 |
//open output file "nnnnnmmm_work.dat" |
//open output file "nnnnnmmm_work.dat" |
128 |
fout=fopen(fno, "wb"); |
fout=fopen(fno, "wb"); |
129 |
if(fout==0) {cerr<<"can not open outputfile"; exit(0);} |
if(fout==0) {cerr<<"can not open work file"; exit(1);} |
130 |
|
|
131 |
|
strcpy(ch5,"info"); |
132 |
|
strcpy(ch4,fno); |
133 |
|
for(i=0;i<4;i++){ch4[strlen(ch4)-8+i]=ch5[i];} |
134 |
|
// open input file "nnnnnmmm_info.dat" |
135 |
|
fo_info.open(ch4, ifstream::binary); |
136 |
|
if(fo_info.good()==0) {cerr<<"can not open info file"; exit(1);} |
137 |
|
|
138 |
//open output file "nnnnnmmm_protocol.txt" |
//open output file "nnnnnmmm_protocol.txt" |
139 |
fo=fopen(protocol, "wb"); |
fo=fopen(protocol, "wb"); |
140 |
if(fo==0) {cerr<<"can not open protocol file"; exit(0);} |
if(fo==0) {cerr<<"can not open protocol file"; exit(1);} |
|
//open output file "nnnnnmmm_cln1.inf" |
|
|
fo1=fopen(INF, "wb"); |
|
|
if(fo1==0) {cerr<<"can not open inf file"; exit(0);} |
|
141 |
//open output file "nnnnnmmm_route.log" |
//open output file "nnnnnmmm_route.log" |
142 |
strncpy(log_route,INF,strlen(INF)-9); |
strncpy(log_route,INF,strlen(INF)-9); |
143 |
log_route[strlen(INF)-9]='\0'; |
log_route[strlen(INF)-9]='\0'; |
144 |
strcat(log_route,"_route.log"); |
strcat(log_route,"_route.log"); |
145 |
fo_route=fopen(log_route, "wb"); |
fo_route=fopen(log_route, "wb"); |
146 |
if(fo_route==0) {cerr<<"can not open file for routes number"; exit(0);} |
if(fo_route==0) {cerr<<"can not open file for routes number"; exit(1);} |
147 |
///////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////// |
148 |
// cin>>stop1; |
// cin>>stop1; |
149 |
k=0; |
k=0; |
150 |
while(fin.eof()==0) |
while(fin.eof()==0) |
151 |
{ |
{ |
152 |
counter=0; //pounter for position of kadr truncation |
counter=0; //pounter for position of cadre truncation |
153 |
N_er=0; |
N_er=0; |
|
M_er=0; |
|
154 |
P_er=0; |
P_er=0; |
155 |
CRC0_er=0; |
CRC0_er=0; |
156 |
if (N1==0) Rcount=1; |
if (N1==0) Rcount=1; |
169 |
count_ident[Rcount-1]+=8; count_tot[Rcount-1]+=8; |
count_ident[Rcount-1]+=8; count_tot[Rcount-1]+=8; |
170 |
|
|
171 |
while((ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&& |
while((ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&& |
172 |
(N1==0||buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0]))) |
(N1==0||(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])))) |
173 |
|| |
|| |
174 |
(ch2!=(char)(CODE2)&&ch3!=(char)(CODE3)&&(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||(numP[2]+1)!=tmpP)) |
(ch2!=(char)(CODE2)&&ch3!=(char)(CODE3)&&(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||(numP[2]+1)!=tmpP)) |
175 |
|| |
|| |
176 |
(ch3!=(char)(CODE3)&&ch1!=(char)(CODE1)&&((numP[2]+1)!=tmpP||buffer3[1023]!=(int)(unsigned char)(Short_Buf[4]))) |
(ch3!=(char)(CODE3)&&ch1!=(char)(CODE1)&&(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])|| |
177 |
|
(buffer3[5]!=(int)(unsigned char)(Short_Buf[2])&& buffer3[6]!=(int)(unsigned char)(Short_Buf[3])))) |
178 |
|| |
|| |
179 |
(ch1!=(char)(CODE1)&& |
(ch1!=(char)(CODE1)&& |
180 |
(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP)) |
(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])&& buffer3[3]!=(int)(unsigned char)(Short_Buf[0])&& |
181 |
|
buffer3[5]!=(int)(unsigned char)(Short_Buf[2])&& buffer3[6]!=(int)(unsigned char)(Short_Buf[3]))) |
182 |
|| |
|| |
183 |
(ch2!=(char)(CODE2)&& |
(ch2!=(char)(CODE2)&& |
184 |
(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP)) |
(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])&& buffer3[3]!=(int)(unsigned char)(Short_Buf[0])&& |
185 |
|
buffer3[5]!=(int)(unsigned char)(Short_Buf[2])&& buffer3[6]!=(int)(unsigned char)(Short_Buf[3]))) |
186 |
|| |
|| |
187 |
(ch3!=(char)(CODE3)&& |
(ch3!=(char)(CODE3)&& |
188 |
(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP)) |
(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])&& buffer3[3]!=(int)(unsigned char)(Short_Buf[0])&& |
189 |
|
buffer3[5]!=(int)(unsigned char)(Short_Buf[2])&& buffer3[6]!=(int)(unsigned char)(Short_Buf[3]))) |
190 |
|| |
|| |
191 |
(ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&&ch3!=(char)(CODE3))) |
(ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&&ch3!=(char)(CODE3))) |
192 |
{fin.get(ch); |
{fin.get(ch); |
193 |
if (fin.eof()) {/*cerr<<"\n"<<"gopa";*/ break;} |
if (fin.eof()) {break;} |
194 |
ch1=ch2; ch2=ch3; ch3=Short_Buf[0]; |
ch1=ch2; ch2=ch3; ch3=Short_Buf[0]; |
195 |
for (i=0;i<4;i++) Short_Buf[i]=Short_Buf[i+1]; Short_Buf[4]=ch; |
for (i=0;i<4;i++) Short_Buf[i]=Short_Buf[i+1]; Short_Buf[4]=ch; |
196 |
icount_total+=1; count_tot[Rcount-1]+=1; |
icount_total+=1; count_tot[Rcount-1]+=1; |
201 |
if ((fin.eof())&&(N1==0)) |
if ((fin.eof())&&(N1==0)) |
202 |
{ |
{ |
203 |
fclose(fout); |
fclose(fout); |
204 |
|
fo_info.close(); |
205 |
remove(fno); |
remove(fno); |
206 |
fclose(fo); |
fclose(fo); |
207 |
remove(protocol); |
remove(protocol); |
|
fclose(fo1); |
|
208 |
remove(INF); |
remove(INF); |
209 |
exit(0); |
exit(1); |
210 |
} |
} |
|
// cout<<"icount_total="<<icount_total<<" "<<N1<<"\n"; |
|
|
// printf("%x %x %x \n",(int)(unsigned char)(ch1),(int)(unsigned char)(ch2),(int)(unsigned char)(ch3)); |
|
|
// printf("%x %x %x %x %x\n",(int)(unsigned char)(Short_Buf[0]),(int)(unsigned char)(Short_Buf[1]), |
|
|
// (int)(unsigned char)(Short_Buf[2]),(int)(unsigned char)(Short_Buf[3]), |
|
|
// (int)(unsigned char)(Short_Buf[4])); |
|
|
// printf("buffer3[3]= %x\n",(int)(unsigned char)buffer3[3]); |
|
|
// printf("numP[2]+1= %x tmpP= %x\n",numP[2]+1, tmpP); |
|
|
// printf("buffer3[1023]= %x\n",(int)(unsigned char)buffer3[1023], tmpP); |
|
|
|
|
211 |
/*****************************************************************/ |
/*****************************************************************/ |
212 |
/*********************data reading********************************/ |
/*********************data reading********************************/ |
213 |
fin.read(buf,LenthBuf); |
fin.read(buf,LenthBuf); |
252 |
CRC_bad_kadr[2]=0; |
CRC_bad_kadr[2]=0; |
253 |
flag_pack[2]=0; flag_rout[2]=0; |
flag_pack[2]=0; flag_rout[2]=0; |
254 |
flag_name[2]=0; flag_CRC0[2]=0; flag_tr[2]=0; |
flag_name[2]=0; flag_CRC0[2]=0; flag_tr[2]=0; |
255 |
flag_CRC[2]=0; flag_CRC_cor[2]=0; |
flag_CRC[2]=0; flag_CRC_cor[2]=0; |
256 |
for (i=0; i<2; i++) |
for (i=0; i<2; i++) |
257 |
{numP[i]=numP[2];CRC_bad_kadr[i]=CRC_bad_kadr[2]; |
{numP[i]=numP[2];CRC_bad_kadr[i]=CRC_bad_kadr[2]; |
258 |
flag_pack[i]=flag_pack[2]; flag_rout[i]=flag_rout[2]; |
flag_pack[i]=flag_pack[2]; flag_rout[i]=flag_rout[2]; |
266 |
for (i=0; i<2; i++) |
for (i=0; i<2; i++) |
267 |
{CRC_1[i]=CRC_1[2];} |
{CRC_1[i]=CRC_1[2];} |
268 |
packet_first[Rcount-1]=numP[2]; |
packet_first[Rcount-1]=numP[2]; |
269 |
|
control[0]=0; control[1]=0; |
270 |
break; |
break; |
271 |
} |
} |
272 |
default:{ |
default:{ |
304 |
CRC_0[2]=(int)(unsigned char)(Short_Buf[4]); |
CRC_0[2]=(int)(unsigned char)(Short_Buf[4]); |
305 |
for (i=0; i<2; i++) {CRC_1[i]=CRC_1[i+1];} |
for (i=0; i<2; i++) {CRC_1[i]=CRC_1[i+1];} |
306 |
CRC_1[2]=(int)(unsigned char)(ch); |
CRC_1[2]=(int)(unsigned char)(ch); |
307 |
|
control[0]=control[1]; |
308 |
|
control[1]=0; |
309 |
} |
} |
310 |
} |
} |
311 |
// if (fmod(N1,10000)==0.) cout<<N1<<"\n"; |
// if (print_flag>0 && fmod(N1,10000)==0) cout<<N1<<"\n"; |
312 |
// Caf mod on 31 Aug 2006 |
if (print_flag>0 && !(N1%10000)) cout<<N1<<"\n"; |
|
if ((N1%10000)==0 && N1>0) cout<<N1<<"\n"; |
|
|
// end mod |
|
313 |
|
|
314 |
/******************CRC ERROR ANALYSIS***************************/ |
/******************CRC ERROR ANALYSIS***************************/ |
315 |
CalcCheckSum=CRC(buffer3); |
CalcCheckSum=CRC(buffer3); |
316 |
if (CalcCheckSum!=(short int)(buffer3[1023])) |
if (CalcCheckSum!=(short int)(buffer3[1023])) |
317 |
{ |
{ |
318 |
/*if (numP[2]==1026) |
//write in file nnnnnmmm_info.dat |
319 |
{for (i=0;i<8;i++) printf(" %x ",buffer3[i]); printf("\n"); |
fo_info<<"real CRC = "<<hex<<buffer3[1023]<<" (calculated CRC ="<<CalcCheckSum<<") in cadre "<<dec<<numP[2]<<"\n"; |
320 |
for (i=8;i<16;i++) printf(" %x ",buffer3[i]); printf("\n"); |
//write in file nnnnnmmm_work.dat |
321 |
for (i=1000;i<1008;i++) printf(" %x ",buffer3[i]); printf("\n"); |
fprintf(fout,"%10i %4i %4i\n", numP[2], CalcCheckSum, buffer3[1023]); |
322 |
printf("%x %x %x %x",buffer3[1020],buffer3[1021],buffer3[1022],buffer3[1023]); |
|
|
cin>>i;}*/ |
|
|
fprintf(fout,"CRC = %x (%x) error in kadr %i\n", buffer3[1023],CalcCheckSum,numP[2]); //write in file nnnnn_work.dat |
|
|
// cerr<<"checksum error "<<Rcount<<" Cadre="<<numP[2]<< |
|
|
// " "<<buffer3[3]<<"\n"; |
|
323 |
flag_CRC[2]=1; |
flag_CRC[2]=1; |
324 |
Num_bad_kadrs[Rcount-1]+=1; |
Num_bad_kadrs[Rcount-1]+=1; |
325 |
CRC_bad_kadr[2]=numP[2]; |
CRC_bad_kadr[2]=numP[2]; |
326 |
counter=restrict(buffer3,numP,buffer2[3]); |
counter=restrict(buffer3,numP,buffer2[3]); |
327 |
if (counter!=0) |
if (counter!=0) |
328 |
{fprintf(fout," truncate byte=%i",counter); |
{fo_info<<" truncate byte="<<counter<<" in cadre "<<numP[2]<<"\n"; |
329 |
cout<<" truncate counter="<<counter<<" route="<<buffer2[3]<<" "<<buffer3[3]<<" kadr="<<numP[2]<<" "<<numP[1]<<" "<<numP[0]<<"\n"; |
if (print_flag>0) |
330 |
|
{cout<<" truncate counter="<<counter<<" route="<<buffer2[3]<<" "<<buffer3[3]<<" cadre="<<numP[2]<<" "<<numP[1]<<" "<<numP[0]<<"\n";} |
331 |
fin.seekg(-(1024-counter),ios::cur); |
fin.seekg(-(1024-counter),ios::cur); |
332 |
icount-=1024; |
icount-=1024; |
333 |
count_ident[Rcount-1]-=1024; |
count_ident[Rcount-1]-=1024; |
351 |
{flag_CRC0[1]=1; CRC0_er=N1-1;} |
{flag_CRC0[1]=1; CRC0_er=N1-1;} |
352 |
/****************************************************************/ |
/****************************************************************/ |
353 |
|
|
354 |
/******************KADR NUMBER ANALYSIS**************************/ |
/******************CADRE NUMBER ANALYSIS*************************/ |
355 |
if ((numP[1]!=(numP[0]+1))&&(numP[1]!=(numP[2]-1))&&(N1!=1)&&(CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)) |
if ((numP[1]!=(numP[0]+1))&&(numP[1]!=(numP[2]-1))&&(N1!=1)&&(CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)) |
356 |
{P_er=N1-1; flag_pack[1]=1; |
{P_er=N1-1; flag_pack[1]=1; |
357 |
//Correct error packet number// |
//Correct error packet number// |
361 |
{if (tmpP/(long int)(pow(256.,2-i))>=1) |
{if (tmpP/(long int)(pow(256.,2-i))>=1) |
362 |
{Hex[2-i]=(int)(tmpP/(long int)(pow(256.,2-i))); |
{Hex[2-i]=(int)(tmpP/(long int)(pow(256.,2-i))); |
363 |
tmpP=tmpP-(long int)pow(256.,2-i)*(int)(tmpP/(long int)(pow(256.,2-i)));}} |
tmpP=tmpP-(long int)pow(256.,2-i)*(int)(tmpP/(long int)(pow(256.,2-i)));}} |
364 |
for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]); |
// for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]); |
365 |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
366 |
|
|
367 |
tmpP=numP[2]-1; |
tmpP=numP[2]-1; |
370 |
{if (tmpP/(long int)(pow(256.,2-i))>=1) |
{if (tmpP/(long int)(pow(256.,2-i))>=1) |
371 |
{Hex[2-i]=(int)(tmpP/(long int)(pow(256.,2-i))); |
{Hex[2-i]=(int)(tmpP/(long int)(pow(256.,2-i))); |
372 |
tmpP=tmpP-(long int)pow(256.,2-i)*(int)(tmpP/(long int)(pow(256.,2-i)));}} |
tmpP=tmpP-(long int)pow(256.,2-i)*(int)(tmpP/(long int)(pow(256.,2-i)));}} |
373 |
for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]); |
// for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]); |
374 |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
375 |
} |
} |
376 |
///////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////// |
377 |
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; |
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; |
378 |
if (flag_pack[2]!=1) packet_last[Rcount-1]=numP[2]; |
if (flag_pack[2]!=1) packet_last[Rcount-1]=numP[2]; |
379 |
////////Missing kadr analysis//////////////////////////////////// |
////////Missing cadre analysis//////////////////////////////////// |
380 |
/**route number: 10 (10 19 10) 10 ******************************/ |
/**route number: 10 (10 19 10) 10 ******************************/ |
381 |
/**kadr number: 21 (22 17 18) 19 ******************************/ |
/**cadre number: 21 (22 17 18) 19 ******************************/ |
382 |
/**missed kadrs: 21 20 19 18 17 ******************************/ |
/**missed cadres: 21 20 19 18 17 ******************************/ |
383 |
if ((numP[1]<numP[0])&&(numP[1]==numP[2]-1)&&(buffer1[3]==buffer3[3])&&(flag_tr[1]==0)&& |
if ((numP[1]<numP[0])&&(numP[1]==numP[2]-1)&&(buffer1[3]==buffer3[3])&&(flag_tr[1]==0)&& |
384 |
(flag_pack[0]==0)&&(flag_pack[1]==0)&&(flag_pack[2]==0)) |
(flag_pack[0]==0)&&(flag_pack[1]==0)&&(flag_pack[2]==0)&&(control[0]==0)) |
385 |
{Mis_group[Rcount-1]+=1; |
{Mis_group[Rcount-1]+=1; |
386 |
fprintf(foMiss,"secondary transmitted kadres may be %9i%9i\n",numP[1]+1,numP[0]-1); |
count_sec_missed[Rcount-1]+=numP[0]-1-numP[1]; |
387 |
count_sec_missed[Rcount-1]+=numP[0]-1-numP[1]-1;} |
fprintf(foMiss,"secondary transmitted cadres may be %lli - %lli number of cadres=%lli\n", |
388 |
|
numP[1],numP[0],numP[0]-1-numP[1]); |
389 |
|
} |
390 |
/**route number: 10 (10 19 10) 10 ******************************/ |
/**route number: 10 (10 19 10) 10 ******************************/ |
391 |
/**kadr number: 11 (12 15 20) 21 ******************************/ |
/**cadre number: 11 (12 15 20) 21 ******************************/ |
392 |
/**missed kadrs: 16 17 18 19 ******************************/ |
/**missed cadres: 16 17 18 19 ******************************/ |
393 |
if ((numP[1]>numP[0]+1)&&(numP[1]<numP[2]-1)&&(buffer1[3]==buffer3[3])&&(flag_tr[1]==0)&& |
if ((numP[1]>numP[0]+1)&&(numP[1]<numP[2]-1)&&(buffer1[3]==buffer3[3])&&(flag_tr[1]==0)&& |
394 |
(flag_pack[0]==0)&&(flag_pack[1]==0)&&(flag_pack[2]==0)) |
(flag_pack[0]==0)&&(flag_pack[1]==0)&&(flag_pack[2]==0)) |
395 |
{Mis_group[Rcount-1]+=1; |
{Mis_group[Rcount-1]+=1; |
396 |
fprintf(foMiss,"%9i%9i\n",numP[1]+1,numP[2]-1); |
fprintf(foMiss,"1) %9lli%9lli\n",numP[1]+1,numP[2]-1); |
397 |
|
if (print_flag>0) cout<<"1) "<<numP[0]<<" "<<numP[1]<<" "<<numP[2]<<"\n"; |
398 |
count_missed[Rcount-1]+=numP[2]-numP[1]-1;} |
count_missed[Rcount-1]+=numP[2]-numP[1]-1;} |
399 |
/**route number: (10 10 10) 10 10 ******************************/ |
/**route number: (10 10 10) 10 10 ******************************/ |
400 |
/**kadr number: (11 12 15) 20 21 ******************************/ |
/**cadre number: (11 29 15) 14 15 ******************************/ |
401 |
/**missed kadrs: 13 14 ******************************/ |
/**number of missed cadres:2 ******************************/ |
|
else if ((numP[1]>=numP[0]+1)&&(numP[1]<numP[2]-1)&& |
|
|
(buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&& |
|
|
(flag_tr[1]==0)&&(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0)) |
|
|
{Mis_group[Rcount-1]+=1; |
|
|
fprintf(foMiss,"%9i%9i\n",numP[0]+2,numP[2]-1); |
|
|
count_missed[Rcount-1]+=numP[2]-numP[0]-1-1;} |
|
|
/**route number: (10 10 10) 10 10 ******************************/ |
|
|
/**kadr number: (11 29 15) 14 15 ******************************/ |
|
|
/**number of missed kadrs:2 ******************************/ |
|
402 |
else if (((numP[1]<numP[0]+1)||(numP[1]>numP[2]-1))&&(numP[2]-numP[0]>2)&& |
else if (((numP[1]<numP[0]+1)||(numP[1]>numP[2]-1))&&(numP[2]-numP[0]>2)&& |
403 |
(buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&&(flag_tr[1]==0)&& |
(buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&&(flag_tr[1]==0)&& |
404 |
(flag_pack[2]==0)&&(flag_pack[1]==1)&&(flag_pack[0]==0)) |
(flag_pack[2]==0)&&(flag_pack[1]==1)&&(flag_pack[0]==0)) |
405 |
{Mis_group[Rcount-1]+=1; |
{Mis_group[Rcount-1]+=1; |
406 |
fprintf(foMiss,"%9i%9i -1\n",numP[0]+1,numP[2]-1); |
fprintf(foMiss,"2) %9lli%9lli\n",numP[0]+1,numP[2]-1); |
407 |
|
if (print_flag>0) cout<<"2) "<<numP[0]<<" "<<numP[1]<<" "<<numP[2]<<"\n"; |
408 |
count_missed[Rcount-1]+=numP[2]-numP[0]-1-1;} |
count_missed[Rcount-1]+=numP[2]-numP[0]-1-1;} |
409 |
//truncate kadr |
else if (((numP[1]<numP[0]+1)||(numP[1]>numP[2]-1))&&((numP[2]-numP[0])==2)&& |
410 |
/**route number: 10 (10 10 10) 10 ******************************/ |
(buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&&(flag_tr[1]==0)) |
411 |
/**kadr number: 11 (12 13 14) 15 ******************************/ |
{control[1]=1;} |
412 |
/**missed truncate kadr:13 ******************************/ |
/**route number: (10 10 10) 10 10 ******************************/ |
413 |
|
/**cadre number: (11 15 16) 17 18 ******************************/ |
414 |
|
/**missed kadrs: 12 13 14 ******************************/ |
415 |
|
else if ((numP[1]>numP[0]+1)&&(numP[1]<=numP[2]-1)&&(buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&& |
416 |
|
(flag_tr[1]==0)&&(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0)&&(control[0]==0)) |
417 |
|
{Mis_group[Rcount-1]+=1; |
418 |
|
fprintf(foMiss,"3) %9lli%9lli\n",numP[0]+1,numP[1]-1); |
419 |
|
if (print_flag>0) cout<<"3) "<<numP[0]<<" "<<numP[1]<<" "<<numP[2]<<"\n"; |
420 |
|
count_missed[Rcount-1]+=numP[1]-numP[0]-1;} |
421 |
|
/**route number:(10 10 )10 10 10 10 ******************************/ |
422 |
|
/**cadre number:( 1 11 )12 13 14 15 ******************************/ |
423 |
|
/**number of missed cadres: 10 ******************************/ |
424 |
|
else if ((N1>2)&&(abs(numP[1]-pack_good3)>abs(Num_kadrs[Rcount-1]-number_good3-1))&& |
425 |
|
(buffer2[3]==route_good3)&&(flag_tr[2]==0)&&(flag_pack[2]==0)&&(numP[2]>numP[0]+2)&&(control[0]==0)) |
426 |
|
{Mis_group[Rcount-1]+=1; |
427 |
|
if (pack_good3<numP[2]) count_missed[Rcount-1]+=abs(numP[2]-pack_good3)-1; |
428 |
|
fprintf(foMiss,"4) %9lli%9lli number of missed cadres=%i\n", pack_good3, numP[1], abs(numP[1]-pack_good3-1)); |
429 |
|
if (print_flag>0) cout<<"P1="<<numP[0]<<" P2="<<numP[1]<<" P3="<<numP[2]<<"\n"; |
430 |
|
// cout<<"pack_good1="<<pack_good1<<" pack_good2="<<pack_good2<<" pack_good3="<<pack_good3<<"\n"; |
431 |
|
// cout<<"number_good1="<<number_good1<<" number_good2="<<number_good2<<" number_good3="<<number_good3<<"\n"; |
432 |
|
} |
433 |
|
//truncate cadres |
434 |
|
/**route number: 10 (10 10 10) 10 ******************************/ |
435 |
|
/**cadre number: 11 (12 13 14) 15 ******************************/ |
436 |
|
/**missed truncate cadre:13 ******************************/ |
437 |
else if ((numP[0]<numP[2]-1)&&(buffer1[3]==buffer3[3])&& |
else if ((numP[0]<numP[2]-1)&&(buffer1[3]==buffer3[3])&& |
438 |
(flag_tr[0]==0)&&(flag_tr[1]==1)&&(flag_tr[2]==0)&& |
(flag_tr[0]==0)&&(flag_tr[1]==1)&&(flag_tr[2]==0)&& |
439 |
(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0)) |
(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0)) |
440 |
{Mis_group[Rcount-1]+=1; |
{Mis_group[Rcount-1]+=1; |
441 |
fprintf(foMiss,"%9i%9i\n",numP[0]+1,numP[2]-1); |
fprintf(foMiss,"5) %9lli%9lli\n",numP[0]+1,numP[2]-1); |
442 |
count_missed[Rcount-1]+=numP[2]-numP[0]-1;} |
count_missed[Rcount-1]+=numP[2]-numP[0]-1;} |
443 |
/***************************************************************/ |
/***************************************************************/ |
444 |
|
|
445 |
|
if (flag_CRC[2]!=1) |
446 |
|
{ |
447 |
|
pack_good1=pack_good2; |
448 |
|
pack_good2=pack_good3; |
449 |
|
route_good1=route_good2; |
450 |
|
route_good2=route_good3; |
451 |
|
number_good1=number_good2; |
452 |
|
number_good2=number_good3; |
453 |
|
|
454 |
|
pack_good3=numP[2]; |
455 |
|
route_good3=buffer3[3]; |
456 |
|
number_good3=Num_kadrs[Rcount-1]; |
457 |
|
} |
458 |
/******************ROUTE NUMBER ANALYSIS**************************/ |
/******************ROUTE NUMBER ANALYSIS**************************/ |
459 |
if ((buffer2[3]!=buffer1[3])&&(buffer2[3]!=buffer3[3])&&(buffer1[3]!=buffer3[3])&& |
if ((buffer2[3]!=buffer1[3])&&(buffer2[3]!=buffer3[3])&&(buffer1[3]!=buffer3[3])&& |
460 |
(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0)) |
(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0)) |
461 |
{ |
{ |
462 |
/******************Interface route error 1***********************/ |
|
|
/**route number:7 7 ( 7 4 8) 8 8 **************************/ |
|
|
/**kadr number:197 198 (199 200 1) 2 3 **************************/ |
|
|
/*if ((numP[1]==numP[0]+1)&&(numP[2]<numP[0])) |
|
|
{Rcount+=1; flag_rout[1]=1; |
|
|
packet_last[Rcount-2]=numP[1]; |
|
|
packet_first[Rcount-1]=numP[2]; |
|
|
Num_kadrs[Rcount-1]+=1; |
|
|
Num_kadrs[Rcount-2]-=1; |
|
|
R_er[Rcount-2]+=1; |
|
|
R_er_interf2[Rcount-2]+=1; |
|
|
M_er=N1-1; |
|
|
count_ident[Rcount-1]+=1024; count_ident[Rcount-2]-=1024; |
|
|
count_tot[Rcount-1]+=1024; count_tot[Rcount-2]-=1024; |
|
|
NumRout[Rcount-1]=Rcount; |
|
|
cout<<"\n interface1 "<<NumRout[Rcount-1]<<" "<<Rcount; |
|
|
// cin>>stop1; |
|
|
if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)) |
|
|
{ |
|
|
//Correct error route number////////////////////////////////////////// |
|
|
buffer2[3]=buffer1[3]; |
|
|
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
|
|
//////////////////////////////////////////////////////////////////// |
|
|
flags=(short int)(pow((float)(2*flag_name[1]),4)+ |
|
|
pow((float)(2*flag_rout[1]),1)+ |
|
|
pow((float)(2*flag_pack[1]),2)+ |
|
|
pow((float)(2*flag_CRC0[1]),3)+ |
|
|
pow((float)(2*flag_CRC[1]),5)+ |
|
|
pow((float)(2*flag_CRC_cor[1]),6)); |
|
|
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]), |
|
|
(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags)); |
|
|
fprintf(fout,"%i Interface route error 1 %i\n",CRC_bad_kadr[1],flags); |
|
|
CRC_bad_kadr[1]=0; |
|
|
} |
|
|
// CREATE FILE NAMES |
|
|
filename(file_route, miss_file, cln1_file, path, |
|
|
NumRout[Rcount-1], name); |
|
|
strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3); |
|
|
cln1_kadr[strlen(cln1_file)-3]='\0'; |
|
|
strcat(cln1_kadr,"bin"); |
|
|
strncpy(log_kadr,file_route,strlen(file_route)-6); |
|
|
log_kadr[strlen(file_route)-6]='\0'; |
|
|
strcat(log_kadr,"_bin.log"); |
|
|
fclose(foRout); //Close files |
|
|
fo_cln1.close(); //for old |
|
|
fclose(foMiss); //route |
|
|
fokadr_cln1.close(); |
|
|
fclose(fo_log_kadr); |
|
|
//Open files for new route |
|
|
foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log |
|
|
foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat |
|
|
fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam |
|
|
fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin |
|
|
fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log |
|
|
}*/ |
|
|
/******************Interface route error 2***********************/ |
|
|
/**route number:7 7 ( 7 4 8) 8 ******************************/ |
|
|
/**kadr number:198 199 (200 1 2) 3 ******************************/ |
|
|
/*if ((numP[1]==numP[2]-1)&&(numP[1]<numP[0])&&(buffer2[3]!=0)) |
|
|
{Rcount+=1; flag_rout[1]=1; |
|
|
packet_last[Rcount-2]=numP[0]; |
|
|
packet_first[Rcount-1]=numP[1]; |
|
|
Num_kadrs[Rcount-1]+=2; |
|
|
Num_kadrs[Rcount-2]-=2; |
|
|
R_er[Rcount-1]+=1; |
|
|
R_er_interf1[Rcount-1]+=1; |
|
|
M_er=N1-1; |
|
|
count_ident[Rcount-1]+=2048; count_ident[Rcount-2]-=2048; |
|
|
count_tot[Rcount-1]+=2048; count_tot[Rcount-2]-=2048; |
|
|
NumRout[Rcount-1]=Rcount; |
|
|
cout<<"\n interface2 "<<NumRout[Rcount-1]<<" "<<Rcount; |
|
|
// cin>>stop1; |
|
|
// CREATE FILE NAMES |
|
|
filename(file_route, miss_file, cln1_file, path, |
|
|
NumRout[Rcount-1], name); |
|
|
strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3); |
|
|
cln1_kadr[strlen(cln1_file)-3]='\0'; |
|
|
strcat(cln1_kadr,"bin"); |
|
|
strncpy(log_kadr,file_route,strlen(file_route)-6); |
|
|
log_kadr[strlen(file_route)-6]='\0'; |
|
|
strcat(log_kadr,"_bin.log"); |
|
|
fclose(foRout); //Close files |
|
|
fo_cln1.close(); //for old |
|
|
fclose(foMiss); //route |
|
|
fokadr_cln1.close(); |
|
|
fclose(fo_log_kadr); |
|
|
//Open files for new route |
|
|
foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log |
|
|
foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat |
|
|
fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam |
|
|
fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin |
|
|
fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log |
|
|
if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)) |
|
|
{Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1; |
|
|
//Correct error rout number////////////////////////////////////////// |
|
|
buffer2[3]=buffer3[3]; |
|
|
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
|
|
//////////////////////////////////////////////////////////////////// |
|
|
flags=(short int)(pow((float)(2*flag_name[1]),4)+ |
|
|
pow((float)(2*flag_rout[1]),1)+ |
|
|
pow((float)(2*flag_pack[1]),2)+ |
|
|
pow((float)(2*flag_CRC0[1]),3)+ |
|
|
pow((float)(2*flag_CRC[1]),5)+ |
|
|
pow((float)(2*flag_CRC_cor[1]),6)); |
|
|
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags)); |
|
|
fprintf(fout,"%i Interface route error 2 %i\n",CRC_bad_kadr[1],flags); |
|
|
CRC_bad_kadr[1]=0;} |
|
|
}*/ |
|
|
/******************Interface route error 3************************/ |
|
|
/**route number:7 7 ( 7 8 4) 8 8******************************/ |
|
|
/**kadr number:198 199 (200 1 2) 3 4******************************/ |
|
|
/* if ((numP[1]==numP[2]-1)&&(flag_CRC[1]==0)&&(flag_CRC[2]==1)) |
|
|
{Rcount+=1; |
|
|
packet_last[Rcount-2]=numP[0]; |
|
|
packet_first[Rcount-1]=numP[1]; |
|
|
NumRout[Rcount-1]=Rcount; |
|
|
Num_kadrs[Rcount-2]-=2; |
|
|
Num_kadrs[Rcount-1]+=2; |
|
|
count_ident[Rcount-1]+=2048; count_ident[Rcount-2]-=2048; |
|
|
count_tot[Rcount-1]+=2048; count_tot[Rcount-2]-=2048; |
|
|
Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1; |
|
|
cout<<"\n interface3 "<<NumRout[Rcount-1]<<" "<<Rcount; |
|
|
// cin>>stop1; |
|
|
// CREATE FILE NAMES |
|
|
filename(file_route, miss_file, cln1_file, path, |
|
|
NumRout[Rcount-1], name); |
|
|
strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3); |
|
|
cln1_kadr[strlen(cln1_file)-3]='\0'; |
|
|
strcat(cln1_kadr,"bin"); |
|
|
strncpy(log_kadr,file_route,strlen(file_route)-6); |
|
|
log_kadr[strlen(file_route)-6]='\0'; |
|
|
strcat(log_kadr,"_bin.log"); |
|
|
fclose(foRout); //Close files |
|
|
fo_cln1.close(); //for old |
|
|
fclose(foMiss); //route |
|
|
fokadr_cln1.close(); |
|
|
fclose(fo_log_kadr); |
|
|
//Open files for new route |
|
|
foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log |
|
|
foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat |
|
|
fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam |
|
|
fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin |
|
|
fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log |
|
|
flags=(short int)(pow((float)(2*flag_name[1]),4)+ |
|
|
pow((float)(2*flag_rout[1]),1)+ |
|
|
pow((float)(2*flag_pack[1]),2)+ |
|
|
pow((float)(2*flag_CRC0[1]),3)+ |
|
|
pow((float)(2*flag_CRC[1]),5)+ |
|
|
pow((float)(2*flag_CRC_cor[1]),6)); |
|
|
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags)); |
|
|
fprintf(fout,"%i Interface route error 3 %i\n",CRC_bad_kadr[1],flags); |
|
|
CRC_bad_kadr[1]=0; |
|
|
}*/ |
|
463 |
} |
} |
|
/**************Return to old route*******************************/ |
|
|
/**route number: 7 (8 4 8) 8*************************************/ |
|
|
/*if ((buffer2[3]!=buffer1[3])&&(buffer2[3]!=buffer3[3])&& |
|
|
(buffer1[3]==buffer3[3])&&(buffer2[3]!=0)&&(N1>2)) |
|
|
{ |
|
|
R_er[Rcount-1]+=1; flag_rout[1]=1; |
|
|
M_er=N1-1; |
|
|
if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)) |
|
|
{ |
|
|
//Correct error route number////////////////////////////////////////// |
|
|
buffer2[3]=buffer1[3]; |
|
|
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
|
|
//////////////////////////////////////////////////////////////////// |
|
|
flags=(short int)(pow((float)(2*flag_name[1]),4)+ |
|
|
pow((float)(2*flag_rout[1]),1)+ |
|
|
pow((float)(2*flag_pack[1]),2)+ |
|
|
pow((float)(2*flag_CRC0[1]),3)+ |
|
|
pow((float)(2*flag_CRC[1]),5)+ |
|
|
pow((float)(2*flag_CRC_cor[1]),6)); |
|
|
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags)); |
|
|
fprintf(fout,"%i Old route error %i\n",CRC_bad_kadr[1],flags); |
|
|
CRC_bad_kadr[1]=0;} |
|
|
cout<<"\n"<<Rcount<<" old "<<NumRout[Rcount-1]<<" "<<buffer1[3]<<" "<<buffer2[3]<<" "<<buffer3[3]<<" N1="<<N1-1<<"\n"; |
|
|
}*/ |
|
464 |
/**************First route***************************************/ |
/**************First route***************************************/ |
465 |
/**route number: (0 4) 4*****************************************/ |
/**route number: (0 4) 4*****************************************/ |
466 |
/**kadr number: (0 1) 2*****************************************/ |
/**cadre number: (0 1) 2*****************************************/ |
467 |
if (N1==2) |
if (N1==2) |
468 |
{packet_first[Rcount-1]=numP[1]; |
{packet_first[Rcount-1]=numP[1]; |
469 |
packet_last[Rcount-1]=numP[2]; |
packet_last[Rcount-1]=numP[2]; |
470 |
NumRout[Rcount-1]=1; |
NumRout[Rcount-1]=1; |
471 |
// CREATE FILE NAMES |
// CREATE FILE NAMES |
472 |
filename(file_route, miss_file, cln1_file, path, |
filename(file_route, miss_file, cln1_file, path, NumRout[Rcount-1], name); |
|
NumRout[Rcount-1], name); |
|
473 |
strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3); |
strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3); |
474 |
cln1_kadr[strlen(cln1_file)-3]='\0'; |
cln1_kadr[strlen(cln1_file)-3]='\0'; |
475 |
strcat(cln1_kadr,"bin"); |
strcat(cln1_kadr,"bin"); |
477 |
log_kadr[strlen(file_route)-6]='\0'; |
log_kadr[strlen(file_route)-6]='\0'; |
478 |
strcat(log_kadr,"_bin.log"); |
strcat(log_kadr,"_bin.log"); |
479 |
//Open files for new route |
//Open files for new route |
480 |
foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log |
foRout=fopen(file_route, "wb"); //nnnnn_mmm_xxx_cln1Er.log |
481 |
foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat |
foMiss=fopen(miss_file, "wb"); //nnnnn_mmm_xxx_mis_cln1.dat |
482 |
fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam |
if (CLN1_MEPHI>0) |
483 |
|
{strcpy(ch4,""); |
484 |
|
strncat(ch4,path,strlen(path)-6); |
485 |
|
strcat(strcpy(temp1,ch4),"Cln1/tmp.dat"); |
486 |
|
if ((fo_tmp=fopen(temp1,"w"))==NULL) |
487 |
|
{strcat(strcat(strcpy(command,"mkdir "),ch4),"Cln1"); |
488 |
|
//Creata special directory for cln1 files |
489 |
|
system(command); |
490 |
|
} |
491 |
|
else |
492 |
|
{ |
493 |
|
fclose(fo_tmp); |
494 |
|
remove(temp1); |
495 |
|
} |
496 |
|
for(i=0;i<22;i++) |
497 |
|
{name11[i]=cln1_file[i+strlen(cln1_file)-22];} |
498 |
|
name11[22]='\0'; |
499 |
|
strcat(strcat(ch4,"Cln1/"),name11); |
500 |
|
strcpy(cln1_file,ch4); |
501 |
|
} |
502 |
|
fo_cln1.open(cln1_file, ios::binary); //nnnnn_mmm_xxx_cln1.pam |
503 |
|
|
504 |
if (!fo_cln1) cout<<"can not open "<<cln1_file<<"\n"; |
if (!fo_cln1) cout<<"can not open "<<cln1_file<<"\n"; |
505 |
fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin |
fokadr_cln1.open(cln1_kadr,ios::binary); //nnnnn_mmm_xxx_cln1.bin |
506 |
if (!fokadr_cln1) cout<<"can not open "<<cln1_kadr<<"\n"; |
if (!fokadr_cln1) cout<<"can not open "<<cln1_kadr<<"\n"; |
507 |
fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log |
fo_log_kadr=fopen(log_kadr,"wb"); //nnnnn_mmm_xxx_cln1_bin.log |
508 |
// cout<<"\n"<<Rcount<<" old "<<NumRout[Rcount-1]<<" "<<numP[1]<<" N1="<<N1-1; |
} |
509 |
} |
/***************New route****************************************/ |
510 |
/***************New route***************************************/ |
/**route number: 7 ( 7 0 8) 8*********************************/ |
511 |
/**route number: 7 ( 7 0 8) 8*********************************/ |
/**cadre number: 199 (200 0 1) 2*********************************/ |
512 |
/**kadr number: 199 (200 0 1) 2*********************************/ |
/**route number: 7 ( 7 8 8) 8*********************************/ |
513 |
/**route number: 7 ( 7 8 8) 8*********************************/ |
/**cadre number: 199 (200 0 1) 2*********************************/ |
|
/**kadr number: 199 (200 0 1) 2*********************************/ |
|
514 |
if ( ((buffer1[3]!=buffer3[3])&&(buffer2[3]==0)&&(N1>3)&&(numP[1]!=numP[0]+1)&&(numP[1]<10))|| |
if ( ((buffer1[3]!=buffer3[3])&&(buffer2[3]==0)&&(N1>3)&&(numP[1]!=numP[0]+1)&&(numP[1]<10))|| |
515 |
((buffer1[3]!=buffer2[3])&&(buffer2[3]==buffer3[3])&&(buffer1[3]!=0)&&(numP[1]!=numP[0]+1)&&(numP[1]<10))|| |
((buffer1[3]!=buffer2[3])&&(buffer2[3]==buffer3[3])&&(buffer1[3]!=0)&&(numP[1]!=numP[0]+1)&&(numP[1]<10)&& |
516 |
|
(flag_pack[0]==0)&&(flag_pack[1]==0))|| |
517 |
((numP[2]==numP[1]+1)&&(numP[1]==0)&&(Num_kadrs[Rcount-1]>1000000)) ) |
((numP[2]==numP[1]+1)&&(numP[1]==0)&&(Num_kadrs[Rcount-1]>1000000)) ) |
518 |
{Rcount+=1; |
{Rcount+=1; |
519 |
packet_last[Rcount-2]=numP[0]; |
packet_last[Rcount-2]=numP[0]; |
520 |
packet_first[Rcount-1]=numP[1]; |
packet_first[Rcount-1]=numP[1]; |
521 |
NumRout[Rcount-1]=Rcount; |
NumRout[Rcount-1]=Rcount; |
522 |
cout<<"New route="<<Rcount<<" "<<buffer1[3]<<" "<<buffer2[3]<<" "<<buffer3[3]<<"\n"; |
if (print_flag>0) |
523 |
cout<<numP[0]<<" "<<numP[1]<<" "<<numP[2]<<"\n";cin>>i; |
{cout<<"New route="<<Rcount<<" "<<buffer1[3]<<" "<<buffer2[3]<<" "<<buffer3[3]<<"\n"; |
524 |
|
cout<<numP[0]<<" "<<numP[1]<<" "<<numP[2]<<"\n";} |
525 |
if (flag_tr[1]==0) |
if (flag_tr[1]==0) |
526 |
{Num_kadrs[Rcount-2]-=2; |
{Num_kadrs[Rcount-2]-=2; |
527 |
Num_kadrs[Rcount-1]+=2; |
Num_kadrs[Rcount-1]+=2; |
533 |
count_ident[Rcount-1]+=1024; count_ident[Rcount-2]-=1024; |
count_ident[Rcount-1]+=1024; count_ident[Rcount-2]-=1024; |
534 |
count_tot[Rcount-1]+=1024; count_tot[Rcount-2]-=1024;} |
count_tot[Rcount-1]+=1024; count_tot[Rcount-2]-=1024;} |
535 |
// CREATE FILE NAMES |
// CREATE FILE NAMES |
536 |
filename(file_route, miss_file, cln1_file, path, |
filename(file_route, miss_file, cln1_file, path, NumRout[Rcount-1], name); |
|
NumRout[Rcount-1], name); |
|
537 |
strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3); |
strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3); |
538 |
cln1_kadr[strlen(cln1_file)-3]='\0'; |
cln1_kadr[strlen(cln1_file)-3]='\0'; |
539 |
strcat(cln1_kadr,"bin"); |
strcat(cln1_kadr,"bin"); |
546 |
fokadr_cln1.close(); |
fokadr_cln1.close(); |
547 |
fclose(fo_log_kadr); |
fclose(fo_log_kadr); |
548 |
//Open files for new route |
//Open files for new route |
549 |
foRout=fopen(file_route, "wb"); //mmm_nnnnn_cln1Er.log |
foRout=fopen(file_route, "wb"); //nnnnn_mmm_xxx_cln1Er.log |
550 |
foMiss=fopen(miss_file, "wb"); //mmm_nnnnn_mis_cln1.dat |
foMiss=fopen(miss_file, "wb"); //nnnnn_mmm_xxx_mis_cln1.dat |
551 |
fo_cln1.open(cln1_file, ios::binary); //mmm_nnnnn_cln1.pam |
fo_cln1.open(cln1_file, ios::binary); //nnnnn_mmm_xxx_cln1.pam |
552 |
fokadr_cln1.open(cln1_kadr,ios::binary); //mmm_nnnnn_cln1.bin |
fokadr_cln1.open(cln1_kadr,ios::binary); //nnnnn_mmm_xxx_cln1.bin |
553 |
fo_log_kadr=fopen(log_kadr,"wb"); //mmm_nnnnn_cln1_bin.log |
fo_log_kadr=fopen(log_kadr,"wb"); //nnnnn_mmm_xxx_cln1_bin.log |
554 |
if ((CRC_bad_kadr[2]==numP[2])&&(numP[2]!=0)) {Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1;} |
if ((CRC_bad_kadr[2]==numP[2])&&(numP[2]!=0)) {Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1;} |
555 |
if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)) |
if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)) |
556 |
{Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1; |
{Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1; |
561 |
pow((float)(2*flag_CRC[1]),5)+ |
pow((float)(2*flag_CRC[1]),5)+ |
562 |
pow((float)(2*flag_CRC_cor[1]),6)); |
pow((float)(2*flag_CRC_cor[1]),6)); |
563 |
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags)); |
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags)); |
564 |
fprintf(fout,"%i New route %i\n",CRC_bad_kadr[1],flags); |
fo_info<<"New route: cadre="<<CRC_bad_kadr[1]<<" error flag="<<flags<<"\n"; |
565 |
CRC_bad_kadr[1]=-1;} |
CRC_bad_kadr[1]-=1;} |
|
// cout<<Rcount<<" New "<<NumRout[Rcount-1]<<" "<<numP[1]<<"\n"; |
|
566 |
} |
} |
567 |
|
|
568 |
if ((numP[1]==0)&&(N1>1)) |
if (((numP[1]==0)&&(N1>1))||(N1==2)) |
569 |
{rr=0; |
{rr=0; |
570 |
FindRoute(buffer2, &rr); |
FindRoute(buffer2, &rr); |
571 |
if (rr>0) |
if (rr>0) |
581 |
if (CRC_bad_kadr[1]==numP[1]) |
if (CRC_bad_kadr[1]==numP[1]) |
582 |
{ |
{ |
583 |
//Correct CRC0 error///////////////////////////////////////////////// |
//Correct CRC0 error///////////////////////////////////////////////// |
584 |
buffer2[7]=buffer1[1023]; |
if (flag_CRC0[1]!=0) |
585 |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
{ |
586 |
|
buffer2[7]=buffer1[1023]; |
587 |
|
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
588 |
|
} |
589 |
//Correct name error///////////////////////////////////////////////// |
//Correct name error///////////////////////////////////////////////// |
590 |
buffer2[0]=(int)(CODE1); |
if (flag_name[1]!=0) |
591 |
buffer2[1]=(int)(CODE2); |
{buffer2[0]=(int)(CODE1); |
592 |
buffer2[2]=(int)(CODE3); |
buffer2[1]=(int)(CODE2); |
593 |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
buffer2[2]=(int)(CODE3); |
594 |
|
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; |
595 |
|
} |
596 |
} |
} |
597 |
//////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////// |
598 |
/*******************************************************************/ |
/*******************************************************************/ |
606 |
pow((float)(2*flag_CRC_cor[1]),6)); |
pow((float)(2*flag_CRC_cor[1]),6)); |
607 |
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]), |
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]), |
608 |
(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags)); |
(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags)); |
609 |
fprintf(fout,"%i flags=%i\n",CRC_bad_kadr[1],flags);} |
fo_info<<" error flag="<<flags<<" in cadre "<<numP[1]<<"\n";} |
610 |
|
|
611 |
/***************************************************************/ |
/***************************************************************/ |
|
// cout <<"\nCalcChekSum="<<dec <<right<<CalcCheckSum |
|
|
// <<"\npacket.CheckSum1="<<right<<packet.CheckSum1; |
|
|
// cout <<"\nPacket number="<<packet.Pckt_Num<<" "<<endl; |
|
612 |
//*Packet analysis********************************************** |
//*Packet analysis********************************************** |
613 |
if (N_er!=0) fprintf(fout,"Name error %i in kadr %i\n",numP[2],N_er); |
if (N_er!=0) fo_info<<"Name error "<<N_er<<" in cadre "<<numP[2]<<"\n"; |
614 |
if (M_er!=0) fprintf(fout,"Root number error %i in kadr %i\n",numP[1],M_er); |
if (P_er!=0) fo_info<<"Number packet error "<<numP[1]<<" in cadre "<<P_er<<"\n"; |
615 |
if (P_er!=0) fprintf(fout,"Number packet error %i in kadr %i\n",numP[1], P_er); |
if (CRC0_er!=0) fo_info<<"CRC0 error "<<numP[1]<<" in cadre "<<CRC0_er<<"\n"; |
|
if (CRC0_er!=0) fprintf(fout,"CRC0 error %i in kadr %i\n",numP[1], CRC0_er); |
|
616 |
|
|
617 |
/***************PAMELA data extracting for each route***********/ |
/***************PAMELA data extracting for each route***********/ |
618 |
// if (N1!=1&&(flag_CRC[1]==0||(flag_rout[1]==0&&flag_pack[1]==0)|| |
// if (N1!=1&&(flag_CRC[1]==0||(flag_rout[1]==0&&flag_pack[1]==0)|| |
619 |
// (flag_CRC[1]!=0&&flag_CRC_cor[1]==1))) |
// (flag_CRC[1]!=0&&flag_CRC_cor[1]==1))) |
620 |
if (N1!=1) |
if ((N1!=1)&&(flag_tr[1]==0)) |
621 |
{end=0; |
{end=0; |
622 |
if (buffer2[3]!=buffer1[3]||buffer2[3]!=buffer3[3]) |
if (buffer2[3]!=buffer1[3]||buffer2[3]!=buffer3[3]) |
623 |
{for (i=8;i<1020;i++) |
{for (i=8;i<1020;i++) |
630 |
} |
} |
631 |
else {for(i=8;i<1023;i++) fo_cln1<<(unsigned char)buffer2[i];} |
else {for(i=8;i<1023;i++) fo_cln1<<(unsigned char)buffer2[i];} |
632 |
for (i=0;i<1024;i++) {fokadr_cln1<<(unsigned char)buffer2[i];} |
for (i=0;i<1024;i++) {fokadr_cln1<<(unsigned char)buffer2[i];} |
633 |
//Write in file mmm_counter_nnnnn_cln1_bin.log |
//Write in file nnnnn_mmm_xxx_cln1_bin.log |
634 |
tmp=numP[1]; |
tmp=numP[1]; |
635 |
for (k=0;k<4;k++) numPack[k]=0; |
for (k=0;k<4;k++) numPack[k]=0; |
636 |
for (k=0;k<4;k++) |
for (k=0;k<3;k++) |
637 |
{if (tmp/(long int)(pow(256.,3-k))>=1) |
{if (tmp/(long int)(pow(256.,2-k))>=1) |
638 |
{numPack[3-k]=(int)(tmp/(long int)(pow(256.,3-k))); |
{numPack[2-k]=(int)(tmp/(long int)(pow(256.,2-k))); |
639 |
tmp=tmp-(long int)pow(256.,3-k)*(int)(tmp/(long int)(pow(256.,3-k)));}} |
tmp=tmp-(long int)pow(256.,2-k)*(int)(tmp/(long int)(pow(256.,2-k)));}} |
640 |
for (i=0;i<4;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr); |
for (i=0;i<3;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr); |
641 |
adr1=icount-1024*2; |
adr1=icount-1024*2; |
642 |
for (k=0;k<4;k++) adress[k]=0; |
for (k=0;k<4;k++) adress[k]=0; |
643 |
for (k=0;k<4;k++) |
for (k=0;k<4;k++) |
659 |
} |
} |
660 |
/***************************************************************/ |
/***************************************************************/ |
661 |
/***************************************************************/ |
/***************************************************************/ |
662 |
if (flag_CRC[2]==0||(flag_rout[2]==0&&flag_pack[2]==0)|| |
if (flag_CRC[2]==0||(flag_rout[2]==0&&flag_pack[2]==0)||(flag_CRC[2]!=0&&flag_CRC_cor[2]==1)) |
|
(flag_CRC[2]!=0&&flag_CRC_cor[2]==1)) |
|
663 |
{end=0; |
{end=0; |
664 |
for (i=0;i<1024;i++) fokadr_cln1<<(unsigned char)buffer3[i]; |
for (i=0;i<1024;i++) fokadr_cln1<<(unsigned char)buffer3[i]; |
665 |
//Write in file mmm_counter_nnnnn_cln1_bin.log |
//Write in file nnnnn_mmm_xxx_cln1_bin.log |
666 |
tmp=numP[2]; |
tmp=numP[2]; |
667 |
for (k=0;k<4;k++) numPack[k]=0; |
for (k=0;k<4;k++) numPack[k]=0; |
668 |
for (k=0;k<4;k++) |
for (k=0;k<3;k++) |
669 |
{if (tmp/(long int)(pow(256.,3-k))>=1) |
{if (tmp/(long int)(pow(256.,2-k))>=1) |
670 |
{numPack[3-k]=(int)(tmp/(long int)(pow(256.,3-k))); |
{numPack[2-k]=(int)(tmp/(long int)(pow(256.,2-k))); |
671 |
tmp=tmp-(long int)pow(256.,3-k)* |
tmp=tmp-(long int)pow(256.,2-k)* |
672 |
(int)(tmp/(long int)(pow(256.,3-k)));}} |
(int)(tmp/(long int)(pow(256.,2-k)));}} |
673 |
for (i=0;i<4;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr); |
for (i=0;i<3;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr); |
674 |
adr1=icount-1024; |
adr1=icount-1024; |
675 |
for (k=0;k<4;k++) adress[k]=0; |
for (k=0;k<4;k++) adress[k]=0; |
676 |
for (k=0;k<4;k++) |
for (k=0;k<4;k++) |
701 |
|
|
702 |
icount_int = (int)(icount/1024); |
icount_int = (int)(icount/1024); |
703 |
icount_frac= icount%1024; |
icount_frac= icount%1024; |
|
// cout<<"\nfile size="<<icount_total<<" Byte "<<N1 |
|
|
// <<" identified cadrs Number of routs="<<Rcount<<"\n"; |
|
|
// cout<<" size of identified cadrs="<<icount<<" bytes "<<count_ident[0]<<"\n"; |
|
704 |
|
|
705 |
//***protocol file*********************************************** |
//***protocol file*********************************************** |
|
strcpy(file_name_prot, path); |
|
|
strcat(file_name_prot, name); |
|
706 |
file_length=(int)(strlen(name)); |
file_length=(int)(strlen(name)); |
707 |
fprintf(fo,"file name=%s\n",file_name_prot); |
fprintf(fo,"file name=/home/ntsomz/downlinks/%s\n",name); |
708 |
fprintf(fo,"file size= %i,%i kByte \n", icount_int, |
fprintf(fo,"file size= %i,%i kByte \n", icount_int, icount_frac); |
709 |
icount_frac); |
fprintf(fo,"number identified cadres= %i\n", N1); |
710 |
for (i=0;i<Rcount;i++) |
fprintf(fo,"number of routes= %i\n", Rcount); |
711 |
{fprintf(fo,"route=%i;",NumRout[i]); |
|
712 |
fprintf(fo," size of identified cadrs =%lli bytes;",count_ident[i]); |
for(i=0;i<5;i++) {temp[i]=name[i]; temp[5]='\0';} |
713 |
|
sscanf(temp,"%5d", &cirquit_no); |
714 |
|
for(i=0;i<3;i++) {temp[i]=name[i+5]; temp[3]='\0';} |
715 |
|
sscanf(temp,"%3i", &route); |
716 |
|
|
717 |
|
for (i=0;i<Rcount;i++) |
718 |
|
{ |
719 |
|
for(j=0;j<22;j++) temp[j]=cln1_file[j+strlen(cln1_file)-22]; |
720 |
|
temp[22]='\0'; |
721 |
|
oss.str(""); |
722 |
|
oss << "INSERT INTO RAW_FILES (cirquit_n, route_n, counter, NumCadr, CRCerr, cln1_name, cln1_size)" |
723 |
|
<< " VALUES ("<< cirquit_no << ","<< route << ","<< i+1 <<","<< Num_kadrs[i]<< "," << Num_bad_kadrs[i] << ",'" |
724 |
|
<< temp << "'," << count_ident[i]-Num_kadrs[i]*9 << ")"; |
725 |
|
if (print_flag>0) cout<<oss.str().c_str()<<" table RAW_FILES\n"; |
726 |
|
TSQLResult *res=sqlServer->Query(oss.str().c_str()); |
727 |
|
|
728 |
|
Num_good_kadrs[i]=Num_kadrs[i]-Num_bad_kadrs[i]; |
729 |
|
if (packet_first[i]>1) |
730 |
|
{first_missed[i]=(float)(1.)-float(packet_first[i]-1.)/(float)(packet_last[i]);} |
731 |
|
else if (packet_first[i]==0) |
732 |
|
{first_missed[i]=1.;} |
733 |
|
|
734 |
|
|
735 |
|
quality[i]=(float)(1.)-(float)(Num_bad_kadrs[i])/(float)(Num_kadrs[i]); |
736 |
|
fprintf(fo,"\nRoute number=%i: number of normal cadres= %i: number of errors=%i; \n",NumRout[i],Num_good_kadrs[i],Num_bad_kadrs[i]); |
737 |
|
fprintf(fo,"size of identified cadres =%lli bytes;",count_ident[i]); |
738 |
fprintf(fo," total size of route=%lli bytes;\n",count_tot[i]); |
fprintf(fo," total size of route=%lli bytes;\n",count_tot[i]); |
739 |
fprintf(fo,"number of errors=%i;\n",Num_bad_kadrs[i]); |
fprintf(fo,"first cadre number= %lli:", packet_first[i]); |
740 |
|
fprintf(fo," last cadre number= %lli:", packet_last[i]); |
741 |
|
fprintf(fo," Number of missed cadres= %lli: Number of double transmitted cadres= %lli\n", |
742 |
|
count_missed[i], count_sec_missed[i]); |
743 |
|
fprintf(fo,"number of identified cadres=%lli: quality index=%f: completness=%f \n", Num_kadrs[i], quality[i], |
744 |
|
first_missed[i]); |
745 |
} |
} |
746 |
|
|
747 |
//***route's number log file************************************** |
//***route number log file************************************** |
748 |
for (i=0;i<Rcount;i++) {fprintf(fo_route,"%1c",(char)(NumRout[i]));} |
for (i=0;i<Rcount;i++) {fprintf(fo_route,"%1c",(char)(NumRout[i]));} |
749 |
|
|
750 |
//***cln1.inf file************************************************* |
|
|
fprintf(fo1,"file name="); |
|
|
fprintf(fo1,"%s%s",path,name); |
|
|
fprintf(fo1,"\nfile size= %i,%i kByte \n", icount_int, |
|
|
icount_frac); |
|
|
fprintf(fo1,"number identified kadrs= %i\n", N1); |
|
|
fprintf(fo1,"number of routes= %i\n", Rcount); |
|
|
|
|
|
for (i=0;i<Rcount;i++) |
|
|
{ |
|
|
Num_good_kadrs[i]=Num_kadrs[i]-Num_bad_kadrs[i]; |
|
|
quality[i]=(float)(1.)-(float)(Num_bad_kadrs[i])/(float)(Num_kadrs[i]); |
|
|
fprintf(fo1,"\nRoute number=%i: number of normal kadrs= %i:\n", |
|
|
NumRout[i],Num_good_kadrs[i]); |
|
|
fprintf(fo1,"first kadre number= %lli:", packet_first[i]); |
|
|
fprintf(fo1," last kadre number= %lli:", packet_last[i]); |
|
|
fprintf(fo1," Number of missed kadrs= %i:\n", count_missed[i]); |
|
|
// fprintf(fo1,"Number of double transmitted kadrs= %i:\n", count_sec_missed[i]); |
|
|
fprintf(fo1,"number of identified kadres=%lli: quality index=%f\n", Num_kadrs[i], quality[i]); |
|
|
} |
|
751 |
//*************************************************************** |
//*************************************************************** |
752 |
fin.close(); |
fin.close(); |
753 |
fclose(fout); |
fclose(fout); |
754 |
|
fo_info.close(); |
755 |
fclose(fo); |
fclose(fo); |
|
fclose(fo1); |
|
756 |
fclose(foRout); |
fclose(foRout); |
757 |
fclose(foMiss); |
fclose(foMiss); |
758 |
fo_cln1.close(); |
fo_cln1.close(); |