From d3b8cc3b48c1a1ee6af980f987c98bcae9ca7753 Mon Sep 17 00:00:00 2001 From: Matthew Farejowicz Date: Mon, 8 Jul 2024 23:26:38 -0700 Subject: [PATCH 1/5] make InboundNetworkIssueDetector consistent with other detectors --- src/detectors/InboundNetworkIssueDetector.ts | 31 +++++++++----------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/detectors/InboundNetworkIssueDetector.ts b/src/detectors/InboundNetworkIssueDetector.ts index 2c4296f..19955cb 100644 --- a/src/detectors/InboundNetworkIssueDetector.ts +++ b/src/detectors/InboundNetworkIssueDetector.ts @@ -4,9 +4,9 @@ import { IssueType, WebRTCStatsParsed, } from '../types'; -import BaseIssueDetector from './BaseIssueDetector'; +import BaseIssueDetector, { BaseIssueDetectorParams } from './BaseIssueDetector'; -export interface InboundNetworkIssueDetectorParams { +interface InboundNetworkIssueDetectorParams extends BaseIssueDetectorParams { highPacketLossThresholdPct?: number; highJitterThreshold?: number; highJitterBufferDelayThresholdMs?: number; @@ -14,20 +14,17 @@ export interface InboundNetworkIssueDetectorParams { } class InboundNetworkIssueDetector extends BaseIssueDetector { - readonly highPacketLossThresholdPct: number; - - readonly highJitterThreshold: number; - - readonly highJitterBufferDelayThresholdMs: number; - - readonly highRttThresholdMs: number; + readonly #highPacketLossThresholdPct: number; + readonly #highJitterThreshold: number; + readonly #highJitterBufferDelayThresholdMs: number; + readonly #highRttThresholdMs: number; constructor(params: InboundNetworkIssueDetectorParams = {}) { super(); - this.highPacketLossThresholdPct = params.highPacketLossThresholdPct ?? 5; - this.highJitterThreshold = params.highJitterThreshold ?? 200; - this.highJitterBufferDelayThresholdMs = params.highJitterBufferDelayThresholdMs ?? 500; - this.highRttThresholdMs = params.highRttThresholdMs ?? 250; + this.#highPacketLossThresholdPct = params.highPacketLossThresholdPct ?? 5; + this.#highJitterThreshold = params.highJitterThreshold ?? 200; + this.#highJitterBufferDelayThresholdMs = params.highJitterBufferDelayThresholdMs ?? 500; + this.#highRttThresholdMs = params.highRttThresholdMs ?? 250; } performDetection(data: WebRTCStatsParsed): IssueDetectorResult { @@ -87,10 +84,10 @@ class InboundNetworkIssueDetector extends BaseIssueDetector { ? Math.round((deltaPacketLost * 100) / (deltaPacketReceived + deltaPacketLost)) : 0; - const isHighPacketsLoss = packetLossPct > this.highPacketLossThresholdPct; - const isHighJitter = avgJitter >= this.highJitterThreshold; - const isHighRTT = rtt >= this.highRttThresholdMs; - const isHighJitterBufferDelay = avgJitterBufferDelay > this.highJitterBufferDelayThresholdMs; + const isHighPacketsLoss = packetLossPct > this.#highPacketLossThresholdPct; + const isHighJitter = avgJitter >= this.#highJitterThreshold; + const isHighRTT = rtt >= this.#highRttThresholdMs; + const isHighJitterBufferDelay = avgJitterBufferDelay > this.#highJitterBufferDelayThresholdMs; const isNetworkIssue = isHighJitter || isHighPacketsLoss; const isServerIssue = isHighRTT && !isHighJitter && !isHighPacketsLoss; const isNetworkMediaLatencyIssue = isHighPacketsLoss && isHighJitter; From adb8f8ad4378d574b5ba1542ad8c670470d9a1b1 Mon Sep 17 00:00:00 2001 From: Matthew Farejowicz Date: Mon, 8 Jul 2024 23:32:54 -0700 Subject: [PATCH 2/5] make params configurable for network media sync and outbound network --- .../NetworkMediaSyncIssueDetector.ts | 15 ++++++++++++-- src/detectors/OutboundNetworkIssueDetector.ts | 20 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/detectors/NetworkMediaSyncIssueDetector.ts b/src/detectors/NetworkMediaSyncIssueDetector.ts index a5c6c7a..8bacd94 100644 --- a/src/detectors/NetworkMediaSyncIssueDetector.ts +++ b/src/detectors/NetworkMediaSyncIssueDetector.ts @@ -4,9 +4,20 @@ import { IssueType, WebRTCStatsParsed, } from '../types'; -import BaseIssueDetector from './BaseIssueDetector'; +import BaseIssueDetector, { BaseIssueDetectorParams } from './BaseIssueDetector'; + +interface NetworkMediaSyncIssueDetectorParams extends BaseIssueDetectorParams { + correctedSamplesThresholdPct?: number +} class NetworkMediaSyncIssueDetector extends BaseIssueDetector { + readonly #correctedSamplesThresholdPct: number; + + constructor(params: NetworkMediaSyncIssueDetectorParams = {}) { + super(); + this.#correctedSamplesThresholdPct = params.correctedSamplesThresholdPct ?? 5; + } + performDetection(data: WebRTCStatsParsed): IssueDetectorResult { const { connection: { id: connectionId } } = data; const issues = this.processData(data); @@ -45,7 +56,7 @@ class NetworkMediaSyncIssueDetector extends BaseIssueDetector { correctedSamplesPct, }; - if (correctedSamplesPct > 5) { + if (correctedSamplesPct > this.#correctedSamplesThresholdPct) { issues.push({ statsSample, type: IssueType.Network, diff --git a/src/detectors/OutboundNetworkIssueDetector.ts b/src/detectors/OutboundNetworkIssueDetector.ts index a037e9e..36260ed 100644 --- a/src/detectors/OutboundNetworkIssueDetector.ts +++ b/src/detectors/OutboundNetworkIssueDetector.ts @@ -4,9 +4,23 @@ import { IssueType, WebRTCStatsParsed, } from '../types'; -import BaseIssueDetector from './BaseIssueDetector'; +import BaseIssueDetector, { BaseIssueDetectorParams } from './BaseIssueDetector'; + +interface OutboundNetworkIssueDetectorParams extends BaseIssueDetectorParams { + highPacketLossThresholdPct?: number; + highJitterThreshold?: number; +} class OutboundNetworkIssueDetector extends BaseIssueDetector { + readonly #highPacketLossThresholdPct: number; + readonly #highJitterThreshold: number; + + constructor(params: OutboundNetworkIssueDetectorParams = {}) { + super(); + this.#highPacketLossThresholdPct = params.highPacketLossThresholdPct ?? 5; + this.#highJitterThreshold = params.highJitterThreshold ?? 200; + } + performDetection(data: WebRTCStatsParsed): IssueDetectorResult { const { connection: { id: connectionId } } = data; const issues = this.processData(data); @@ -64,8 +78,8 @@ class OutboundNetworkIssueDetector extends BaseIssueDetector { ? Math.round((deltaPacketLost * 100) / (deltaPacketSent + deltaPacketLost)) : 0; - const isHighPacketsLoss = packetLossPct > 5; - const isHighJitter = avgJitter >= 200; + const isHighPacketsLoss = packetLossPct > this.#highPacketLossThresholdPct; + const isHighJitter = avgJitter >= this.#highJitterThreshold; const isNetworkMediaLatencyIssue = isHighPacketsLoss && isHighJitter; const isNetworkIssue = (!isHighPacketsLoss && isHighJitter) || isHighJitter || isHighPacketsLoss; From 62c33cf8c2e8b44a53da5982b06023f0825603fe Mon Sep 17 00:00:00 2001 From: Matthew Farejowicz Date: Mon, 8 Jul 2024 23:33:45 -0700 Subject: [PATCH 3/5] restore export to not cause breakages --- src/detectors/InboundNetworkIssueDetector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/InboundNetworkIssueDetector.ts b/src/detectors/InboundNetworkIssueDetector.ts index 19955cb..c15b985 100644 --- a/src/detectors/InboundNetworkIssueDetector.ts +++ b/src/detectors/InboundNetworkIssueDetector.ts @@ -6,7 +6,7 @@ import { } from '../types'; import BaseIssueDetector, { BaseIssueDetectorParams } from './BaseIssueDetector'; -interface InboundNetworkIssueDetectorParams extends BaseIssueDetectorParams { +export interface InboundNetworkIssueDetectorParams extends BaseIssueDetectorParams { highPacketLossThresholdPct?: number; highJitterThreshold?: number; highJitterBufferDelayThresholdMs?: number; From ad3093a705188d9d3da06be3f18f2a633ca511eb Mon Sep 17 00:00:00 2001 From: Matthew Farejowicz Date: Mon, 8 Jul 2024 23:41:23 -0700 Subject: [PATCH 4/5] retrigger checks From 53b5c59bb5fac45bb55316a9008c2481c9e991bb Mon Sep 17 00:00:00 2001 From: Matthew Farejowicz Date: Thu, 11 Jul 2024 23:08:38 -0700 Subject: [PATCH 5/5] add blank lines in between class variables --- src/detectors/InboundNetworkIssueDetector.ts | 3 +++ src/detectors/OutboundNetworkIssueDetector.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/src/detectors/InboundNetworkIssueDetector.ts b/src/detectors/InboundNetworkIssueDetector.ts index c15b985..f1736a3 100644 --- a/src/detectors/InboundNetworkIssueDetector.ts +++ b/src/detectors/InboundNetworkIssueDetector.ts @@ -15,8 +15,11 @@ export interface InboundNetworkIssueDetectorParams extends BaseIssueDetectorPara class InboundNetworkIssueDetector extends BaseIssueDetector { readonly #highPacketLossThresholdPct: number; + readonly #highJitterThreshold: number; + readonly #highJitterBufferDelayThresholdMs: number; + readonly #highRttThresholdMs: number; constructor(params: InboundNetworkIssueDetectorParams = {}) { diff --git a/src/detectors/OutboundNetworkIssueDetector.ts b/src/detectors/OutboundNetworkIssueDetector.ts index 36260ed..95a637a 100644 --- a/src/detectors/OutboundNetworkIssueDetector.ts +++ b/src/detectors/OutboundNetworkIssueDetector.ts @@ -13,6 +13,7 @@ interface OutboundNetworkIssueDetectorParams extends BaseIssueDetectorParams { class OutboundNetworkIssueDetector extends BaseIssueDetector { readonly #highPacketLossThresholdPct: number; + readonly #highJitterThreshold: number; constructor(params: OutboundNetworkIssueDetectorParams = {}) {