#!/usr/bin/env bash

echo "--- run largish topology and show LSDB flooding timing on core "
echo "    (measures basically effective flooding speed)"
echo

# Copyright (c) 2016-, Juniper Networks, Inc.
# All rights reserved.

set -e

ulimit -n 4096

`which python` --version || {
    echo "install python ..."
    exit 1
}

echo
echo "LSDB update timing distribution for cores, each line is #TIES updated"
echo "in LSDB at given timestamp ..."
echo

OF=/tmp/rift.out.$$

../bin/rift-environ topology -DD ../topology/3pod2edge4acc3core100pfx.yaml > $OF

for N in "core_1" "core_2" "core_3" "agg_101" "agg_201" "agg_301"
do

    echo
    echo "timing for $N"

    cat $OF | python lib/curlies.py "LSDB for $N" "[" "]" > $OF.2

    cat $OF.2 | python lib/curlies.py " *North.*" "[" "]" | cut -d/ -f7 | sort -n | cut -c1-4 | uniq -c

done 

echo
cat $OF | ./lib/countfloodcountfilter.sh
cat $OF | ./lib/countfloodretransmits.sh
cat $OF | ./lib/countfloodreductions.sh

unlink $OF
unlink $OF.2
