-->

I LOVE TO DESIGN

I AM

image
Hello,

I'm Kutty selva

no comments simply code


Education
Velammal college of engineering and technology

Bachelor of Engineering

Extra

2D Animation

Udemy.inc

Django Core | A Reference Guide to Core Django Concepts


Experience
Lead Developer

Farm to home

project Handler

Smart Shopiee

google developer group

Madurai member


My Skills
Design
Android
java/python
Web development

4

Awards Won

6

minions

18

Projects Done

564

Days worked

WHAT CAN I DO

Web Design

posts day today updates in web development and tutorials

Codes

uploads tutorials with sample source code or github repositories

Graphic Design

Graphics work done for your requirements

Projects

uploads top most projects details and crew details

Posts

replies within short period, post your problems

Unlimited Support

Provides support for projects

SOME OF WORK
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Program for Address Resolutuion Protocol (ARP) using TCP

Program for Address Resolutuion Protocol (ARP) using TCP


Image result for arp



Client:

import java.io.*;

import java.net.*;

import java.util.*;

class Clientarp

{

public static void main(String args[])

{

try


{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));


Socket clsct=new Socket("127.0.0.1",139);

DataInputStream din=new DataInputStream(clsct.getInputStream()); DataOutputStream dout=new DataOutputStream(clsct.getOutputStream()); System.out.println("Enter the Logical address(IP):"); String str1=in.readLine();

dout.writeBytes(str1+'\n');

String str=din.readLine();

System.out.println("The Physical Address is: "+str);

clsct.close();

}

catch (Exception e)

{

System.out.println(e);

}

}

}


Server:

import java.io.*;

import java.net.*;

import java.util.*;

class Serverarp

{

public static void main(String args[])

{

try

{

ServerSocket obj=new ServerSocket(139);

Socket obj1=obj.accept();

while(true)

{

DataInputStream din=new DataInputStream(obj1.getInputStream()); DataOutputStream dout=new DataOutputStream(obj1.getOutputStream()); String str=din.readLine();

String ip[]={"165.165.80.80","165.165.79.1"}; String mac[]={"6A:08:AA:C2","8A:BC:E3:FA"}; for(int i=0;i<ip.length;i++) {


if(str.equals(ip[i]))

{

dout.writeBytes(mac[i]+'\n');

break;

}

}

obj.close();

}


}

catch(Exception e)

{

System.out.println(e);

}

}

}

Output:

E:\networks>java Serverarp

E:\networks>java Clientarp

Enter the Logical address(IP):

165.165.80.80

The Physical Address is: 6A:08:AA:C2


Java Program to implement Reverse Address Resolution Protocol

Java Program to implement Reverse Address Resolution Protocol


// RARP.java - Client


import java.io.*;

import java.net.*;

import java.util.*;


public class RARP {

    public static void main(String args[]){

    try{

        DatagramSocket client = new DatagramSocket();

        InetAddress addr = InetAddress.getByName("127.0.0.1");

        byte[] sendByte = new byte[1204];

        byte[] receiveByte = new byte[1024];

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        System.out.println("Enter the Physical Address ");

        String str = in.readLine();

        sendByte = str.getBytes();

        DatagramPacket sender = new DatagramPacket(sendByte,sendByte.length,addr,1309);

        client.send(sender);

        DatagramPacket receiver = new DatagramPacket(receiveByte,receiveByte.length);

        client.receive(receiver);

        String s = new String(receiver.getData());

        System.out.println("The Logical Address is :" + s.trim());

        client.close();

    }

    catch(Exception e){

    System.out.println(e);

    }

    }

}


// RARPServer.java - Server


import java.io.*;

import java.net.*;

import java.util.*;


public class RARPServer{


    public static void main(String args[])    {

    try{

    

    DatagramSocket server = new DatagramSocket(1309);

        while(true){

                byte[] sendByte = new byte[1204];

                byte[] receiveByte = new byte[1204];

                DatagramPacket receiver = new DatagramPacket(receiveByte,receiveByte.length);

                server.receive(receiver);

                String str = new String(receiver.getData());

                String s = str.trim();

                InetAddress addr = receiver.getAddress();

                int port = receiver.getPort();

                String ip[] = {"10.0.3.186"};

                String mac[] = {"D4:3D:7E:12:A3:D9"};

                

                    for (int i = 0; i < ip.length; i++) {

                    if(s.equals(mac[i]))

                    {

                    sendByte = ip[i].getBytes();

            DatagramPacket sender = new DatagramPacket(sendByte,sendByte.length,addr,port);

                    server.send(sender);

                    break;

                    }            

            }

            break;

        }        

    }catch(Exception e)
    {
        System.out.println(e);
    }
    }
}

Output :

Enter the Physical Address :  D4:3D:7E:12:A3:D9
The Logical Address is : 10.0.3.186

Start Work With Me

Contact Us
KUTTY SELVA
+91 7708139984
Madurai,Tamilnadu