Data Communication and Networking Practicals
Data Communication and Networking Practicals
Data Communication and Networking Practicals
for(int i=0;i<a.size();i++)
{
if(a[i]=='1')
{
count++;
}
}
if(count%2!=0)
{
parity="1";
}
else{
parity="0";
}
a=a+parity;
return a;
}
int main()
{
string aa;
ifstream rfile;
rfile.open("D:\input1.txt");
rfile >> aa;
int size=aa.size();
string neww;
neww=neww+lrc(aa);
cout<<neww;
ofstream myfile;
myfile.open ("d:\output1.txt");
myfile << neww;
myfile.close();
}
16ce068 patel jainil
for(int i=0;i<a.size();i++)
{
if(a[i]=='1')
{
count++;
}
}
if(count%2!=0)
{
parity="1";
}
else{
parity="0";
}
a=parity;
return a;
}
int main()
{
string aa;
ifstream rfile;
rfile.open("D:\output1.txt");
rfile >> aa;
string k;
string kk;
int flag=0;
if(lrc(aa)=="0")
{
cout<<"file is perfect";
}
else{
cout<<"file is damaged and droped"; } }
16ce068 patel jainil
for(int i=0;i<a.size();i++)
{
if(a[i]=='1')
{ count++; }
}
if(count%2!=0)
{ parity="1"; }
else { parity="0"; }
a=a+parity;
return a;
}
int main()
{
string aa;
ifstream rfile;
rfile.open("D:\input1.txt");
rfile >> aa;
int size=aa.size();
string k;
string neww;
for(int i=0;i<aa.size();i=i+8)
{
k=aa.substr(i,8);
neww=neww+lrc(k);
}
cout<<neww;
ofstream myfile;
myfile.open ("d:\output1.txt");
myfile << neww;
myfile.close();
}
16ce068 patel jainil
for(int i=0;i<a.size();i++)
{
if(a[i]=='1')
{ count++; }
}
if(count%2!=0)
{ parity="1"; }
else
{ parity="0"; }
a=a+parity;
return a;
}
int main()
{
string aa;
ifstream rfile;
rfile.open("D:\output1.txt");
rfile >> aa;
string k;
string kk;
int flag=0;
for(int i=0;i<aa.size()-9;i=i+9)
{
k=aa.substr(i,8);
kk=aa.substr(i,9);
if((kk)!=lrc(k))
{ cout<<"error detected at"<<(i/9)<<" th byte \n";
flag=1; }
}
if(flag==0)
{ cout<<"no error detected \n"; } }
16ce068 patel jainil
string aa;
ifstream rfile;
rfile.open("D:\output1.txt");
rfile >> aa;
string k;
string kk;
for(int j=0;j<8;j++){
for(int i=j;i<aa.size()-8;i=i+8)
{
k=aa.substr(i,1);
kk=k+kk;
}
vrc=vrc+vrccheck(kk);
16ce068 patel jainil
if(aa.substr(aa.length()-8+j,1)!=vrccheck(kk))
{
cout<<aa.substr(aa.length()-8+j,1)<<" "<<vrccheck(kk);
cout<<"error detected at level "<<j<<"\n";
}
kk="";
}
string check=aa.substr(aa.length()-8,8);
if(vrc==check)
{
cout<<"file is perfect"<<"\n";
}
else
{
cout<<"error in file drop the whole file"<<"\n";
}
}
16ce068 patel jainil
for(int i=0;i<a.size();i++)
{
if(a[i]=='1')
{
count++;
}
}
if(count%2!=0)
{
parity="1";
}
else{
16ce068 patel jainil
parity="0";
}
a=a+parity;
return a;
}
int main()
{
string aa;
ifstream rfile;
rfile.open("D:\input1.txt");
rfile >> aa;
int size=aa.size();
string k;
string neww;
for(int i=0;i<aa.size();i=i+8)
{
k=aa.substr(i,8);
neww=neww+lrc(k);
}
string vrc;
string vk;
string vkk;
for(int j=0;j<9;j++){
for(int i=j;i<neww.size();i=i+9)
{
vk=neww.substr(i,1);
vkk=vk+vkk;
}
vrc=vrc+vrccheck(vkk);
vkk="";
}
cout<<neww+vrc;
ofstream myfile;
myfile.open ("d:\output1.txt");
myfile << neww+vrc;
myfile.close();
}
16ce068 patel jainil
for(int i=0;i<a.size();i++)
{
if(a[i]=='1')
{
count++;
}
}
if(count%2!=0)
{
parity="1";
}
else{
16ce068 patel jainil
parity="0";
}
a=a+parity;
return a;
}
int lrcclient()
{
string aa;
ifstream rfile;
rfile.open("D:\output1.txt");
rfile >> aa;
string k;
string kk;
int flag=0;
for(int i=0;i<aa.size()-9;i=i+9)
{
k=aa.substr(i,8);
kk=aa.substr(i,9);
if((kk)!=lrc(k))
{
return i/9;
}
}
return 0;
}
int main()
{
string vrc;
int level=0;
string aa;
ifstream rfile;
rfile.open("D:\output1.txt");
rfile >> aa;
string k;
string kk;
for(int j=0;j<9;j++){
for(int i=j;i<aa.size()-9;i=i+9)
{
16ce068 patel jainil
k=aa.substr(i,1);
kk=k+kk;
}
vrc=vrc+vrccheck(kk);
if(aa.substr(aa.length()-9+j,1)!=vrccheck(kk))
{
cout<<aa.substr(aa.length()-9+j,1)<<" "<<vrccheck(kk);
level=j;
goto x;
}
kk="";
}
x:
cout<<"error found at"<<(((lrcclient())*8)+(level+1));