in reply to Re: how to count route diffs in traceroute outputs
in thread how to count route diffs in traceroute outputs

Hi Limbic~Region,

many thanx for your answer. I understand what you mean. But my main problem is how to interpret the diff output, how do I count the route differences. This code should run mainly on OpenBSD and Linux. Traceroute and diff operates the same way on these OSs according to my tests.
Many thanx in advance.

Clint
  • Comment on Re^2: how to count route diffs in traceroute outputs

Replies are listed 'Best First'.
Re^3: how to count route diffs in traceroute outputs
by Limbic~Region (Chancellor) on Jun 20, 2005 at 13:36 UTC
    clint,
    As merlyn was keen to point out, more details are required. The single most important piece of my response was "it would helpful to see a sample output". That isn't just the traceroute output, but also what you want to do with it. I am more of a visual person and want to "see" what you want to accomplish while merlyn is more of an auditory person and wants you to describe the process. Either way - we need more information.

    Cheers - L~R

      Hi PerlMonks,

      many thanx for your help!
      I try to specify everything better this time.
      So I have two example files, which should be produced by my script, (to reach this state is no problem):

      File: route_1

      3 r26-lo1-ixi1.vie.as1901.net (193.154.162.15)
      4 r4-vlan-167-ixi1.vie.as1901.net.167.154.193.in-addr.arpa (193.154.167.1)
      5 msw02-01-w15-vlan-145-dbg2.vie.at.eu.net (193.154.145.19)
      6 194.96.203.74 (194.96.203.74)

      File: route_2

      3 r26-lo1-ixi1.vie.as1901.net (193.154.162.15)
      4 r4-vlan-167-ixi1.vie.as1902.net.167.154.193.in-addr.arpa (193.154.167.1)
      5 msw02-01-w15-vlan-145-dbg2.vie.at.eu.net (193.154.145.19)
      6 64.233.174.114 (64.233.174.114)
      7 194.96.203.74 (194.96.203.74)

      Diff:

      diff route_1 route_2
      2c2
      < 4 r4-vlan-167-ixi1.vie.as1901.net.167.154.193.in-addr.arpa (193.154.167.1)
      ---
      > 4 r4-vlan-167-ixi1.vie.as1902.net.167.154.193.in-addr.arpa (193.154.167.1)
      4c4,5
      < 6 194.96.203.74 (194.96.203.74)
      ---
      > 6 64.233.174.114 (64.233.174.114)
      > 7 194.96.203.74 (194.96.203.74)

      There are two differences, which I made in the route. My question is how to interpret the diff output? I mean, how to count the diffs in the route? A diff in a route is for example if a IP or hostname of a hop is changed or there is a new hop... I would like count to the diffs, but I do not know what to do with the diff output, how to parse it.

      Many thanx for any help!

      Clint
        A diff in a route is for example if a IP or hostname of a hop is changed or there is a new hop
        That's still not a complete spec.

        What if you have A-B-C-D-E vs A-B-XX-C-D-E? Are you wanting to count that as 1 (because 1 hop got added), or 3 or 4 because the last 3 or 4 are different?

        What if you have A-B-C-D-E vs A-B-D-C-E? Is that two differences?

        What if one is A-B-(C1,C2)-D-E vs A-B-C1-D-E, because there was a route flappage within one of the traces? Do you count that at all, or just as 1?

        I suspect that the closer you think about all the possibilities, the closer you'll be to implementing it yourself. The problem will be figuring out all the ways it could be different.

        That's why your problem's not solvable yet. You don't have a complete idea of what you want to do, or if you think you do, you still aren't communicating it clearly.

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.

        For that format of diff, any line that starts with '<' comes from the first file, any line that starts with '>' comes from the second file, and all other lines are infrastructure.

        The infrastructure comes in three flavours; 4c4,5 means "to minimise differences, I have to replace line 4 in the first file with lines 4-5 in the second file"; you may also see 4,10d3 which means "I have to delete lines 4-10 from the first file (which would have appeared after line 3 in the second file)", or 5a6 which means "I have to add line 6 in the second file, which should have appeared after line 5 in the first file".

        For 'a' and 'd' only the added/removed lines are shown; for 'c' the old lines are shown, then the '---' separator, then the new lines.

        Note that there are other formats for the diffs that you may see depending on the version and the flags you supply.

        At the simplest level, you could just count the number of lines starting with '<' and '>': for your example that would give "2 hops in the first trace were replaced by 3 hops in the second trace", or take the difference to report "the second trace was 1 hop longer" (though you don't need diff to get the latter output).

        Hugo

Re^3: how to count route diffs in traceroute outputs
by merlyn (Sage) on Jun 20, 2005 at 13:30 UTC
    You'll probably need to be more specific. Traceroute generally has 3 probes per hopcount. How do you want to show the differences? Between the smallest of one set to the largest of the other?

    And what if the route flaps in the middle (where you get a new host on a given line)? How do you want to see that?

    And what if the route is different from one view to the next? The hop-by-hop counts will be relatively unrelated after the first branch point.

    So, if you can explain (as in provide a specification) what you mean by "count the route differences", you might get a more concrete answer rather than all the handwaving responses so far.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.