code: public final ByteBuffer serialize () throws InternetSCSIException , IOException {
  
          basicHeaderSegment.getParser().checkIntegrity();
  
          final ByteBuffer pdu = ByteBuffer.allocate(calcSize());
  
          int offset = 0;
          offset += basicHeaderSegment.serialize(pdu, offset);
  
          if (LOGGER.isTraceEnabled()) {
              LOGGER.trace("Serialized Basic Header Segment:\n" + toString());
          }
  
          offset += serializeAdditionalHeaderSegments(pdu, offset);
          
          // write header digest
          // TODO: Move CRC calculation in BasicHeaderSegment.serialize?
          if (basicHeaderSegment.getParser().canHaveDigests()) {
              offset += serializeDigest(pdu, headerDigest);
          }
  
          // serialize data segment
          offset += serializeDataSegment(pdu, offset);
  
          // write data segment digest
          // TODO: Move CRC calculation in BasicHeaderSegment.serialize?
          if (basicHeaderSegment.getParser().canHaveDigests()) {
              offset += serializeDigest(pdu, dataDigest);
          }
  
          return (ByteBuffer) pdu.rewind();
      }
docs: Serialize all informations of this PDU object to its byte representation.
  
  @return The byte representation of this PDU.
  @throws InternetSCSIException If any violation of the iSCSI-Standard emerge.
  @throws IOException if an I/O error occurs.