Skip to content

Commit 409ddaf

Browse files
committed
Silly Modification
1 parent 0459de4 commit 409ddaf

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Solutions/Q-01/CRC_ErrorDetectionAlgorithm.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Contributed by - Anuj Das ( GC University, Silchar - @ Department of Computer Science )
22

3-
// 1. Simulate Cyclic Redundancy Check (CRC) Error Detection Algorithm for Noisy Channel.
3+
// 1. Simulate and implement Cyclic Redundancy Check (CRC) Error Detection Algorithm for Noisy Channel.
44

55
import java.util.Scanner;
66

@@ -10,7 +10,7 @@ public static String xorOperation(String modified_message, String polynomial) {
1010
int size_in_bits = 16;
1111
int shift = modified_message.length() - polynomial.length();
1212
while(shift >= 0) {
13-
modified_message = Integer.toBinaryString(Integer.parseInt(modified_message,2)^(Integer.parseInt(polynomial,2)<<shift));
13+
modified_message = Integer.toBinaryString(Integer.parseInt(modified_message,2)^Integer.parseInt(polynomial,2)<<shift);
1414
shift = modified_message.length() - polynomial.length();
1515
}
1616

@@ -25,8 +25,8 @@ public static String xorOperation(String modified_message, String polynomial) {
2525

2626
// It generates the encoded data/message to be transmitted (i.e., by adding CRC Check Bits to the Original Message)
2727
public static String generateCRC_CheckBits(String modified_message, String polynomial) {
28-
String remainder = xorOperation(modified_message,polynomial);
29-
remainder = remainder.substring(remainder.length() - modified_message.length());
28+
String remainder = xorOperation(modified_message,polynomial); // 16bits remainder
29+
remainder = remainder.substring(remainder.length() - modified_message.length()); // substring(int startIndex)
3030

3131
int CRC_CheckBits[] = new int[modified_message.length()];
3232
for(int i = 0; i < modified_message.length(); i++) {
@@ -66,15 +66,19 @@ public static void main(String[] args) {
6666
System.out.print("Enter the CRC Generator(Polynomial): "); // CRC Generator
6767
String polynomial = sc.next(); // Test --> 1001
6868

69+
// Sender's end
6970
String modified_message = modifyMessage(message,polynomial);
7071
System.out.println("Modified Data(Message): " + modified_message);
7172

7273
String msgToBeTransmitted = generateCRC_CheckBits(modified_message, polynomial);
7374
System.out.println("\nData(Message) is ready to be Transmitted: " + msgToBeTransmitted);
7475

76+
// Noisy Transmission Channel
7577
String send_data = noisyChannel(msgToBeTransmitted);
7678
System.out.println("Data(Message) Transmitted through Noisy Channel: "+send_data);
7779

80+
81+
// Receiver's end
7882
String checkAllZeroes = xorOperation(send_data,polynomial);
7983

8084
// It checks if the remainder contains only zeroes --> If it contains only zeros then the data/message is accepted else considered as error in Transmission

Solutions/Q-06/GetLocalHostAddress.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
class GetLocalHostAddress {
88
public static void main(String[] args) throws UnknownHostException {
99
InetAddress localhost = InetAddress.getLocalHost();
10-
System.out.println(localhost.getHostAddress());
10+
System.out.println("LocalHost Address: "+localhost.getHostAddress());
1111
}
1212
}

0 commit comments

Comments
 (0)