-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenerate.sh
executable file
·55 lines (45 loc) · 1.17 KB
/
generate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -e
function create_ribs {
python create-ribs.py --prefixes unique-prefixes.txt \
--topo inet-edges.txt \
--dir inet \
--log \
--routes routes \
--rib inet-ribs.csv
}
function fetch_bgpdump {
url='http://irl.cs.ucla.edu/bgpparser/download.cgi?file=bgpparser-0.3b2.tgz'
if [ -f bgpparser/bin/bgpparser ] && [ ! bgpparser/bin/bgpparser ]; then
return
fi
if [ ! -f bgpparser.tgz ]; then
wget $url -O bgpparser.tgz
fi
tar xf bgpparser.tgz
pushd bgpparser
./configure
pushd parser
# This only works on Linux. Not sure what the workaround on Mac
# OSX systems is.
sed -i.bak 's/^CFLAGS=.*/CFLAGS=-g -fPIC -fpermissive/g' Makefile
popd
make
popd
}
function get_prefixes {
RIBFILE=rib.20130801.0000
if [ ! -f $RIBFILE ]; then
echo "Please download RIB file in MRT format from http://routeviews.org/bgpdata/2013.08/RIBS/"
exit
fi
bgpparser/bin/bgpparser -f $RIBFILE | \
grep PREFIX | \
sed -e 's/PREFIX//g' -e 's/<//g' -e 's|/>||g' -e 's/>//g' | \
awk '{ print $1 }' | uniq | unique-prefixes.txt
}
fetch_bgpdump
if [ ! -f unique-prefixes.txt ]; then
get_prefixes
fi
create_ribs