mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-08-04 00:11:49 +00:00
.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
26 lines
596 B
Go
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
|
|
}
|