Thanks, useful(at least for me).
On Apr 5, 2011, at 5:57 PM, Stuart Henderson wrote:
> On 2011/04/05 16:51, Stuart Henderson wrote:
>> if -t is used, display a notice when the TOS changes en-route.
>> ok?
>
> oh, it's better with a (contrived) example:
>
> $ traceroute -nt 7 naiad
> traceroute to naiad.spacehopper.org (195.95.187.35), 64 hops max, 40 byte
packets
> 1 85.158.44.145 0.441 ms (TOS=33!) 0.328 ms 0.396 ms
> 2 193.178.223.245 14.637 ms 15.213 ms 15.466 ms
> 3 194.39.143.145 16.600 ms 15.468 ms 16.206 ms
> 4 194.39.143.205 16.483 ms 16.210 ms 15.843 ms
> 5 193.203.5.182 17.475 ms 16.708 ms 16.986 ms
> 6 195.95.187.248 17.211 ms (TOS=4!) 16.460 ms 16.468 ms
> 7 195.95.187.35 27.99 ms 16.207 ms 17.467 ms
>
>
>
>> Index: traceroute.8
>> ===================================================================
>> RCS file: /cvs/src/usr.sbin/traceroute/traceroute.8,v
>> retrieving revision 1.44
>> diff -u -p -r1.44 traceroute.8
>> --- traceroute.8 8 Jul 2010 20:23:03 -0000 1.44
>> +++ traceroute.8 5 Apr 2011 15:50:38 -0000
>> @@ -177,6 +177,8 @@ in probe packets to the following value
>> The value must be a decimal integer in the range 0 to 255.
>> This option can be used to
>> see if different types-of-service result in different paths.
>> +If this option is used, changes to the type-of-service in the
>> +returned packets are displayed.
>> (If you are not running a
>> .Bx 4.3 tahoe
>> or later system, this may be academic since the normal network
>> @@ -384,6 +386,8 @@ ever occur and the associated gateway is
>> (destination network or host unreachable for TOS),
>> .Sy !<code>
>> (other ICMP unreachable code).
>> +.Sy TOS=xxx
>> +(TOS bit in returned packet differs from last hop).
>> If almost all the probes result in some kind of unreachable,
>> .Nm
>> will give up and exit.
>> Index: traceroute.c
>> ===================================================================
>> RCS file: /cvs/src/usr.sbin/traceroute/traceroute.c,v
>> retrieving revision 1.74
>> diff -u -p -r1.74 traceroute.c
>> --- traceroute.c 22 Mar 2011 10:16:23 -0000 1.74
>> +++ traceroute.c 5 Apr 2011 15:50:38 -0000
>> @@ -293,11 +293,13 @@ main(int argc, char *argv[])
>> int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL };
>> int ttl_flag = 0, incflag = 1, protoset = 0, sump = 0;
>> int ch, i, lsrr = 0, on = 1, probe, seq = 0, tos = 0;
>> + int last_tos, tos_returned;
>> size_t size = sizeof(max_ttl);
>> struct sockaddr_in from, to;
>> struct hostent *hp;
>> u_int32_t tmprnd;
>> - struct ip *ip;
>> + struct ip *ip, *inner_ip;
>> + struct icmp *icp;
>> u_int8_t ttl;
>> char *ep;
>> const char *errstr;
>> @@ -427,7 +429,7 @@ main(int argc, char *argv[])
>> l = strtol(optarg, &ep, 10);
>> if (errno || !*optarg || *ep || l < 0 || l > 255)
>> errx(1, "tos must be 0 to 255.");
>> - tos = (int)l;
>> + last_tos = tos = (int)l;
>> break;
>> case 'v':
>> verbose++;
>> @@ -636,9 +638,21 @@ main(int argc, char *argv[])
>> ++got_there;
>> break;
>> }
>> +
>> + icp = (struct icmp *) (((u_char
>> *)ip)+(ip->ip_hl<<2));
>> + inner_ip = (struct ip *) (((u_char *)icp)+8);
>> +
>> + tos_returned = inner_ip->ip_tos;
>> +
>> + if (tos_returned != last_tos)
>> + printf (" (TOS=%d!)", tos_returned);
>> +
>> + last_tos = tos_returned;
>> +
>> /* time exceeded in transit */
>> if (i == -1)
>> break;
>> +
>> code = i - 1;
>> switch (code) {
>> case ICMP_UNREACH_PORT: