home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / src / traceroute / vj_traceroute / LSRR.patches next >
Internet Message Format  |  1989-11-22  |  17KB

  1. From owner-ineng-interest@venera.isi.edu Thu Aug  3 13:17:46 1989
  2. Received: from venera.isi.edu by sccgate (5.61/1.34)
  3.     id AA19575; Thu, 3 Aug 89 13:17:40 -0400
  4. Received: by venera.isi.edu (5.61/5.61+local)
  5.     id <AA08207>; Thu, 3 Aug 89 07:40:09 -0700
  6. Posted-Date: Thu, 03 Aug 89 10:40:06 EDT
  7. Received-Date: Thu, 3 Aug 89 07:40:03 -0700
  8. Received: from FORNAX.ECE.CMU.EDU by venera.isi.edu (5.61/5.61+local)
  9.     id <AA08200>; Thu, 3 Aug 89 07:40:03 -0700
  10. Received: by fornax.ece.cmu.edu (5.54-ECE2/5.17)
  11.     id AA20308; Thu, 3 Aug 89 10:40:08 EDT
  12. From: Matt Mathis <mathis@fornax.ece.cmu.edu>
  13. Message-Id: <8908031440.AA20308@fornax.ece.cmu.edu>
  14. To: ietf@venera.isi.edu
  15. Cc: van@helios.ee.lbl.gov
  16. Subject: 3 Party traceroute
  17. Date: Thu, 03 Aug 89 10:40:06 EDT
  18. Status: R
  19.  
  20.  
  21. Attached below is a patch file for Van Jacobson's traceroute, to add support
  22. the IP LSRR (Loose Source Record Route) option in addition to the standard
  23. traceroute/ttl stuff.
  24.  
  25. This is useful for asking how somebody else reaches a particular target.
  26. For example: "traceroute -g 10.3.0.5 128.182.0.0" shows the path from the
  27. Cambridge Mailbridge to PSC.  This works from (almost) anywhere!
  28.  
  29. traceroute -g 192.5.146.4 -g 10.3.0.5 35.0.0.0
  30. Shows how the Cambridge Mailbrige reaches Merit, by using PSC to reach the
  31. Mailbridge.
  32.  
  33. This version is substantially cleaned up by Jeff Honig at Cornell.  Thanks!
  34.  
  35. Van Jacobson's original traceroute (spring 1988) supported this feature,
  36. but he removed it due to pressure from people with broken gateways.   At the
  37. July 1989 IETF this issue was discussed, and the only objection noted was
  38. later retracted with "I've been trying to get my management to upgrade our
  39. gateways for a long time, maybe this will force the issue".   I expect Van's
  40. traceroute to support LSRR sometime soon.  This patch should be considered
  41. interim.
  42.  
  43. The Van's traceroute is available with anonymous ftp from ftp.ee.lbl.gov.
  44. It does require kernel mods (Sorry, I don't have object modules.)
  45.  
  46. Caveats:
  47.  
  48. LSRR must be fully supported at least as far as the specified gateway.  This
  49. seems to be the case for the NSFnet, ARPAnet and all reasonably recent
  50. commercial gateways/routers.
  51.  
  52. LSRR must be supported (recognized as completed) or ignored between the
  53. specified gateway to the final target.  This seems to be the case almost
  54. every where else.
  55.  
  56. THERE MAY STILL BE GATEWAYS OUT IN THE INTERNET WHICH HAVE FATAL BUGS IN THE
  57. CODE TO PROCESS ROUTING OPTIONS.   Be nice to your neighbors.
  58.  
  59. All of the the usual disclaimers about free code apply.
  60.  
  61. --MM--
  62.  
  63. *** /tmp/,RCSt1a01058    Mon Jul 31 22:20:06 1989
  64. --- traceroute.c    Mon Jul 31 22:14:29 1989
  65. ***************
  66. *** 202,210 ****
  67. --- 202,212 ----
  68.   #include <netinet/in_systm.h>
  69.   #include <netinet/in.h>
  70.   #include <netinet/ip.h>
  71. + #include <netinet/ip_var.h>
  72.   #include <netinet/ip_icmp.h>
  73.   #include <netinet/udp.h>
  74.   #include <netdb.h>
  75. + #include <ctype.h>
  76.   
  77.   #define    MAXPACKET    65535    /* max ip packet size */
  78.   #ifndef MAXHOSTNAMELEN
  79. ***************
  80. *** 223,228 ****
  81. --- 225,231 ----
  82.   #define Fprintf (void)fprintf
  83.   #define Sprintf (void)sprintf
  84.   #define Printf (void)printf
  85.   extern    int errno;
  86.   extern  char *malloc();
  87.   extern  char *inet_ntoa();
  88. ***************
  89. *** 265,271 ****
  90.   int nflag;            /* print addresses numerically */
  91.   
  92.   char usage[] =
  93. !  "Usage: traceroute [-dnrv] [-w wait] [-m max_ttl] [-p port#] [-q nqueries] [-t tos] [-s src_addr] host [data size]\n";
  94.   
  95.   
  96.   main(argc, argv)
  97. --- 268,274 ----
  98.   int nflag;            /* print addresses numerically */
  99.   
  100.   char usage[] =
  101. !  "Usage: traceroute [-dnrv] [-w wait] [-m max_ttl] [-p port#] [-q nqueries] [-t tos] [-s src_addr] [-g gateway] host [data size]\n";
  102.   
  103.   
  104.   main(argc, argv)
  105. ***************
  106. *** 280,286 ****
  107. --- 283,295 ----
  108.       int seq = 0;
  109.       int tos = 0;
  110.       struct hostent *hp;
  111. +     int lsrr = 0;
  112. +     u_long gw;
  113. +     u_char optlist[MAX_IPOPTLEN], *oix;
  114.   
  115. +     oix = optlist;
  116. +     bzero(optlist, sizeof(optlist));
  117.       argc--, av++;
  118.       while (argc && *av[0] == '-')  {
  119.           while (*++av[0])
  120. ***************
  121. *** 288,293 ****
  122. --- 297,334 ----
  123.               case 'd':
  124.                   options |= SO_DEBUG;
  125.                   break;
  126. +             case 'g':
  127. +                 argc--, av++;
  128. +                 if ((lsrr+1) >= ((MAX_IPOPTLEN-IPOPT_MINOFF)/sizeof(u_long))) {
  129. +                   Fprintf(stderr,"No more than %d gateways\n",
  130. +                       ((MAX_IPOPTLEN-IPOPT_MINOFF)/sizeof(u_long))-1);
  131. +                   exit(1);
  132. +                 }
  133. +                 if (lsrr == 0) {
  134. +                   *oix++ = IPOPT_LSRR;
  135. +                   *oix++;    /* Fill in total length later */
  136. +                   *oix++ = IPOPT_MINOFF; /* Pointer to LSRR addresses */
  137. +                 }
  138. +                 lsrr++;
  139. +                 if (isdigit(*av[0])) {
  140. +                   gw = inet_addr(*av);
  141. +                   if (gw) {
  142. +                     bcopy(&gw, oix, sizeof(u_long));
  143. +                   } else {
  144. +                     Fprintf(stderr, "Unknown host %s\n",av[0]);
  145. +                     exit(1);
  146. +                   }
  147. +                 } else {
  148. +                   hp = gethostbyname(av[0]);
  149. +                   if (hp) {
  150. +                     bcopy(hp->h_addr, oix, sizeof(u_long));
  151. +                   } else {
  152. +                     Fprintf(stderr, "Unknown host %s\n",av[0]);
  153. +                     exit(1);
  154. +                   }
  155. +                 }
  156. +                 oix += sizeof(u_long);
  157. +                 goto nextarg;
  158.               case 'm':
  159.                   argc--, av++;
  160.                   max_ttl = atoi(av[0]);
  161. ***************
  162. *** 411,416 ****
  163. --- 452,475 ----
  164.           perror("traceroute: raw socket");
  165.           exit(5);
  166.       }
  167. +     if (lsrr > 0) {
  168. +       lsrr++;
  169. +       optlist[IPOPT_OLEN]=IPOPT_MINOFF-1+(lsrr*sizeof(u_long));
  170. +       bcopy((caddr_t)&to->sin_addr, oix, sizeof(u_long));
  171. +       oix += sizeof(u_long);
  172. +       while ((oix - optlist)&3) oix++;        /* Pad to an even boundry */
  173. +       if ((pe = getprotobyname("ip")) == NULL) {
  174. +         perror("traceroute: unknown protocol ip\n");
  175. +         exit(10);
  176. +       }
  177. +       if ((setsockopt(sndsock, pe->p_proto, IP_OPTIONS, optlist, oix-optlist)) < 0) {
  178. +         perror("traceroute: lsrr options");
  179. +         exit(5);
  180. +       }
  181. +     }
  182.   #ifdef SO_SNDBUF
  183.       if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen,
  184.                  sizeof(datalen)) < 0) {
  185.  
  186.  
  187.  
  188.  
  189.  
  190. ++++++++++++
  191. >From owner-ineng-interest@venera.isi.edu Tue Aug  8 18:22:35 1989
  192. Received: from venera.isi.edu by sccgate (5.61/1.34)
  193.     id AA25608; Tue, 8 Aug 89 18:22:26 -0400
  194. Received: by venera.isi.edu (5.61/5.61+local)
  195.     id <AA12406>; Tue, 8 Aug 89 13:58:10 -0700
  196. Posted-Date: Tue, 8 Aug 89 15:58:25 -0500
  197. Received-Date: Tue, 8 Aug 89 13:58:06 -0700
  198. Received: from uxc.cso.uiuc.edu by venera.isi.edu (5.61/5.61+local)
  199.     id <AA12402>; Tue, 8 Aug 89 13:58:06 -0700
  200. Received: by uxc.cso.uiuc.edu
  201.     (5.61+/IDA-1.2.8) id AA28286; Tue, 8 Aug 89 15:58:25 -0500
  202. Date: Tue, 8 Aug 89 15:58:25 -0500
  203. From: "Paul Pomes (I'm the NRA!)" <paul@uxc.cso.uiuc.edu>
  204. Message-Id: <8908082058.AA28286@uxc.cso.uiuc.edu>
  205. To: ietf@venera.isi.edu, mathis@fornax.ece.cmu.edu
  206. Subject: new traceroute man page w. IP LSRR
  207. Cc: van@helios.ee.lbl.gov
  208. Status: R
  209.  
  210. .\" Copyright (c) 1988 The Regents of the University of California.
  211. .\" All rights reserved.
  212. .\"
  213. .\" Redistribution and use in source and binary forms are permitted
  214. .\" provided that the above copyright notice and this paragraph are
  215. .\" duplicated in all such forms and that any documentation,
  216. .\" advertising materials, and other materials related to such
  217. .\" distribution and use acknowledge that the software was developed
  218. .\" by the University of California, Berkeley.  The name of the
  219. .\" University may not be used to endorse or promote products derived
  220. .\" from this software without specific prior written permission.
  221. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  222. .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  223. .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  224. .\"
  225. .\"    $Header: traceroute.8,v 1.1 89/02/28 20:46:12 van Exp $
  226. .\"
  227. .TH TRACEROUTE 8 "February 28, 1989"
  228. .UC 6
  229. .SH NAME
  230. traceroute \- print the route packets take to network host
  231. .SH SYNOPSIS
  232. .B traceroute
  233. [
  234. .B \-m
  235. max_ttl
  236. ] [
  237. .B \-n
  238. ] [
  239. .B \-p
  240. port
  241. ] [
  242. .B \-q
  243. nqueries
  244. ] [
  245. .B \-r
  246. ] [
  247. .B \-s
  248. src_addr
  249. ] [
  250. .B \-g
  251. addr
  252. ] [
  253. .B \-t
  254. tos
  255. ] [
  256. .B \-w
  257. waittime
  258. ]
  259. .I host
  260. [
  261. .I packetsize
  262. ]
  263. .SH DESCRIPTION
  264. The Internet is a large and complex aggregation of
  265. network hardware, connected together by gateways.
  266. Tracking the route one's packets follow (or finding the miscreant
  267. gateway that's discarding your packets) can be difficult.
  268. .I Traceroute
  269. utilizes the IP protocol `time to live' field and attempts to elicit an
  270. ICMP TIME_EXCEEDED response from each gateway along the path to some
  271. host.
  272. .PP
  273. The only mandatory parameter is the destination host name or IP number.
  274. The default probe datagram length is 38 bytes, but this may be increased
  275. by specifying a packet size (in bytes) after the destination host name.
  276. .PP
  277. Other options are:
  278. .TP 5 5
  279. .BI \-m\  n
  280. Set the max time-to-live (max number of hops) used in outgoing probe
  281. packets to
  282. .I n
  283. hops.
  284. The default is 30 hops (the same default used for TCP connections).
  285. .TP 5 5
  286. .B \-n
  287. Print hop addresses numerically rather than symbolically and numerically
  288. (saves a nameserver address-to-name lookup for each gateway found on the
  289. path).
  290. .TP 5 5
  291. .BI \-p\  n
  292. Set the base UDP port number used in probes to
  293. .I n
  294. (default is 33434).
  295. .I Traceroute
  296. hopes that nothing is listening on UDP ports
  297. .I base
  298. to
  299. .I base+nhops-1
  300. at the destination host (so an ICMP PORT_UNREACHABLE message will
  301. be returned to terminate the route tracing).
  302. If something is listening on a port in the default range,
  303. this option can be used to pick an unused port range.
  304. .TP 5 5
  305. .B \-r
  306. Bypass the normal routing tables and send directly to a host on an attached
  307. network.
  308. If the host is not on a directly-attached network,
  309. an error is returned.
  310. This option can be used to ping a local host through an interface
  311. that has no route through it (e.g., after the interface was dropped by
  312. .IR routed (8C)).
  313. .TP 8 8
  314. .BI \-s\  addr
  315. Use
  316. .I addr
  317. as the IP address (which must be given as an IP number,
  318. not a hostname) as the source address in outgoing probe packets.
  319. On hosts with more than one IP address, this option can be used to
  320. force the source address to be something other than the IP address
  321. of the interface the probe packet is sent on.
  322. If the IP address is not one of this machine's interface addresses,
  323. an error is returned and nothing is sent.
  324. .TP 8 8
  325. .BI \-g\  addr
  326. Enable the IP LSRR (Loose Source Record Route) option in addition to the
  327. TTL tests.
  328. This is useful for asking how somebody else, at IP address
  329. .IR addr ,
  330. reaches a particular target.
  331. .TP 8 8
  332. .BI \-t\  tos
  333. Set the
  334. .I type-of-service
  335. in probe packets to the following value (default zero).
  336. The value must be a decimal integer in the range 0 to 255.
  337. This option can be used to see if different types-of-service result
  338. in different paths.
  339. (If you are not running 4.4bsd, this may be academic since the normal network
  340. services like telnet and ftp don't let you control the TOS).
  341. Not all values of TOS are legal or meaningful \- see the IP spec
  342. for definitions.
  343. Useful values are probably `\-t 16' (low delay) and `\-t 8' (high throughput).
  344. .TP 5 5
  345. .B \-v
  346. Verbose output.
  347. Received ICMP packets other than TIME_EXCEEDED and UNREACHABLEs are listed.
  348. .TP 5 5
  349. .BI \-w\  n
  350. Set the time to wait for a response to a probe to
  351. .I n
  352. seconds (default 3 sec.).
  353. .PP
  354. This program attempts to trace the route an IP packet would follow to some
  355. internet host by launching UDP probe packets with a small ttl (time to live)
  356. then listening for an ICMP "time exceeded" reply from a gateway.
  357. We start our probes with a ttl of one and increase by one until we get an
  358. ICMP "port unreachable" (which means we got to "host") or hit a max (which
  359. defaults to 30 hops & can be changed with the
  360. .B \-m
  361. flag).
  362. Three probes (change with
  363. .B \-q
  364. flag) are sent at each ttl setting and a line is printed showing the ttl,
  365. address of the gateway and round trip time of each probe.
  366. If the probe answers come from different gateways,
  367. the address of each responding system will be printed.
  368. If there is no response within a 3 sec. timeout interval (changed with the
  369. .B \-w
  370. flag), a "*" is printed for that probe.
  371. .PP
  372. We don't want the destination host to process the UDP probe packets
  373. so the destination port is set to an unlikely value (if some clod on
  374. the destination is using that value, it can be changed with the
  375. .B \-p
  376. flag).
  377. .PP
  378. A sample use and output might be:
  379. .PP
  380. .RS
  381. .nf
  382. [yak 71]% traceroute nis.nsf.net.
  383. traceroute to nis.nsf.net (35.1.1.48), 30 hops max, 56 byte packet
  384.  1  helios.ee.lbl.gov (128.3.112.1)  19 ms  19 ms  0 ms
  385.  2  lilac-dmc.Berkeley.EDU (128.32.216.1)  39 ms  39 ms  19 ms
  386.  3  lilac-dmc.Berkeley.EDU (128.32.216.1)  39 ms  39 ms  19 ms
  387.  4  ccngw-ner-cc.Berkeley.EDU (128.32.136.23)  39 ms  40 ms  39 ms
  388.  5  ccn-nerif22.Berkeley.EDU (128.32.168.22)  39 ms  39 ms  39 ms
  389.  6  128.32.197.4 (128.32.197.4)  40 ms  59 ms  59 ms
  390.  7  131.119.2.5 (131.119.2.5)  59 ms  59 ms  59 ms
  391.  8  129.140.70.13 (129.140.70.13)  99 ms  99 ms  80 ms
  392.  9  129.140.71.6 (129.140.71.6)  139 ms  239 ms  319 ms
  393. 10  129.140.81.7 (129.140.81.7)  220 ms  199 ms  199 ms
  394. 11  nic.merit.edu (35.1.1.48)  239 ms  239 ms  239 ms
  395. .fi
  396. .RE
  397. .PP
  398. Note that lines 2 & 3 are the same.  This is due to a buggy
  399. kernel on the 2nd hop system \- lbl-csam.arpa \- that forwards
  400. packets with a zero ttl (a bug in the distributed version of 4.3BSD).
  401. .PP
  402. A more interesting example is:
  403. .PP
  404. .RS
  405. .nf
  406. [yak 72]% traceroute allspice.lcs.mit.edu.
  407. traceroute to allspice.lcs.mit.edu (18.26.0.115), 30 hops max
  408.  1  helios.ee.lbl.gov (128.3.112.1)  0 ms  0 ms  0 ms
  409.  2  lilac-dmc.Berkeley.EDU (128.32.216.1)  19 ms  19 ms  19 ms
  410.  3  lilac-dmc.Berkeley.EDU (128.32.216.1)  39 ms  19 ms  19 ms
  411.  4  ccngw-ner-cc.Berkeley.EDU (128.32.136.23)  19 ms  39 ms  39 ms
  412.  5  ccn-nerif22.Berkeley.EDU (128.32.168.22)  20 ms  39 ms  39 ms
  413.  6  128.32.197.4 (128.32.197.4)  59 ms  119 ms  39 ms
  414.  7  131.119.2.5 (131.119.2.5)  59 ms  59 ms  39 ms
  415.  8  129.140.70.13 (129.140.70.13)  80 ms  79 ms  99 ms
  416.  9  129.140.71.6 (129.140.71.6)  139 ms  139 ms  159 ms
  417. 10  129.140.81.7 (129.140.81.7)  199 ms  180 ms  300 ms
  418. 11  129.140.72.17 (129.140.72.17)  300 ms  239 ms  239 ms
  419. 12  * * *
  420. 13  128.121.54.72 (128.121.54.72)  259 ms  499 ms  279 ms
  421. 14  * * *
  422. 15  * * *
  423. 16  * * *
  424. 17  * * *
  425. 18  ALLSPICE.LCS.MIT.EDU (18.26.0.115)  339 ms  279 ms  279 ms
  426. .fi
  427. .RE
  428. .PP
  429. Note that the gateways 12, 14, 15, 16 & 17 hops away
  430. either don't send ICMP "time exceeded" messages or send them
  431. with a ttl too small to reach us.
  432. 14 \- 17 are running the MIT C Gateway code that doesn't
  433. send "time exceeded"s.
  434. God only knows what's going on with 12.
  435. .PP
  436. The silent gateway 12 in the above may be the result of a bug in
  437. the 4.[23]BSD network code (and its derivatives):  4.x (x <= 3)
  438. sends an unreachable message using whatever ttl remains in the
  439. original datagram.
  440. Since, for gateways, the remaining ttl is zero, the ICMP "time exceeded"
  441. is guaranteed to not make it back to us.
  442. The behavior of this bug is slightly more interesting when it
  443. appears on the destination system:
  444. .PP
  445. .RS
  446. .nf
  447.  1  helios.ee.lbl.gov (128.3.112.1)  0 ms  0 ms  0 ms
  448.  2  lilac-dmc.Berkeley.EDU (128.32.216.1)  39 ms  19 ms  39 ms
  449.  3  lilac-dmc.Berkeley.EDU (128.32.216.1)  19 ms  39 ms  19 ms
  450.  4  ccngw-ner-cc.Berkeley.EDU (128.32.136.23)  39 ms  40 ms  19 ms
  451.  5  ccn-nerif35.Berkeley.EDU (128.32.168.35)  39 ms  39 ms  39 ms
  452.  6  csgw.Berkeley.EDU (128.32.133.254)  39 ms  59 ms  39 ms
  453.  7  * * *
  454.  8  * * *
  455.  9  * * *
  456. 10  * * *
  457. 11  * * *
  458. 12  * * *
  459. 13  rip.Berkeley.EDU (128.32.131.22)  59 ms !  39 ms !  39 ms !
  460. .fi
  461. .RE
  462. .PP
  463. Notice that there are 12 "gateways" (13 is the final
  464. destination) and exactly the last half of them are "missing".
  465. What's really happening is that rip (a Sun-3 running Sun OS3.5)
  466. is using the ttl from our arriving datagram as the ttl in its ICMP reply.
  467. So, the reply will time out on the return path (with no notice sent
  468. to anyone since ICMP's aren't sent for ICMP's)
  469. until we probe with a ttl that's at least twice the path length.
  470. I.e., rip is really only 7 hops away.
  471. A reply that returns with a ttl of 1 is a clue this problem exists.
  472. .I Traceroute
  473. prints a "!" after the time if the ttl is <= 1.
  474. Since vendors ship a lot of obsolete (DEC's Ultrix, Sun 3.x) or
  475. non-standard (HPUX) software, expect to see this problem
  476. frequently and/or take care picking the target host of your probes.
  477. .PP
  478. Other possible annotations after the time are
  479. .BR !H ,
  480. .BR !N ,
  481. .B !P
  482. (got a host, network or protocol unreachable, respectively),
  483. .br
  484. .B !S
  485. or
  486. .B !F
  487. (source route failed or fragmentation needed \- neither of these should
  488. ever occur and the associated gateway is busted if you see one).
  489. If almost all the probes result in some kind of unreachable,
  490. .I traceroute
  491. will give up and exit.
  492. .PP
  493. .RS
  494. traceroute \-g 10.3.0.5 128.182.0.0
  495. .RE
  496. .PP
  497. will show the path from the Cambridge Mailbridge to PSC while
  498. .PP
  499. .RS
  500. traceroute \-g 192.5.146.4 \-g 10.3.0.5 35.0.0.0
  501. .RE
  502. .PP
  503. shows how the Cambridge Mailbrige reaches Merit,
  504. by using PSC to reach the Mailbridge.
  505. .PP
  506. This program is intended for use in network testing, measurement
  507. and management.
  508. It should be used primarily for manual fault isolation.
  509. Because of the load it could impose on the network, it is unwise to use
  510. .I traceroute
  511. during normal operations or from automated scripts.
  512. .SH AUTHOR
  513. Implemented by Van Jacobson from a suggestion by Steve Deering.
  514. Debugged by a cast of thousands with particularly cogent suggestions
  515. or fixes from C. Philip Wood, Tim Seaver and Ken Adelman.
  516. .SH SEE ALSO
  517. .IR netstat (1),
  518. .IR ping (8)
  519.  
  520.  
  521.  
  522.  
  523.