0% found this document useful (0 votes)
386 views3 pages

ARP Simulation for Java Developers

The document describes a simulation of the Address Resolution Protocol (ARP) implemented in Java. The simulation includes an ARP server that listens for client requests, looks up the IP address in its configuration file, and returns the corresponding MAC address if it finds a match. It also includes an ARP client that sends an IP address to the server, receives the MAC address response, and displays it if found or an error if not found. The Java code for the ARP client and server are provided. The output shows the physical address was successfully retrieved when testing with sample IP and MAC addresses configured in the server.

Uploaded by

ASD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
386 views3 pages

ARP Simulation for Java Developers

The document describes a simulation of the Address Resolution Protocol (ARP) implemented in Java. The simulation includes an ARP server that listens for client requests, looks up the IP address in its configuration file, and returns the corresponding MAC address if it finds a match. It also includes an ARP client that sends an IP address to the server, receives the MAC address response, and displays it if found or an error if not found. The Java code for the ARP client and server are provided. The output shows the physical address was successfully retrieved when testing with sample IP and MAC addresses configured in the server.

Uploaded by

ASD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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.

You might also like