Here is the core simulation of the ARP(Address Resolution Protocol) and RARP(Reverse Address
Resolution Protocol) ARP used to map the ip address with the corresponding MAC address and
RARP do that in reverse. it maps the MAC with the ip.
Resolution Protocol) ARP used to map the ip address with the corresponding MAC address and
RARP do that in reverse. it maps the MAC with the ip.
#include "stdio.h" #include "string.h" int main() { char table[3][2][40]; char ipin[10],macin[30]; int i,j,found; strcpy(table[0][0],"127.0.0.1"); strcpy(table[0][1],"44:dd:22:11:33"); strcpy(table[1][0],"10.1.1.8"); strcpy(table[1][1],"33:aa:fe:4e:2d"); strcpy(table[2][0],"10.1.8.5"); strcpy(table[2][1],"23:a3:5d:33:9d"); printf("IP address\t MAC address\n"); for(i=0;i<3;i++) { printf("%s\t %s\n",table[i][0],table[i][1]); } printf("simulating ARP\n\n"); printf("enter the IP address\n"); scanf("%s",&ipin); for(i=0;i<3;i++) { if(strcmp(ipin,table[i][0])==0) { printf("%s mac id is %s\n\n",ipin,table[i][1]); found=1; } } if(found!=1) { printf("mac not found\n\n"); } printf("simulating RARP\n\n"); printf("enter the MAC address\n"); scanf("%s",&macin); for(i=0;i<3;i++) { if(strcmp(macin,table[i][1])==0) { printf("%s ip is %s\n",macin,table[i][0]); found=1; } } if(found!=1) { printf("ip not found\n"); } return 0; }
Comments
Post a Comment