Source File
flow_controller_base.go
Belonging Package
github.com/tmc/go-iroh/internal/qng
package quicimport ()type receiveFlowController struct {//nolint:structcheck // The mutex is used both by the stream and the connection flow controllermutex sync.MutexbytesRead protocol.ByteCounthighestReceived protocol.ByteCountreceiveWindow protocol.ByteCountreceiveWindowSize protocol.ByteCountmaxReceiveWindowSize protocol.ByteCountallowWindowIncrease func(size protocol.ByteCount) boolepochStartTime monotime.TimeepochStartOffset protocol.ByteCountrttStats *utils.RTTStatslogger utils.Logger}// needs to be called with locked mutexfunc ( *receiveFlowController) ( protocol.ByteCount) {.bytesRead +=}func ( *receiveFlowController) () bool {:= .receiveWindow - .bytesRead// update the window when more than the threshold was consumedreturn <= protocol.ByteCount(float64(.receiveWindowSize)*(1-protocol.WindowUpdateThreshold))}// getWindowUpdate updates the receive window, if necessary// it returns the new offsetfunc ( *receiveFlowController) ( monotime.Time) protocol.ByteCount {if !.hasWindowUpdate() {return 0}.maybeAdjustWindowSize().receiveWindow = .bytesRead + .receiveWindowSizereturn .receiveWindow}// maybeAdjustWindowSize increases the receiveWindowSize if we're sending updates too often.// For details about auto-tuning, see https://docs.google.com/document/d/1SExkMmGiz8VYzV3s9E35JQlJ73vhzCekKkDi85F1qCE/edit?usp=sharing.func ( *receiveFlowController) ( monotime.Time) {:= .bytesRead - .epochStartOffset// don't do anything if less than half the window has been consumedif <= .receiveWindowSize/2 {return}:= .rttStats.SmoothedRTT()if == 0 {return}:= float64() / float64(.receiveWindowSize)if .Sub(.epochStartTime) < time.Duration(4**float64()) {// window is consumed too fast, try to increase the window size:= min(2*.receiveWindowSize, .maxReceiveWindowSize)if > .receiveWindowSize && (.allowWindowIncrease == nil || .allowWindowIncrease(-.receiveWindowSize)) {.receiveWindowSize =}}.startNewAutoTuningEpoch()}func ( *receiveFlowController) ( monotime.Time) {.epochStartTime =.epochStartOffset = .bytesRead}func ( *receiveFlowController) () bool {return .highestReceived > .receiveWindow}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |