Deterministic network calculus: traffic contracts, min-plus curves, feed-forward bounds and capacity planning
| 使用者与问题 | 输入 → 分析 → 输出 | 可运行程序 |
|---|---|---|
| 平台设计者:服务链需要多少容量和缓冲区 | 流量突发/速率、各节点速率/时延、预算 → 服务串联、最坏界、容量反解 → 可行配置或明确不可行原因 | examples/capacity |
| 监控/数据管道开发者:实际流量是否满足声明的契约 | 有序时间与工作量记录、流量契约 → 所有事件区间核验、最坏反例、固定速率下最小观测突发 → 违例记录与只对观测成立的包络 | examples/trace_contract |
| 网络/实时系统工具作者:共享链路会怎样影响目标流 | 有向节点、严格服务曲线、各流路径 → 拓扑检查、交叉流量聚合、剩余服务、逐跳传播 → 各跳及端到端上界 | examples/feed_forward |
moon version --all
moon check --deny-warn --target all
moon build --target all
moon test --deny-warn --target all
moon run examples/capacity --target wasm-gc
moon run examples/trace_contract --target wasm-gc
moon run examples/feed_forward --target wasm-gcmoon add niuniu513-ask/moon-netcalculus@0.1.2import {
"niuniu513-ask/moon-netcalculus" @nc,
}fn main raise {
let a = @nc.token_bucket(10.0, 2.0)
let s = @nc.rate_latency(5.0, 3.0)
let report = @nc.bounds(a, s)
println(report.delay) // 5
}moon run cmd/main --target native -- '{"op":"bound","arrival":{"burst":10,"rate":2},"service":{"capacity":5,"latency":3}}'{"ok":true,"result":{"backlog":16,"delay":5,"output":{"burst":16,"rate":2},"utilization":0.4}}$req = '{"op":"bound","arrival":{"burst":10,"rate":2},"service":{"capacity":5,"latency":3}}'
cmd /c ('moon run cmd/main --target native -- "' + $req.Replace('"','\"') + '"')moon fmt --check
moon info
python scripts/verify.py
python scripts/verify_consumer.pypub suberror CalculusError {
Invalid(String)
Unbounded(String)
Infeasible(String)
Limit(String)
Numerical(String)
} derive(Debug)pub(all) struct Admission {
admitted : Bool
delay_ok : Bool
buffer_ok : Bool
metrics : AnalyticBounds
} derive(ToJson, Debug)pub(all) struct AnalyticBounds {
backlog : Double
delay : Double
output : TokenBucket
utilization : Double
} derive(ToJson, Debug)pub(all) struct BurstFit {
envelope : TokenBucket
witness : ContractWitness?
scope : String
} derive(ToJson, Debug)pub(all) struct ContractReport {
conforms : Bool
violating_intervals : Int
worst : ContractWitness?
checked_intervals : Int
events : Int
tolerance : Double
scope : String
} derive(ToJson, Debug)pub(all) struct Flow {
id : String
arrival : TokenBucket
route : Array[String]
} derive(ToJson, Debug)pub(all) struct FlowBound {
id : String
hops : Array[HopBound]
end_to_end : AnalyticBounds
sum_hop_delay : Double
maximum_hop_backlog : Double
exit_envelope : TokenBucket
} derive(ToJson, Debug)pub(all) struct HopBound {
server : String
input : TokenBucket
cross : TokenBucket
service : RateLatency
metrics : AnalyticBounds
} derive(ToJson, Debug)pub(all) struct WindowBounds {
backlog : Double
backlog_tick : Int
resolved_delay_max_ticks : Int
delay_upper_ticks : Int?
censored_samples : Int
horizon : Int
scope : String
} derive(Debug)impl ToJson for WindowBoundsfn admit(a : TokenBucket, s : RateLatency, delay_limit : Double, buffer_limit : Double) -> Admission raise CalculusErrorfn analyze_network(servers : Array[Server], flows : Array[Flow]) -> NetworkReport raise CalculusErrorfn check_contract(events : Array[TrafficEvent], contract : TokenBucket, tolerance? : Double) -> ContractReport raise CalculusErrorfn empirical_envelope(events : Array[TrafficEvent], windows : Array[Double]) -> Array[EnvelopeSample] raise CalculusErrorfn process_json(input : String) -> Stringfn required_capacity(a : TokenBucket, latency : Double, delay_limit : Double, buffer_limit : Double) -> CapacityPlan raise CalculusErrorInstall
Download zipDeterministic network calculus: traffic contracts, min-plus curves, feed-forward bounds and capacity planning