From 4c9c4b825e8c9bb7b9a07149651b722873d5050d Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Sat, 12 Aug 2017 00:08:50 +0000 Subject: [PATCH 1/2] Improve ipfix collector test Runs the test with both v9 and v10 modes. Better error checking and minor refactoring as well. --- src/program/ipfix/tests/collector-test.sh | 56 +++++++++++++++-------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/src/program/ipfix/tests/collector-test.sh b/src/program/ipfix/tests/collector-test.sh index 90777b795b..fd0b7ebe1a 100755 --- a/src/program/ipfix/tests/collector-test.sh +++ b/src/program/ipfix/tests/collector-test.sh @@ -5,35 +5,53 @@ # export process with an actual flow collector. DURATION=10 -FLOWDIR=`mktemp -d` PCAP=program/wall/tests/data/http.cap +if [ -z "$SNABB_PCI0" ]; then + echo "SNABB_PCI0 must be set" + exit 1 +fi + # tap interface setup +echo "setting up tap interface" ip tuntap add tap-snabb-ipfix mode tap ip addr add 10.0.0.2 dev tap-snabb-ipfix ip link set dev tap-snabb-ipfix up -# Run the flow collector, output in $FLOWDIR -nfcapd -b 10.0.0.2 -p 4739 -l $FLOWDIR & -CAPD=$! +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` + version_flag=$1 + + # Run the flow collector, output in $flowdir + nfcapd -b 10.0.0.2 -p 4739 -l $flowdir & + capd=$! -# Run probe first -./snabb ipfix probe -D $DURATION -a 10.0.0.1 -c 10.0.0.2\ - --active-timeout 5 --idle-timeout 5 -o tap $SNABB_PCI0 tap-snabb-ipfix & -sleep 0.5 + # Run probe first + ./snabb ipfix probe -D $DURATION -a 10.0.0.1 -c 10.0.0.2\ + $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 + # ... then feed it some packets + ./snabb packetblaster replay -D $DURATION --no-loop $PCAP $SNABB_PCI1 > /dev/null -kill $CAPD + 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 -STATUS=$? + # 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 + status=$? -# teardown -ip link del tap-snabb-ipfix -rm -r $FLOWDIR + rm -r $flowdir + [ $status -eq 0 ] || exit 1 +} -exit $STATUS +test_probe "--netflow-v9" +test_probe "--ipfix" From 17ac209459976c345b030a8c632bbbe3d209e0e7 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 11 Aug 2017 16:13:07 -0700 Subject: [PATCH 2/2] Fix typo in IPFIX v9 mode --- src/apps/ipfix/ipfix.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/ipfix/ipfix.lua b/src/apps/ipfix/ipfix.lua index 590bf43207..ccd2b1672f 100644 --- a/src/apps/ipfix/ipfix.lua +++ b/src/apps/ipfix/ipfix.lua @@ -363,7 +363,7 @@ function IPFIX:add_ipfix_header(pkt, count) header.version = htons(self.version) if self.version == 9 then - header.count = htons(count) + header.record_count = htons(count) header.uptime = htonl(to_milliseconds(engine.now() - self.boot_time)) elseif self.version == 10 then header.byte_length = htons(pkt.length)