bloghow2doitde

A blog about computer science and a life between Heidelberg and Munich

During a project at university I had to analyse raw RIS data dumps of the RIPE NCC. As BGP related stuff is a fairly advanced topic which is only used by computer scientists there are few tool around to work with those raw data dumps. This is why I’m publishing a small Bash snippet I wrote to create a non-binary data dump joining all the raw data files from RIPE NCC.

Some small scripts make things a lot easier, especially when using BGP raw dumps as they are sometimes hard to handle. Often a lot of manual work is needed to get them into a format for further work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

RESULTFILE="updates.total"
echo -n "" > $RESULTFILE
fslist=$(ls | grep -P "^updates.2[0-9]{7}.[0-2][0-9][0-5][0|5]$")

for file in $fslist
do
    echo -n "Parsing $file ... "
        if [ $# -eq 1 ]
        then
            bgpdump -m $file -v | grep "$1" >> $RESULTFILE
        else
            bgpdump -m $file -v >> $RESULTFILE
        fi
    echo "done!"
done

SIZE=$(du -h $RESULTFILE -0 | cut -f 1)
echo "All done - size of $RESULTFILE is $SIZE"

It’s fairly simple to use. If the script is called without an argument it will use bgpdump to create human-readable data files using alphabetically ordered raw dumps without any filtering. This can be usefully because a program can now access the whole updates of a certain timespan without opening hundreds of files. The default name of the resulting file is updates.total.

If there is filtering needed or only a certain IP range is of interest the script can be called with one argument like ./script 127.0.0.0/8. In this case there is a grep between bgpdump and the output into updates.total.

posted in: Bash, Border Gateway Protocol, Linux