Class NetworkStatsPresentation
Every rule the network statistics overlay applies between the transport's numbers and the text on screen: units, rounding, what "unknown" looks like, which badge a row wears, and what its tooltip says about why.
public static class NetworkStatsPresentation
- Inheritance
-
NetworkStatsPresentation
- Inherited Members
Remarks
Units are decimal (SI) throughout. 1 kB is 1,000 bytes and 1 Mbps is 1,000,000 bits a second, so a byte rate and the bit rate beside it differ by exactly eight — the way an internet plan and a network monitor both count. Binary kibibytes would make "1 MB/s" and "8 Mbps" disagree by five per cent, and a player comparing the overlay against their plan is the reader this is for.
Bytes in the table, bits in the headline. The table's per-layer figures are bytes, which is what the counters count and what adds up across layers; the headline is the on-the-wire rate in bits, because that is the unit a connection's speed is sold in. Every tooltip gives both.
Unknown is a dash, never a zero. The transport reports what it cannot see as -1 or NaN; every formatter here turns those into Unknown. A measured zero is still written as zero.
Culture-invariant, so a comma-decimal machine still reads "1.25 MB".
Fields
BadgeClasses
Every badge class, so a refresh can clear the ones that no longer apply.
public static readonly string[] BadgeClasses
Field Value
- string[]
ConnectionStaleSeconds
How old the connection figures may be, relative to the snapshot, before they are shown as unknown. The client socket refreshes them once a second while the overlay is open; older than this means it has stopped (the connection closed between refreshes).
public const double ConnectionStaleSeconds = 5
Field Value
SentDatagramCaveat
The one msquic quirk that bounds a figure: its count of datagrams SENT is too high during bursts, so the sent datagrams and the sent wire bytes derived from them are upper bounds. Received counts are exact.
public const string SentDatagramCaveat = "Upload is an upper bound: msquic 2.5.9 counts some sent datagrams twice when a burst (such as a handshake) goes out in several batches, and each extra count adds 28 bytes to the header estimate. Received counts are exact, and the QUIC byte counts are unaffected."
Field Value
Unknown
What an unknown value reads as.
public const string Unknown = "—"
Field Value
Methods
BackendCaption(in NetworkStatsReadout)
The backend as a short caption for the overlay's header.
public static string BackendCaption(in NetworkStatsReadout readout)
Parameters
readoutNetworkStatsReadout
Returns
BadgeClass(TrafficMeasure, bool)
USS class of a badge for measure, or the pending class.
public static string BadgeClass(TrafficMeasure measure, bool pending = false)
Parameters
measureTrafficMeasurependingbool
Returns
BadgeText(TrafficMeasure, bool)
The word a badge shows for measure.
public static string BadgeText(TrafficMeasure measure, bool pending = false)
Parameters
measureTrafficMeasurependingbool
Returns
BitRate(double)
A byte rate written in bits, e.g. "345 kbps", or Unknown.
public static string BitRate(double bytesPerSecond)
Parameters
bytesPerSeconddouble
Returns
BuildGraphTooltip(TooltipContent, double, TrafficMeasure)
Writes the explanation of the traffic graph: what a point is, what the scale is, and what a gap means.
public static void BuildGraphTooltip(TooltipContent content, double peak, TrafficMeasure wire)
Parameters
contentTooltipContentThe content being assembled.
peakdoubleThe highest known point in the graph, bytes a second, or NaN.
wireTrafficMeasureThe wire layer's measure in the newest snapshot.
BuildTooltip(TooltipContent, NetworkStatsRow, in NetworkStatsReadout)
Writes the explanation of one row into content: what it counts, how it
was obtained, and why that is the best this process can do.
public static void BuildTooltip(TooltipContent content, NetworkStatsRow row, in NetworkStatsReadout readout)
Parameters
contentTooltipContentrowNetworkStatsRowreadoutNetworkStatsReadout
ByteRate(double)
A byte rate, e.g. "43.1 kB/s", or Unknown.
public static string ByteRate(double bytesPerSecond)
Parameters
bytesPerSeconddouble
Returns
Bytes(long)
A byte count, e.g. "12.4 MB", or Unknown when negative.
public static string Bytes(long bytes)
Parameters
byteslong
Returns
ConnectionIsCurrent(in TransportTrafficSnapshot)
True when the snapshot carries connection figures that are valid and recent.
public static bool ConnectionIsCurrent(in TransportTrafficSnapshot snapshot)
Parameters
snapshotTransportTrafficSnapshot
Returns
Remarks
A reading older than ConnectionStaleSeconds is not presented as the current round-trip time. The socket withdraws its figures when it disconnects, but a read that failed quietly would otherwise leave the last good number on screen forever.
Count(long)
A count, e.g. "48,210", or Unknown when negative.
public static string Count(long count)
Parameters
countlong
Returns
Describe(NetworkStatsRow, in NetworkStatsReadout)
The text a row shows for readout.
public static NetworkStatsFigures Describe(NetworkStatsRow row, in NetworkStatsReadout readout)
Parameters
rowNetworkStatsRowreadoutNetworkStatsReadout
Returns
GraphScale(double, double)
The graph's vertical scale: the peak rounded up to 1, 2 or 5 times a power of ten, and
never below floor bytes a second.
public static double GraphScale(double peak, double floor = 1000)
Parameters
Returns
Remarks
The floor keeps an idle connection's few hundred bytes of acknowledgements from being drawn as a full-height mountain. The rounding keeps the scale label a number a person would say ("50 kB/s", not "43.7 kB/s"), and keeps it from twitching every second.
GraphY(double, double, float)
The vertical position of a graph point, 0 at the top, height at the
bottom, or NaN for an unknown point (a break in the line, never a zero).
public static float GraphY(double value, double scale, float height)
Parameters
Returns
Headline(in NetworkStatsReadout, out string, out string)
The on-the-wire rate each way in bits, for the headline.
public static void Headline(in NetworkStatsReadout readout, out string down, out string up)
Parameters
readoutNetworkStatsReadoutdownstringupstring
IsKnown(double)
True for a finite, non-negative value.
public static bool IsKnown(double value)
Parameters
valuedouble
Returns
MeasureName(TrafficMeasure)
The measure spelled out, for a tooltip's subtitle.
public static string MeasureName(TrafficMeasure measure)
Parameters
measureTrafficMeasure
Returns
Milliseconds(double)
Milliseconds, e.g. "42 ms" or "4.2 ms", or Unknown.
public static string Milliseconds(double ms)
Parameters
msdouble
Returns
Mtu(int)
A path MTU in bytes, e.g. "1452 B", or Unknown when not positive.
public static string Mtu(int bytes)
Parameters
bytesint
Returns
PerSecond(double)
A count per second, e.g. "62/s" or "2.5/s", or Unknown.
public static string PerSecond(double perSecond)
Parameters
perSeconddouble
Returns
Percent(double)
A fraction as a percentage, e.g. "0.20%", "1.5%", "12%", or Unknown.
public static string Percent(double fraction)
Parameters
fractiondouble
Returns
Ratio(double)
A wire-per-app ratio, e.g. "×1.13", or Unknown.
public static string Ratio(double ratio)
Parameters
ratiodouble
Returns
RowMeasure(NetworkStatsRow, in NetworkStatsReadout)
The measure a row's badge names, read from the newest snapshot.
public static TrafficMeasure RowMeasure(NetworkStatsRow row, in NetworkStatsReadout readout)
Parameters
rowNetworkStatsRowreadoutNetworkStatsReadout
Returns
- TrafficMeasure
Remarks
The snapshot, not the interval: the totals come from it, and it is what the next interval will be measured as. The two differ only for the one sample after a layer changes definition, when the rates read unknown anyway.
RowName(NetworkStatsRow)
The row's name as the overlay's first column shows it.
public static string RowName(NetworkStatsRow row)
Parameters
rowNetworkStatsRow
Returns
RowTitle(NetworkStatsRow)
The row's name as a tooltip's title spells it out.
public static string RowTitle(NetworkStatsRow row)
Parameters
rowNetworkStatsRow