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
boban 2026-06-21 00:04:07 +02:00
parent 130e1aeaf6
commit 49f70c0c9f
2 changed files with 4 additions and 2 deletions

View File

@ -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];

View File

@ -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']);
}