import ———————– */ System.out.println(” Enter the message bits :

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class crc {

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

public static void main(String args) throws IOException {

InputStreamReader crc = new InputStreamReader(System.in);

BufferedReader br = new BufferedReader(crc);

int data_maessage, crc_gen, message, random, transmitter;

int data_bits, gen_bits, total_bits;

/*
* ——————— Here we enter the Number of bit for massage length
* ——————–
*/

System.out.println(”
Enter the Number of bits in message:
“);
data_bits = Integer.parseInt(br.readLine());
data_maessage = new intdata_bits;

/*
* ———————- here we enter the massage in bits
* ———————–
*/

System.out.println(”
Enter the message bits :
“);
for (int i = 0; i < data_bits; i++) data_maessagei = Integer.parseInt(br.readLine()); /* * --------------------- here we enter how number of the generator Polynomial Division * means divided ---------------------- */ System.out.println(" Enter the number of bits in Generetor Polynomial Division : "); gen_bits = Integer.parseInt(br.readLine()); crc_gen = new intgen_bits; /* * -------------------------here we enter the Generator Polynomial Division bits * ------------------------ */ System.out.println(" Enter the Generator Polynomial Division bits : "); for (int i = 0; i < gen_bits; i++) { crc_geni = Integer.parseInt(br.readLine()); } total_bits = data_bits + gen_bits - 1; message = new inttotal_bits; random = new inttotal_bits; transmitter = new inttotal_bits; /*------------------ CRC GENERATION-----------------------*/ for (int i = 0; i < data_maessage.length; i++) { messagei = data_maessagei; } System.out.print(" The Massage bits areΒ  : "); for (int i = 0; i < data_bits; i++) { // here its print the massage System.out.println(data_maessagei); } System.out.print(" The Geberators bits are : "); for (int i = 0; i < gen_bits; i++) { // here its print the generator polynomial System.out.println(crc_geni); } /* * --------------------- append dividend and remainder ------------------------- */ System.out.print(" The Appended message is : "); for (int i = 0; i < message.length; i++) { System.out.print(messagei); } for (int j = 0; j < message.length; j++) { randomj = messagej; } random = CRC(message, crc_gen, random); for (int i = 0; i < message.length; i++) { transmitteri = (messagei ^ randomi); } System.out.println(" The Message is Transmitted from the transmitter : "); for (int i = 0; i < transmitter.length; i++) { System.out.print(transmitteri); } System.out.println(" Enter message of " + total_bits + " bits at receiver end : "); for (int i = 0; i < transmitter.length; i++) { transmitteri = Integer.parseInt(br.readLine()); } System.out.println(" The Received message is : "); for (int i = 0; i < transmitter.length; i++) { System.out.print(transmitteri); } for (int j = 0; j < transmitter.length; j++) { randomj = transmitterj; } /* ----------------------- ERROR DETECTION ------------------------ */ random = CRC(transmitter, crc_gen, random); for (int i = 0; i < random.length; i++) { if (randomi != 0) { System.out.println(" There is an error in received data πŸ™ .....Β  "); break; } if (i == random.length - 1) { System.out.println(" Data was received without any error πŸ™‚ .....Β  "); } } System.out.println("Thank you πŸ™‚ and My References are in this projecr which i used for study in References in below the Package name...."); } public static int CRC(int message, int crc_generator, int random) { int crc = 0; while (true) { for (int i = 0; i < crc_generator.length; i++) { randomcrc + i = (randomcrc + i ^ crc_generatori); } while (randomcrc == 0 && crc != random.length - 1) { crc++; } if ((random.length - crc) < crc_generator.length) { break; } } return random; } }