public static NetFlowV5Packet parsePacket(ByteBuf bb) {
        final int readableBytes = bb.readableBytes();

        final NetFlowV5Header header = parseHeader(bb.slice(bb.readerIndex(), HEADER_LENGTH));
        final int packetLength = HEADER_LENGTH + header.count() * RECORD_LENGTH;
        if (header.count() <= 0 || readableBytes < packetLength) {
            throw new CorruptFlowPacketException("Insufficient data (expected: " + packetLength + " bytes, actual: " + readableBytes + " bytes)");
        }

        final ImmutableList.Builder<NetFlowV5Record> records = ImmutableList.builder();
        int offset = HEADER_LENGTH;
        for (int i = 0; i < header.count(); i++) {
            records.add(parseRecord(bb.slice(offset + bb.readerIndex(), RECORD_LENGTH)));
            offset += RECORD_LENGTH;
        }

        return NetFlowV5Packet.create(header, records.build(), offset);
    }
@Test
    public void testParse2() throws IOException {
        final byte[] b = Resources.toByteArray(Resources.getResource("netflow-data/netflow-v5-2.dat"));
        NetFlowV5Packet packet = NetFlowV5Parser.parsePacket(Unpooled.wrappedBuffer(b));
        assertNotNull(packet);

        NetFlowV5Header h = packet.header();
        assertEquals(5, h.version());
        assertEquals(30, h.count());
        assertEquals(234994, h.sysUptime());
        assertEquals(1369017138, h.unixSecs());
        assertEquals(805, h.unixNsecs());

        assertEquals(30, packet.records().size());
        final NetFlowV5Record r = packet.records().get(0);
        assertEquals(InetAddresses.forString("192.168.124.20"), r.dstAddr());
        assertEquals(6, r.protocol());
        assertEquals(0, r.srcAs());
        assertEquals(InetAddresses.forString("14.63.211.15"), r.srcAddr());
        assertEquals(202992L, r.last());
        assertEquals(47994, r.dstPort());
        assertEquals(317221L, r.octetCount());
        assertEquals(80, r.srcPort());
        assertEquals(0, r.srcMask());
        assertEquals(0, r.tos());
        assertEquals(0, r.inputIface());
        assertEquals(InetAddresses.forString("0.0.0.0"), r.nextHop());
        assertEquals(27, r.tcpFlags());
        assertEquals(0, r.dstAs());
        assertEquals(0, r.outputIface());
        assertEquals(202473L, r.first());
        assertEquals(0, r.dstMask());
        assertEquals(110L, r.packetCount());
    }