fix(wg): WgTraffic up = throughput delta (not raw tx) — consistent with down
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>feat/v1-foundation
parent
130e1aeaf6
commit
49f70c0c9f
|
|
@ -42,7 +42,7 @@ class WgTraffic
|
|||
$idx = (int) floor(($t - $from) / $width);
|
||||
if ($idx >= 0 && $idx < $buckets) {
|
||||
$down[$idx] += $dRx;
|
||||
$up[$idx] += (int) $r->tx;
|
||||
$up[$idx] += $dTx;
|
||||
}
|
||||
}
|
||||
$prev[$pk] = ['rx' => (int) $r->rx, 'tx' => (int) $r->tx];
|
||||
|
|
|
|||
|
|
@ -37,8 +37,10 @@ class WgTrafficTest extends TestCase
|
|||
$this->sample('B', 50, 5, 600);
|
||||
|
||||
$s = app(WgTraffic::class)->series(3600, 6);
|
||||
// Both directions are THROUGHPUT (sum of positive per-peer deltas), not raw counters:
|
||||
// down = A(100+200)+B(50) = 350 ; up = A(10+20)+B(5) = 35.
|
||||
$this->assertSame(350, $s['total_down']);
|
||||
$this->assertSame(45, $s['total_up']);
|
||||
$this->assertSame(35, $s['total_up']);
|
||||
$this->assertGreaterThan(0, $s['peak_down']);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue