diff --git a/tools/etcpmon/etcpmon_client.c b/tools/etcpmon/etcpmon_client.c index 2967fdfd..690a1071 100644 --- a/tools/etcpmon/etcpmon_client.c +++ b/tools/etcpmon/etcpmon_client.c @@ -1048,17 +1048,18 @@ void etcpmon_client_add_to_history(struct etcpmon_client* client, struct etcpmon struct metrics_history* h = &client->history; int idx = h->head; + for (int metric = 0; metric < GRAPH_METRIC_COUNT; metric++) h->values[metric][idx] = 0; /* BBR per-link metrics (use first link as representative) */ if (client->last_links_count > 0 && client->last_links) { struct etcpmon_link_metrics* l = &client->last_links[0]; - h->values[GRAPH_METRIC_INFLIGHT_BYTES][idx] = l->inflight_bytes / 1024.f; - h->values[GRAPH_METRIC_INFLIGHT_LIM][idx] = l->inflight_lim_bytes / 1024.f; + h->values[GRAPH_METRIC_INFLIGHT_BYTES][idx] = (float)l->inflight_bytes; + h->values[GRAPH_METRIC_INFLIGHT_LIM][idx] = (float)l->inflight_lim_bytes; h->values[GRAPH_METRIC_MIN_RTT][idx] = l->bbr_min_rtt_us / 1000.f; - h->values[GRAPH_METRIC_BW_HI][idx] = l->bbr_bw_hi / 125.f; - h->values[GRAPH_METRIC_PACING_RATE][idx] = l->bbr_pacing_rate / 125.f; - h->values[GRAPH_METRIC_BW_LO][idx] = l->bbr_bw_lo / 125.f; - h->values[GRAPH_METRIC_INFLIGHT_HI][idx] = l->bbr_inflight_hi / 1024.f; + h->values[GRAPH_METRIC_BW_HI][idx] = (float)l->bbr_bw_hi; + h->values[GRAPH_METRIC_PACING_RATE][idx] = (float)l->bbr_pacing_rate; + h->values[GRAPH_METRIC_BW_LO][idx] = (float)l->bbr_bw_lo; + h->values[GRAPH_METRIC_INFLIGHT_HI][idx] = (float)l->bbr_inflight_hi; h->values[GRAPH_METRIC_BBR_MODE][idx] = (float)l->bbr_mode; } diff --git a/tools/etcpmon/etcpmon_graph.c b/tools/etcpmon/etcpmon_graph.c index c6d5a66e..4d34a565 100644 --- a/tools/etcpmon/etcpmon_graph.c +++ b/tools/etcpmon/etcpmon_graph.c @@ -153,24 +153,24 @@ void UpdateChannelValues(struct etcpmon_app* app, int history_idx) { if (!app || !app->client) return; struct metrics_history* h = etcpmon_client_get_history(app->client); - if (!h || history_idx < 0 || history_idx >= GRAPH_HISTORY_SIZE) { + if (!h || !h->count || history_idx < 0 || history_idx >= GRAPH_HISTORY_SIZE) { for (int i = 0; i < GRAPH_METRICS_COUNT; i++) { if (app->hChannelValue[i]) SetWindowTextA(app->hChannelValue[i], "-"); } return; } - static char last_text[GRAPH_METRICS_COUNT][32] = {0}; for (int i = 0; i < GRAPH_METRICS_COUNT; i++) { if (!app->hChannelValue[i]) continue; float val = h->values[i][history_idx]; char buf[32] = {0}; if (i == GRAPH_METRIC_BW_HI || i == GRAPH_METRIC_BW_LO || i == GRAPH_METRIC_PACING_RATE) { - if (val >= 1024) snprintf(buf, sizeof(buf), "%.1f MB/s", val/1024.); - else snprintf(buf, sizeof(buf), "%.1f KB/s", val); + if (val >= 1024*1024) snprintf(buf, sizeof(buf), "%.1f MiB/s", val/(1024.*1024.)); + else if (val >= 1024) snprintf(buf, sizeof(buf), "%.1f KiB/s", val/1024.); + else snprintf(buf, sizeof(buf), "%.0f B/s", val); } else if (i == GRAPH_METRIC_INFLIGHT_BYTES || i == GRAPH_METRIC_INFLIGHT_LIM || i == GRAPH_METRIC_INFLIGHT_HI) { - if (val >= 1024*1024) snprintf(buf, sizeof(buf), "%.1f MB", val/(1024.*1024.)); - else if (val >= 1024) snprintf(buf, sizeof(buf), "%.1f KB", val/1024.); + if (val >= 1024*1024) snprintf(buf, sizeof(buf), "%.1f MiB", val/(1024.*1024.)); + else if (val >= 1024) snprintf(buf, sizeof(buf), "%.1f KiB", val/1024.); else snprintf(buf, sizeof(buf), "%.0f B", val); } else if (i == GRAPH_METRIC_MIN_RTT) { snprintf(buf, sizeof(buf), "%.1f ms", val); @@ -181,9 +181,9 @@ void UpdateChannelValues(struct etcpmon_app* app, int history_idx) } else { snprintf(buf, sizeof(buf), "%.1f", val); } - if (strcmp(buf, last_text[i]) == 0) - continue; - strcpy(last_text[i], buf); + char current[32]; + GetWindowTextA(app->hChannelValue[i], current, sizeof(current)); + if (strcmp(buf, current) == 0) continue; SendMessageA(app->hChannelValue[i], WM_SETREDRAW, FALSE, 0); SetWindowTextA(app->hChannelValue[i], buf); SendMessageA(app->hChannelValue[i], WM_SETREDRAW, TRUE, 0); diff --git a/tools/etcpmon/etcpmon_gui.c b/tools/etcpmon/etcpmon_gui.c index 5750d8d1..fec845c9 100644 --- a/tools/etcpmon/etcpmon_gui.c +++ b/tools/etcpmon/etcpmon_gui.c @@ -1792,18 +1792,18 @@ void etcpmon_gui_update_metrics(struct etcpmon_app* app, const char* mode_names[] = {"STARTUP","DRAIN","PROBE_BW","PROBE_RTT"}; const char* cycle_names[] = {"UP","DOWN","CRUISE","REFILL"}; snprintf(line3, sizeof(line3), - " BBR: mode=%s cycle=%s full_bw=%s loss=%s pace=%.1f KB/s rtt=%u us gain=%.2f", + " BBR: mode=%s cycle=%s full_bw=%s loss=%s pace=%.1f KiB/s rtt=%u us gain=%.2f", mode_names[links[i].bbr_mode > 3 ? 0 : links[i].bbr_mode], cycle_names[links[i].bbr_cycle_idx > 3 ? 0 : links[i].bbr_cycle_idx], links[i].bbr_full_bw_reached ? "yes" : "no", links[i].bbr_loss_in_round ? "yes" : "no", - (float)links[i].bbr_pacing_rate / 125.0f, + (float)links[i].bbr_pacing_rate / 1024.0f, links[i].bbr_min_rtt_us, (float)links[i].bbr_pacing_gain / 256.0f); snprintf(line4, sizeof(line4), - " bwHi=%.1f KB/s bwLo=%.1f KB/s infHi=%u infLo=%u", - (float)links[i].bbr_bw_hi / 125.0f, - (float)links[i].bbr_bw_lo / 125.0f, + " bwHi=%.1f KiB/s bwLo=%.1f KiB/s infHi=%u infLo=%u", + (float)links[i].bbr_bw_hi / 1024.0f, + (float)links[i].bbr_bw_lo / 1024.0f, links[i].bbr_inflight_hi, links[i].bbr_inflight_lo);