2

I'm trying to implement traceroute for ios in c. (For example:in order to find which router is not working). Unfortunately I can't use ICMP protocol which send me response each time router kills my packet. Is it any way to implement it with TCP or other protocol. I need some thinking direction of how it can be done.

simonc
  • 41,632
  • 12
  • 85
  • 103
Mike.R
  • 2,824
  • 2
  • 26
  • 34
  • 1
    Check http://michael.toren.net/code/tcptraceroute/. – netcoder Jan 04 '13 at 16:11
  • See http://www.inetdaemon.com/tutorials/troubleshooting/tools/traceroute/definition.shtml – banuj Jan 04 '13 at 16:16
  • As reference code i use http://www.opensource.apple.com/source/network_cmds/network_cmds-307/traceroute.tproj/traceroute.c which provide good result only when using ICMP protocol. – Mike.R Jan 04 '13 at 16:22

1 Answers1

1

Basically, one can use all three, ICMP, UDP and TCP. The BSD implementations use UDP AFAIK, as in this source file:

http://www.opensource.apple.com/source/network_cmds/network_cmds-307/traceroute.tproj/traceroute.c

As you can see, it isn't too trivial.

EDIT:

Source of FreeBSD's traceroute:

http://svnweb.freebsd.org/base/release/9.1.0/contrib/traceroute/

Sam
  • 7,778
  • 1
  • 23
  • 49
  • I currently working with that source code but as you can see in the code , it will give me a "good result" ( that actually show my trace only when i use ICMP protocole). With all rest of the protocols i will get nothing or *** which is no use – Mike.R Jan 04 '13 at 16:19
  • I do have root privileges.It can be configured in the Xcode – Mike.R Jan 04 '13 at 16:20
  • Do you mean root for raw sockets or others? I don't have much specific knowlege of apple systems. I'd go for the source of FreeBSD's traceroute utility, which might be protable in case the above isn't fully implemented. I've just tried on my FreebSD 8.2 machine using `traceroute -PUDP google.com`, it shows proper results as ICMP does. Note, that some routers may just not respond properly on certain layer 3/4 protocols. – Sam Jan 04 '13 at 16:52
  • What i meant that i have root privileges for open a socket (with or without SOCK_RAW) – Mike.R Jan 04 '13 at 17:11
  • Ah, OK, otherwise, you couldn't run any socket code at all. Checkout the link to the FreeBSD 9.1.0 traceroute sources above. – Sam Jan 04 '13 at 17:22