Go Back N (Java)

Problem Definition: Write a program in Java to implement Go Back N algorithm. The Program sends the frames from the Client to the Server with checking for missing frames via sending an acknowledgement. P.S. Enter the inputs in the Client program after the connection is established with the Server. /*Server Program*/ import java.net.*; import java.io.*; import java.util.*; public class Server { public static void main(String … Continue reading Go Back N (Java)

Socket Programming | Chat Server (Java)

Problem Definition: Write a program in Java to implement Socket Programming. P.S. Here, both the programs viz., Server & Client needs to be executed simultaneously on different Java Windows (2 Terminals). It’s the one-to-one message provision, where after each message from the Client Server has to respond and vice verse. /*Server Program*/ import java.util.*; import java.io.*; import java.net.*; public class server { public static void … Continue reading Socket Programming | Chat Server (Java)

Subnetting (Java)

Problem Definition: Write a program to implement subnetting and find the subnet masks. import java.util.Scanner; class Subnet{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.print(“Enter the ip address: “); String ip = sc.nextLine(); String split_ip[] = ip.split(“\\.”); //SPlit the string after every . String split_bip[] = new String[4]; //split binary ip String bip = “”; for(int i=0;i<4;i++){ split_bip[i] = appendZeros(Integer.toBinaryString(Integer.parseInt(split_ip[i]))); // “18” … Continue reading Subnetting (Java)

CRC (Java)

Problem Definition: Write a program in Java to find CRC of a given number. import java.util.Scanner; class CRC{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); //Input Data Stream System.out.print(“Enter data stream: “); String datastream = sc.nextLine(); System.out.print(“Enter generator: “); String generator = sc.nextLine(); int data[] = new int[datastream.length() + generator.length() – 1]; int divisor[] = new int[generator.length()]; for(int i=0;i<datastream.length();i++) data[i] = Integer.parseInt(datastream.charAt(i)+””); for(int … Continue reading CRC (Java)

Internet Checksum (Java)

Problem Definition: Write a program in Java to calculate the Internet Checksum and verify it at the Sender’s & Receiver’s side. import java.util.Scanner; class Checksum{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println(“**********SENDER**********”); System.out.print(“Enter the word: “); String input = sc.nextLine(); //Calculation of hex string String hex[]; if(input.length()%2 == 0){ //Even length input hex = new String[input.length()/2]; for(int i=0;i<hex.length;i++) hex[i] = Integer.toHexString(input.charAt(2*i))+Integer.toHexString(input.charAt(2*i+1)); }else{//odd … Continue reading Internet Checksum (Java)