coxley / aspath_graph

Take BGP AS PATHs and generate an interactive javascript graph using NetJSON
Do What The F*ck You Want To Public License
31 stars 6 forks source link

duplicate count of links #4

Open acoul opened 7 years ago

acoul commented 7 years ago

greetings,

first of all thank you for such a nice tool

I am trying to graph our BGP here at AWMN (http://bgpmap.ozo.com/)

I am getting duplicate counts for each link

for instance for a full BGP path dump, for node 3298:

11350 3298 13101 3298 14534 3298 17599 3298 19074 3298 20042 3298 20305 3298 3267 3298 3298 11350 3298 11663 3298 13101 3298 14534 3298 17599 3298 19074 3298 1982 3298 20042 3298 20305 3298 22128 3298 3267 3298 57 3298 7736 3298 9632 57 3298 7736 3298 9632 3298

aspath_graph counts 25 links instead of the actual links which is 14

3298 11350 3298 11663 3298 13101 3298 14534 3298 17599 3298 19074 3298 1982 3298 20042 3298 20305 3298 22128 3298 3267 3298 57 3298 7736 3298 9632

is there a way to deal with this issue?

acoul commented 7 years ago

I managed to work around the above issue and successfully get correct results (you can check them @ http://spq.ozo.com/live/) with the following hackish script

#!/bin/sh
rm -f /tmp/lili
touch /tmp/lili
vtysh -c "sh ip bgp" | grep -v " h " | grep -v ^*d | grep -v \} | grep " i\| e" | awk -F " i| e" '{printf $1"\n"}' | cut -c 62-600 | sed 's/^ //g' | awk '{printf NF"\t"$0"\n"}' | grep -P ^[1-9]'\t' | cut -f 2-30 | egrep -o '[0-9]+ [0-9 ]+' | rev | cut -d " " -f 1,2 | rev | sort | uniq > /tmp/awmn-full
cat /tmp/awmn-full | awk '{printf $NF"\n"}' | sort | uniq > /tmp/tasn-out-awmn
IFS=$'\n'
for y in `cat /tmp/tasn-out-awmn`
do
grep $y" \| "$y'$' /tmp/awmn-full > /tmp/awmn-full-tmp
for i in `cat /tmp/awmn-full-tmp`
do
UPATH="$i"
RUPATH="`echo $UPATH | awk '{for (i=NF;i>0;i--){printf $i" "};printf "\n"}' | awk -F " $" '{printf $1"\n"}'`"
if ! grep -q "$UPATH" /tmp/lili
then
echo $RUPATH >> /tmp/lili
fi
done
done
awk -F " $" '{printf $1"\n"}' /tmp/lili | sort | uniq > /tmp/aspaths.txt

output looks like this:

grep 3298 /tmp/aspaths.txt

11663 3298
1982 3298
22128 3298
3298 11350
3298 13101
3298 14534
3298 17599
3298 19074
3298 20042
3298 20305
3298 3267
57 3298
7736 3298
9632 3298
coxley commented 7 years ago

Hey @acoul! Thanks for stopping by. :)

It's been awhile since touching this so I'll need to sit down and play with the example you sent to see why it's acting up. Shouldn't be too tough. I need to dedicate some time during the weekend or something to address the other issues too. :)

acoul commented 7 years ago

Hello @coxley, I have to tell you that this is a really neat and handy tool. thank you so much for bringing it to life and sharing it with the community.

here is a simpler aspaths that does generate false results:

240 416 8506 410 416 240 410 416 8506 416 240 416 410 11087 416 410 18523 416 410 3200 416 8506 416 8506 11607

in this case 416 has just three peers: 240, 410, 8506

aspath_graph insists they are 5 peers