|
1 | 1 | # ARIEC61850 C++ Port |
2 | 2 |
|
3 | | -Incremental C++20 migration of the ARIEC61850 C# protocol stack. The C# implementation |
4 | | -remains the behavioral oracle until cross-language comparison and isolated-laboratory |
5 | | -interoperability are complete. |
| 3 | +Incremental C++20 migration of the ARIEC61850 C# protocol stack. The C# implementation remains |
| 4 | +the behavioral oracle until cross-language comparison and isolated-laboratory interoperability |
| 5 | +are complete. |
6 | 6 |
|
7 | 7 | ## Implemented |
8 | 8 |
|
9 | | -### Phase 0 — portable foundation |
10 | | - |
11 | | -- CMake-based C++20 static library. |
12 | | -- BER TLV and primitive codecs. |
13 | | -- MAC, VLAN, Ethernet, IEC 61850 process-bus, and classic PCAP codecs. |
14 | | -- GOOSE retransmission schedule. |
15 | | - |
16 | | -### Phase 1A–1E — deterministic process-bus core |
17 | | - |
18 | | -- IEC 61850 UTC time and recursive MMS Data/AllData codec. |
19 | | -- Complete GOOSE PDU/frame codecs and offline publisher/subscriber supervision. |
20 | | -- Sampled Values ASDU, multi-ASDU PDU, Ethernet frame, payload, quality, counter, and |
21 | | - stream supervision. |
22 | | -- C#-derived synthetic PCAP equivalence evidence. |
23 | | -- Sanitizer, deterministic mutation-smoke, and LLVM libFuzzer coverage. |
24 | | -- Receive-only isolated-laboratory tooling. |
25 | | - |
26 | | -### Phase 2A — SCL foundation |
27 | | - |
28 | | -- Bounded, dependency-free XML/SCL reader. |
29 | | -- IED, DataSet, FCDA, GOOSE, Sampled Values, report-control, and communication mapping. |
30 | | -- SCL edition detection, type-template resolution, DataSet binding, diagnostics, and |
31 | | - SCL/XML fuzzing. |
32 | | - |
33 | | -### Phase 2B — COMTRADE foundation |
34 | | - |
35 | | -- CFG parsing for IEEE C37.111-style 1991/1999/2013 records. |
36 | | -- ASCII, BINARY, BINARY32, and FLOAT32 DAT readers. |
37 | | -- Analog engineering scaling (`a * raw + b`) and packed digital status decoding. |
38 | | -- Timestamp multiplier and multi-rate fallback scheduling. |
39 | | -- Default `Va/Vb/Vc/Vn/Ia/Ib/Ic/In` channel mapping. |
40 | | -- Deterministic SCL Sampled Values to COMTRADE channel binding. |
41 | | -- Read-only `ariec61850_comtrade_inspect` human/JSON CLI. |
42 | | -- C#-derived ASCII and binary fixtures, mutation smoke, sanitizer, and libFuzzer corpus. |
43 | | - |
44 | | -### Phase 3A — MMS transport foundation |
45 | | - |
46 | | -- RFC 1006 TPKT frame encode/decode with strict version, reserved-octet, and length validation. |
47 | | -- Incremental TPKT stream framing for fragmented and coalesced TCP byte streams. |
48 | | -- COTP Connection Request, Connection Confirm, Data, Disconnect Request, and Error TPDU decoding. |
49 | | -- Default C#-compatible CR vector, TPDU-size negotiation, and TSAP selector mirroring. |
50 | | -- COTP Data segmentation by negotiated TPDU size and bounded EOT reassembly. |
51 | | -- Fragment-count, byte-count, and empty non-final fragment abuse guards. |
52 | | -- C#-derived golden vectors, deterministic mutation smoke, sanitizer, and libFuzzer coverage. |
53 | | - |
54 | | -### Phase 3B — MMS association codecs |
55 | | - |
56 | | -- Bounded ISO Session Connect/Accept SPDU and data-transfer profile codecs. |
57 | | -- Presentation CP/CPA context definitions, negotiation results, selectors, and PDV routing. |
58 | | -- ACSE and MMS context negotiation using BER transfer syntax. |
59 | | -- Structured ACSE AARQ/AARE application context, AP-title, AE-qualifier, result, and diagnostic parsing. |
60 | | -- EXTERNAL user-information handling with MMS Initiate retained as an opaque Phase 3C payload. |
61 | | -- Deterministic association-response construction with session and context mirroring. |
62 | | -- Byte-exact C# request/response golden vectors, mutation smoke, sanitizer, and libFuzzer coverage. |
63 | | - |
64 | | -### Phase 3C — MMS service codecs |
65 | | - |
66 | | -- MMS Initiate request/response and confirmed request/response/error envelopes. |
67 | | -- Invoke-ID routing, ObjectName, GetNameList, GetVariableAccessAttributes, Read, and Write. |
68 | | -- Recursive bounded TypeSpecification and mixed success/failure access results. |
69 | | -- C#-derived vectors, sanitizer, deterministic mutation smoke, and libFuzzer coverage. |
70 | | - |
71 | | -### Phase 4A — offline DataSet and report monitoring |
72 | | - |
73 | | -- DataSet and buffered/unbuffered RCB inventory from supplied GetNameList evidence. |
74 | | -- GetNamedVariableListAttributes request/response and IEC reference normalization. |
75 | | -- Strict InformationReport and OptFlds-driven report-frame decoding. |
76 | | -- RCB attribute read-plan/state mapping with cautious availability confidence. |
77 | | -- Sequence, configuration, DataSet, overflow, and segmentation continuity tracking. |
78 | | -- Bounded offline report monitor and dedicated MMS-reporting fuzz corpus. |
79 | | - |
80 | | -### Phase 4B — association and report-subscription runtime |
81 | | - |
82 | | -- Transport-injected COTP, Session, Presentation, ACSE/MMS Initiate lifecycle. |
83 | | -- Confirmed-service routing, timeout/cancellation handling, and explicit reconnect. |
84 | | -- Persistent RCB re-probe, reservation, `RptEna`, optional GI, report delivery, and |
85 | | - ownership-aware cleanup. See `ASSOCIATION_RUNTIME_PROFILE.md`. |
86 | | - |
87 | | -### Phase 4C — built-in TCP and live read-only discovery |
88 | | - |
89 | | -- Cross-platform non-blocking Winsock/POSIX `TcpMmsByteTransport`. |
90 | | -- IPv4/IPv6 resolution, deadline/cancellation-aware readiness waits, TCP_NODELAY, |
91 | | - keepalive, partial sends, arbitrary receive chunking, and peer-close detection. |
92 | | -- Bounded live GetNameList discovery for domains, variables, and named-variable lists. |
93 | | -- Optional variable type, DataSet directory, and read-only RCB state probes. |
94 | | -- `MmsTcpLiveDiscoverySession` ready-to-use association/discovery composition. |
95 | | -- Read-only `ariec61850_live_discover` human/JSON CLI. |
96 | | -- Scripted service-allowlist regression that rejects MMS Write. See |
97 | | - `LIVE_DISCOVERY_PROFILE.md`. |
98 | | - |
99 | | -The TCP transport performs no operation on its own. The live discovery API and CLI emit only |
100 | | -GetNameList, GetVariableAccessAttributes, GetNamedVariableListAttributes, and Read requests. |
101 | | -Physical IED interoperability remains a separate laboratory acceptance gate. |
| 9 | +### Portable protocol foundation |
| 10 | + |
| 11 | +- CMake-based C++20 static library with strict warnings. |
| 12 | +- BER, MMS Data/UTC time, Ethernet/VLAN, classic PCAP. |
| 13 | +- GOOSE and Sampled Values codecs plus offline supervision. |
| 14 | +- SCL read-only parser and COMTRADE CFG/DAT readers. |
| 15 | +- RFC 1006 TPKT, COTP, ISO Session, Presentation, ACSE, and MMS Initiate. |
| 16 | +- Confirmed MMS GetNameList, variable attributes, Read, and Write codecs. |
| 17 | +- DataSet directory, InformationReport, RCB state, offline monitoring, and report subscription. |
| 18 | + |
| 19 | +### Phase 4C — built-in TCP and read-only discovery |
| 20 | + |
| 21 | +- Non-blocking Windows Winsock and POSIX TCP transport. |
| 22 | +- IPv4/IPv6 resolution, deadlines, cancellation, partial sends, receive chunking, and peer close. |
| 23 | +- Bounded live domain, variable, DataSet, type, and RCB discovery. |
| 24 | +- `ariec61850_live_discover` CLI. |
| 25 | + |
| 26 | +### Phase 4C.1 — C# live-model parity |
| 27 | + |
| 28 | +- `live-ied-model-v1` JSON compatible with the C# exporter. |
| 29 | +- Logical Device / Logical Node / Data Object / Data Attribute hierarchy. |
| 30 | +- Functional constraints, MMS/SCL types, DataSets, report controls, identity, and CDC confidence. |
| 31 | +- Deterministic canonical manifest and model fingerprint. |
| 32 | +- C#↔C++ parity script. |
| 33 | +- Windows/Linux repeated reconnect and physical read-only evidence runner. |
| 34 | + |
| 35 | +The live discovery surface sends only GetNameList, GetVariableAccessAttributes, |
| 36 | +GetNamedVariableListAttributes, and Read. It does not construct Write, control, GI, RCB |
| 37 | +reservation/enable, dynamic DataSet mutation, or file-service requests. |
102 | 38 |
|
103 | 39 | ## Build |
104 | 40 |
|
105 | | -### Windows — Visual Studio |
| 41 | +### Windows |
106 | 42 |
|
107 | 43 | ```powershell |
108 | 44 | cmake -S . -B build -A x64 -DARIEC61850_WARNINGS_AS_ERRORS=ON |
109 | 45 | cmake --build build --config Release --parallel |
110 | 46 | ctest --test-dir build -C Release --output-on-failure |
111 | 47 | ``` |
112 | 48 |
|
113 | | -### Linux — GCC or Clang |
| 49 | +### Linux |
114 | 50 |
|
115 | 51 | ```bash |
116 | 52 | cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DARIEC61850_WARNINGS_AS_ERRORS=ON |
117 | 53 | cmake --build build --parallel |
118 | 54 | ctest --test-dir build --output-on-failure |
119 | 55 | ``` |
120 | 56 |
|
121 | | -### Sanitizers |
| 57 | +## Live read-only discovery |
122 | 58 |
|
123 | | -```bash |
124 | | -CC=clang CXX=clang++ cmake -S . -B build-sanitizers \ |
125 | | - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ |
126 | | - -DARIEC61850_ENABLE_SANITIZERS=ON |
127 | | -cmake --build build-sanitizers --parallel |
128 | | -ctest --test-dir build-sanitizers --output-on-failure |
129 | | -``` |
| 59 | +Human summary: |
130 | 60 |
|
131 | | -## Read-only tools |
| 61 | +```powershell |
| 62 | +.\build\Release\ariec61850_live_discover.exe 192.168.1.10 102 |
| 63 | +``` |
132 | 64 |
|
133 | | -### Discover a live MMS endpoint |
| 65 | +C#-compatible model: |
134 | 66 |
|
135 | 67 | ```powershell |
136 | | -.\build\Release\ariec61850_live_discover.exe 192.168.1.10 102 --json |
| 68 | +.\build\Release\ariec61850_live_discover.exe 192.168.1.10 102 ` |
| 69 | + --model-json --ied-name IED_A > live-ied-model.json |
137 | 70 | ``` |
138 | 71 |
|
139 | | -Use `--no-types`, `--no-datasets`, or `--no-rcb` to reduce probe scope. All discovery counts |
140 | | -and request timeouts are bounded through CLI options or `MmsLiveDiscoveryOptions`. |
| 72 | +Cross-language parity: |
| 73 | + |
| 74 | +```bash |
| 75 | +python scripts/compare-live-model-parity.py \ |
| 76 | + csharp-live-ied-model.json cpp-live-ied-model.json \ |
| 77 | + --output csharp-cpp-parity.json |
| 78 | +``` |
141 | 79 |
|
142 | | -### Inspect a COMTRADE record |
| 80 | +Physical read-only acceptance: |
143 | 81 |
|
144 | 82 | ```powershell |
145 | | -.\build\Release\ariec61850_comtrade_inspect.exe .\record.cfg --json |
| 83 | +.\scripts\run-live-readonly-interop.ps1 ` |
| 84 | + -HostName 192.168.1.10 -Cycles 10 ` |
| 85 | + -OutputDirectory .\evidence\IED_A ` |
| 86 | + -ExpectedCSharpModel .\csharp-live-ied-model.json |
146 | 87 | ``` |
147 | 88 |
|
148 | | -### Analyze a saved process-bus PCAP |
| 89 | +See `PHASE_4C1_LIVE_MODEL_INTEROP.md` for acceptance rules and evidence requirements. |
| 90 | + |
| 91 | +## Other read-only tools |
149 | 92 |
|
150 | 93 | ```powershell |
| 94 | +.\build\Release\ariec61850_comtrade_inspect.exe .\record.cfg --json |
151 | 95 | .\scripts\run-lab-check.ps1 -Pcap .\captures\device-session.pcap |
152 | 96 | ``` |
153 | 97 |
|
154 | | -See `REPORTING_PROFILE.md` for the offline report decoder profile, |
155 | | -`LAB_INTEROP_CHECKLIST.md` before using a physical IED, and |
156 | | -`MIGRATION_CHECKLIST.md` for the detailed progress ledger. |
| 98 | +## Acceptance boundary |
| 99 | + |
| 100 | +Source implementation and deterministic/simulated validation do not replace physical IED |
| 101 | +acceptance. Before merging Phase 4C/4C.1, run the repository GCC/Clang/MSVC and security |
| 102 | +workflows, execute the physical evidence runner against a reachable IED or vendor simulator, |
| 103 | +and review C#↔C++ parity against the same configuration. |
0 commit comments