EX.NO: IMPLEMENTATION OF ADDRESS RESOLUTION PROTOCOL DATE : AIM: To implement Address Resolution Protocol . ALGORITHM: Client Side: 1. Establish a connection between the Client and Server. Socket ss=new Socket(InetAddress.getLocalHost(),1100); 2. Create instance output stream writer . PrintWriter ps=new PrintWriter(s.getOutputStream(),true); 3. Get the IP Address to resolve its physical address. 4. Send the IPAddress to its output Stream. ps.println(ip); 5. Print the Physical Address received from the server. Server Side: 1. Accept the connection request by the client. ServerSocket ss=new ServerSocket(2000); Socket s=ss.accept(); 2 . Get the IPaddress from its inputstream. BufferedReader br1=new BufferedReader(new InputStreamReader(s.getInputStream())); ip=br1.readLine(); 3. During runtime execute the process Runtime r=Runtime.getRuntime(); Process p=r.exec("arp -a "+ip); 4. Send the Physical Address to the client.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
EX.NO: IMPLEMENTATION OF ADDRESS RESOLUTION PROTOCOL DATE :
AIM:
To implement Address Resolution Protocol . ALGORITHM:
Client Side:
1. Establish a connection between the Client and Server.Socket ss=new Socket(InetAddress.getLocalHost(),1100);
SERVER WINDOW:C:\Networking Programs>java EchoServerServer To LocalHost:haiServer To LocalHost:welcomeServer To LocalHost:how are youServer To LocalHost:End
CLIENT WINDOW:C:\Networking Programs>java EchoClientEcho From Server::haiEcho From Server::welcomeEcho From Server::how are youEcho From Server::end
EX.NO: IMPLEMENTATION OF REMOTE METHOD INVOCATIONDATE :
AIM:
To implement remote method invocation.
ALGORITHM:
1.Create the rmi interface where the following methods are declared.
public int add(float a,float b)throws RemoteException;
public int multiply(int a,int b)throws RemoteException;
public float divide(float a,float b)throws RemoteException;
2.Implement remote objects at server side which are declared in the rmi
interface.
3. At client side the remote objects are called and their process is
nEnter U'R choice:"); int sw=Integer.parseInt(br.readLine());
switch(sw) {
case 1:System.out.println("Enter the First Value");a=Float.parseFloat(br.readLine());System.out.println("Enter the Second Value");b=Float.parseFloat(br.readLine());System.out.println("The Added Value Is:"+ ri.add(a,b));break;
case 2:System.out.println("Enter the First Value");e=Integer.parseInt(br.readLine());System.out.println("Enter the Second Value");f=Integer.parseInt(br.readLine());System.out.println("The Added Value Is:"+
ri.multiply(e,f));break;
case 3:System.out.println("Enter the First Value");c=Float.parseFloat(br.readLine());System.out.println("Enter the Second Value");d=Float.parseFloat(br.readLine());System.out.println("The Added Value Is:"+
ri.divide(c,d));break;
case 4:System.exit(0);break;
} System.out.println("Do u Want to Continue 1/0"); rr=br.readLine();}while(rr.equalsIgnoreCase("1"));
Enter U'R choice:1Enter the First Value12Enter the Second Value12The Added Value Is:24Do u Want to Continue 1/011.Add()2.Multiply()3.Divide()4.Exit()Enter U'R choice:2Enter the First Value12Enter the Second Value12The Added Value Is:144Do u Want to Continue 1/00
RESULT:
Thus the implementation of RMI is done & executed successfully.
OUTPUTC:\Networking Programs>java PingServerC:\Networking Programs>java PingClientEnter the IPADDRESS:192.168.11.57Ping From Server::Pinging 192.168.11.57 with 32 bytes of data:
Reply from 192.168.11.57: bytes=32 time<10ms TTL=128Reply from 192.168.11.57: bytes=32 time<10ms TTL=128Reply from 192.168.11.57: bytes=32 time<10ms TTL=128Reply from 192.168.11.57: bytes=32 time<10ms TTL=128Ping statistics for 192.168.11.57: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
RESULT:
Thus the implementation of PING is done & executed successfully.
3. Get the Physical Address to resolve its IP address. 4. Send the Physical Address to its output Stream. 5. Print the IP address received from the server.
Server Side:
1. Accept the connection request by the client.ServerSocket ss=new ServerSocket(2000);
Socket s=ss.accept(); 2 . Get the Physical address from its inputstream. 3. During runtime execute the process
Runtime r=Runtime.getRuntime();Process p=r.exec("arp -a "+ip);
4. Send the Physical Address to the client.
PROGRAM:
RARP CLIENT:import java.io.*;import java.net.*;class rarpclient{ public static void main(String args[])throws IOException { Socket s1=new Socket("localhost",3500); DataInputStream in=new DataInputStream(s1.getInputStream()); DataOutputStream on=new DataOutputStream(s1.getOutputStream()); BufferedReader b=new BufferedReader(new InputStreamReader(System.in)); while(true) { System.out.println("Enter mac add"); String o=b.readLine() ; on.writeUTF(o);String t=in.readUTF(); System.out.println("The IP add"+t);} } }RARP SERVER:import java.io.*;import java.net.*;class rarpserver{ public static void main(String args[])throws IOException { ServerSocket s=new ServerSocket(3500); Socket c=s.accept(); DataInputStream i=new DataInputStream(c.getInputStream()); DataOutputStream o=new DataOutputStream(c.getOutputStream()); BufferedReader b=new BufferedReader(new InputStreamReader(System.in)); String ip[]=new String[100]; String mac[]=new String[100]; System.out.println("How many add to be updated"); int n=Integer.parseInt(b.readLine()); int f=0,h=0; for(int j=0;j<n;j++) { int u=j+1; System.out.println("Enter the "+u+"ip address"); ip[j]=b.readLine(); System.out.println("Enter CORRES mac address"); mac[j]=b.readLine();} while(true) { f=0; String t=i.readUTF(); System.out.println("Please send the ip add of"+t);
C:\jdk1.3\bin>java rarpserverHow many add to be updated2
Enter the 1ip address192.168.0.10Enter CORRES mac address10Enter the 2ip address192.168.0.23Enter CORRES mac address23Please send the ip add of10Please send the ip add of23Please send the ip add of12
C:\jdk1.3\bin>javac rarpclient.java
C:\jdk1.3\bin>java rarpclientEnter mac add10The IP add192.168.0.10Enter mac add23The IP add192.168.0.23Enter mac add12The IP addadd cannot be resolved
RESULT:
Thus the implementation RARP is done & executed successfully.