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
11
workspace/crates/icenet-sdk/Cargo.toml
Normal file
11
workspace/crates/icenet-sdk/Cargo.toml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "icenet-sdk"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
icenet-core = { path = "../icenet-core" }
|
||||
icenet-wire = { path = "../icenet-wire" }
|
||||
icenet-guard = { path = "../icenet-guard" }
|
||||
icenet-transport = { path = "../icenet-transport" }
|
||||
28
workspace/crates/icenet-sdk/src/lib.rs
Normal file
28
workspace/crates/icenet-sdk/src/lib.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//! An early public facade for application developers.
|
||||
//!
|
||||
//! There is no networking daemon or authenticated handshake in this scaffold.
|
||||
#![forbid(unsafe_code)]
|
||||
#![warn(missing_docs)]
|
||||
|
||||
pub use icenet_core::{NodeId, ServiceId, TrafficClass};
|
||||
pub use icenet_guard::{Context, Guard, Limits, Verdict};
|
||||
pub use icenet_transport::{
|
||||
MAX_DATAGRAM_BYTES, MemoryTransport, Transport, TransportError, UdpTransport,
|
||||
};
|
||||
pub use icenet_wire::{Frame, FrameError, decode, encode};
|
||||
|
||||
/// Builds an encoded *local test* message without cryptographic protection.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns a `FrameError` for oversized frames.
|
||||
pub fn encode_message(
|
||||
service: ServiceId,
|
||||
class: TrafficClass,
|
||||
text: &[u8],
|
||||
) -> Result<Vec<u8>, FrameError> {
|
||||
icenet_wire::encode(&Frame {
|
||||
service,
|
||||
class,
|
||||
payload: text.to_vec(),
|
||||
})
|
||||
}
|
||||
7
workspace/crates/icenet-sdk/tests/facade.rs
Normal file
7
workspace/crates/icenet-sdk/tests/facade.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
use icenet_sdk::{ServiceId, TrafficClass, encode_message};
|
||||
|
||||
#[test]
|
||||
fn sdk_constructs_bounded_frames() {
|
||||
let bytes = encode_message(ServiceId(77_777), TrafficClass::Text, b"hi").unwrap();
|
||||
assert!(!bytes.is_empty());
|
||||
}
|
||||
33
workspace/crates/icenet-sdk/tests/udp_roundtrip.rs
Normal file
33
workspace/crates/icenet-sdk/tests/udp_roundtrip.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//! End-to-end frame exchange over a real UDP loopback pair.
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use icenet_sdk::{Frame, ServiceId, TrafficClass, Transport, UdpTransport, decode, encode};
|
||||
|
||||
#[test]
|
||||
fn encoded_frame_survives_a_udp_round_trip() {
|
||||
let first = UdpTransport::bind("127.0.0.1:0").expect("bind first");
|
||||
let second = UdpTransport::bind("127.0.0.1:0").expect("bind second");
|
||||
let first_addr = first.local_addr().expect("first address");
|
||||
let second_addr = second.local_addr().expect("second address");
|
||||
let mut sender = first.connect(second_addr).expect("connect sender");
|
||||
let mut receiver = second.connect(first_addr).expect("connect receiver");
|
||||
|
||||
let frame = Frame {
|
||||
class: TrafficClass::Text,
|
||||
service: ServiceId(77_777),
|
||||
payload: b"hello over udp".to_vec(),
|
||||
};
|
||||
sender.send(encode(&frame).expect("encode")).expect("send");
|
||||
|
||||
let deadline = Instant::now() + Duration::from_secs(2);
|
||||
let mut received = None;
|
||||
while Instant::now() < deadline {
|
||||
if let Some(bytes) = receiver.recv().expect("recv") {
|
||||
received = Some(bytes);
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(5));
|
||||
}
|
||||
let bytes = received.expect("frame within deadline");
|
||||
assert_eq!(decode(&bytes), Ok(frame));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue