-/* 1000 + one "infinity" bucket. */
-#define OPING_HISTOGRAM_BUCKETS 1001
- uint32_t *histogram_counters;
- uint32_t *histogram_accumulated;
- double *histogram_ratio;
- size_t latency_histogram_size;
+#ifndef HISTORY_SIZE_MAX
+# define HISTORY_SIZE_MAX 900
+#endif
+ /* The last n RTTs in the order they were sent. */
+ double history_by_time[HISTORY_SIZE_MAX];
+
+ /* Current number of entries in the history. This is a value between 0
+ * and HISTORY_SIZE_MAX. */
+ size_t history_size;
+
+ /* Total number of reponses received. */
+ size_t history_received;
+
+ /* Index of the next RTT to be written to history_by_time. This wraps
+ * around to 0 once the histroty has grown to HISTORY_SIZE_MAX. */
+ size_t history_index;
+
+ /* The last history_size RTTs sorted by value. timed out packets (NAN
+ * entries) are sorted to the back. */
+ double history_by_value[HISTORY_SIZE_MAX];
+
+ /* If set to true, history_by_value has to be re-calculated. */
+ _Bool history_dirty;