Class ServerBandwidthMath
The rules the bandwidth tables are read and written by, as pure functions.
public static class ServerBandwidthMath
- Inheritance
-
ServerBandwidthMath
- Inherited Members
Fields
CurrentFreshSeconds
A server's latest minute counts as its current rate only while it is at most this old by the database clock. A server samples every 60 seconds, so a live one is never more than two minutes behind; five leaves room for a deferred sample.
public const int CurrentFreshSeconds = 300
Field Value
HourRetentionMonths
How long hour rows are kept: 13 months, so a year-on-year comparison always exists.
public const int HourRetentionMonths = 13
Field Value
IpV4UdpHeaderBytes
IPv4 (20) plus UDP (8) header bytes per datagram, the difference between msquic's UDP payload count and the bytes on the wire.
public const int IpV4UdpHeaderBytes = 28
Field Value
Remarks
The same constant as TransportTrafficMath.IpV4UdpHeaderBytes in the WebTransport
plugin, which this assembly cannot reference; a test pins them equal. The native stack
binds IPv4 only. Ethernet framing is deliberately not added: egress is billed at the IP
level.
MaxPendingMinutes
The most minutes a server process holds for retry while the database refuses its writes; older ones are dropped, and the drop is logged.
public const int MaxPendingMinutes = 60
Field Value
MinuteRetentionDays
How long minute rows are kept before the rollup job folds and deletes them.
public const int MinuteRetentionDays = 14
Field Value
RollupWindowHours
How many trailing hours every rollup pass recomputes, the current one included.
public const int RollupWindowHours = 6
Field Value
Remarks
A server holds a minute it could not write and retries it for up to MaxPendingMinutes, so a minute row can land that long after its minute. The window has to reach further back than that, or the hour it belongs to would have been rolled for the last time before the row arrived.
StitchHours
How far behind the current hour the 30-day figures stop reading hour rows and start reading minutes, so they never depend on the rollup having run in the last few minutes.
public const int StitchHours = 3
Field Value
Methods
EstimateWireBytes(long, long)
The bytes on the wire: UDP payload plus IpV4UdpHeaderBytes per datagram. An estimate.
public static long EstimateWireBytes(long udpPayloadBytes, long datagrams)
Parameters
Returns
EstimateWireRate(double, double)
The wire rate estimated from a payload rate and a datagram rate.
public static double EstimateWireRate(double udpPayloadPerSecond, double datagramsPerSecond)
Parameters
Returns
FloorToHour(DateTime)
Truncates a UTC time to its hour.
public static DateTime FloorToHour(DateTime utc)
Parameters
utcDateTime
Returns
FloorToMinute(DateTime)
Truncates a UTC time to its minute.
public static DateTime FloorToMinute(DateTime utc)
Parameters
utcDateTime
Returns
MinuteRetentionCutoff(DateTime)
The oldest hour whose minutes the retention job may fold and delete: every minute before this instant is older than MinuteRetentionDays. Whole hours only, so no hour is ever left with some of its minutes gone.
public static DateTime MinuteRetentionCutoff(DateTime nowUtc)
Parameters
nowUtcDateTime
Returns
MonthWindowStart(DateTime)
The start of the 30-day window: whole hours, so it lines up with the hour rows.
public static DateTime MonthWindowStart(DateTime nowUtc)
Parameters
nowUtcDateTime
Returns
PerSecond(long, long)
value per second over intervalMs, or NaN when the
interval is empty. Never value / 60: a minute row's interval is what it says.
public static double PerSecond(long value, long intervalMs)
Parameters
Returns
RangeStart(ServerBandwidthRange, DateTime)
Where a range's chart starts, by the database clock.
public static DateTime RangeStart(ServerBandwidthRange range, DateTime nowUtc)
Parameters
rangeServerBandwidthRangenowUtcDateTime
Returns
ResolutionSeconds(ServerBandwidthRange)
The width of one chart point for a range, in seconds.
public static int ResolutionSeconds(ServerBandwidthRange range)
Parameters
rangeServerBandwidthRange
Returns
StitchPoint(DateTime)
Where the 30-day figures switch from hour rows to minute rows: the start of the hour StitchHours before the current one.
public static DateTime StitchPoint(DateTime nowUtc)
Parameters
nowUtcDateTime