Skip to content

Commit 86214bb

Browse files
committed
Add GOOSE subscriber supervision and publisher runtime
1 parent fb7684e commit 86214bb

10 files changed

Lines changed: 1022 additions & 89 deletions

‎CMakeLists.txt‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.20)
22

33
project(ARIEC61850Cpp
4-
VERSION 0.3.0
4+
VERSION 0.4.0
55
DESCRIPTION "Incremental C++20 port of the ARIEC61850 protocol stack"
66
LANGUAGES CXX)
77

@@ -15,6 +15,8 @@ add_library(ariec61850_core
1515
src/goose/retransmission_schedule.cpp
1616
src/goose/pdu_codec.cpp
1717
src/goose/frame_codec.cpp
18+
src/goose/subscriber_supervisor.cpp
19+
src/goose/publisher_runtime.cpp
1820
src/mms/utc_time.cpp
1921
src/mms/data_value.cpp
2022
src/mms/data_codec.cpp)
@@ -60,4 +62,10 @@ if(ARIEC61850_BUILD_TESTS)
6062
ariec61850_apply_warnings(ariec61850_${test_name}_tests)
6163
add_test(NAME ariec61850_${test_name}_tests COMMAND ariec61850_${test_name}_tests)
6264
endforeach()
65+
66+
add_executable(ariec61850_goose_runtime_tests tests/test_goose_runtime.cpp)
67+
target_link_libraries(ariec61850_goose_runtime_tests PRIVATE ARIEC61850::core)
68+
target_compile_features(ariec61850_goose_runtime_tests PRIVATE cxx_std_20)
69+
ariec61850_apply_warnings(ariec61850_goose_runtime_tests)
70+
add_test(NAME ariec61850_goose_runtime_tests COMMAND ariec61850_goose_runtime_tests)
6371
endif()

‎MIGRATION_CHECKLIST.md‎

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,49 @@ interoperability is complete.
1717

1818
**Phase 0 status: complete.**
1919

20-
## Phase 1 — deterministic process-bus codecs
20+
## Phase 1 — deterministic process-bus codecs and runtime
21+
22+
### Phase 1A — MMS data foundation
2123

2224
- [x] IEC 61850 8-byte UTC time with quality byte.
2325
- [x] Recursive MMS Data value model.
2426
- [x] MMS AllData BER encoder/decoder.
27+
28+
### Phase 1B — GOOSE wire codec
29+
2530
- [x] GOOSE PDU model.
2631
- [x] GOOSE PDU BER encoder/decoder.
2732
- [x] GOOSE `numDatSetEntries` consistency validation.
2833
- [x] GOOSE Ethernet/VLAN/process-bus frame encoder/decoder.
2934
- [x] GOOSE C#-compatible byte-for-byte golden vectors.
3035
- [x] GOOSE malformed/truncated-input regression tests.
31-
- [ ] GOOSE subscriber TTL, `stNum`/`sqNum` supervision, and duplicate detection.
32-
- [ ] GOOSE publisher session and retransmission state machine.
36+
37+
### Phase 1C — GOOSE supervision and publisher runtime
38+
39+
- [x] Subscriber TimeAllowedToLive deadline supervision.
40+
- [x] One-shot expiry events and expiration statistics.
41+
- [x] First/retransmission/duplicate classification.
42+
- [x] Sequence gap and sequence regression detection.
43+
- [x] State change, state jump, and state regression detection.
44+
- [x] `stNum` and `sqNum` 32-bit wraparound behavior.
45+
- [x] Expected control-block, dataset, and configuration-revision checks.
46+
- [x] Changed AllData without `stNum` increment detection.
47+
- [x] Publisher session with C#-compatible state/sequence behavior.
48+
- [x] Publisher retransmission runtime with exponential scheduling.
49+
- [x] Schedule reset and `sqNum = 0` on state changes.
50+
- [x] Stable state timestamp across retransmissions.
51+
- [x] Offline encoded-frame output with no raw-network activation.
52+
53+
### Phase 1D — Sampled Values and evidence hardening
54+
3355
- [ ] Sampled Values ASDU model.
3456
- [ ] Sampled Values APDU and Ethernet frame codec.
3557
- [ ] Sampled Values sequence supervision and stream diagnostics.
3658
- [ ] Captured PCAP equivalence tests from real or simulated IED traffic.
3759
- [ ] Decoder fuzzing corpus for BER, GOOSE, and SV.
3860

39-
**Phase 1 status: GOOSE wire codec complete; runtime publisher/subscriber behavior and
40-
Sampled Values remain.**
61+
**Phase 1 status: MMS and GOOSE wire/runtime layers complete; Sampled Values and
62+
capture/fuzz evidence remain.**
4163

4264
## Phase 2 — engineering file formats
4365

@@ -84,18 +106,20 @@ Sampled Values remain.**
84106

85107
- [x] GCC C++20 build with warnings as errors.
86108
- [x] Clang C++20 build with warnings as errors.
87-
- [x] Windows MSVC build for Phase 1A.
88-
- [x] Windows MSVC build and CTest for Phase 1B.
109+
- [x] Windows MSVC build and CTest through Phase 1B.
110+
- [x] Windows MSVC build and CTest for Phase 1C.
89111
- [x] MMS C#-derived golden vector.
90112
- [x] GOOSE PDU C#-derived golden vector.
91113
- [x] GOOSE complete Ethernet frame golden vector with VLAN and process-bus header.
92114
- [x] Malformed BER and GOOSE count-mismatch rejection.
115+
- [x] Deterministic subscriber and publisher runtime regression suite.
93116
- [ ] C# and C++ executable oracle comparison in one CI job.
94117
- [ ] Sanitizer jobs and fuzzing.
95118
- [ ] Isolated-lab IED interoperability.
96119

97120
## Safety gate
98121

99-
Active GOOSE publishing, MMS write/control, and raw-Ethernet transmission remain outside
100-
the enabled runtime surface. They should only be enabled after sequence, timeout,
101-
cancellation, disconnect cleanup, PCAP equivalence, and isolated-lab tests pass.
122+
The Phase 1C publisher is an offline state machine that returns encoded bytes. Active
123+
Npcap transmission, MMS write/control, and IED operation remain outside the enabled
124+
runtime surface until timeout, cancellation, disconnect cleanup, PCAP equivalence, and
125+
isolated-lab tests pass.

‎PORT_STATUS.md‎

Lines changed: 62 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,67 @@
11
# C++ Port Status
22

3-
## Current milestone: Phase 1B
4-
5-
The C++20 port now includes the deterministic foundation, MMS Data values, IEC 61850 UTC
6-
time, and the complete GOOSE wire codec from BER PDU through Ethernet/VLAN/process-bus
7-
framing.
8-
9-
| Original C# area | C++ target | Status |
10-
|---|---|---|
11-
| ASN.1 BER primitives | `asn1` | Ported and tested |
12-
| Ethernet, VLAN, process-bus header | `ethernet` | Ported and tested |
13-
| Classic PCAP | `capture` | Ported and tested |
14-
| GOOSE retransmission schedule | `goose/retransmission_schedule` | Ported and tested |
15-
| IEC 61850 UTC time | `mms/utc_time` | Ported and tested |
16-
| MMS Data / AllData | `mms/data_value`, `mms/data_codec` | Ported and tested |
17-
| GOOSE PDU | `goose/pdu`, `goose/pdu_codec` | Ported and tested |
18-
| GOOSE Ethernet frame | `goose/frame`, `goose/frame_codec` | Ported and tested |
19-
| GOOSE runtime publisher/subscriber | Phase 1C | Pending |
20-
| Sampled Values | Phase 1D | Pending |
21-
| SCL and COMTRADE | Phase 2 | Pending |
22-
| TPKT/COTP/ACSE/MMS association | Phase 3 | Pending |
23-
| Reporting, control, and file service | Phase 4 | Pending |
24-
| Simulator, CLI, and native UI | Phase 5 | Pending |
25-
26-
## Phase 1B validation
27-
28-
- C++20 GCC 14.2, warnings as errors: passed.
29-
- C++20 Clang 17, warnings as errors: passed.
30-
- Three CTest executables: core, MMS, and GOOSE.
31-
- GOOSE PDU golden vector matches the C# encoder field order and BER representation.
32-
- Complete VLAN-tagged GOOSE Ethernet frame has a byte-for-byte golden vector.
33-
- PDU and frame round trips pass.
34-
- Dataset entry-count mismatch, invalid UTC time, wrong outer tag, and wrong EtherType are rejected.
35-
- No external C++ runtime dependency is required.
36-
37-
See `MIGRATION_CHECKLIST.md` for the complete roadmap and current checkboxes.
3+
## Current milestone
4+
5+
**Phase 1C — GOOSE subscriber supervision and publisher runtime is implemented.**
6+
7+
The C++ stack now covers the deterministic path from MMS values through a complete
8+
GOOSE Ethernet frame and the state machines immediately above that wire codec.
9+
10+
## Delivered modules
11+
12+
| Area | Status |
13+
|---|---|
14+
| BER primitives | Complete |
15+
| Ethernet, VLAN, process-bus header | Complete |
16+
| Classic PCAP reader/writer | Complete |
17+
| IEC 61850 UTC time | Complete |
18+
| MMS Data / AllData codec | Complete |
19+
| GOOSE PDU codec | Complete |
20+
| GOOSE Ethernet frame codec | Complete |
21+
| GOOSE subscriber supervision | Complete |
22+
| GOOSE publisher session/runtime | Complete, offline frame output only |
23+
| Sampled Values | Not started |
24+
| SCL and COMTRADE | Not started |
25+
| TPKT/COTP/ACSE/MMS association | Not started |
26+
| Reporting and control | Not started |
27+
| Simulator and native UI | Not started |
28+
29+
## Phase 1C behavior
30+
31+
Subscriber supervision includes:
32+
33+
- TimeAllowedToLive deadline calculation and one-shot expiry reporting;
34+
- arrival-gap tracking;
35+
- duplicate, retransmission, sequence-gap, sequence-regression, state-change,
36+
state-jump, and state-regression classification;
37+
- `uint32` counter wraparound;
38+
- expected stream identity validation;
39+
- configuration revision change indication; and
40+
- detection of changed AllData while `stNum` remains unchanged.
41+
42+
Publisher runtime includes:
43+
44+
- initial publication with configured state and sequence counters;
45+
- state-change publication with `stNum` increment and `sqNum = 0`;
46+
- retransmissions with `sqNum` increment and wraparound;
47+
- exponential min-time to max-time scheduling;
48+
- schedule reset after every state change; and
49+
- a deterministic `poll(now)` API that avoids sleeping threads and timing-flaky tests.
50+
51+
## Validation
52+
53+
- GNU C++ 14.2, Release, warnings as errors: passed.
54+
- Clang 17, Release, warnings as errors: passed.
55+
- Four CTest executables passed under both compilers:
56+
- core foundation;
57+
- MMS values;
58+
- GOOSE wire codec; and
59+
- GOOSE subscriber/publisher runtime.
60+
- Windows MSVC verification is performed by GitHub Actions for every stacked PR.
3861

3962
## Safety boundary
4063

41-
This milestone provides offline codecs only. It does not start a raw-Ethernet publisher,
42-
subscribe to a network interface, perform MMS writes, or execute IED control.
64+
No network adapter is opened by Phase 1C. The publisher runtime only returns encoded
65+
Ethernet-frame bytes. Npcap transmission, background network threads, active GOOSE
66+
publishing, MMS writes, and IED controls remain disabled until PCAP equivalence and
67+
isolated-lab interoperability are completed.

‎README.md‎

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,69 @@
11
# ARIEC61850 C++ Port
22

3-
Incremental C++20 migration of the ARIEC61850 C# stack. The C# implementation remains
4-
the behavioral oracle while each module gains byte-for-byte vectors and malformed-input
5-
tests.
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.
66

7-
## Implemented through Phase 1B
7+
## Implemented
88

9-
- BER primitives, Ethernet/VLAN/process-bus framing, PCAP, and GOOSE retransmission timing.
10-
- IEC 61850 UTC time and recursive MMS Data / AllData codecs.
11-
- GOOSE PDU encoder/decoder for `gocbRef`, `timeAllowedToLive`, `datSet`, `goID`, `t`,
12-
`stNum`, `sqNum`, `test`, `confRev`, `ndsCom`, `numDatSetEntries`, and `allData`.
13-
- Complete GOOSE Ethernet frame encoder/decoder with optional VLAN.
14-
- GCC, Clang, and MSVC GitHub Actions coverage.
15-
- C#-compatible MMS and GOOSE golden vectors.
9+
### Phase 0 — portable foundation
1610

17-
See [`MIGRATION_CHECKLIST.md`](MIGRATION_CHECKLIST.md) for detailed progress.
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.
1815

19-
## Build
16+
### Phase 1A — MMS data foundation
2017

21-
```bash
22-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
23-
cmake --build build --parallel
24-
ctest --test-dir build --output-on-failure
25-
```
18+
- IEC 61850 8-byte UTC time and quality byte.
19+
- Recursive MMS Data values and AllData BER codec.
20+
- C#-derived byte-for-byte golden vectors.
2621

27-
For Visual Studio multi-configuration builds:
22+
### Phase 1B — GOOSE wire codec
23+
24+
- Complete GOOSE PDU encode/decode.
25+
- Ethernet/VLAN/process-bus GOOSE frame encode/decode.
26+
- Dataset count and malformed-frame validation.
27+
28+
### Phase 1C — GOOSE runtime state machines
29+
30+
- Subscriber TTL supervision and one-shot expiry events.
31+
- `stNum`/`sqNum` classification: first, retransmission, duplicate, gap, regression,
32+
state change, state jump, and state regression.
33+
- 32-bit sequence and state wraparound handling.
34+
- Expected control-block, dataset, and configuration-revision identity checks.
35+
- Detection of data changes without a matching `stNum` increment.
36+
- Publisher session matching the C# counter semantics.
37+
- Deterministic publisher runtime with exponential retransmission scheduling.
38+
- State timestamps remain stable during retransmission and change only on a state event.
39+
40+
The publisher runtime returns encoded frames to its caller. It does not open Npcap,
41+
raw sockets, or a network interface.
42+
43+
## Build
44+
45+
### Windows — Visual Studio
2846

2947
```powershell
30-
cmake -S . -B build -A x64
48+
cmake -S . -B build -A x64 -DARIEC61850_WARNINGS_AS_ERRORS=ON
3149
cmake --build build --config Release --parallel
3250
ctest --test-dir build -C Release --output-on-failure
3351
```
3452

53+
### Linux — GCC or Clang
54+
55+
```bash
56+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DARIEC61850_WARNINGS_AS_ERRORS=ON
57+
cmake --build build --parallel
58+
ctest --test-dir build --output-on-failure
59+
```
60+
3561
## Migration rule
3662

37-
A module is complete only after C++ tests, C#-versus-C++ vectors, malformed-input coverage,
38-
and relevant PCAP or laboratory evidence. Active publishing and control remain disabled
39-
until their state-machine safety gates pass.
63+
1. Capture deterministic C# behavior and byte vectors.
64+
2. Port the same behavior to C++.
65+
3. Run strict multi-compiler builds and semantic state-machine tests.
66+
4. Compare real or simulated PCAP/SCL evidence.
67+
5. Enable active transport only after safety and interoperability gates pass.
68+
69+
See `MIGRATION_CHECKLIST.md` for the detailed progress ledger.

‎VALIDATION.txt‎

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
ARIEC61850 C++ Phase 1A validation
1+
ARIEC61850 C++ Phase 1C validation
2+
Date: 2026-08-06
23

3-
Local toolchains:
4-
- GNU C++ 14.2.0, C++20, -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Werror: PASS
5-
- Clang 17.0.0, C++20, same strict warning policy: PASS
4+
GNU C++ 14.2 / Release / warnings-as-errors:
5+
Configure: PASS
6+
Build: PASS
7+
CTest: PASS (4/4 test executables)
68

7-
CTest:
8-
- ariec61850_core_tests: PASS
9-
- ariec61850_mms_tests: PASS
10-
- Internal checks: 12/12 PASS
9+
Clang 17 / Release / warnings-as-errors:
10+
Configure: PASS
11+
Build: PASS
12+
CTest: PASS (4/4 test executables)
1113

12-
New parity evidence:
13-
- IEC 61850 UTC time vector: 6A2B77254000000A
14-
- MMS AllData vector: byte-for-byte match with the C# MmsDataCodec behavior
15-
- Recursive Structure, BitString, Unknown high-tag, and malformed nested TLV coverage: PASS
14+
Windows MSVC / Release / warnings-as-errors / GitHub Actions:
15+
Configure: PASS
16+
Build: PASS
17+
CTest: PASS (4/4 test executables)
1618

17-
CI added:
18-
- Ubuntu GCC
19-
- Ubuntu Clang
20-
- Windows MSVC
19+
Test executables:
20+
1. ariec61850_core_tests
21+
2. ariec61850_mms_tests
22+
3. ariec61850_goose_tests
23+
4. ariec61850_goose_runtime_tests
2124

22-
Safety boundary:
23-
No active IED control or raw-Ethernet publisher session is enabled by this phase.
25+
Phase 1C runtime checks:
26+
- subscriber sequence and state classification
27+
- TTL expiry and one-shot timeout reporting
28+
- expected stream identity rejection
29+
- state and sequence counter wraparound
30+
- publisher C# sequence semantics
31+
- retransmission schedule and state-change reset
32+
- stable state timestamp across retransmissions
33+
- publisher state and sequence wraparound

0 commit comments

Comments
 (0)