#include "descript.h" #include "flag.h" void filename(char [], char [], char [], char[], int, char[]); void FindRoute(int[], int*); short int CRC(int []); int restrict(int [], long long int[], int); void read(char fni[], char fno[], char INF[], char protocol[], char path[], char name[], char nnnnn_TMP[], float quality[], int real_route[], int &Rcount) { FILE *fo, *fout, *foRout, *foMiss, *fo_log_kadr, *fo_route; ifstream fin; ofstream fo_cln1, fokadr_cln1; char buf[1024]; // char stop1; char ch1,ch2,ch3, ch; char file_route[80]; /*protocol binary filesm mmm_counter_nnnnn_cln1Er.log*/ char miss_file[80]; /*protocol files mmm_counter_nnnnn_mis_cln1.dat*/ char cln1_file[80]; /*route binary data files mmm_counter_nnnnn_cln1.pam*/ char cln1_kadr[80]; /*route binary data files mmm_counter_nnnnn_cln1.bin*/ char log_kadr[80]; /*log binary data files mmm_counter_nnnnn_cln1.log*/ char log_route[80]; /*log binary file for number of routes*/ char Short_Buf[8], Name_Buf[4]; short int CalcCheckSum; int LenthBuf=1015, flag_help=0; int i, j, k, file_length=0, Hex[3]; int N_er=0; /*Number of kadr with name error*/ int CRC0_er=0; /*Number of kadr with CRC0 error*/ int P_er=0; /*Number of kadr with packet error number*/ int M_er=0; /*Number of kadr with rout error number*/ int end=0; /*End of last pamela packet*/ // Buffers for Kadr analysis int buffer1[1024], buffer2[1024], buffer3[1024]; int rr=0; int header1, header2, header3, CRC_0[3], CRC_1[3]; long long int icount_int; long long int icount_frac, tmpP, numP[3]; long int N1=0; /* Number of identified kadrs*/ long long int icount=0; /* Number of bytes in identified kadrs*/ long long int icount_total=0; /* Total number of bytes*/ long long int packet_first[100];/*First kadr number for each route*/ long long int packet_last[100]; /*Second kadr number for each route*/ long int count_missed[100]; /* Number of missed kadrs in each route*/ long int count_sec_missed[100]; unsigned long long int count_ident[100]; /* Number of good bytes in each rout*/ unsigned long long int count_tot[100]; /* Total number of bytes in each rout*/ int NumRout[1000]; /* Number of Route*/ long long int Num_kadrs[1000]; /* Number of identified kadrs in each rout*/ long int Num_good_kadrs[1000]; /* Number of normal kadrs in each rout*/ long long int Num_bad_kadrs[1000]; /* Bad kadrs number in each rout*/ // float quality[100]; /* File quality pointer*/ int counter=0; /* Last byte position in truncated kadr*/ int adr1=0; /* Initial byte of kadr in cln1.bin*/ int adr2=0; /* Last byte of kadr in cln2.bin*/ int tmp=0; int numPack[4]; /* Number of kadr in given route*/ int good_pack=0; int good_number=0; int good_route=0; int adress[4]; int R_er[100]; /* Rout errors number in given rout*/ int R_er_interf1[100]; /* Interface Rout error at begin of rout*/ int R_er_interf2[100]; /* Interface Rout error at end of rout*/ int Mis_group[1000]; /* Number of missed kadrs group for each route*/ int Pack_Er[1000]; /* Number of packets with packet number error for each route*/ int CRC_bad_kadr[3]; /* Current CRC bad kadr number*/ int flag_pack[3]; /* Flag for error in packet number*/ int flag_rout[3]; /* Flag for error in rout number*/ int flag_name[3]; /* Flag for name error*/ int flag_CRC0[3]; /* Flag for CRC0 error*/ int flag_CRC[3]; /* Flag for CRC error*/ int flag_CRC_cor[3]; /* Flag for CRC error correction*/ int flag_tr[3]; /* Truncate flag*/ short int flags; /* Number for all errors*/ for (j=0; j<4; j++) {adress[j]=0; numPack[j]=0;} for (j=0; j<1024; j++) {buffer1[j]=0; buffer2[j]=0; buffer3[j]=0;} for (i=0; i<100; i++) {Num_kadrs[i]=0; NumRout[i]=0; packet_first[i]=0; packet_last[i]=0; count_missed[i]=0; count_sec_missed[i]=0; count_ident[i]=0; count_tot[i]=0; R_er[i]=0; R_er_interf1[i]=0; Num_bad_kadrs[i]=0; Num_good_kadrs[i]=0; quality[i]=0; Mis_group[i]=0; Pack_Er[i]=0; R_er_interf2[i]=0;} for (i=0; i<3; i++) {numP[i]=0; CRC_bad_kadr[i]=0; Hex[i]=0; flag_pack[i]=0; flag_rout[i]=0; flag_name[i]=0; flag_CRC0[i]=0; flag_tr[i]=0; flag_CRC[i]=0; flag_CRC_cor[i]=0;} // open input file "nnnnnmmm.pam" fin.open(fni, ifstream::binary); if(fin.good()==0) {cerr<<"can not open input file"; exit(0);} //open output file "nnnnnmmm_work.dat" fout=fopen(fno, "wb"); if(fout==0) {cerr<<"can not open outputfile"; exit(0);} //open output file "nnnnnmmm_protocol.txt" fo=fopen(protocol, "wb"); if(fo==0) {cerr<<"can not open protocol file"; exit(0);} //open output file "nnnnnmmm_route.log" strncpy(log_route,INF,strlen(INF)-9); log_route[strlen(INF)-9]='\0'; strcat(log_route,"_route.log"); fo_route=fopen(log_route, "wb"); if(fo_route==0) {cerr<<"can not open file for routes number"; exit(0);} ///////////////////////////////////////////////////////////////// // cin>>stop1; k=0; while(fin.eof()==0) { counter=0; //pounter for position of kadr truncation N_er=0; M_er=0; P_er=0; CRC0_er=0; if (N1==0) Rcount=1; /**********************data reading********************************/ fin.read(Name_Buf,3); if (fin.eof()) break; fin.read(Short_Buf,5); if (fin.eof()) break; ch1=Name_Buf[0]; ch2=Name_Buf[1]; ch3=Name_Buf[2]; tmpP=(long int)(unsigned char)(Short_Buf[1])+ 256*(long int)(unsigned char)(Short_Buf[2])+ 256*256*(long int)(unsigned char)(Short_Buf[3]); icount+=8; icount_total+=8; count_ident[Rcount-1]+=8; count_tot[Rcount-1]+=8; while((ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&& (N1==0||buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0]))) || (ch2!=(char)(CODE2)&&ch3!=(char)(CODE3)&&(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||(numP[2]+1)!=tmpP)) || (ch3!=(char)(CODE3)&&ch1!=(char)(CODE1)&&((numP[2]+1)!=tmpP||buffer3[1023]!=(int)(unsigned char)(Short_Buf[4]))) || (ch1!=(char)(CODE1)&& (buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP)) || (ch2!=(char)(CODE2)&& (buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP)) || (ch3!=(char)(CODE3)&& (buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP)) || (ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&&ch3!=(char)(CODE3))) {fin.get(ch); if (fin.eof()) {break;} ch1=ch2; ch2=ch3; ch3=Short_Buf[0]; for (i=0;i<4;i++) Short_Buf[i]=Short_Buf[i+1]; Short_Buf[4]=ch; icount_total+=1; count_tot[Rcount-1]+=1; tmpP=(long int)(unsigned char)(Short_Buf[1])+ 256*(long int)(unsigned char)(Short_Buf[2])+ 256*256*(long int)(unsigned char)(Short_Buf[3]); } if ((fin.eof())&&(N1==0)) { fclose(fout); remove(fno); fclose(fo); remove(protocol); remove(INF); exit(0); } /*****************************************************************/ /*********************data reading********************************/ fin.read(buf,LenthBuf); if (fin.eof()) break; icount+=1015; icount_total+=1015; count_ident[Rcount-1]+=1015; count_tot[Rcount-1]+=1015; /****************************************************************/ /********************data reading********************************/ fin.get(ch); icount+=1; icount_total+=1; count_ident[Rcount-1]+=1; count_tot[Rcount-1]+=1; if (fin.eof()) break; /***************************************************************/ N1+=1; Num_kadrs[Rcount-1]+=1; /**********************DATA ANALYSIS****************************/ /***************************************************************/ header1=(unsigned char)(ch1); header2=(unsigned char)(ch2); header3=(unsigned char)(ch3); switch (N1) { case 1:{ buffer3[0]=(int)(unsigned char)(ch1); buffer3[1]=(int)(unsigned char)(ch2); buffer3[2]=(int)(unsigned char)(ch3); buffer3[3]=(int)(unsigned char)(Short_Buf[0]); buffer3[4]=(int)(unsigned char)(Short_Buf[1]); buffer3[5]=(int)(unsigned char)(Short_Buf[2]); buffer3[6]=(int)(unsigned char)(Short_Buf[3]); buffer3[7]=(int)(unsigned char)(Short_Buf[4]); for (i=0; i<1015; i++) {buffer3[i+8]=(int)(unsigned char)(buf[i]);} buffer3[1023]=(int)(unsigned char)(ch); for (i=0; i<1024; i++) {buffer1[i]=buffer3[i];buffer2[i]=buffer3[i];} NumRout[Rcount-1]=1; numP[2]=(long int)(unsigned char)(Short_Buf[1])+ 256*(long int)(unsigned char)(Short_Buf[2])+ 256*256*(long int)(unsigned char)(Short_Buf[3]); CRC_bad_kadr[2]=0; flag_pack[2]=0; flag_rout[2]=0; flag_name[2]=0; flag_CRC0[2]=0; flag_tr[2]=0; flag_CRC[2]=0; flag_CRC_cor[2]=0; for (i=0; i<2; i++) {numP[i]=numP[2];CRC_bad_kadr[i]=CRC_bad_kadr[2]; flag_pack[i]=flag_pack[2]; flag_rout[i]=flag_rout[2]; flag_name[i]=flag_name[2]; flag_CRC0[i]=flag_CRC0[2]; flag_CRC[i]=flag_CRC[2]; flag_tr[i]=flag_tr[2]; flag_CRC_cor[i]=flag_CRC_cor[2];} CRC_0[2]=(int)(unsigned char)(Short_Buf[4]); for (i=0; i<2; i++) {CRC_0[i]=CRC_0[2];} CRC_1[2]=(int)(unsigned char)(ch); for (i=0; i<2; i++) {CRC_1[i]=CRC_1[2];} packet_first[Rcount-1]=numP[2]; break; } default:{ for (i=0; i<1024; i++) {buffer1[i]=buffer2[i];buffer2[i]=buffer3[i];} buffer3[0]=(int)(unsigned char)(ch1); buffer3[1]=(int)(unsigned char)(ch2); buffer3[2]=(int)(unsigned char)(ch3); buffer3[3]=(int)(unsigned char)(Short_Buf[0]); buffer3[4]=(int)(unsigned char)(Short_Buf[1]); buffer3[5]=(int)(unsigned char)(Short_Buf[2]); buffer3[6]=(int)(unsigned char)(Short_Buf[3]); buffer3[7]=(int)(unsigned char)(Short_Buf[4]); for (i=0; i<1015; i++) {buffer3[i+8]=(int)(unsigned char)(buf[i]);} buffer3[1023]=(int)(unsigned char)(ch); for (i=0; i<2; i++) {numP[i]=numP[i+1]; CRC_bad_kadr[i]=CRC_bad_kadr[i+1]; flag_pack[i]=flag_pack[i+1]; flag_rout[i]=flag_rout[i+1]; flag_name[i]=flag_name[i+1]; flag_CRC0[i]=flag_CRC0[i+1]; flag_tr[i]=flag_tr[i+1]; flag_CRC[i]=flag_CRC[i+1]; flag_CRC_cor[i]=flag_CRC_cor[i+1];} numP[2]=(long int)(unsigned char)(Short_Buf[1])+ 256*(long int)(unsigned char)(Short_Buf[2])+ 256*256*(long int)(unsigned char)(Short_Buf[3]); CRC_bad_kadr[2]=0; flag_pack[2]=0; flag_rout[2]=0; flag_name[2]=0; flag_CRC0[2]=0; flag_CRC[2]=0; flag_CRC_cor[2]=0; flag_tr[2]=0; for (i=0; i<2; i++) CRC_0[i]=CRC_0[i+1]; CRC_0[2]=(int)(unsigned char)(Short_Buf[4]); for (i=0; i<2; i++) {CRC_1[i]=CRC_1[i+1];} CRC_1[2]=(int)(unsigned char)(ch); } } // if (fmod(N1,10000)==0.) cout<>i;}*/ fprintf(fout,"CRC = %x (%x) error in kadr %i\n", buffer3[1023],CalcCheckSum,numP[2]); //write in file nnnnn_work.dat flag_CRC[2]=1; Num_bad_kadrs[Rcount-1]+=1; CRC_bad_kadr[2]=numP[2]; counter=restrict(buffer3,numP,buffer2[3]); if (counter!=0) {fprintf(fout," truncate byte=%i",counter); // cout<<" truncate counter="<2)) {flag_CRC0[1]=1; CRC0_er=N1-1;} /****************************************************************/ /******************KADR NUMBER ANALYSIS**************************/ if ((numP[1]!=(numP[0]+1))&&(numP[1]!=(numP[2]-1))&&(N1!=1)&&(CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)) {P_er=N1-1; flag_pack[1]=1; //Correct error packet number// tmpP=numP[0]+1; for (i=0;i<3;i++) Hex[i]=0; for (i=0;i<3;i++) {if (tmpP/(long int)(pow(256.,2-i))>=1) {Hex[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)));}} for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]); if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; tmpP=numP[2]-1; for (i=0;i<3;i++) Hex[i]=0; for (i=0;i<3;i++) {if (tmpP/(long int)(pow(256.,2-i))>=1) {Hex[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)));}} for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]); if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=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; if (flag_pack[2]!=1) packet_last[Rcount-1]=numP[2]; ////////Missing kadr analysis//////////////////////////////////// /**route number: 10 (10 19 10) 10 ******************************/ /**kadr number: 21 (22 17 18) 19 ******************************/ /**missed kadrs: 21 20 19 18 17 ******************************/ if ((numP[1]numP[0]+1)&&(numP[1]=numP[0]+1)&&(numP[1]numP[2]-1))&&(numP[2]-numP[0]>2)&& (buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&&(flag_tr[1]==0)&& (flag_pack[2]==0)&&(flag_pack[1]==1)&&(flag_pack[0]==0)) {Mis_group[Rcount-1]+=1; fprintf(foMiss,"%9i%9i -1\n",numP[0]+1,numP[2]-1); count_missed[Rcount-1]+=numP[2]-numP[0]-1-1;} /**route number:10 (10 10 10) 10 10 ******************************/ /**kadr number: 1 (11 12 13) 14 15 ******************************/ /**number of missed kadrs: 10 ******************************/ else if ((N1>1)&&(abs(numP[2]-good_pack-2)>abs(Num_kadrs[Rcount-1]-good_number))&& (buffer2[3]==good_route)&&(flag_tr[2]==0)&&(flag_pack[2]==0)) {Mis_group[Rcount-1]+=1; fprintf(foMiss,"%9i%9i \n",good_pack+1,numP[2]-1); count_missed[Rcount-1]+=numP[2]-good_pack-1; } //truncate kadr /**route number: 10 (10 10 10) 10 ******************************/ /**kadr number: 11 (12 13 14) 15 ******************************/ /**missed truncate kadr:13 ******************************/ else if ((numP[0]3)&&(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))|| ((numP[2]==numP[1]+1)&&(numP[1]==0)&&(Num_kadrs[Rcount-1]>1000000)) ) {Rcount+=1; packet_last[Rcount-2]=numP[0]; packet_first[Rcount-1]=numP[1]; NumRout[Rcount-1]=Rcount; cout<<"New route="<1))||(N1==2)) {rr=0; FindRoute(buffer2, &rr); if (rr>0) { real_route[Rcount]=rr; } else { real_route[Rcount]=0; } } /***************************************************************/ if (CRC_bad_kadr[1]==numP[1]) { //Correct CRC0 error///////////////////////////////////////////////// buffer2[7]=buffer1[1023]; if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; //Correct name error///////////////////////////////////////////////// buffer2[0]=(int)(CODE1); buffer2[1]=(int)(CODE2); buffer2[2]=(int)(CODE3); if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1; } //////////////////////////////////////////////////////////////////// /*******************************************************************/ if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)&&(N1>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 flags=%i\n",CRC_bad_kadr[1],flags);} /***************************************************************/ //*Packet analysis********************************************** if (N_er!=0) fprintf(fout,"Name error %i in kadr %i\n",numP[2],N_er); if (M_er!=0) fprintf(fout,"Root number error %i in kadr %i\n",numP[1],M_er); if (P_er!=0) fprintf(fout,"Number packet error %i in kadr %i\n",numP[1], P_er); if (CRC0_er!=0) fprintf(fout,"CRC0 error %i in kadr %i\n",numP[1], CRC0_er); /***************PAMELA data extracting for each route***********/ // if (N1!=1&&(flag_CRC[1]==0||(flag_rout[1]==0&&flag_pack[1]==0)|| // (flag_CRC[1]!=0&&flag_CRC_cor[1]==1))) if ((N1!=1)&&(flag_tr[1]==0)) {end=0; if (buffer2[3]!=buffer1[3]||buffer2[3]!=buffer3[3]) {for (i=8;i<1020;i++) { // if (fmodf(float((Num_kadrs[Rcount-1]-1)*1015+i-8),float(64))==0.&&buffer2[i]==0&&buffer2[i+1]==0&& // buffer2[i+2]==0&&buffer2[i+3]==0) end=1; if (end!=1) fo_cln1<<(unsigned char)buffer2[i]; } if (end!=1) for(i=1020;i<1023;i++) {fo_cln1<<(unsigned char)buffer2[i];} } else {for(i=8;i<1023;i++) fo_cln1<<(unsigned char)buffer2[i];} for (i=0;i<1024;i++) {fokadr_cln1<<(unsigned char)buffer2[i];} //Write in file mmm_counter_nnnnn_cln1_bin.log tmp=numP[1]; for (k=0;k<4;k++) numPack[k]=0; for (k=0;k<3;k++) {if (tmp/(long int)(pow(256.,2-k))>=1) {numPack[2-k]=(int)(tmp/(long int)(pow(256.,2-k))); tmp=tmp-(long int)pow(256.,2-k)*(int)(tmp/(long int)(pow(256.,2-k)));}} for (i=0;i<3;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr); adr1=icount-1024*2; for (k=0;k<4;k++) adress[k]=0; for (k=0;k<4;k++) {if (adr1/(long int)(pow(256.,3-k))>=1) {adress[3-k]=(int)(adr1/(long int)(pow(256.,3-k))); adr1=adr1-(long int)pow(256.,3-k)* (int)(adr1/(long int)(pow(256.,3-k)));}} for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr); adr2=icount-1024; for (k=0;k<4;k++) adress[k]=0; for (k=0;k<4;k++) {if (adr2/(long int)(pow(256.,3-k))>=1) {adress[3-k]=(int)(adr2/(long int)(pow(256.,3-k))); adr2=adr2-(long int)pow(256.,3-k)* (int)(adr2/(long int)(pow(256.,3-k)));}} for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr); fputc(flags,fo_log_kadr); } } /***************************************************************/ /***************************************************************/ if (flag_CRC[2]==0||(flag_rout[2]==0&&flag_pack[2]==0)|| (flag_CRC[2]!=0&&flag_CRC_cor[2]==1)) {end=0; for (i=0;i<1024;i++) fokadr_cln1<<(unsigned char)buffer3[i]; //Write in file mmm_counter_nnnnn_cln1_bin.log tmp=numP[2]; for (k=0;k<4;k++) numPack[k]=0; for (k=0;k<3;k++) {if (tmp/(long int)(pow(256.,2-k))>=1) {numPack[2-k]=(int)(tmp/(long int)(pow(256.,2-k))); tmp=tmp-(long int)pow(256.,2-k)* (int)(tmp/(long int)(pow(256.,2-k)));}} for (i=0;i<3;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr); adr1=icount-1024; for (k=0;k<4;k++) adress[k]=0; for (k=0;k<4;k++) {if (adr1/(long int)(pow(256.,3-k))>=1) {adress[3-k]=(int)(adr1/(long int)(pow(256.,3-k))); adr1=adr1-(long int)pow(256.,3-k)* (int)(adr1/(long int)(pow(256.,3-k)));}} for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr); adr2=icount; for (k=0;k<4;k++) adress[k]=0; for (k=0;k<4;k++) {if (adr2/(long int)(pow(256.,3-k))>=1) {adress[3-k]=(int)(adr2/(long int)(pow(256.,3-k))); adr2=adr2-(long int)pow(256.,3-k)* (int)(adr2/(long int)(pow(256.,3-k)));}} for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr); fputc(flags,fo_log_kadr); for (i=8;i<1019;i++) { // if (fmodf(float((Num_kadrs[Rcount-1]-1)*1015+i-8), // float(64))==0.&&buffer3[i]==0&&buffer3[i+1]==0&& // buffer3[i+2]==0&&buffer3[i+3]==0&&buffer3[i+4]==0) end=1; if (end!=1) fo_cln1<<(unsigned char)buffer3[i]; } if (end!=1) {for(i=1019;i<1023;i++) {fo_cln1<<(unsigned char)buffer3[i];}} } icount_int = (int)(icount/1024); icount_frac= icount%1024; //***protocol file*********************************************** file_length=(int)(strlen(name)); fprintf(fo,"file name=/home/ntsomz/downlinks/%s\n",name); fprintf(fo,"file size= %i,%i kByte \n", icount_int, icount_frac); fprintf(fo,"number identified cadres= %i\n", N1); fprintf(fo,"number of routes= %i\n", Rcount); for (i=0;i