File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Developing  a traceroute clone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Developing  a traceroute clone" Watch "Developing  a traceroute clone" New topic
Author

Developing a traceroute clone

Dishpal Bhaluja
Ranch Hand

Joined: Dec 30, 2007
Posts: 96
I am currently trying to develop a traceroute clone.Can you please tell me how to receive a UDP packet(i know to recieve and send using the default DatagramSocket and DatagramPacket Classes) but they dont allow me to edit the TTL fields.Whats the feasibility in doing this is in Java.
I want to edit the TTL fields :send and receive the packets.

Without using 3rd party libraries like JPCAP

Thanks in advance
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Traceroute doesn't use UDP; it uses a lower level IP protocol called ICMP. J2SE doesn't support ICMP, nor does it support much else in the way of low-level networking. A traceroute clone, while trivial in C, is going to be a difficult mess in Java.


[Jess in Action][AskingGoodQuestions]
Dishpal Bhaluja
Ranch Hand

Joined: Dec 30, 2007
Posts: 96
No solution to get around this.Please anyone help.Im ready to mess with this
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8876
    
    8

As Ernest pointed out, Java doesn't have the functionality you require.
Is there a reason you can't use 3rd party libraries or a more suitable language like C?
[ March 19, 2008: Message edited by: Joe Ess ]

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Dishpal Bhaluja
Ranch Hand

Joined: Dec 30, 2007
Posts: 96
Im now using JPCap.Following errors occuring.Help me please
Environment
Installed Winpcap and jpcap
IDe:Eclipse 3.2
In new java project added jpcap.jar and added their default traceroute.java
Succesfully compiled and got the result saying traceroute syntax is:
traceroute [device number 0,1,2][device name]
When i tried running frm cmd prompt
cmd>java traceroute 0 localhost
It gave me packet/DatalinkPacket Class not found.

Im stuck.How can I get rid of this error.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55

cmd>java traceroute 0 localhost
It gave me packet/DatalinkPacket Class not found.

How are you adding the "packet" package to your classpath? I'm guessing this should read

(or ; instead of : if you're using Windows)


Ping & DNS - my free Android networking tools app
Dishpal Bhaluja
Ranch Hand

Joined: Dec 30, 2007
Posts: 96
Ya Netbeans/Eclipse builds it correctly without any error.
I am the prompt where class files have been generated for the project(Def for netbeans)
and frm cmd
prjct/class>java traceroute.java 0 localhost

and then the error pops up.
Any solutions.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
Did you try what I suggested? I'm pretty sure that is the solution.
Dishpal Bhaluja
Ranch Hand

Joined: Dec 30, 2007
Posts: 96
Ya got it.Thanks.I am working around other issues.Thanks for your help.

More doubts on the ways,I know you will help me
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Developing a traceroute clone