Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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?
 
lowercase baba
Posts: 12871
62
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
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic