Files
.github
app
core
client
errors
internal
congestion
bbr
bandwidth.go
bandwidth_sampler.go
bbr_sender.go
clock.go
windowed_filter.go
brutal
common
utils.go
frag
integration_tests
pmtud
protocol
utils
server
go.mod
go.sum
extras
media-kit
scripts
.gitignore
CHANGELOG.md
Dockerfile
LICENSE.md
PROTOCOL.md
README.md
go.work
go.work.sum
hyperbole.py
logo.svg
platforms.txt
hysteria-dev/core/internal/congestion/bbr/bandwidth.go
2023-08-04 17:29:15 -07:00

26 lines
596 B
Go

package bbr
import (
"math"
"time"
"github.com/apernet/quic-go/congestion"
)
// Bandwidth of a connection
type Bandwidth uint64
const infBandwidth Bandwidth = math.MaxUint64
const (
// BitsPerSecond is 1 bit per second
BitsPerSecond Bandwidth = 1
// BytesPerSecond is 1 byte per second
BytesPerSecond = 8 * BitsPerSecond
)
// BandwidthFromDelta calculates the bandwidth from a number of bytes and a time delta
func BandwidthFromDelta(bytes congestion.ByteCount, delta time.Duration) Bandwidth {
return Bandwidth(bytes) * Bandwidth(time.Second) / Bandwidth(delta) * BytesPerSecond
}