MCPcopy Create free account
hub / github.com/NetSys/bess / ProcessBatch

Method ProcessBatch

core/modules/measure.cc:102–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102void 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
145template <typename T>
146static void SetHistogram(

Callers

nothing calls this directly

Calls 11

tsc_to_nsFunction · 0.85
rdtscFunction · 0.85
mcs_lockFunction · 0.85
IsTimestampedFunction · 0.85
absdiffFunction · 0.85
mcs_unlockFunction · 0.85
total_lenMethod · 0.80
GetRealNonzeroMethod · 0.80
cntMethod · 0.45
pktsMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected