Skip to main content


Showing posts with the label Computer Networks

Java Socket Programming

To implement communication between Client and Server using the UDP protocol and datagrams

import*; import*; import java.util.*; public class TServer { public static void main(String[] args) throws Exception{ DatagramSocket ss = new DatagramSocket(1234); while(true){ System.out.println("Server is up...."); byte[] rd=new byte[100]; byte[] sd=new byte[100]; DatagramPacket rp = new DatagramPacket(rd,rd.length); ss.receive(rp); InetAddress ip= rp.getAddress(); int port=rp.getPort(); Date d=new Date(); // getting system time String time= d + ""; // converting it to String sd=time.getBytes(); // converting that String to byte System.out.println(port); System.out.println(ip); DatagramPacket sp=new DatagramPacket(sd,sd.length,ip,port); ss.send(sp); rp=null; System.out.println("Done !! "); } } }


import*; import*; public class TClient { public static void main(String[] args) throws Exception{ System.out.print…

Implementation of error detection & correction methods in C

TITLE: Lab #7-Implementation of error detection & correction methods in C
Objective:To implement CRC encoding at the Sender, and CRC decoding at the Receiver
In C, write a function MakeCRC, which takes in 2 parameters Divisor and Dividend, and returns a Remainder.
At the Sender, provide the Divisor and Dividend according to Figure 10.15.
Check that MakeCRC returns the correct remainder, to be appended to the Dataword.
At the Receiver, enter the Dataword, as the Dividend to the MakeCRC function.
If no error is detected, the Remainder (also known as the Syndrome) is 000.  Else, an error has been detected.
Inject error(s) into the Dataword received by the Receiver:-
single-bit (isolated) errors burst (consecutive) errors Is the Receiver able to detect the errors?