diff --git a/algorithms/Networks/Hamming_Code/hamming_code_reciever.cpp b/algorithms/Networks/Hamming_Code/hamming_code_reciever.cpp new file mode 100644 index 00000000..803fbdc5 --- /dev/null +++ b/algorithms/Networks/Hamming_Code/hamming_code_reciever.cpp @@ -0,0 +1,167 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +using namespace std; + +#define MAX 2048 +#define port 5200 + + +void flip(int &a) { + a=!a; +} + + +void revprint(int codeword[],int n) { + for(int i=n-1;i>=0;i--) { + cout<=1) { + cout<<"Hence flip bit "<=0;i--) { + if((i+1)!=1&&(i+1)!=2&&(i+1)!=4&&(i+1)!=8) { + message[j--]=codeword[i]; + } + } + + cout<<"Message : "; + revprint(message,8); + + int x=0; + for(int i=0;i<8;i++) { + if(message[i]==1) { + x+=(1<>ch; + + switch(ch) { + case 1:{ + cout<<"Recieved Message: "; + revprint(codeword,12); + decoded(codeword); + + cout<<"Meesage Recieved Successfully...!"< +#include +#include +#include +#include +#include + +using namespace std; + +#define MAX 500 +#define port 5200 + + +void tobinary(int a[],char c) { + int x=(int)c; + + cout<=0;i--) { + cout<=0;i--) { + if(a[i]==-1) { + a[i]=b[j]; + j--; + } + } +} + + +int main(){ + + int clientSocket , serverSocket , receiveMsgSize; + + clientSocket = socket(AF_INET , SOCK_STREAM , 0); // creating the socket + + if(clientSocket < 0){ + cout << "Creation of client socket failed" << endl; + return 0; + } + + struct sockaddr_in serverAddr , clientAddr; + + // providing socket with IP and port + serverAddr.sin_family = AF_INET; + serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); + serverAddr.sin_port = htons(port); + + if(connect(clientSocket , (struct sockaddr*) & serverAddr , sizeof(serverAddr)) < 0){ // connecting to the receiver + cout << "Connection Error..!" << endl; + return 0; + } + else{ + cout << "Connection Established..!" << endl; + } + + + char c; + cout<<"Enter the First letter of your name: "; + cin>>c; + + int binary[8]; + tobinary(binary,c); + + cout<<"The entered message in binary is: "; + revprint(binary,8); + + + int codeword[12]; + fillmessageintocodes(codeword,binary); + + + for(int i=0;i<4;i++) { + int count=0; + for(int j=0;j<12;j++) { + if((j+1)&(1< pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy