Skip to content
This repository was archived by the owner on Mar 21, 2023. It is now read-only.

Commit 7615f80

Browse files
author
Jochen Schalanda
committed
Add nprobe NetFlow 5 pcap sample to NetFlowV5ParserTest
1 parent 0e10445 commit 7615f80

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/java/org/graylog/plugins/netflow/v5/NetFlowV5ParserTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,24 @@ public void pcap_pmacctd_NetFlowV5() throws Exception {
166166
}
167167
assertThat(allRecords).hasSize(42);
168168
}
169+
170+
@Test
171+
public void pcap_nprobe_NetFlowV5() throws Exception {
172+
final List<NetFlowV5Record> allRecords = new ArrayList<>();
173+
try (InputStream inputStream = Resources.getResource("netflow-data/nprobe-netflow5.pcap").openStream()) {
174+
final Pcap pcap = Pcap.openStream(inputStream);
175+
pcap.loop(packet -> {
176+
if (packet.hasProtocol(Protocol.UDP)) {
177+
final UDPPacket udp = (UDPPacket) packet.getPacket(Protocol.UDP);
178+
final ByteBuf byteBuf = Unpooled.wrappedBuffer(udp.getPayload().getArray());
179+
final NetFlowV5Packet netFlowV5Packet = NetFlowV5Parser.parsePacket(byteBuf);
180+
assertThat(netFlowV5Packet).isNotNull();
181+
allRecords.addAll(netFlowV5Packet.records());
182+
}
183+
return true;
184+
}
185+
);
186+
}
187+
assertThat(allRecords).hasSize(120);
188+
}
169189
}

0 commit comments

Comments
 (0)