smolpy 1.10.2.dev2__py3-none-any.whl → 1.10.3.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smolpy/backends.py +5 -1
- smolpy/core/network.py +2 -1
- smolpy/ethernet/switch.py +9 -1
- smolpy/lang/ast.py +1 -0
- smolpy/lang/interpreter.py +1 -0
- smolpy/lang/transformer.py +20 -0
- smolpy/model/frames.py +1 -0
- smolpy/model/scenario.py +13 -1
- smolpy/model/validate.py +42 -1
- smolpy/ns3/__init__.py +4 -0
- {smolpy-1.10.2.dev2.dist-info → smolpy-1.10.3.dev2.dist-info}/METADATA +38 -8
- {smolpy-1.10.2.dev2.dist-info → smolpy-1.10.3.dev2.dist-info}/RECORD +15 -15
- {smolpy-1.10.2.dev2.dist-info → smolpy-1.10.3.dev2.dist-info}/WHEEL +0 -0
- {smolpy-1.10.2.dev2.dist-info → smolpy-1.10.3.dev2.dist-info}/entry_points.txt +0 -0
- {smolpy-1.10.2.dev2.dist-info → smolpy-1.10.3.dev2.dist-info}/licenses/LICENSE +0 -0
smolpy/backends.py
CHANGED
|
@@ -52,7 +52,8 @@ class Capabilities:
|
|
|
52
52
|
traffic: frozenset[str]
|
|
53
53
|
patterns: frozenset[str] # of flows
|
|
54
54
|
metrics: frozenset[str]
|
|
55
|
-
|
|
55
|
+
# "imix": IMIX frame sizes; "bounded_buffer": switch buffers (ADR-0011)
|
|
56
|
+
features: frozenset[str] = frozenset()
|
|
56
57
|
priorities: bool = True # 802.1Q priorities above 0 on flows
|
|
57
58
|
half_duplex: bool = False
|
|
58
59
|
dashboards: bool = False # the live and text modes of simulate()
|
|
@@ -278,6 +279,9 @@ def check(scenario: Scenario, backend: str = DEFAULT, *, dashboard: bool = False
|
|
|
278
279
|
for i, node in enumerate(scenario.nodes):
|
|
279
280
|
if node.kind not in caps.nodes:
|
|
280
281
|
raise unsupported(node, label(node.kind), ("nodes", i))
|
|
282
|
+
bounded = getattr(node, "buffer_bytes", None) is not None
|
|
283
|
+
if bounded and "bounded_buffer" not in caps.features:
|
|
284
|
+
raise unsupported(node, "bounded switch buffers", ("nodes", i))
|
|
281
285
|
for i, link in enumerate(scenario.links):
|
|
282
286
|
if not link.duplex and not caps.half_duplex:
|
|
283
287
|
raise unsupported(link, "half-duplex links", ("links", i))
|
smolpy/core/network.py
CHANGED
|
@@ -142,8 +142,9 @@ class Network:
|
|
|
142
142
|
mode: SwitchMode = "store-and-forward",
|
|
143
143
|
qos: SwitchQoS = "strict",
|
|
144
144
|
mac_table: MacTableMode = "learning",
|
|
145
|
+
buffer: int | None = None,
|
|
145
146
|
) -> Switch:
|
|
146
|
-
node = Switch(name, ports=ports, mode=mode, qos=qos, mac_table=mac_table)
|
|
147
|
+
node = Switch(name, ports=ports, mode=mode, qos=qos, mac_table=mac_table, buffer=buffer)
|
|
147
148
|
self._register(node)
|
|
148
149
|
return node
|
|
149
150
|
|
smolpy/ethernet/switch.py
CHANGED
|
@@ -22,6 +22,10 @@ class Switch(Node):
|
|
|
22
22
|
meanwhile. mac_table="topology" starts with the port towards every end
|
|
23
23
|
station already known (shortest path), i.e. the converged state, and
|
|
24
24
|
keeps learning on top of it.
|
|
25
|
+
|
|
26
|
+
buffer bounds every egress queue, in bytes: a frame that would take the
|
|
27
|
+
bytes waiting on its port beyond it is dropped (ADR-0011). None, the
|
|
28
|
+
default, is unbounded.
|
|
25
29
|
"""
|
|
26
30
|
|
|
27
31
|
def __init__(
|
|
@@ -31,13 +35,17 @@ class Switch(Node):
|
|
|
31
35
|
mode: SwitchMode = "store-and-forward",
|
|
32
36
|
qos: SwitchQoS = "strict",
|
|
33
37
|
mac_table: MacTableMode = "learning",
|
|
38
|
+
buffer: int | None = None,
|
|
34
39
|
) -> None:
|
|
35
40
|
super().__init__(name)
|
|
36
41
|
self.ports = ports
|
|
37
42
|
self.mode = mode
|
|
38
43
|
self.qos = qos
|
|
39
44
|
self.mac_table_mode = mac_table
|
|
45
|
+
self.buffer = buffer
|
|
40
46
|
check_node(self.to_spec())
|
|
41
47
|
|
|
42
48
|
def to_spec(self) -> SwitchNode:
|
|
43
|
-
return SwitchNode(
|
|
49
|
+
return SwitchNode(
|
|
50
|
+
self.name, self.ports, self.mode, self.qos, self.mac_table_mode, self.buffer
|
|
51
|
+
)
|
smolpy/lang/ast.py
CHANGED
smolpy/lang/interpreter.py
CHANGED
|
@@ -120,6 +120,7 @@ class _Interpreter:
|
|
|
120
120
|
mode=d.mode, # type: ignore[arg-type]
|
|
121
121
|
qos=d.qos, # type: ignore[arg-type]
|
|
122
122
|
mac_table=d.mac_table, # type: ignore[arg-type]
|
|
123
|
+
buffer=d.buffer, # type: ignore[arg-type]
|
|
123
124
|
)
|
|
124
125
|
elif isinstance(d, smol_ast.MqttBrokerDecl):
|
|
125
126
|
net.mqtt_broker(d.name, ip=d.ip)
|
smolpy/lang/transformer.py
CHANGED
|
@@ -43,6 +43,25 @@ def _coerce(raw: str) -> int | float | str:
|
|
|
43
43
|
return raw
|
|
44
44
|
|
|
45
45
|
|
|
46
|
+
_BYTE_SUFFIXES = {"kB": 10**3, "MB": 10**6, "KiB": 2**10, "MiB": 2**20}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _bytes(raw: Any) -> Any:
|
|
50
|
+
"""A byte count with an optional suffix (``115kB``, ``112KiB``), as an int
|
|
51
|
+
when it is a whole number of bytes. Anything else is returned as it is,
|
|
52
|
+
for validation to reject with the scenario's own message."""
|
|
53
|
+
if isinstance(raw, str):
|
|
54
|
+
for suffix, factor in _BYTE_SUFFIXES.items():
|
|
55
|
+
if raw.endswith(suffix):
|
|
56
|
+
number = _coerce(raw[: -len(suffix)])
|
|
57
|
+
if isinstance(number, (int, float)) and not isinstance(number, bool):
|
|
58
|
+
value = number * factor
|
|
59
|
+
return int(value) if value == int(value) else value
|
|
60
|
+
if isinstance(raw, float) and raw == int(raw):
|
|
61
|
+
return int(raw)
|
|
62
|
+
return raw
|
|
63
|
+
|
|
64
|
+
|
|
46
65
|
def _require(kwargs: dict[str, Any], key: str, *, file: str, line: int, stmt: str) -> Any:
|
|
47
66
|
if key not in kwargs:
|
|
48
67
|
raise SMOLSyntaxError(file, line, f"'{stmt}' is missing required argument '{key}'")
|
|
@@ -98,6 +117,7 @@ class _SmolTransformer(Transformer):
|
|
|
98
117
|
line=meta.line,
|
|
99
118
|
qos=str(kw.get("qos", "strict")),
|
|
100
119
|
mac_table=str(kw.get("mac_table", "learning")),
|
|
120
|
+
buffer=_bytes(kw["buffer"]) if "buffer" in kw else None,
|
|
101
121
|
)
|
|
102
122
|
|
|
103
123
|
def mqtt_broker_decl(self, meta: Any, children: list) -> MqttBrokerDecl:
|
smolpy/model/frames.py
CHANGED
|
@@ -16,6 +16,7 @@ ETHERNET_HEADER_BYTES = 14
|
|
|
16
16
|
FCS_BYTES = 4
|
|
17
17
|
VLAN_TAG_BYTES = 4 # 802.1Q, on frames with a priority above 0
|
|
18
18
|
MIN_FRAME_BYTES = 64
|
|
19
|
+
MAX_STANDARD_FRAME_BYTES = 1522 # 1 518 B and an 802.1Q tag: the least a bounded buffer holds
|
|
19
20
|
PREAMBLE_SFD_BYTES = 8
|
|
20
21
|
IFG_BYTES = 12 # inter-frame gap
|
|
21
22
|
WIRE_OVERHEAD_BYTES = PREAMBLE_SFD_BYTES + IFG_BYTES # 20 B per frame on the wire
|
smolpy/model/scenario.py
CHANGED
|
@@ -26,6 +26,11 @@ from smolpy.core.batch import BatchSpec
|
|
|
26
26
|
FORMAT = "smol-ir"
|
|
27
27
|
VERSION = 2 # 2: Ethernet frames on the wire (ADR-0010)
|
|
28
28
|
|
|
29
|
+
# Optional fields that are left out of the JSON while they hold their default,
|
|
30
|
+
# so that documents not using them read as before, in older readers too
|
|
31
|
+
# (ADR-0011: switch buffers).
|
|
32
|
+
_OMITTED_WHEN_UNSET = {"buffer_bytes"}
|
|
33
|
+
|
|
29
34
|
SwitchMode = Literal["store-and-forward", "cut-through"]
|
|
30
35
|
SwitchQoS = Literal["strict", "fifo"]
|
|
31
36
|
MacTableMode = Literal["learning", "topology"]
|
|
@@ -48,7 +53,11 @@ class AdapterNode:
|
|
|
48
53
|
|
|
49
54
|
@dataclass(frozen=True)
|
|
50
55
|
class SwitchNode:
|
|
51
|
-
"""Layer-2 switch: per-port egress queues and a MAC table.
|
|
56
|
+
"""Layer-2 switch: per-port egress queues and a MAC table.
|
|
57
|
+
|
|
58
|
+
*buffer_bytes* bounds each egress queue: the frame bytes waiting on a
|
|
59
|
+
port, the frame in transmission not counted. A frame that would exceed it
|
|
60
|
+
is dropped (ADR-0011). ``None`` is unbounded."""
|
|
52
61
|
|
|
53
62
|
kind: ClassVar[str] = "switch"
|
|
54
63
|
name: str
|
|
@@ -56,6 +65,7 @@ class SwitchNode:
|
|
|
56
65
|
mode: SwitchMode = "store-and-forward"
|
|
57
66
|
qos: SwitchQoS = "strict"
|
|
58
67
|
mac_table: MacTableMode = "learning"
|
|
68
|
+
buffer_bytes: int | None = None
|
|
59
69
|
|
|
60
70
|
|
|
61
71
|
@dataclass(frozen=True)
|
|
@@ -422,6 +432,8 @@ def _encode(obj: Any) -> dict[str, Any]:
|
|
|
422
432
|
out["kind"] = kind
|
|
423
433
|
for f in dataclasses.fields(obj):
|
|
424
434
|
value = getattr(obj, f.name)
|
|
435
|
+
if f.name in _OMITTED_WHEN_UNSET and value is None:
|
|
436
|
+
continue
|
|
425
437
|
if isinstance(value, BatchSpec):
|
|
426
438
|
value = {"kind": value.kind, "param": value.param}
|
|
427
439
|
elif isinstance(value, tuple):
|
smolpy/model/validate.py
CHANGED
|
@@ -20,7 +20,17 @@ from collections.abc import Mapping
|
|
|
20
20
|
from typing import Literal
|
|
21
21
|
|
|
22
22
|
from smolpy.model import timebase
|
|
23
|
-
from smolpy.model.frames import
|
|
23
|
+
from smolpy.model.frames import (
|
|
24
|
+
IMIX_SIZES,
|
|
25
|
+
MAX_STANDARD_FRAME_BYTES,
|
|
26
|
+
MIN_FRAME_BYTES,
|
|
27
|
+
PN_CYCLES_MS,
|
|
28
|
+
PN_MAX_IO_BYTES,
|
|
29
|
+
flow_frame_size,
|
|
30
|
+
modbus_response_frame_size,
|
|
31
|
+
mqtt_publish_frame_size,
|
|
32
|
+
pn_frame_size,
|
|
33
|
+
)
|
|
24
34
|
from smolpy.model.scenario import (
|
|
25
35
|
AdapterNode,
|
|
26
36
|
Flow,
|
|
@@ -168,6 +178,13 @@ def check_node(node: NodeSpec) -> None:
|
|
|
168
178
|
_one_of(node, "mode", node.mode, SWITCH_MODES)
|
|
169
179
|
_one_of(node, "qos", node.qos, SWITCH_QOS)
|
|
170
180
|
_one_of(node, "mac_table", node.mac_table, MAC_TABLES)
|
|
181
|
+
b = node.buffer_bytes
|
|
182
|
+
if b is not None and (not _integer(b) or b < MAX_STANDARD_FRAME_BYTES):
|
|
183
|
+
raise _fail(
|
|
184
|
+
node,
|
|
185
|
+
f"buffer must be a whole number of bytes, at least one maximum frame"
|
|
186
|
+
f" ({MAX_STANDARD_FRAME_BYTES} B), got {b!r}",
|
|
187
|
+
)
|
|
171
188
|
if isinstance(node, ModbusSlaveNode):
|
|
172
189
|
_in_range(node, "unit_id", node.unit_id, 0, 255)
|
|
173
190
|
|
|
@@ -229,6 +246,20 @@ def check_traffic(t: TrafficSpec, nodes: Mapping[str, NodeSpec] | None = None) -
|
|
|
229
246
|
_non_negative(t, "delay", getattr(t, "delay_ms", 0.0))
|
|
230
247
|
|
|
231
248
|
|
|
249
|
+
def _largest_frame(t: TrafficSpec) -> int:
|
|
250
|
+
"""The largest frame *t* sends, in bytes (Model Semantics §2)."""
|
|
251
|
+
if isinstance(t, Flow):
|
|
252
|
+
size = max(s for s, _ in IMIX_SIZES) if t.size == "imix" else t.size
|
|
253
|
+
return flow_frame_size(size, t.priority)
|
|
254
|
+
if isinstance(t, Publish):
|
|
255
|
+
return mqtt_publish_frame_size(t.topic, t.payload, t.qos)
|
|
256
|
+
if isinstance(t, Poll):
|
|
257
|
+
return modbus_response_frame_size(t.count)
|
|
258
|
+
if isinstance(t, ProfinetAR):
|
|
259
|
+
return pn_frame_size(max(t.inputs, t.outputs))
|
|
260
|
+
return 0 # a route forwards PUBLISH frames, sized by their publish
|
|
261
|
+
|
|
262
|
+
|
|
232
263
|
def _check_batch(t: Flow) -> None:
|
|
233
264
|
b = t.batch
|
|
234
265
|
assert b is not None
|
|
@@ -324,6 +355,16 @@ def validate(scenario: Scenario) -> None:
|
|
|
324
355
|
raise _fail(t, "topic is routed twice")
|
|
325
356
|
routes.add((t.broker, t.topic))
|
|
326
357
|
|
|
358
|
+
largest = max((_largest_frame(t) for t in scenario.traffic), default=0)
|
|
359
|
+
for i, node in enumerate(scenario.nodes):
|
|
360
|
+
if isinstance(node, SwitchNode) and node.buffer_bytes is not None:
|
|
361
|
+
if node.buffer_bytes < largest:
|
|
362
|
+
raise ScenarioError(
|
|
363
|
+
f"{describe(node)}: buffer {node.buffer_bytes} B is smaller than the"
|
|
364
|
+
f" largest frame of the scenario, {largest} B, which it would always drop",
|
|
365
|
+
("nodes", i),
|
|
366
|
+
)
|
|
367
|
+
|
|
327
368
|
observed: set[tuple[str, str]] = set()
|
|
328
369
|
for i, o in enumerate(scenario.observations):
|
|
329
370
|
with _at("observations", i):
|
smolpy/ns3/__init__.py
CHANGED
|
@@ -224,6 +224,10 @@ def lower(scenario: model.Scenario) -> tuple[str, list[_Sampler]]:
|
|
|
224
224
|
lines = [f"smol-ns3 {FORMAT_VERSION}", f"duration {tb.ms_to_ns(scenario.run.duration_ms)}"]
|
|
225
225
|
for n in scenario.nodes:
|
|
226
226
|
if isinstance(n, model.SwitchNode):
|
|
227
|
+
if n.buffer_bytes is not None: # never run as unbounded (ADR-0011)
|
|
228
|
+
raise ValueError(
|
|
229
|
+
f"switch {n.name!r}: the ns3 backend does not support bounded switch buffers"
|
|
230
|
+
)
|
|
227
231
|
lines.append("switch")
|
|
228
232
|
else:
|
|
229
233
|
lines.append(f"adapter {n.mac} {n.ip}") # a station, with IPv4
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: smolpy
|
|
3
|
-
Version: 1.10.
|
|
3
|
+
Version: 1.10.3.dev2
|
|
4
4
|
Summary: Network simulation DSL and discrete-event simulator
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -39,16 +39,17 @@ Python rewrite of SMOL — a Network Description Language and Discrete-Event Sim
|
|
|
39
39
|
|
|
40
40
|
SMOLPy lets you describe a network topology in pure Python, define traffic flows, and run a discrete-event simulation that produces real metric time-series. A built-in Dear PyGui desktop dashboard shows the topology and live metric charts as the simulation runs.
|
|
41
41
|
|
|
42
|
-
> **
|
|
42
|
+
> **Three simulation engines, one model.** A scenario, written in Python or in a `.smol` file, becomes one execution-independent model, and it runs on any of three engines:
|
|
43
43
|
>
|
|
44
44
|
> - **SimPy** (Python): the reference implementation. It is always installed, runs the whole model and drives the dashboards.
|
|
45
45
|
> - **Rust** (`smol-engine`): a native engine that gives **SimPy's results bit for bit** and runs about **40× faster**. B1 at 10 M frames takes 4.9 s, against 200.8 s on SimPy.
|
|
46
|
+
> - **ns-3**: the same scenario on **[ns-3](https://www.nsnam.org/)**, the established network simulator, with its real IPv4, UDP and **TCP** stack. Modbus TCP and MQTT run over ns-3's TCP, with its handshake, acknowledgements, and flow and congestion control. Ethernet and PROFINET RT give SimPy's results bit for bit.
|
|
46
47
|
>
|
|
47
48
|
> ```python
|
|
48
|
-
> result = net.simulate(duration=60_000, backend="rust")
|
|
49
|
+
> result = net.simulate(duration=60_000, backend="rust") # or "ns3"
|
|
49
50
|
> ```
|
|
50
51
|
>
|
|
51
|
-
>
|
|
52
|
+
> Every engine runs the whole model: Ethernet, Modbus TCP, MQTT and PROFINET RT. Only the live and text dashboards need SimPy. See [Simulation engine](#simulation-engine), [Running on ns-3](#running-on-ns-3) and [Execution backends](https://jwszolek.github.io/SMOLPy/backends/).
|
|
52
53
|
|
|
53
54
|
📖 **Full documentation:** [jwszolek.github.io/SMOLPy](https://jwszolek.github.io/SMOLPy/)
|
|
54
55
|
|
|
@@ -99,7 +100,7 @@ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy run plant.smol --backend
|
|
|
99
100
|
- It runs as uid 1000. To own the files it writes as yourself, add `--user "$(id -u):$(id -g)"`.
|
|
100
101
|
- A version is pinned as `ghcr.io/jwszolek/smolpy:<version>`; `latest` is the latest release.
|
|
101
102
|
|
|
102
|
-
**With ns-3,** from the image `<version>-ns3` or `latest-ns3`, for `linux/amd64
|
|
103
|
+
**With ns-3,** from the image `<version>-ns3` or `latest-ns3`, published from 1.10.0 on, for `linux/amd64` and, from the release after 1.10.1, `linux/arm64`. It adds the pinned ns-3 build and the ns-3 backend, ready to run:
|
|
103
104
|
|
|
104
105
|
```bash
|
|
105
106
|
docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3 -o results.csv
|
|
@@ -483,7 +484,7 @@ IRT (isochronous, scheduled) traffic, AR establishment (DCP / RPC connect), acyc
|
|
|
483
484
|
|
|
484
485
|
## Simulation engine
|
|
485
486
|
|
|
486
|
-
Every simulation goes through the same path. The Python API and `.smol` files build a **Scenario IR**, an execution-independent model ([ADR-0007](https://jwszolek.github.io/SMOLPy/adr/0007-execution-independent-scenario-model/)), and a **backend** runs it.
|
|
487
|
+
Every simulation goes through the same path. The Python API and `.smol` files build a **Scenario IR**, an execution-independent model ([ADR-0007](https://jwszolek.github.io/SMOLPy/adr/0007-execution-independent-scenario-model/)), and a **backend** runs it. Every engine follows the same written contract, [Model Semantics](https://jwszolek.github.io/SMOLPy/model-semantics/):
|
|
487
488
|
- simulated time is integer nanoseconds;
|
|
488
489
|
- frames are modelled on the wire as real Ethernet, with preamble, FCS and inter-frame gap.
|
|
489
490
|
|
|
@@ -502,11 +503,11 @@ batch = run_many(net, runs=30, duration=60_000, backend="rust")
|
|
|
502
503
|
smolpy run plant.smol --backend rust
|
|
503
504
|
```
|
|
504
505
|
|
|
505
|
-
- **The same numbers.** On deterministic scenarios the Rust engine reproduces SimPy's results bit for bit, down to the event count. Random traffic uses
|
|
506
|
+
- **The same numbers.** On deterministic scenarios the Rust engine reproduces SimPy's results bit for bit, down to the event count. Random traffic uses its own generator, so there the results agree statistically. ns-3 draws random traffic from SimPy's streams, so its Ethernet and PROFINET RT results are bit for bit with the same seed, random traffic included. CI checks both on every pull request ([ADR-0009](https://jwszolek.github.io/SMOLPy/adr/0009-batch-execution-and-cross-backend-validation/)).
|
|
506
507
|
- **ns-3 adds TCP.** Ethernet and PROFINET on ns-3 also give SimPy's results bit for bit. Modbus and MQTT run over ns-3's TCP, so their results differ by what TCP does: under heavy load by up to +43 % in latency. [Execution backends](https://jwszolek.github.io/SMOLPy/backends/) has the details and measurements.
|
|
507
508
|
- **Nothing is skipped silently.** A scenario that uses something a backend does not support is rejected before the run with a message naming the element. Asking the Rust engine for a dashboard is an error too.
|
|
508
509
|
|
|
509
|
-
The model
|
|
510
|
+
The model every engine implements:
|
|
510
511
|
|
|
511
512
|
- **MAC-learning switch** — each switch pre-seeds its forwarding table from the topology wiring, eliminating spurious flooding toward silent endpoints (e.g. a server that only receives). Dynamic learning still operates for traffic through intermediate switches.
|
|
512
513
|
- **Store-and-forward model** — transmission delay + propagation delay per hop.
|
|
@@ -516,6 +517,35 @@ The model both engines implement:
|
|
|
516
517
|
|
|
517
518
|
---
|
|
518
519
|
|
|
520
|
+
## Running on ns-3
|
|
521
|
+
|
|
522
|
+
The `ns3` backend runs a SMOL scenario on [ns-3](https://www.nsnam.org/) 3.49, the open-source network simulator used widely in networking research. The same `.smol` file or `Network` that runs on SimPy runs there too, unchanged:
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3 -o results.csv
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
```python
|
|
529
|
+
result = net.simulate(duration=60_000, backend="ns3")
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
**What it is for.**
|
|
533
|
+
- **A real TCP.** SMOL sizes Modbus TCP and MQTT frames as TCP segments, but SimPy and Rust do not model TCP's behaviour. On ns-3 every Modbus master–slave and MQTT client–broker pair has one persistent connection over ns-3's TCP: the handshake, delayed acknowledgements, CUBIC congestion control and the receiver's window.
|
|
534
|
+
- **A cross-check against an established simulator.** Below the TCP layer, ns-3 runs SMOL's own full-duplex Ethernet device and switch. So Ethernet over UDP and PROFINET RT on layer 2 give SimPy's results **bit for bit**, watchdog expiries and stochastic traffic included. That ties SMOL's reference model to ns-3's event scheduler and IP stack.
|
|
535
|
+
- **Where TCP matters.** `python -m benchmarks load` runs a plant cell whose Modbus and MQTT traffic shares a 10 Mb/s uplink with a UDP camera, from 50 % to 150 % offered load:
|
|
536
|
+
|
|
537
|
+
| Offered load | Modbus RTT, SimPy → ns-3 | MQTT latency, SimPy → ns-3 | Delivered to the HMI |
|
|
538
|
+
|---|---|---|---|
|
|
539
|
+
| 0.50 – 0.95 | within 0.4 % | within 0.4 % | the same |
|
|
540
|
+
| 1.00 | +18 % | +25 % | the same |
|
|
541
|
+
| 1.50 | 3.2 → 3.4 s (+6 %) | 3.2 → 4.5 s (+43 %) | −41 % |
|
|
542
|
+
|
|
543
|
+
Below saturation the engines agree. At saturation, TCP's own acknowledgements tip the link over. Heavily overloaded, TCP's windows hold MQTT back while the UDP stream, which does not back off, takes the link. [Execution backends](https://jwszolek.github.io/SMOLPy/backends/#modbus-and-mqtt-over-tcp) has the full table and the mechanism.
|
|
544
|
+
|
|
545
|
+
**Getting it.** ns-3 cannot be installed with `pip`, so the simplest way is the image `ghcr.io/jwszolek/smolpy:latest-ns3` ([Install](#install)). It holds the ns-3 build, SMOLPy, the Rust engine and `smol-ns3`, the C++ program that runs scenarios on ns-3, compiled in. With your own ns-3 3.49 build instead, set `NS3_HOME` to it: the first run compiles `smol-ns3` in about 8 s and caches it.
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
519
549
|
## Examples
|
|
520
550
|
|
|
521
551
|
See [`examples/README.md`](examples/README.md) for ten ready-to-run scenarios covering single-switch saturation, oversubscription, two-tier access bottlenecks, MQTT publish-subscribe, Modbus TCP polling, and PROFINET RT cyclic I/O.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
smolpy/__init__.py,sha256=f8Cp7OfQ9ZJZfwD-Au3CFH3VjJOYYH_pW_znR6uMrgM,630
|
|
2
2
|
smolpy/_worker.py,sha256=bDP1qTs2AFatzsN-R_cxuGyRgimXRqjuWfhu1TiYqcQ,2128
|
|
3
|
-
smolpy/backends.py,sha256=
|
|
3
|
+
smolpy/backends.py,sha256=z1JGgUgWLy9Tr7-ifbdnzkEnEvlgRFr6JfB-q0ySbNA,11118
|
|
4
4
|
smolpy/batch.py,sha256=qz00omQ7SqnV9K0CtogUHOzV3a_Vpy_3ViSYJcIN3oU,16999
|
|
5
5
|
smolpy/cli.py,sha256=i_Tlw8nElU8FvSlk2Ts3oQMbMuSUgwXM6dQD1w29pl0,12346
|
|
6
6
|
smolpy/stats.py,sha256=7ZU3JE3iXRUpTLrWbL_zQgm5Zsj3QYgAAMILniuLDkQ,5515
|
|
@@ -8,28 +8,28 @@ smolpy/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
8
8
|
smolpy/core/adapter.py,sha256=rMdIkeZiRS4pR285-VCxxHtOw_Xct5x6ZW-H4zrCA4Q,6764
|
|
9
9
|
smolpy/core/batch.py,sha256=Rmf72_Z7OSUSq21m5C59mxaj5dby1YJ305UYrpX2tsA,3980
|
|
10
10
|
smolpy/core/link.py,sha256=Xq-NOm361WLYyv0Rbx8aAuP2PgBirBwWSIgj3nxteYI,606
|
|
11
|
-
smolpy/core/network.py,sha256=
|
|
11
|
+
smolpy/core/network.py,sha256=v4jmgSkrElKOPX9kyz8-nwa_8b2l_Ek0ikdvpxEq81Y,10338
|
|
12
12
|
smolpy/core/node.py,sha256=fCHVE_Bk18bpVdNWkYcdeLStNCx3RWIxLqkK7mFuin0,599
|
|
13
13
|
smolpy/core/observation.py,sha256=LnCQ3ddx1XyDOZW0FvBls9L3289Lt34itgrEwfTQhGY,523
|
|
14
14
|
smolpy/ethernet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
smolpy/ethernet/switch.py,sha256=
|
|
15
|
+
smolpy/ethernet/switch.py,sha256=qme4Bg7D25XNzcuajfDaeZgq-fxu1GIi45kmUCo9A_8,1674
|
|
16
16
|
smolpy/lang/__init__.py,sha256=ZKwtOchpxVrSs768WHhGxmyM-cL1PnzgWWs4tZw6Qrg,314
|
|
17
|
-
smolpy/lang/ast.py,sha256=
|
|
17
|
+
smolpy/lang/ast.py,sha256=yez2nwL78g_NQqgkD43JotveiR581cAkowuE7zfyVn4,2040
|
|
18
18
|
smolpy/lang/errors.py,sha256=aPvk4dgIb4GiRZ6dVM2PbXIFro75pq-R6HUbC7RhK9g,684
|
|
19
19
|
smolpy/lang/grammar.lark,sha256=oHc50SVLwLFLdWc9NZkWIKwxIYOE0Xj-P-O0Hq__oqk,1343
|
|
20
|
-
smolpy/lang/interpreter.py,sha256=
|
|
21
|
-
smolpy/lang/transformer.py,sha256=
|
|
20
|
+
smolpy/lang/interpreter.py,sha256=yKLCfbNKwmcOR0VckGEybRaEdIN8QAJ-H9x4N1ZBgGE,11592
|
|
21
|
+
smolpy/lang/transformer.py,sha256=nbl5rUyaPU02ZQdGP5c_uZXPTtkmklzNSSJA0DPQIMw,10195
|
|
22
22
|
smolpy/modbus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
smolpy/modbus/slave.py,sha256=8HYIPWYsG18dA9nUYQAfFnviN84zQBnCokfBNVaAJx0,780
|
|
24
24
|
smolpy/model/__init__.py,sha256=jDG2h9hBtpruhEexo_3No7b1CIE17TdsuCSrVbAdXwg,725
|
|
25
|
-
smolpy/model/frames.py,sha256=
|
|
26
|
-
smolpy/model/scenario.py,sha256=
|
|
25
|
+
smolpy/model/frames.py,sha256=P_mf3HL-nkajLQBhtAW3aXu_AVW62_bNdCjLkJYJRfQ,3138
|
|
26
|
+
smolpy/model/scenario.py,sha256=OMTxy93bO5Ax0PjzlaeNBb91HOmbgt4pkWHLXIPbrCc,16306
|
|
27
27
|
smolpy/model/streams.py,sha256=D47EtmPLcArjOtE2mNZUmyUb_4xpHAHRCn_L_P6-1yE,1774
|
|
28
28
|
smolpy/model/timebase.py,sha256=vSOObQhnEsKcHOBoP2IFWkXKS3VJdaI32_-fX7b1cDQ,4924
|
|
29
|
-
smolpy/model/validate.py,sha256=
|
|
29
|
+
smolpy/model/validate.py,sha256=NuUqieiiWL3VjT9cq4FDgUMVloiXa5VrEpXhvPl97uY,18195
|
|
30
30
|
smolpy/mqtt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
smolpy/mqtt/broker.py,sha256=fgc8MBsjBoppzrjWXzrlio_Zig6IfTlYnvT2AgnFy4k,1310
|
|
32
|
-
smolpy/ns3/__init__.py,sha256=
|
|
32
|
+
smolpy/ns3/__init__.py,sha256=A9oMOsum2CN9O601GLuNlLdLCmBXPTifoq0iVzklsiY,18289
|
|
33
33
|
smolpy/ns3/cpp/smol-ns3.cc,sha256=AHSmnSj3lzv0dsYiOU6OE-pgPhaYPOdxsO4sXjbIDO8,50387
|
|
34
34
|
smolpy/profinet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
smolpy/profinet/device.py,sha256=M-evpCOjT1O6GEvHZDmHpkA9Q_9Tb_KDtV304j1dSls,778
|
|
@@ -38,8 +38,8 @@ smolpy/sim/engine.py,sha256=LjWrQTYdOYUXbKZP8V4lfiI0rdONuFxUywnDndZBduo,37781
|
|
|
38
38
|
smolpy/viz/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
39
|
smolpy/viz/dashboard.py,sha256=VFpLa2RjcoaikkMW4d3FL6-g9aECMcTvnMYMq-gsY9Y,19561
|
|
40
40
|
smolpy/viz/text_dashboard.py,sha256=n-z1FMF1UBGYf-u8XY1NSSVVaJcZQ2jEjkZpJRHPkbM,4688
|
|
41
|
-
smolpy-1.10.
|
|
42
|
-
smolpy-1.10.
|
|
43
|
-
smolpy-1.10.
|
|
44
|
-
smolpy-1.10.
|
|
45
|
-
smolpy-1.10.
|
|
41
|
+
smolpy-1.10.3.dev2.dist-info/METADATA,sha256=ji-bCs7vhi5u-X4kI8rq85C8VySrz7maTwNiMkY-hKM,28523
|
|
42
|
+
smolpy-1.10.3.dev2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
43
|
+
smolpy-1.10.3.dev2.dist-info/entry_points.txt,sha256=hu51QgFSZg23v_VO01FgARiFfmSTFSHJykFOI2gaVdo,43
|
|
44
|
+
smolpy-1.10.3.dev2.dist-info/licenses/LICENSE,sha256=3AUGEmG-_hI18sPKmnlIKUxjaYepiEtuq1euWLVrnX8,1065
|
|
45
|
+
smolpy-1.10.3.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|