File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes I made an ARP with java but it do not work properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "I made an ARP with java but it do not work properly" Watch "I made an ARP with java but it do not work properly" New topic
Author

I made an ARP with java but it do not work properly

ken jun
Ranch Hand

Joined: Apr 23, 2010
Posts: 46
need some help! I made an ARP with java but it do not work properly!

I find an article form the web that tell how to achieve ARP with JAVA . It need a library called Jpcap ( download from http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) .

But when I use the original code(class ARP) to run, it works properly.I type my local IP address , it return my pc's MAC address.

However, when I made a GUI with awt(two classes ARPGUI and ARPcode) ,I type my pc's IP, it return my gateway's MAC!!! So I need your help to tell me what's wrong with my code.

BTW:the TCP/IP has 5 layers . Could anybody tell me which layer can java works and difference between C/C++ . Thank you very much! Best wishes!



class ARP(the code below)



class ARPGUI(the code below)



class ARPcode(below)
ken jun
Ranch Hand

Joined: Apr 23, 2010
Posts: 46
Could anyone give me little help?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10908
    
  12

Is there any way you can narrow the scope? I doubt most folks here are going to want to spend the time to slog through nearly 400 lines of code.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
ken jun
Ranch Hand

Joined: Apr 23, 2010
Posts: 46
fred rosenberger wrote:Is there any way you can narrow the scope? I doubt most folks here are going to want to spend the time to slog through nearly 400 lines of code.
..
er...thanks for your advising..

I finally find where is wrong.In the class ARPGUI line 153 ipaddr = new byte[]{b_ip1,b_ip1,b_ip1,b_ip1}; I copy all of them and forgot to alter the number,it make my inputting IP address is not the same network segment with my PC's ip,and then it shows the MAC of gateway , so the correct definition is
ipaddr = new byte[]{b_ip1,b_ip2,b_ip3,b_ip4};

haha an angry for my careless
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I made an ARP with java but it do not work properly
 
Similar Threads
So difficult to use Layout managers!!!
Display image in a BorderLayout
Layout Problems
Frames
Determining computers on a network...