public MessageDescription shallowParseMessage(ByteBuf packet) {
        final ByteBuf buffer = packet.readSlice(MessageHeader.LENGTH);
        LOG.debug("Shallow parse header\n{}", ByteBufUtil.prettyHexDump(buffer));
        final MessageHeader header = parseMessageHeader(buffer);
        final MessageDescription messageDescription = new MessageDescription(header);

        // sanity check: we need the complete packet in the buffer
        if (header.length() != packet.readableBytes() + MessageHeader.LENGTH) {
            throw new IllegalArgumentException("Buffer does not contain the complete IPFIX message");
        }
        // loop over all the contained sets in the message
        while (packet.isReadable()) {
            final int setId = packet.readUnsignedShort();
            final int setLength = packet.readUnsignedShort();
            // the buffer limited to the declared length of the set.
            final ByteBuf setContent = packet.readSlice(setLength - 4);
            switch (setId) {
                case 0:
                case 1:
                    throw new IpfixException("Invalid set id in IPFIX message: " + setId);
                case 2:
                    final ShallowTemplateSet templateSet = shallowParseTemplateSet(setContent);
                    messageDescription.addTemplateSet(templateSet);
                    break;
                case 3:
                    final ShallowOptionsTemplateSet optionsTemplateSet = shallowParseOptionsTemplateSet(setContent);
                    messageDescription.addOptionsTemplateSet(optionsTemplateSet);
                    break;
                default:
                    final ShallowDataSet dataSet = shallowParseDataSet(setId, setLength, setContent, header.exportTime());
                    messageDescription.addDataSet(dataSet);
                    break;
            }
        }
        return messageDescription;
    }
@Test
    public void notIpfixMessage() throws IOException {
        final ByteBuf packet = Utils.readPacket("netflow-v9.dat");
        try {
            new IpfixParser(definitions).shallowParseMessage(packet);
            fail("Wrong netflow version");
        } catch (InvalidMessageVersion e) {
            assertThat(e).hasMessageContaining("9");
        } catch (Exception e) {
            fail("Unexpected exception thrown", e);
        }
    }