static void megacostat_draw(void *pms) { megacostat_t *ms=(megacostat_t *)pms; int i; /* printing results */ printf("\n"); printf("=====================================================================================================\n"); printf("MEGACO Response Time Delay (RTD) Statistics:\n"); printf("Filter for statistics: %s\n",ms->filter?ms->filter:""); printf("Duplicate requests: %u\n",ms->req_dup_num); printf("Duplicate responses: %u\n",ms->rsp_dup_num); printf("Open requests: %u\n",ms->open_req_num); printf("Discarded responses: %u\n",ms->disc_rsp_num); printf(" Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame |\n"); for(i=0;i<NUM_TIMESTATS;i++) { if(ms->rtd[i].num) { printf("%5s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u |\n", val_to_str(i,megaco_message_type,"Other"),ms->rtd[i].num, nstime_to_msec(&(ms->rtd[i].min)), nstime_to_msec(&(ms->rtd[i].max)), get_average(&(ms->rtd[i].tot), ms->rtd[i].num), ms->rtd[i].min_num, ms->rtd[i].max_num ); } } printf("=====================================================================================================\n"); }
static void megacostat_draw(void *pms) { megacostat_t *ms=(megacostat_t *)pms; int i; char *str[7]; for(i=0; i<7; i++) { str[i]=g_malloc(sizeof(char[256])); } /* clear list before printing */ gtk_clist_clear(ms->table); for(i=0; i<NUM_TIMESTATS; i++) { /* nothing seen, nothing to do */ if(ms->rtd[i].num==0) { continue; } g_snprintf(str[0], sizeof(char[256]), "%s", val_to_str(i,megaco_message_type,"Other")); g_snprintf(str[1], sizeof(char[256]), "%d", ms->rtd[i].num); g_snprintf(str[2], sizeof(char[256]), "%8.2f msec", nstime_to_msec(&(ms->rtd[i].min))); g_snprintf(str[3], sizeof(char[256]), "%8.2f msec", nstime_to_msec(&(ms->rtd[i].max))); g_snprintf(str[4], sizeof(char[256]), "%8.2f msec", get_average(&(ms->rtd[i].tot), ms->rtd[i].num)); g_snprintf(str[5], sizeof(char[256]), "%6u", ms->rtd[i].min_num); g_snprintf(str[6], sizeof(char[256]), "%6u", ms->rtd[i].max_num); gtk_clist_append(ms->table, str); } gtk_widget_show(GTK_WIDGET(ms->table)); for(i=0; i<7; i++) { g_free(str[i]); } }
static void megacostat_draw(void *pms) { megacostat_t *ms=(megacostat_t *)pms; int i; char str[3][256]; GtkListStore *store; GtkTreeIter iter; /* clear list before printing */ store = GTK_LIST_STORE(gtk_tree_view_get_model(ms->table)); gtk_list_store_clear(store); for(i=0;i<NUM_TIMESTATS;i++) { /* nothing seen, nothing to do */ if(ms->rtd[i].num==0){ continue; } g_snprintf(str[0], sizeof(char[256]), "%8.2f msec", nstime_to_msec(&(ms->rtd[i].min))); g_snprintf(str[1], sizeof(char[256]), "%8.2f msec", nstime_to_msec(&(ms->rtd[i].max))); g_snprintf(str[2], sizeof(char[256]), "%8.2f msec", get_average(&(ms->rtd[i].tot), ms->rtd[i].num)); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, val_to_str(i,megaco_message_type,"Other"), 1, ms->rtd[i].num, 2, str[0], 3, str[1], 4, str[2], 5, ms->rtd[i].min_num, 6, ms->rtd[i].max_num, -1); } }
static void rtd_draw(void *arg) { rtd_data_t* rtd_data = (rtd_data_t*)arg; rtd_t* rtd = (rtd_t*)rtd_data->user_data; gchar* tmp_str; guint i, j; /* printing results */ printf("\n"); printf("=====================================================================================================\n"); printf("%s Response Time Delay (RTD) Statistics:\n", rtd->type); printf("Filter for statistics: %s\n", rtd->filter ? rtd->filter : ""); if (rtd_data->stat_table.num_rtds == 1) { printf("Duplicate requests: %u\n", rtd_data->stat_table.time_stats[0].req_dup_num); printf("Duplicate responses: %u\n", rtd_data->stat_table.time_stats[0].rsp_dup_num); printf("Open requests: %u\n", rtd_data->stat_table.time_stats[0].open_req_num); printf("Discarded responses: %u\n", rtd_data->stat_table.time_stats[0].disc_rsp_num); printf("Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame |\n"); for (i=0; i<rtd_data->stat_table.time_stats[0].num_timestat; i++) { if (rtd_data->stat_table.time_stats[0].rtd[i].num) { tmp_str = val_to_str_wmem(NULL, i, rtd->vs_type, "Other (%d)"); printf("%s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u |\n", tmp_str, rtd_data->stat_table.time_stats[0].rtd[i].num, nstime_to_msec(&(rtd_data->stat_table.time_stats[0].rtd[i].min)), nstime_to_msec(&(rtd_data->stat_table.time_stats[0].rtd[i].max)), get_average(&(rtd_data->stat_table.time_stats[0].rtd[i].tot), rtd_data->stat_table.time_stats[0].rtd[i].num), rtd_data->stat_table.time_stats[0].rtd[i].min_num, rtd_data->stat_table.time_stats[0].rtd[i].max_num ); wmem_free(NULL, tmp_str); } } } else { printf("Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame | Open Requests | Discarded responses | Duplicate requests | Duplicate responses\n"); for (i=0; i<rtd_data->stat_table.num_rtds; i++) { for (j=0; j<rtd_data->stat_table.time_stats[i].num_timestat; j++) { if (rtd_data->stat_table.time_stats[i].rtd[j].num) { tmp_str = val_to_str_wmem(NULL, i, rtd->vs_type, "Other (%d)"); printf("%s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u | %10u | %10u | %4u (%4.2f%%) | %4u (%4.2f%%) |\n", tmp_str, rtd_data->stat_table.time_stats[i].rtd[j].num, nstime_to_msec(&(rtd_data->stat_table.time_stats[i].rtd[j].min)), nstime_to_msec(&(rtd_data->stat_table.time_stats[i].rtd[j].max)), get_average(&(rtd_data->stat_table.time_stats[i].rtd[j].tot), rtd_data->stat_table.time_stats[i].rtd[j].num), rtd_data->stat_table.time_stats[i].rtd[j].min_num, rtd_data->stat_table.time_stats[i].rtd[j].max_num, rtd_data->stat_table.time_stats[i].open_req_num, rtd_data->stat_table.time_stats[i].disc_rsp_num, rtd_data->stat_table.time_stats[i].req_dup_num, rtd_data->stat_table.time_stats[i].rtd[j].num?((double)rtd_data->stat_table.time_stats[i].req_dup_num*100)/(double)rtd_data->stat_table.time_stats[i].rtd[j].num:0, rtd_data->stat_table.time_stats[i].rsp_dup_num, rtd_data->stat_table.time_stats[i].rtd[j].num?((double)rtd_data->stat_table.time_stats[i].rsp_dup_num*100)/(double)rtd_data->stat_table.time_stats[i].rtd[j].num:0 ); wmem_free(NULL, tmp_str); } } } } printf("=====================================================================================================\n"); }
static void remove_old_requests(ipmi_packet_data_t * data, const nstime_t * curr_time) { wmem_list_frame_t * iter = wmem_list_head(data->request_list); while (iter) { ipmi_request_t * rq = (ipmi_request_t *) wmem_list_frame_data(iter); ipmi_frame_data_t * frame = get_frame_data(data, rq->frame_num); nstime_t delta; /* calculate time delta */ nstime_delta(&delta, curr_time, &frame->ts); if (nstime_to_msec(&delta) > response_after_req) { wmem_list_frame_t * del = iter; /* proceed to next request */ iter = wmem_list_frame_next(iter); /* free request data */ wmem_free(wmem_file_scope(), rq); /* remove list item */ wmem_list_remove_frame(data->request_list, del); } else { break; } } }
void nvme_publish_cmd_latency(proto_tree *tree, struct nvme_cmd_ctx *cmd_ctx, int field_index) { proto_item *cmd_ref_item; nstime_t ns; double cmd_latency; nstime_delta(&ns, &cmd_ctx->cmd_end_time, &cmd_ctx->cmd_start_time); cmd_latency = nstime_to_msec(&ns); cmd_ref_item = proto_tree_add_double_format_value(tree, field_index, NULL, 0, 0, cmd_latency, "%.3f ms", cmd_latency); proto_item_set_generated(cmd_ref_item); }
/* will be the tap packet cb */ extern int stats_tree_packet(void *p, packet_info *pinfo, epan_dissect_t *edt, const void *pri) { stats_tree *st = (stats_tree *)p; double now = nstime_to_msec(&pinfo->rel_ts); if (st->start < 0.0) st->start = now; st->elapsed = now - st->start; if (st->cfg->packet) return st->cfg->packet(st,pinfo,edt,pri); else return 0; }
static gint dissect_sbc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { proto_item *ti; proto_tree *sbc_tree; proto_item *pitem; proto_tree *rtree; gint offset = 0; guint8 number_of_frames; guint8 syncword; guint8 byte; guint8 blocks; guint8 channels; guint8 subbands; guint8 bitpool; guint frequency; guint8 sbc_blocks; gint sbc_channels; guint8 sbc_subbands; gint val; gint counter = 1; gint frame_length; gint expected_speed_data; gdouble frame_duration; gdouble cummulative_frame_duration = 0; bta2dp_codec_info_t *info; col_set_str(pinfo->cinfo, COL_PROTOCOL, "SBC"); info = (bta2dp_codec_info_t *) data; ti = proto_tree_add_item(tree, proto_sbc, tvb, offset, -1, ENC_NA); sbc_tree = proto_item_add_subtree(ti, ett_sbc); proto_tree_add_item(sbc_tree, hf_sbc_fragmented, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(sbc_tree, hf_sbc_starting_packet, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(sbc_tree, hf_sbc_last_packet, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(sbc_tree, hf_sbc_rfa, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(sbc_tree, hf_sbc_number_of_frames, tvb, offset, 1, ENC_BIG_ENDIAN); number_of_frames = tvb_get_guint8(tvb, offset) & 0x0F; offset += 1; while (tvb_length_remaining(tvb, offset) > 0) { byte = tvb_get_guint8(tvb, offset + 1); frequency = (byte & 0xC0) >> 6; blocks = (byte & 0x30) >> 4; channels = (byte & 0x0C)>> 2; subbands = byte & 0x01; bitpool = tvb_get_guint8(tvb, offset + 2); if (channels == CHANNELS_MONO) sbc_channels = 1; else sbc_channels = 2; switch (frequency) { case FREQUENCY_16000: frequency = 16000; break; case FREQUENCY_32000: frequency = 32000; break; case FREQUENCY_44100: frequency = 44100; break; case FREQUENCY_48000: frequency = 48000; break; default: frequency = 0; } sbc_subbands = 4 * (subbands + 1); sbc_blocks = 4 * (blocks + 1); frame_length = (4 * sbc_subbands * sbc_channels) / 8; if (sbc_channels == 1) val = sbc_blocks * sbc_channels * bitpool; else val = (((channels == CHANNELS_JOINT_STEREO) ? 1 : 0) * sbc_subbands + sbc_blocks * bitpool); frame_length += val / 8; if (val % 8) frame_length += 1; expected_speed_data = (frame_length * frequency) / (sbc_subbands * sbc_blocks); rtree = proto_tree_add_subtree_format(sbc_tree, tvb, offset, 4 + frame_length, ett_sbc_list, NULL, "Frame: %3u/%3u", counter, number_of_frames); pitem = proto_tree_add_item(rtree, hf_sbc_syncword, tvb, offset, 1, ENC_BIG_ENDIAN); syncword = tvb_get_guint8(tvb, offset); if (syncword != 0x9C) { expert_add_info(pinfo, pitem, &ei_sbc_syncword); } offset += 1; proto_tree_add_item(rtree, hf_sbc_sampling_frequency, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(rtree, hf_sbc_blocks, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(rtree, hf_sbc_channel_mode, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(rtree, hf_sbc_allocation_method, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(rtree, hf_sbc_subbands, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(rtree, hf_sbc_bitpool, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(rtree, hf_sbc_crc_check, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(rtree, hf_sbc_data, tvb, offset, frame_length, ENC_NA); offset += frame_length; /* TODO: expert_info for invalid CRC */ pitem = proto_tree_add_uint(rtree, hf_sbc_expected_data_speed, tvb, offset, 0, expected_speed_data / 1024); proto_item_append_text(pitem, " KiB/s"); PROTO_ITEM_SET_GENERATED(pitem); frame_duration = (((double) frame_length / (double) expected_speed_data) * 1000.0); cummulative_frame_duration += frame_duration; pitem = proto_tree_add_double(rtree, hf_sbc_frame_duration, tvb, offset, 0, frame_duration); proto_item_append_text(pitem, " ms"); PROTO_ITEM_SET_GENERATED(pitem); counter += 1; } pitem = proto_tree_add_double(sbc_tree, hf_sbc_cummulative_frame_duration, tvb, offset, 0, cummulative_frame_duration); proto_item_append_text(pitem, " ms"); PROTO_ITEM_SET_GENERATED(pitem); if (info && info->previous_media_packet_info && info->current_media_packet_info) { nstime_t delta; nstime_delta(&delta, &pinfo->fd->abs_ts, &info->previous_media_packet_info->abs_ts); pitem = proto_tree_add_double(sbc_tree, hf_sbc_delta_time, tvb, offset, 0, nstime_to_msec(&delta)); proto_item_append_text(pitem, " ms"); PROTO_ITEM_SET_GENERATED(pitem); nstime_delta(&delta, &pinfo->fd->abs_ts, &info->previous_media_packet_info->first_abs_ts); pitem = proto_tree_add_double(sbc_tree, hf_sbc_delta_time_from_the_beginning, tvb, offset, 0, nstime_to_msec(&delta)); proto_item_append_text(pitem, " ms"); PROTO_ITEM_SET_GENERATED(pitem); if (!pinfo->fd->flags.visited) info->current_media_packet_info->cummulative_frame_duration += cummulative_frame_duration; pitem = proto_tree_add_double(sbc_tree, hf_sbc_cummulative_duration, tvb, offset, 0, info->previous_media_packet_info->cummulative_frame_duration); proto_item_append_text(pitem, " ms"); PROTO_ITEM_SET_GENERATED(pitem); pitem = proto_tree_add_double(sbc_tree, hf_sbc_diff, tvb, offset, 0, info->previous_media_packet_info->cummulative_frame_duration - nstime_to_msec(&delta)); proto_item_append_text(pitem, " ms"); PROTO_ITEM_SET_GENERATED(pitem); } /* TODO: more precise dissection: blocks, channels, subbands, padding */ col_append_fstr(pinfo->cinfo, COL_INFO, " Frames=%u", number_of_frames); return offset; }
// Adapted from get_it_value in gtk/io_stat.c. double get_io_graph_item(const io_graph_item_t *items_, io_graph_item_unit_t val_units_, int idx, int hf_index_, const capture_file *cap_file, int interval_, int cur_idx_) { double value = 0; /* FIXME: loss of precision, visible on the graph for small values */ int adv_type; const io_graph_item_t *item; guint32 interval; item = &items_[idx]; // Basic units switch (val_units_) { case IOG_ITEM_UNIT_PACKETS: return item->frames; case IOG_ITEM_UNIT_BYTES: return (double) item->bytes; case IOG_ITEM_UNIT_BITS: return (double) (item->bytes * 8); case IOG_ITEM_UNIT_CALC_FRAMES: return item->frames; case IOG_ITEM_UNIT_CALC_FIELDS: return (double) item->fields; default: /* If it's COUNT_TYPE_ADVANCED but not one of the * generic ones we'll get it when we switch on the * adv_type below. */ break; } if (hf_index_ < 0) { return 0; } // Advanced units adv_type = proto_registrar_get_ftype(hf_index_); switch (adv_type) { case FT_UINT8: case FT_UINT16: case FT_UINT24: case FT_UINT32: case FT_UINT64: case FT_INT8: case FT_INT16: case FT_INT24: case FT_INT32: case FT_INT64: switch (val_units_) { case IOG_ITEM_UNIT_CALC_SUM: value = (double) item->int_tot; break; case IOG_ITEM_UNIT_CALC_MAX: value = (double) item->int_max; break; case IOG_ITEM_UNIT_CALC_MIN: value = (double) item->int_min; break; case IOG_ITEM_UNIT_CALC_AVERAGE: if (item->fields) { value = (double)item->int_tot / item->fields; } else { value = 0; } break; default: break; } break; case FT_FLOAT: switch (val_units_) { case IOG_ITEM_UNIT_CALC_SUM: value = item->float_tot; break; case IOG_ITEM_UNIT_CALC_MAX: value = item->float_max; break; case IOG_ITEM_UNIT_CALC_MIN: value = item->float_min; break; case IOG_ITEM_UNIT_CALC_AVERAGE: if (item->fields) { value = (double)item->float_tot / item->fields; } else { value = 0; } break; default: break; } break; case FT_DOUBLE: switch (val_units_) { case IOG_ITEM_UNIT_CALC_SUM: value = item->double_tot; break; case IOG_ITEM_UNIT_CALC_MAX: value = item->double_max; break; case IOG_ITEM_UNIT_CALC_MIN: value = item->double_min; break; case IOG_ITEM_UNIT_CALC_AVERAGE: if (item->fields) { value = item->double_tot / item->fields; } else { value = 0; } break; default: break; } break; case FT_RELATIVE_TIME: switch (val_units_) { case IOG_ITEM_UNIT_CALC_MAX: value = nstime_to_sec(&item->time_max); break; case IOG_ITEM_UNIT_CALC_MIN: value = nstime_to_sec(&item->time_min); break; case IOG_ITEM_UNIT_CALC_SUM: value = nstime_to_sec(&item->time_tot); break; case IOG_ITEM_UNIT_CALC_AVERAGE: if (item->fields) { value = nstime_to_sec(&item->time_tot) / item->fields; } else { value = 0; } break; case IOG_ITEM_UNIT_CALC_LOAD: // "LOAD graphs plot the QUEUE-depth of the connection over time" // (for response time fields such as smb.time, rpc.time, etc.) // This interval is expressed in milliseconds. if (idx == cur_idx_ && cap_file) { interval = (guint32)(nstime_to_msec(&cap_file->elapsed_time) + 0.5); interval -= (interval_ * idx); } else { interval = interval_; } value = nstime_to_msec(&item->time_tot) / interval; break; default: break; } break; default: break; } return value; }