COORDS_PRESENT warmup-then-reactive for DataPackets

Include source and destination coordinates on the first N DataPackets
of each session (default 5, configurable via
node.session.coords_warmup_packets). This warms transit node
coord_caches so multi-hop forwarding and error signal routing work
after SessionSetup cache entries expire.

On CoordsRequired receipt, reset the counter to re-enable coordinate
inclusion for the next N packets, handling mid-session cache expiry
and path changes.

Changes:
- SessionConfig: add coords_warmup_packets field (default 5)
- SessionEntry: add coords_warmup_remaining counter, initialized on
  Established transition (both initiator and responder paths)
- send_session_data(): attach coords via DataPacket::with_coords()
  while counter > 0, decrement per send
- handle_coords_required(): reset counter for affected session
- 4 new unit tests for counter lifecycle and config default
This commit is contained in:
Johnathan Corgan
2026-02-16 23:28:24 +00:00
parent f374370e5c
commit 1f60fbd7a2
4 changed files with 135 additions and 2 deletions
+16
View File
@@ -54,6 +54,10 @@ pub(crate) struct SessionEntry {
created_at: u64,
/// Last activity timestamp (Unix milliseconds).
last_activity: u64,
/// Remaining DataPackets that should include COORDS_PRESENT.
/// Initialized from config when session becomes Established;
/// reset on CoordsRequired receipt.
coords_warmup_remaining: u8,
}
impl SessionEntry {
@@ -70,6 +74,7 @@ impl SessionEntry {
state: Some(state),
created_at: now_ms,
last_activity: now_ms,
coords_warmup_remaining: 0,
}
}
@@ -116,4 +121,15 @@ impl SessionEntry {
pub(crate) fn last_activity(&self) -> u64 {
self.last_activity
}
/// Remaining DataPackets that should include COORDS_PRESENT.
pub(crate) fn coords_warmup_remaining(&self) -> u8 {
self.coords_warmup_remaining
}
/// Set the coords warmup counter (used on Established transition
/// and CoordsRequired reset).
pub(crate) fn set_coords_warmup_remaining(&mut self, value: u8) {
self.coords_warmup_remaining = value;
}
}