Initial import: ICE-NET research docs and Rust workspace (v0.4)
Some checks failed
rust-ci / checks (push) Has been cancelled
Some checks failed
rust-ci / checks (push) Has been cancelled
- Rust workspace: 7 library crates, icenetd CLI, icenet-city (Slint GUI) - Sim: fix false Delivered after a route cut, derive traffic class from payload size, per-link airtime slots (link capacity, queueing) - Docs: single docs/STATUS.md for all figures, remove v0.2/egui leftovers, drop unimplemented seed claims, uncheck store-and-forward - License: LGPL-3.0-or-later (LICENSE, LICENSES/GPL-3.0.txt)
This commit is contained in:
commit
2e61688eb3
141 changed files with 13993 additions and 0 deletions
111
workspace/crates/icenet-routing/tests/routing.rs
Normal file
111
workspace/crates/icenet-routing/tests/routing.rs
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
use icenet_core::{LinkKind, NodeId, TrafficClass};
|
||||
use icenet_routing::{Link, choose_path};
|
||||
|
||||
#[test]
|
||||
fn bulk_never_uses_slow_radio() {
|
||||
let nodes = [NodeId(1), NodeId(2), NodeId(3)];
|
||||
let links = [
|
||||
Link {
|
||||
a: nodes[0],
|
||||
b: nodes[1],
|
||||
kind: LinkKind::SlowRadio,
|
||||
enabled: true,
|
||||
},
|
||||
Link {
|
||||
a: nodes[1],
|
||||
b: nodes[2],
|
||||
kind: LinkKind::SlowRadio,
|
||||
enabled: true,
|
||||
},
|
||||
];
|
||||
assert!(
|
||||
choose_path(
|
||||
&nodes,
|
||||
&links,
|
||||
nodes[0],
|
||||
nodes[2],
|
||||
TrafficClass::Bulk,
|
||||
50_000
|
||||
)
|
||||
.is_none()
|
||||
);
|
||||
assert!(choose_path(&nodes, &links, nodes[0], nodes[2], TrafficClass::Text, 10).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chooses_fast_route_when_bulk_is_allowed() {
|
||||
let nodes = [NodeId(1), NodeId(2), NodeId(3)];
|
||||
let links = [
|
||||
Link {
|
||||
a: nodes[0],
|
||||
b: nodes[1],
|
||||
kind: LinkKind::FastWireless,
|
||||
enabled: true,
|
||||
},
|
||||
Link {
|
||||
a: nodes[1],
|
||||
b: nodes[2],
|
||||
kind: LinkKind::Wired,
|
||||
enabled: true,
|
||||
},
|
||||
];
|
||||
let chosen = choose_path(
|
||||
&nodes,
|
||||
&links,
|
||||
nodes[0],
|
||||
nodes[2],
|
||||
TrafficClass::Bulk,
|
||||
5_000_000,
|
||||
);
|
||||
assert_eq!(chosen.expect("connected").nodes, nodes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_bridge_breaks_route() {
|
||||
let nodes = [NodeId(1), NodeId(2)];
|
||||
let links = [Link {
|
||||
a: nodes[0],
|
||||
b: nodes[1],
|
||||
kind: LinkKind::Wired,
|
||||
enabled: false,
|
||||
}];
|
||||
assert!(choose_path(&nodes, &links, nodes[0], nodes[1], TrafficClass::Text, 5).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn equal_cost_paths_use_a_stable_lexicographic_tie_break() {
|
||||
let nodes = [NodeId(1), NodeId(2), NodeId(3), NodeId(4)];
|
||||
let forward = [
|
||||
Link {
|
||||
a: nodes[0],
|
||||
b: nodes[1],
|
||||
kind: LinkKind::Wired,
|
||||
enabled: true,
|
||||
},
|
||||
Link {
|
||||
a: nodes[1],
|
||||
b: nodes[3],
|
||||
kind: LinkKind::Wired,
|
||||
enabled: true,
|
||||
},
|
||||
Link {
|
||||
a: nodes[0],
|
||||
b: nodes[2],
|
||||
kind: LinkKind::Wired,
|
||||
enabled: true,
|
||||
},
|
||||
Link {
|
||||
a: nodes[2],
|
||||
b: nodes[3],
|
||||
kind: LinkKind::Wired,
|
||||
enabled: true,
|
||||
},
|
||||
];
|
||||
let mut reversed = forward;
|
||||
reversed.reverse();
|
||||
for links in [&forward, &reversed] {
|
||||
let path = choose_path(&nodes, links, nodes[0], nodes[3], TrafficClass::Text, 10)
|
||||
.expect("diamond is connected");
|
||||
assert_eq!(path.nodes, [NodeId(1), NodeId(2), NodeId(4)]);
|
||||
}
|
||||
}
|
||||
79
workspace/crates/icenet-routing/tests/size_limits.rs
Normal file
79
workspace/crates/icenet-routing/tests/size_limits.rs
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
//! Size limits: a payload label cannot smuggle bulk data onto a slow radio.
|
||||
use icenet_core::{LinkKind, NodeId, TrafficClass};
|
||||
use icenet_routing::{Link, choose_path};
|
||||
|
||||
fn slow_pair() -> ([NodeId; 2], [Link; 1]) {
|
||||
let nodes = [NodeId(1), NodeId(2)];
|
||||
let links = [Link {
|
||||
a: nodes[0],
|
||||
b: nodes[1],
|
||||
kind: LinkKind::SlowRadio,
|
||||
enabled: true,
|
||||
}];
|
||||
(nodes, links)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oversized_text_is_treated_as_bulk_and_refused_on_slow_radio() {
|
||||
let (nodes, links) = slow_pair();
|
||||
let at_limit = TrafficClass::TEXT_MAX_BYTES;
|
||||
assert!(
|
||||
choose_path(
|
||||
&nodes,
|
||||
&links,
|
||||
nodes[0],
|
||||
nodes[1],
|
||||
TrafficClass::Text,
|
||||
at_limit
|
||||
)
|
||||
.is_some()
|
||||
);
|
||||
assert!(
|
||||
choose_path(
|
||||
&nodes,
|
||||
&links,
|
||||
nodes[0],
|
||||
nodes[1],
|
||||
TrafficClass::Text,
|
||||
at_limit + 1
|
||||
)
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oversized_control_is_treated_as_text_then_bulk() {
|
||||
let (nodes, links) = slow_pair();
|
||||
let control = TrafficClass::Control;
|
||||
let just_over = TrafficClass::CONTROL_MAX_BYTES + 1;
|
||||
assert!(choose_path(&nodes, &links, nodes[0], nodes[1], control, just_over).is_some());
|
||||
assert!(choose_path(&nodes, &links, nodes[0], nodes[1], control, 1_000_000).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn path_reports_the_index_of_every_link_it_uses() {
|
||||
let nodes = [NodeId(1), NodeId(2), NodeId(3)];
|
||||
let links = [
|
||||
Link {
|
||||
a: nodes[0],
|
||||
b: nodes[1],
|
||||
kind: LinkKind::SlowRadio,
|
||||
enabled: false,
|
||||
},
|
||||
Link {
|
||||
a: nodes[0],
|
||||
b: nodes[1],
|
||||
kind: LinkKind::Wired,
|
||||
enabled: true,
|
||||
},
|
||||
Link {
|
||||
a: nodes[1],
|
||||
b: nodes[2],
|
||||
kind: LinkKind::Wired,
|
||||
enabled: true,
|
||||
},
|
||||
];
|
||||
let path =
|
||||
choose_path(&nodes, &links, nodes[0], nodes[2], TrafficClass::Text, 10).expect("connected");
|
||||
assert_eq!(path.links, [1, 2]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue