| 100 | } |
| 101 | |
| 102 | void Measure::ProcessBatch(Context *ctx, bess::PacketBatch *batch) { |
| 103 | // We don't use ctx->current_ns here for better accuracy |
| 104 | uint64_t now_ns = tsc_to_ns(rdtsc()); |
| 105 | size_t offset = offset_; |
| 106 | |
| 107 | mcslock_node_t mynode; |
| 108 | mcs_lock(&lock_, &mynode); |
| 109 | |
| 110 | pkt_cnt_ += batch->cnt(); |
| 111 | |
| 112 | int cnt = batch->cnt(); |
| 113 | for (int i = 0; i < cnt; i++) { |
| 114 | uint64_t pkt_time; |
| 115 | if (IsTimestamped(batch->pkts()[i], offset, &pkt_time)) { |
| 116 | uint64_t diff; |
| 117 | |
| 118 | if (now_ns >= pkt_time) { |
| 119 | diff = now_ns - pkt_time; |
| 120 | } else { |
| 121 | // The magic number matched, but timestamp doesn't seem correct |
| 122 | continue; |
| 123 | } |
| 124 | |
| 125 | bytes_cnt_ += batch->pkts()[i]->total_len(); |
| 126 | |
| 127 | rtt_hist_.Insert(diff); |
| 128 | if (rand_.GetRealNonzero() <= jitter_sample_prob_) { |
| 129 | if (unlikely(!last_rtt_ns_)) { |
| 130 | last_rtt_ns_ = diff; |
| 131 | continue; |
| 132 | } |
| 133 | uint64_t jitter = absdiff(diff, last_rtt_ns_); |
| 134 | jitter_hist_.Insert(jitter); |
| 135 | last_rtt_ns_ = diff; |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | mcs_unlock(&lock_, &mynode); |
| 141 | |
| 142 | RunNextModule(ctx, batch); |
| 143 | } |
| 144 | |
| 145 | template <typename T> |
| 146 | static void SetHistogram( |
nothing calls this directly
no test coverage detected