Skip to content

Commit

Permalink
Merge pull request #1208 from takikawa/ipfix-fix-v9
Browse files Browse the repository at this point in the history
Fixes for IPFIX v9 mode
  • Loading branch information
wingo committed Aug 13, 2017
2 parents ab02d53 + 17ac209 commit dad3438
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/apps/ipfix/ipfix.lua
Expand Up @@ -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)
Expand Down
56 changes: 37 additions & 19 deletions src/program/ipfix/tests/collector-test.sh
Expand Up @@ -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"

0 comments on commit dad3438

Please sign in to comment.