Bounded GF256 packet innovation, decoding and incomplete-relay recoding in pure MoonBit
moon add ZJH-666-ZJH/moonrecoder@0.1.0import {
"ZJH-666-ZJH/moonrecoder" @r,
}let input = @r.Symbols::from_bytes(b"hello")
let encoder = @r.Encoder::new(7, input, 2)
let decoder = @r.Decoder::new(encoder.generation())
ignore(decoder.admit(encoder.systematic(0, 0)))
ignore(decoder.admit(encoder.systematic(2, 2)))
let hint = @r.feedback_from_wire(decoder.feedback().to_wire())
ignore(decoder.admit_batch(encoder.repair(hint, 10)))
assert_true(decoder.recover().equal(input))| 下游用户 | 输入与处理 | 可核验结果 | 命令 |
|---|---|---|---|
| 遥测网关 / 丢包实验开发者 | 五个系统包中丢两个、重复一个,经反馈请求缺失主元修复 | 两个修复包恢复原始字节,重复计数为 1 | moon run examples/telemetry |
| 多跳仿真 / 中继组件开发者 | 中继仅收到三个源符号中的两个,在秩不足时混合当前基 | 下游收到两个独立混合包和另一个源包后恢复;中继始终秩 2 | moon run examples/relay |
| 测试设施 / 离线诊断作者 | 非法 hex、重复帧、两代交错流和七字节网络切片 | 生成拒绝事件、不污染秩,分别恢复两代并释放保留额度 | moon run examples/trace |
moon info
moon fmt
moon fmt --check
moon check --deny-warn --target wasm-gc
moon build --deny-warn --target wasm-gc
moon test --deny-warn --target wasm-gc
moon run examples/telemetry --target wasm-gc --deny-warn
moon run examples/relay --target wasm-gc --deny-warn
moon run examples/trace --target wasm-gc --deny-warnpub(all) suberror CodeError {
Invalid(String)
Shape(String)
Limit(String)
Inconsistent
Incomplete(Int)
Corrupt(String)
Truncated
}pub struct CoefficientStream {
state : UInt
draw_count : Int
draw_limit : Int
}pub struct Crc32 {
accumulator : UInt
}pub(all) struct DecodeReport {
generation_id : Int
source_count : Int
rank : Int
deficit : Int
admitted : Int
dependent : Int
known : Int
pivots : Array[Int]
}pub struct Decoder {
generation_value : Generation
basis : Basis
packet_limit : Int
admitted_count : Int
dependent_count : Int
}fn Encoder::coded(self : Encoder, stream : CoefficientStream, sequence : Int) -> Packet raise CodeErrorpub struct FrameReader {
pending : Array[Int]
byte_count : Int
frame_count : Int
byte_limit : Int
frame_limit : Int
}pub struct Generation {
id_value : Int
count_value : Int
width_value : Int
length_value : Int
}fn Packet::new(generation : Generation, sequence : Int, equation : Equation) -> Packet raise CodeErrorpub struct Replay {
decoder : Decoder
event_limit : Int
event_values : Array[ReplayEvent]
rejection_count : Int
}pub struct ReplayEvent {
index_value : Int
sequence_value : Int?
rank_value : Int
status_value : String
error_value : String?
}fn SessionPool::new(max_generations? : Int, max_cells? : Int, max_packets_per_generation? : Int) -> SessionPool raise CodeErrorInstall
Download zipBounded GF256 packet innovation, decoding and incomplete-relay recoding in pure MoonBit