namespace MoShiro.Backend.Analysis; /// 线路基础指标(udp_echo / icmp_echo 的回显流)。新增指标 = 加一行声明。 public static class LinkMetrics { private static readonly string[] s_udpMsg = ["udp_echo.msg"]; private static readonly string[] s_udpOrIcmpMsg = ["udp_echo.msg", "icmp_echo.msg"]; public static readonly MetricDef Rtt = Metric.Histogram( "rtt", s_udpOrIcmpMsg, Ops.Rtt, "RTT", "Round-trip time with the Agent processing time removed.", Unit.Ms, [Stat.P50, Stat.P95, Stat.P99, Stat.Mean], good: 50, poor: 150); public static readonly MetricDef LossUp = Metric.Ratio( "loss.up", s_udpMsg, Ops.Loss(Dir.Up), "Loss (up)", "Packets lost between the Probe and the Agent.", good: 0.5, poor: 3); public static readonly MetricDef LossDown = Metric.Ratio( "loss.down", s_udpMsg, Ops.Loss(Dir.Down), "Loss (down)", "Replies lost between the Agent and the Probe, among packets that reached the Agent.", good: 0.5, poor: 3); public static readonly MetricDef LossTotal = Metric.Ratio( "loss.total", s_udpOrIcmpMsg, Ops.Loss(Dir.Total), "Loss (total)", "Packets whose reply never came back.", good: 0.5, poor: 3); public static readonly MetricDef JitterUp = Metric.Histogram( "jitter.up", s_udpMsg, Ops.OwdVar(Dir.Up), "Jitter (up)", "One-way delay variation, offset and drift removed.", Unit.Ms, [Stat.P95], good: 3, poor: 20); public static readonly MetricDef JitterDown = Metric.Histogram( "jitter.down", s_udpMsg, Ops.OwdVar(Dir.Down), "Jitter (down)", "One-way delay variation, offset and drift removed.", Unit.Ms, [Stat.P95], good: 3, poor: 20); public static readonly MetricDef LossRun = Metric.RunLength( "loss.run", s_udpMsg, Ops.LossRuns, "Loss runs", "Lengths of consecutive lost packets.", new MetricExport("loss.run_max", Stat.Max, Unit.Packets, 2, 10), new MetricExport("loss.run_mean", Stat.Mean, Unit.Packets)); public static readonly MetricDef Reorder = Metric.Counter( "reorder", s_udpMsg, Ops.Reorder, "Reordered", "Replies that arrived after a higher sequence number.", new MetricExport("reorder", Stat.Count, Unit.Count)); public static readonly MetricDef Dup = Metric.Counter( "dup", s_udpMsg, Ops.Dup, "Duplicates", "Replies received more than once.", new MetricExport("dup", Stat.Count, Unit.Count)); public static readonly MetricDef SamplesUdp = Metric.Counter( "n.udp_echo", s_udpMsg, Ops.RowCount, "udp_echo samples", "Number of udp_echo records.", new MetricExport("n.udp_echo", Stat.Count, Unit.Count), Better.None); }