code: public MessagePacker packExtensionTypeHeader(byte extType, int payloadLen)
              throws IOException
      {
          if (payloadLen < (1 << 8)) {
              if (payloadLen > 0 && (payloadLen & (payloadLen - 1)) == 0) { // check whether dataLen == 2^x
                  if (payloadLen == 1) {
                      writeByteAndByte(FIXEXT1, extType);
                  }
                  else if (payloadLen == 2) {
                      writeByteAndByte(FIXEXT2, extType);
                  }
                  else if (payloadLen == 4) {
                      writeByteAndByte(FIXEXT4, extType);
                  }
                  else if (payloadLen == 8) {
                      writeByteAndByte(FIXEXT8, extType);
                  }
                  else if (payloadLen == 16) {
                      writeByteAndByte(FIXEXT16, extType);
                  }
                  else {
                      writeByteAndByte(EXT8, (byte) payloadLen);
                      writeByte(extType);
                  }
              }
              else {
                  writeByteAndByte(EXT8, (byte) payloadLen);
                  writeByte(extType);
              }
          }
          else if (payloadLen < (1 << 16)) {
              writeByteAndShort(EXT16, (short) payloadLen);
              writeByte(extType);
          }
          else {
              writeByteAndInt(EXT32, payloadLen);
              writeByte(extType);
  
              // TODO support dataLen > 2^31 - 1
          }
          return this;
      }
docs: Writes header of an Extension value.
  <p>
  You MUST call {@link #writePayload(byte[])} or {@link #addPayload(byte[])} method to write body binary.
  
  @param extType the extension type tag to be written
  @param payloadLen number of bytes of a payload binary to be written
  @return this
  @throws IOException when underlying output throws IOException