// TODO: use rotating hash map void handleResponse() { // row is a response, so address of server = sourceip TidData dummy(transaction_id.val(), sourceip.val(), destip.val()); TidData *t = pending1->lookup(dummy); if (t == NULL) { ++missing_request_count; } else { // we now have both request and response, so we can add latency to statistics // TODO: do the calculation in raw units and convert at the end. int64_t delay_first_raw = reqtime.valRaw() - t->first_reqtime_raw; int64_t delay_last_raw = reqtime.valRaw() - t->last_reqtime_raw; double delay_first_ms = reqtime.rawToDoubleSeconds(delay_first_raw) * 1.0e3; double delay_last_ms = reqtime.rawToDoubleSeconds(delay_last_raw) * 1.0e3; StatsData hdummy(sourceip.val(), operation.stringval()); StatsData *d = stats_table.lookup(hdummy); // add to statistics per request type and server if (d == NULL) { // create new entry hdummy.initStats(enable_first_latency_stat, enable_last_latency_stat); d = stats_table.add(hdummy); } d->add(delay_first_ms, delay_last_ms); // remove request from pending hashtable only if // we haven't seen a duplicate request. If we // have seen a duplicate request, then there might // be a duplicate reply coming if (t->duplicate_count > 0) { d->duplicates->add(t->duplicate_count); if (t->seen_reply) { ++duplicate_reply_count; } else { t->seen_reply = true; } } else { pending1->remove(*t); } } }