code: @Override
      public IPv6Packet frame(final MACPacket parent, final Buffer payload) throws IOException {
          if (parent == null) {
              throw new IllegalArgumentException("The parent frame cannot be null");
          }
  
          final Buffer fixedHeader = payload.readBytes(IPv6PacketImpl.FIXED_HEADER_LENGTH);
  
          // byte 1, contains the version and the length
          final int version = (fixedHeader.getByte(0) & 0xF0) >> 4;
          if (version != IPv6Packet.VERSION_IDENTIFIER) {
              throw new FramingException(String.format("Invalid IPv6 version: %d", version), Protocol.IPv6);
          }
  
          final int payloadLength = fixedHeader.getUnsignedShort(4);
  
          int nextHeader = fixedHeader.getByte(6);
  
          final Buffer extensionHeadersBuffer = Buffers.createBuffer(400);
          while (nextHeader == IPv6Packet.EXTENSION_HOP_BY_HOP ||
                  nextHeader == IPv6Packet.EXTENSION_DESTINATION_OPTIONS ||
                  nextHeader == IPv6Packet.EXTENSION_ROUTING ||
                  nextHeader == IPv6Packet.EXTENSION_FRAGMENT ||
                  nextHeader == IPv6Packet.EXTENSION_AH ||
                  nextHeader == IPv6Packet.EXTENSION_ESP ||
                  nextHeader == IPv6Packet.EXTENSION_MOBILITY) {
              nextHeader = accumulateNextHeader(nextHeader, payload, extensionHeadersBuffer);
          }
          // TODO: extract actual PayloadLength from Hop-by-Hop extension header, if present
  
  
          // Trim off any padding from the upper layer, e.g. Ethernet padding for small packets.
          // If the captured frame was truncated, then use the truncated size for the data buffer, instead of what the
          // IPv6 header says its length should be.
          final int totalLength = IPv6PacketImpl.FIXED_HEADER_LENGTH + extensionHeadersBuffer.getWriterIndex() + payloadLength;
          final Buffer data = payload.slice(Math.min(totalLength, payload.capacity()));
          return new IPv6PacketImpl(parent, Buffers.wrap(fixedHeader, extensionHeadersBuffer), nextHeader, data);
      }
docs: {@inheritDoc}