- SRTT is the smoothed round-trip time.
- RTTVAR describes how much recent samples vary from the smoothed value.
Hivenet Router uses SRTT as an operational routing signal.It does not calculate or use TCP’s retransmission timeout, and its samples measure application-level request behavior rather than TCP packet round trips.
What Hivenet Router measures
The router starts timing immediately before it sends the HTTP request over libp2p. The sample ends when the router receives the HTTP response headers from the agent.- router-to-agent transport time
- work performed by the agent
- time spent waiting for the inference backend
- backend response timing
- agent-to-router transport time
Streaming and non-streaming requests
The meaning of one sample depends on how the response is delivered.Streaming Chat Completions
For a streaming response, the agent forwards the backend’s response headers as soon as the stream begins. The sample therefore approximates:Non-streaming Chat Completions
For the native non-streaming Chat Completions path, the agent buffers the complete backend response before returning headers to the router. The sample therefore approximates:Other passthrough endpoints
For passthrough routes, the exact point at which headers become available depends on the backend and endpoint behavior. Use SRTT to compare agents serving similar workloads and request shapes.What SRTT does not measure
SRTT does not include:- client-to-router network latency
- time spent waiting in Hivenet Router’s per-model capacity queue
- time needed to send a complete stream to the client
- delays caused by a slow client reading streamed output
- application processing before the request reaches Hivenet Router
- application processing after the response leaves Hivenet Router
Why Hivenet Router does not use end-to-end latency
End-to-end latency would mix agent performance with conditions the agent cannot control. For example:- a distant client would make the selected agent look slower
- a request waiting in the router queue would inflate the agent’s value
- a client reading an SSE stream slowly would extend the measured duration
- clients in different locations would make agent comparisons inconsistent
First latency sample
For the first valid sample, Hivenet Router initializes the values as:Subsequent samples
Hivenet Router updates RTTVAR before SRTT.When latency improves
When the new sample is lower than the current SRTT:When latency worsens
When the new sample is equal to or higher than the current SRTT:Why the smoothing is asymmetric
Language-model backends can produce large one-off latency samples. Examples include:- loading a model after startup
- a cold cache
- garbage collection
- temporary host contention
- a large prompt
- an unusually long non-streaming response
This is a Hivenet Router adaptation.RFC 6298 normally uses
α = 1/8 for subsequent SRTT updates in both directions. Hivenet Router uses α = 1/2 only for improving samples.Example
Assume an agent has:After the slow sample
Update RTTVAR first:After a normal 200-millisecond sample
The new sample is better than the current SRTT, so Hivenet Router uses the faster downward update:
The estimate moves back toward normal behavior without forgetting the spike immediately.
Successful and failed requests
Successful requests update SRTT and RTTVAR. Failed requests also update the estimator when the router obtained a positive latency sample before the failure. Examples include:- a backend returning an error response
- an unsuccessful response received from an agent
- a transport failure after the request was sent
- failure to create the outbound request
- failure before a connection to the agent is established
- another local error with a zero sample
Live routing values
Routing policies use the current in-memory SRTT. They do not read the periodically flushed BadgerDB record for every request. This matters because the persistent record may be up to one flush interval behind an actively serving agent. The default universal-history flush interval is:Persistence
Hivenet Router persists SRTT and RTTVAR in BadgerDB under the agent’s peer ID. The router flushes universal agent history:- every 30 seconds by default
- when an agent disconnects
- during graceful router shutdown
Warm start
When an agent reconnects with the same peer ID, Hivenet Router restores its previous SRTT and RTTVAR. For example:Reset latency history
The administration metrics-reset endpoint clears SRTT and RTTVAR together with the other persisted per-agent lifetime metrics.This operation also clears other per-agent historical request, token, failure, and disconnection counters.It is not a latency-only reset.
View current values
Use the routing table:Prometheus metrics
Hivenet Router exports:SRTT by agent
Average SRTT by model
SRTT by engine
Agents above 500 milliseconds
High variation
SRTT compared with variation
Interpret RTTVAR
RTTVAR represents the smoothed absolute difference between recent samples and SRTT. A low value suggests relatively consistent observed latency. A high value suggests greater variation, which may come from:- variable prompt or generation lengths
- queueing
- cache misses
- mixed streaming and non-streaming traffic
- backend contention
- network instability
- cold starts
- different request types sharing one agent
Use SRTT in a routing policy
The policy field is:Missing latency history passes
A new agent with no request samples has no SRTT value. When a policy contains:SRTT is not a ranking strategy
The only currently implemented ranking strategy is:Choose a threshold
A useful SRTT threshold depends on:- streaming or non-streaming behavior
- model size
- prompt length
- expected output length
- backend engine
- hardware
- agent location
- service objective
- collect several days of representative traffic
- group SRTT by model and engine
- identify normal and degraded ranges
- compare SRTT with RTTVAR and backend metrics
- set a conservative threshold
- create a relaxed fallback step
- monitor fallback and policy-exhaustion rates
Alerting examples
The thresholds below are examples. Establish values from your own workload.High SRTT
High RTTVAR
Model-level degradation
Debug latency changes
Enable debug logs:- systemd
- Docker Compose
Troubleshooting
SRTT remains unknown
The agent has not produced a valid recorded request sample. Check that:- the agent is registered
- it has served a request
- the request reached the agent
- the router recorded a success or a failure with a positive sample
SRTT is much higher than TTFT
The requests may be non-streaming. For native non-streaming Chat Completions, SRTT includes the complete inference before the agent returns headers. Engine TTFT measures only the start of model output. Also check:- router-agent network time
- backend queueing
- response parsing
- mixed request types
- different observation windows
SRTT changes after switching to streaming
This is expected. Streaming usually records latency near response start, while non-streaming native chat records latency after the complete backend response is ready. Establish separate baselines when both modes are used heavily.SRTT remains high after a cold start
The estimator moves downward quickly, but it still needs successful faster samples. Send representative requests and check whether:- the backend is fully loaded
- queue pressure has cleared
- new samples are actually lower
- the agent is still serving unusually large requests
SRTT resets after an agent restart
The agent may have started with a new peer ID. Check that--identity-path points to persistent storage and compare the current peer ID with the previous deployment.
Also confirm that:
- the router uses a persistent BadgerDB directory
- universal history was not reset
- the previous record has not expired
- the router shut down or flushed recently enough to preserve the latest value
Policy does not exclude a slow agent
Check that the field is:Prometheus shows zero before traffic
The SRTT gauge may be seeded at zero when the agent first registers without latency history. Use the routing table’s:Next steps
Hardware-aware routing
Combine latency with GPU, CPU, memory, cache, and queue pressure.
Routing concepts
See where the SRTT gate fits inside the complete routing pipeline.
Performance characteristics
Review performance measurements, scope, and testing considerations.

