@Override
    public byte[] serialize() {

        byte[] payloadData = null;
        if (this.payload != null) {
            this.payload.setParent(this);
            payloadData = this.payload.serialize();
        }

        int length = VXLAN_HEADER_LENGTH + (payloadData == null ? 0 : payloadData.length);

        final byte[] data = new byte[length];
        final ByteBuffer bb = ByteBuffer.wrap(data);
        bb.put(this.flags);
        bb.put(this.rsvd1);
        bb.put(this.vni);
        bb.put(this.rsvd2);
        if (payloadData != null) {
            bb.put(payloadData);
        }

        return data;
    }
@Test
    public void testSerialize() {
        VXLAN vxlan = new VXLAN();
        vxlan.setFlag((byte) TEST_FLAGS);
        vxlan.setVni(TEST_VNI1);
        vxlan.setParent(UDP_HDR);
        assertArrayEquals("Serialized packet is not matched", BYTE_PACKET_VXLAN, vxlan.serialize());
    }