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
68
workspace/crates/icenet-sim/tests/scale.rs
Normal file
68
workspace/crates/icenet-sim/tests/scale.rs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
//! Scale smoke tests: 100 and 1000 virtual nodes on a deterministic grid.
|
||||
use std::time::Instant;
|
||||
|
||||
use icenet_core::{LinkKind, NodeId, TrafficClass};
|
||||
use icenet_sim::{City, DeliveryState, DeviceRole, metrics};
|
||||
|
||||
#[test]
|
||||
fn hundred_node_grid_delivers_bulk_with_full_ratio() {
|
||||
let mut city = grid(10, 10);
|
||||
let source = city.devices.first().expect("grid nodes").id;
|
||||
let destination = city.devices.last().expect("grid nodes").id;
|
||||
let id = city.send(source, destination, TrafficClass::Bulk, 5_000_000);
|
||||
city.tick(200_000);
|
||||
assert_eq!(status_of(&city, id), DeliveryState::Delivered);
|
||||
let summary = metrics::summarize(&city);
|
||||
assert_eq!(summary.created, 1);
|
||||
assert!((summary.delivery_ratio() - 1.0).abs() < f64::EPSILON);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thousand_node_grid_reports_route_latency() {
|
||||
let city = grid(40, 25);
|
||||
let nodes: Vec<NodeId> = city.devices.iter().map(|device| device.id).collect();
|
||||
let mut samples = Vec::with_capacity(200);
|
||||
let mut state = 0x2545_f491_4f6c_dd1d_u64;
|
||||
for _ in 0..200 {
|
||||
state = state
|
||||
.wrapping_mul(6_364_136_223_846_793_005)
|
||||
.wrapping_add(1);
|
||||
let from = nodes[(state as usize) % nodes.len()];
|
||||
let to = nodes[((state >> 32) as usize) % nodes.len()];
|
||||
let started = Instant::now();
|
||||
let path = city.route(from, to, TrafficClass::Text, 128);
|
||||
samples.push(u64::try_from(started.elapsed().as_micros()).unwrap_or(u64::MAX));
|
||||
assert!(path.is_some(), "grid must stay connected");
|
||||
}
|
||||
let p50 = metrics::percentile(&mut samples.clone(), 50).expect("samples");
|
||||
let p95 = metrics::percentile(&mut samples, 95).expect("samples");
|
||||
println!("1000-node route search (release-independent debug build): p50={p50}us p95={p95}us");
|
||||
assert!(p50 <= p95);
|
||||
}
|
||||
|
||||
fn grid(columns: usize, rows: usize) -> City {
|
||||
let mut city = City::empty();
|
||||
let ids: Vec<NodeId> = (0..columns * rows)
|
||||
.map(|index| city.add_device(format!("n{index}"), DeviceRole::Relay))
|
||||
.collect();
|
||||
for row in 0..rows {
|
||||
for column in 0..columns {
|
||||
let index = row * columns + column;
|
||||
if column + 1 < columns {
|
||||
assert!(city.add_link(ids[index], ids[index + 1], LinkKind::FastWireless));
|
||||
}
|
||||
if row + 1 < rows {
|
||||
assert!(city.add_link(ids[index], ids[index + columns], LinkKind::FastWireless));
|
||||
}
|
||||
}
|
||||
}
|
||||
city
|
||||
}
|
||||
|
||||
fn status_of(city: &City, id: u64) -> DeliveryState {
|
||||
city.messages
|
||||
.iter()
|
||||
.find(|message| message.id == id)
|
||||
.expect("recorded message")
|
||||
.status
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue