Fetching contributors…
Cannot retrieve contributors at this time
executable file 58 lines (44 sloc) 1.38 KB
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nfdump
# This is a test script for the IPFIX probe program that tests the
# export process with an actual flow collector.
if [ -z "$SNABB_PCI0" ]; then
echo "SNABB_PCI0 must be set"
exit 1
# tap interface setup
echo "setting up tap interface"
ip tuntap add tap-snabb-ipfix mode tap
ip addr add dev tap-snabb-ipfix
ip link set dev tap-snabb-ipfix up
function teardown {
echo "shutting down tap interface"
ip link del tap-snabb-ipfix
trap teardown EXIT
# a function that runs the test, takes the version flag as an argument
function test_probe {
flowdir=`mktemp -d`
# Run the flow collector, output in $flowdir
nfcapd -b -p 4739 -l $flowdir &
# Run probe first
./snabb ipfix probe -D $DURATION -a -c\
$version_flag --active-timeout 5 --idle-timeout 5 -o tap $SNABB_PCI0 tap-snabb-ipfix &
sleep 0.5
# ... then feed it some packets
./snabb packetblaster replay -D $DURATION --no-loop $PCAP $SNABB_PCI1 > /dev/null
kill $capd
# Analyze with nfdump
dumpfile=`ls -1 $flowdir | head -n 1`
nfdump -r $flowdir/$dumpfile | grep "total flows: 6, total bytes: 24609, total packets: 43" > /dev/null
rm -r $flowdir
[ $status -eq 0 ] || exit 1
test_probe "--netflow-v9"
test_probe "--ipfix"