public static Deserializer<PPPoED> deserializer() {
        return (data, offset, length) -> {
            checkInput(data, offset, length, HEADER_LENGTH);

            final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
            PPPoED pppoed = new PPPoED();
            byte versionByte = bb.get();
            pppoed.setVersion((byte) (versionByte >> 4 & 0xf));
            pppoed.setType((byte) (versionByte & 0xf));
            pppoed.setCode(bb.get());
            pppoed.setSessionId(bb.getShort());
            pppoed.setPayloadLength(bb.getShort());
            int remainingLength = pppoed.payloadLength;
            while (remainingLength > 0 && bb.hasRemaining()) {
                PPPoEDTag tag = new PPPoEDTag();
                tag.setType(bb.getShort());
                tag.setLength(bb.getShort());
                tag.value = new byte[tag.length];
                bb.get(tag.value, 0, tag.length);
                pppoed.tags.add(tag);
                remainingLength -= tag.length + TAG_HEADER_LENGTH;
            }
            return pppoed;
        };
    }
@Test
    public void testDeserializeBadInput() throws Exception {
        PacketTestUtils.testDeserializeBadInput(PPPoED.deserializer());
    }