EX.
NO:5A
DATE:
SIMULATION OF ADDRESS RESOLUTION PROTOCOL (ARP)
AIM
To implement the simulation of address resolution protocol (ARP)
using java.
ALGORITHM
Server
1. Create a server socket.
2. Accept client connection.
3. Read IP address from the client request
4. Check its configuration file and compare with its logical
address.
4. If there is a match, send the host physical address.
5. Stop
Client
1. Create a socket.
2. Send IP address to the target machine
3. Receive target's response
4. If it is a MAC address then display it and go to step 6
5. Display "Host not found"
6. Stop
ARPCLIENT:
import [Link].*;
import [Link].*;
import [Link].*;
class Clientarp
{
public static void main(String args[])
{
try
{
BufferedReader in=new BufferedReader(new InputStreamReader([Link]));
Socket clsct=new Socket("[Link]",139);
DataInputStream din=new DataInputStream([Link]());
DataOutputStream dout=new DataOutputStream([Link]());
[Link]("Enter the Logical address(IP):");
String str1=[Link]();
[Link](str1+'\n');
String str=[Link]();
[Link]("The Physical Address is: "+str);
[Link]();
}
catch (Exception e)
{
[Link](e);
}
}
}
ARPSERVER:
import [Link].*;
import [Link].*;
import [Link].*;
class Serverarp
{
public static void main(String args[])
{
try
{
ServerSocket obj=new ServerSocket(139);
Socket obj1=[Link]();
while(true)
{
DataInputStream din=new DataInputStream([Link]());
DataOutputStream dout=new DataOutputStream([Link]());
String str=[Link]();
[Link](“Processing….”)
String ip[]={"[Link]","[Link]"};
String mac[]={"[Link]","[Link]"};
for(int i=0;i<[Link];i++)
{
if([Link](ip[i]))
{
[Link](mac[i]+'\n');
break;
}
}
[Link]();
}
}
catch(Exception e) {
}
[Link]("Physical Address Retrieval Processing");
}
}
OUTPUT:
ARPSERVER:
Z:\>java Serverarp
Physical Address Retrieval Processing
ARPCLIENT:
Z:\>javac [Link]
Note: [Link] uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Z:\>java Clientarp
Enter the Logical address(IP):
[Link]
The Physical Address is: [Link]
RESULT:
Thus , the simulation of address resolution protocol (ARP) was executed and
output is verified successfully.