@Test public void testFlowRecords() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); out.writeShort(5); out.writeShort(2); out.writeInt(29115718); out.writeInt(1470119622); out.writeInt(0); out.writeInt(70); out.writeByte(0); out.writeByte(0); out.writeShort(123); out.writeInt(0xa0000020); out.writeInt(0xa0000030); out.writeInt(0); out.writeShort(48); out.writeShort(80); out.writeInt(16); out.writeInt(1024); out.writeInt(464891488); out.writeInt(465851489); out.writeShort(2336); out.writeShort(1280); out.writeByte(0); out.writeByte(1); out.writeByte(16); out.writeByte(16); out.writeShort(32); out.writeShort(50); out.writeByte(1); out.writeByte(240); out.writeByte(0); out.writeByte(0); out.writeInt(0xb0010203); out.writeInt(0xc0040506); out.writeInt(0x0a000007); out.writeShort(21); out.writeShort(63); out.writeInt(1234); out.writeInt(4096); out.writeInt(464891488); out.writeInt(465851489); out.writeShort(2336); out.writeShort(1280); out.writeByte(2); out.writeByte(5); out.writeByte(17); out.writeByte(9); out.writeShort(32); out.writeShort(50); out.writeByte(24); out.writeByte(128); out.writeByte(0); out.writeByte(0); out.close(); List<TSDRLogRecord> records = parseRecords(bos.toByteArray()); assertEquals(2, records.size()); Map<String, String> attrs = toMap(records.get(0).getRecordAttributes()); assertEquals(Long.valueOf(1470119622L * 1000), records.get(0).getTimeStamp()); assertEquals(NetflowV5PacketParser.LOG_RECORD_TEXT, records.get(0).getRecordFullText()); assertEquals("5", attrs.remove("version")); assertEquals("29115718", attrs.remove("sys_uptime")); assertEquals("0", attrs.remove("unix_nsecs")); assertEquals("70", attrs.remove("flow_sequence")); assertEquals("0", attrs.remove("engine_type")); assertEquals("0", attrs.remove("engine_id")); assertEquals("123", attrs.remove("sampling_interval")); assertEquals("160.0.0.32", attrs.remove("srcaddr")); assertEquals("160.0.0.48", attrs.remove("dstaddr")); assertEquals("0.0.0.0", attrs.remove("nexthop")); assertEquals("48", attrs.remove("input")); assertEquals("80", attrs.remove("output")); assertEquals("16", attrs.remove("dPkts")); assertEquals("1024", attrs.remove("dOctets")); assertEquals("464891488", attrs.remove("first")); assertEquals("465851489", attrs.remove("last")); assertEquals("2336", attrs.remove("srcport")); assertEquals("1280", attrs.remove("dstport")); assertEquals("1", attrs.remove("tcp_flags")); assertEquals("16", attrs.remove("prot")); assertEquals("16", attrs.remove("tos")); assertEquals("32", attrs.remove("src_as")); assertEquals("50", attrs.remove("dst_as")); assertEquals("1", attrs.remove("src_mask")); assertEquals("240", attrs.remove("dst_mask")); assertEquals("960001", attrs.remove("flow_duration")); assertEmpty(attrs); attrs = toMap(records.get(1).getRecordAttributes()); assertEquals(Long.valueOf(1470119622L * 1000), records.get(1).getTimeStamp()); assertEquals(NetflowV5PacketParser.LOG_RECORD_TEXT, records.get(1).getRecordFullText()); assertEquals("5", attrs.remove("version")); assertEquals("29115718", attrs.remove("sys_uptime")); assertEquals("0", attrs.remove("unix_nsecs")); assertEquals("70", attrs.remove("flow_sequence")); assertEquals("0", attrs.remove("engine_type")); assertEquals("0", attrs.remove("engine_id")); assertEquals("123", attrs.remove("sampling_interval")); assertEquals("176.1.2.3", attrs.remove("srcaddr")); assertEquals("192.4.5.6", attrs.remove("dstaddr")); assertEquals("10.0.0.7", attrs.remove("nexthop")); assertEquals("21", attrs.remove("input")); assertEquals("63", attrs.remove("output")); assertEquals("1234", attrs.remove("dPkts")); assertEquals("4096", attrs.remove("dOctets")); assertEquals("464891488", attrs.remove("first")); assertEquals("465851489", attrs.remove("last")); assertEquals("2336", attrs.remove("srcport")); assertEquals("1280", attrs.remove("dstport")); assertEquals("5", attrs.remove("tcp_flags")); assertEquals("17", attrs.remove("prot")); assertEquals("9", attrs.remove("tos")); assertEquals("32", attrs.remove("src_as")); assertEquals("50", attrs.remove("dst_as")); assertEquals("24", attrs.remove("src_mask")); assertEquals("128", attrs.remove("dst_mask")); assertEquals("960001", attrs.remove("flow_duration")); assertEmpty(attrs); }
@Override public void parseRecords() { for (int i = 0; i < totalRecordCount; i++) { parseNextRecord(); } }
NetflowV5PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { for (int i = 0; i < totalRecordCount; i++) { parseNextRecord(); } } }
NetflowV5PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { for (int i = 0; i < totalRecordCount; i++) { parseNextRecord(); } } NetflowV5PacketParser(byte[] data, int initialPosition, TSDRLogRecordBuilder recordBuilder,
            Consumer<TSDRLogRecordBuilder> callback); }
NetflowV5PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { for (int i = 0; i < totalRecordCount; i++) { parseNextRecord(); } } NetflowV5PacketParser(byte[] data, int initialPosition, TSDRLogRecordBuilder recordBuilder,
            Consumer<TSDRLogRecordBuilder> callback); @Override void parseRecords(); }
NetflowV5PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { for (int i = 0; i < totalRecordCount; i++) { parseNextRecord(); } } NetflowV5PacketParser(byte[] data, int initialPosition, TSDRLogRecordBuilder recordBuilder,
            Consumer<TSDRLogRecordBuilder> callback); @Override void parseRecords();  }