static void dissect_serialized_data(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset,
                        int  size, const char *label, guint16 vendor_id, gboolean is_discovery_data,
                        endpoint_guid * guid, gint32 frag_number /* -1 if no fragmentation */) {
  proto_item *ti;
  proto_tree *rtps_parameter_sequence_tree;
  guint16 encapsulation_id;
  gboolean try_dissection_from_type_object = FALSE;
  guint encapsulation_encoding = ENC_BIG_ENDIAN;
  rtps_dissector_data * data = wmem_new(wmem_packet_scope(), rtps_dissector_data);
  data->info_displayed = FALSE;
  data->encapsulation_id = 0;
  data->position_in_batch = -1;
  /* Creates the sub-tree */
  rtps_parameter_sequence_tree = proto_tree_add_subtree(tree, tvb, offset, size,
          ett_rtps_serialized_data, &ti, label);
  if (frag_number > 1) {
    /* if the data is a fragment and not the first fragment, simply dissect the
       content as raw bytes */
    proto_tree_add_item(rtps_parameter_sequence_tree, hf_rtps_issue_data, tvb,
            offset, size, ENC_NA);
  } else {
    /* This logic applies to data that is not a fragment (-1) or is the first fragment */
    /* Encapsulation ID */
    encapsulation_id =  tvb_get_ntohs(tvb, offset);   /* Always big endian */
    proto_tree_add_uint(rtps_parameter_sequence_tree,
            hf_rtps_param_serialize_encap_kind, tvb, offset, 2, encapsulation_id);
    data->encapsulation_id = encapsulation_id;
    offset += 2;

    /* Sets the correct values for encapsulation_le */
    if (encapsulation_id == ENCAPSULATION_CDR_LE ||
        encapsulation_id == ENCAPSULATION_PL_CDR_LE ||
        encapsulation_id == ENCAPSULATION_CDR2_LE ||
        encapsulation_id == ENCAPSULATION_D_CDR2_LE ||
        encapsulation_id == ENCAPSULATION_PL_CDR2_LE) {
      encapsulation_encoding = ENC_LITTLE_ENDIAN;
    }

    /* Encapsulation length (or option) */
    proto_tree_add_item(rtps_parameter_sequence_tree, hf_rtps_param_serialize_encap_len, tvb, offset, 2, ENC_BIG_ENDIAN);
    offset += 2;

    /* Add Topic Information if enabled (checked inside). This call attemps to dissect
     * the sample and will return TRUE if it did. We should return in that case.*/
    if (encapsulation_id == ENCAPSULATION_CDR_LE ||
        encapsulation_id == ENCAPSULATION_CDR_BE ||
        encapsulation_id == ENCAPSULATION_PL_CDR_LE ||
        encapsulation_id == ENCAPSULATION_PL_CDR_BE) {
      try_dissection_from_type_object = TRUE;
    }
    if (rtps_util_topic_info_add_column_info_and_try_dissector(rtps_parameter_sequence_tree,
            pinfo, tvb, offset, guid, data, encapsulation_encoding, try_dissection_from_type_object))
      return;

    /* The payload */
    size -= 4;
    switch (encapsulation_id) {
      /* CDR_LE and CDR_BE data should be dissected like this if it is a fragment or
         if it is not */
      case ENCAPSULATION_CDR_LE:
      case ENCAPSULATION_CDR_BE:
          proto_tree_add_item(rtps_parameter_sequence_tree, hf_rtps_issue_data, tvb,
              offset, size, ENC_NA);
          break;

      case ENCAPSULATION_PL_CDR_LE:
      case ENCAPSULATION_PL_CDR_BE:
          if (is_discovery_data) {
              dissect_parameter_sequence(rtps_parameter_sequence_tree, pinfo, tvb, offset,
                  encapsulation_encoding, size, "serializedData", 0x0200, NULL, vendor_id, FALSE, NULL);
          } else if (frag_number != NOT_A_FRAGMENT) {
              /* fragments should be dissected as raw bytes (not parametrized) */
              proto_tree_add_item(rtps_parameter_sequence_tree, hf_rtps_issue_data, tvb,
                  offset, size, ENC_NA);
              break;
          } else {
              /* Instead of showing a warning like before, we now dissect the data as
               * (id - length - value) members */
              dissect_parametrized_serialized_data(rtps_parameter_sequence_tree,
                      tvb, offset, size, encapsulation_encoding);
          }
          break;

      default:
      proto_tree_add_item(rtps_parameter_sequence_tree, hf_rtps_data_serialize_data, tvb,
              offset, size, ENC_NA);
    }
  }
}