Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ken jun
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anyone give me little help?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12122
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ken jun
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic