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 | [reply] |
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.
| [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
| [reply] [d/l] [select] |