Skip to content

Conversation

@mengelbart
Copy link
Contributor

Description

Moves refactored BWE implementation from interceptors to this repo (as discussed here).

@aalekseevx
Copy link
Member

@mengelbart, I like the new, cleaner BWE interface. I want to understand the implementation more deeply, so I might need an additional 1-2 days for review, if that's not a problem.

@mengelbart
Copy link
Contributor Author

Yes, please take all the time you need. We don't need to rush and it's much better if there's someone else looking over this, too! Please let me know if anything is unclear.

ECNCE // 11
)

type Acknowledgment struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could move this to a separate package? This would allow us to:

  1. Define a generic interface for estimators (currently OnAcks(arrival time.Time, rtt time.Duration, acks []Acknowledgment) int).
  2. Extend the interface later (e.g. provide more data).
  3. Support multiple estimators under a unified pattern.

Arrival: time.Time{}.Add(30 * time.Millisecond),
},
},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify how out-of-order packets are being handled? I notice this packet appears in the expected output, which suggests it's being processed normally rather than ignored.

for len(*e.history) > 0 && (*e.history)[0].arrival.Before(deadline) {
heap.Pop(e.history)
}
earliest := e.latestArrival
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we:

  1. Track the earliest timestamp in the heap (O(1) access)
  2. Maintain a running sum of values in the heap

Then GetRate() could run in O(1) time since we'd just need to:
return 8*sum / (now - earliest)

Departure time.Time
Arrived bool
Arrival time.Time
ECN ECN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason we’re avoiding rtcp.ECN?


import "time"

func MeasureRTT(reportSent, reportReceived, latestAckedSent, latestAckedArrival time.Time) time.Duration {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to be directly related to congestion control. Could we move this computation to the caller instead?

"github.com/pion/logging"
)

const maxSamples = 1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constant seems unused

@mengelbart
Copy link
Contributor Author

@aalekseevx Thanks for reviewing and sorry I didn't look at it yet. I will probably have some time to continue working on this soon but I'd like to get pion/interceptor#300 done first because it blocks this PR.

@mengelbart mengelbart force-pushed the gcc-refactoring branch 2 times, most recently from 5b89400 to b5bd729 Compare July 31, 2025 14:06
@mengelbart
Copy link
Contributor Author

Moving this here: pion/bwe#2

@mengelbart mengelbart closed this Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants