Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
74 views4 pages

RARP Protocol

program for RARP protocol

Uploaded by

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

RARP Protocol

program for RARP protocol

Uploaded by

praveenbss486
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Ex. No.

: 7B SIMULATION OF REVERSEADDRESS
Date : RESOLUTION PROTOCOL (RARP)

AIM
To write a java program to implement RARP.

ABSTRACT:
RARP is Reverse Address Resolution Protocol that determines source network address (IP
address) from source data link address MAC (Media Access Control) address. RARP is used to
determine system’s own IP address when it comes up. When system boots it sends a RARP request
which contains its own layer 2(Data link layer) MAC address to Ethernet broadcast address. RARP
server in the subnet which contains the mapping table from MAC address to IP address responds to
such requests with corresponding IP address. RARP is used in Ethernet, Fiber Distributed-Data
Interface (FDDI) and Token Ring LANs. DHCP (Dynamic Host Configuration Protocol) is modern
implementation of RARP, Which allocates IP address dynamically when system comes up. Thus IP
address can be reused if it is no longer needed.

PROCEDURE: SERVER
1. Import the necessary java package
2. Create a Server socket and bind it to port and accept the client connection.
3. Read the IP Address from the client request
4. Check it configuration file and compare with its logical address
5. If there is a match, send the host physical address.
6. Close the Server socket.

PROCEDURE: CLIENT
1. Import the necessary java packages.
2. Create a client socket and send the IP Address to server.
3. Receive the server response.
4. If it is MAC address, then display else display the message for “HOST NOT FOUND”.
5. Close the socket.

PROGRAM: SERVER
import java.io.*;
import java.net.*;
public class rarpserver
{
public static void main(String args[])
{
String IP_Address[]={"192.168.100.1","192.168.200.1","192.168.300.1",
"192.168.400.1","192.168.500.1"};
String MAC_Address[]={"57-H348-B2AQ01JY-6","93X-H64L-42AM-WHKY-4",
"IOV-JK48- 2TAB-BEJY-8","89X-IOZ8-6ZLB-DHJY-3",
"XJH-4U18-3IAP-BPYS-7"};
String Send_msg,Recv_msg="";
try
{
ServerSocket ss=new ServerSocket(9126);
System.out.println("server started:\n"+ss);
Socket s=ss.accept();
DataInputStream dis=new DataInputStream(s.getInputStream());
DataInputStream d=new DataInputStream(System.in);
PrintStream ps=new PrintStream(s.getOutputStream());
Recv_msg=dis.readLine();
System.out.println("Request received is : "+Recv_msg);
int Host_found=-1;
for(int i=0;i<5;i++)
if(MAC_Address[i].equals(Recv_msg))
Host_found=i;
if(Host_found!=-1)
ps.println(IP_Address[Host_found]);
else
ps.println(Host_found);
ps.close();
s.close();
}
catch(Exception se)
{
System.out.println("Server Socket Problem"+se.getMessage());
}
}
}

PROGRAM: CLIENT
import java.io.*;
import java.net.*;
class rarpcli
{
public static void main(String args[])
{
String Send_msg,Recv_msg="";
try
{
InetAddress ip=InetAddress.getLocalHost();
Socket s=new Socket(ip,9126);
PrintStream ps=new PrintStream(s.getOutputStream());
DataInputStream dis=new DataInputStream(s.getInputStream());
DataInputStream d=new DataInputStream(System.in);
System.out.println("\n\t\t***Implementation of RARP***");
System.out.print("Enter the MAC Address : ");
Send_msg=d.readLine();
ps.println(Send_msg);
Recv_msg=dis.readLine();
if(!Recv_msg.equals("-1"))
{
System.out.print("IP Address of given MAC Address : ");
System.out.println(Recv_msg);
}
else
System.out.println("HOST NOT FOUND");
ps.close();
s.close();
}
catch(Exception se)
{
System.out.println("Exception"+se.getMessage());
}
}
}
OUTPUT:

RESULT:
Thus, the java program to implement RARP was executed and the output is successfully.

You might also like