From 4e33842c1e765d21fc965a1047717f5769356f50 Mon Sep 17 00:00:00 2001 From: Vittorio Palmisano Date: Tue, 18 Jan 2022 18:32:49 +0100 Subject: [PATCH] Apply packetLoss also to up interface If should work (tested running `tc` manually) as already done with the `down` interface. --- lib/tc.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/tc.js b/lib/tc.js index 126a0a6..756fee4 100644 --- a/lib/tc.js +++ b/lib/tc.js @@ -84,7 +84,7 @@ async function setLimits(up, down, halfWayRTT, packetLoss, iFace) { await sudo.apply(this, params); } if (up) { - await sudo( + const params = [ 'tc', 'qdisc', 'add', @@ -98,7 +98,13 @@ async function setLimits(up, down, halfWayRTT, packetLoss, iFace) { `${halfWayRTT}ms`, 'rate', `${up}kbit` - ); + ]; + + if (packetLoss) { + params.push('loss', `${packetLoss}%`); + } + + await sudo.apply(this, params); } if (!up && !down && halfWayRTT > 0) {