ndn_faces/l2/
radio.rs

1use ndn_transport::FaceId;
2
3/// Metadata attached to a wireless face for multi-radio strategy decisions.
4#[derive(Clone, Debug, Default)]
5pub struct RadioFaceMetadata {
6    /// Index of the physical radio (0-based).
7    pub radio_id: u8,
8    /// Current 802.11 channel number.
9    pub channel: u8,
10    /// Frequency band (2.4 GHz = 2, 5 GHz = 5, 6 GHz = 6).
11    pub band: u8,
12}
13
14/// Per-face link quality metrics, updated by the nl80211 task.
15#[derive(Clone, Debug, Default)]
16pub struct LinkMetrics {
17    /// Received signal strength in dBm.
18    pub rssi_dbm: i8,
19    /// MAC-layer retransmission rate (0.0–1.0).
20    pub retransmit_rate: f32,
21    /// Last updated (ns since Unix epoch).
22    pub last_updated: u64,
23}
24
25/// Shared table of link metrics, keyed by `FaceId`.
26///
27/// Written by the nl80211 monitoring task; read by wireless strategies.
28pub struct RadioTable {
29    metrics: dashmap::DashMap<FaceId, LinkMetrics>,
30}
31
32impl RadioTable {
33    pub fn new() -> Self {
34        Self {
35            metrics: dashmap::DashMap::new(),
36        }
37    }
38
39    pub fn update(&self, face_id: FaceId, metrics: LinkMetrics) {
40        self.metrics.insert(face_id, metrics);
41    }
42
43    pub fn get(&self, face_id: &FaceId) -> Option<LinkMetrics> {
44        self.metrics.get(face_id).map(|r| r.clone())
45    }
46}
47
48impl Default for RadioTable {
49    fn default() -> Self {
50        Self::new()
51    }
52}