Add clean-room SNTP clock sync service - #148
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65a5c4f618
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (device.IsConnected) | ||
| ScheduleClockSyncReconcile(device); |
There was a problem hiding this comment.
Skip demo devices before starting SNTP
When demo mode adds its simulated devices, each is already marked IsConnected = true and IsDemo = true before Devices.Add (MainWindow.Demo.cs lines 209-222), so this unconditional scheduling starts a real UDP/123 service for fake addresses such as 192.168.10.11. If that subnet is absent, route resolution can select the machine's default adapter, causing demo mode to bind UDP/123 and transmit recurring time broadcasts onto an unrelated real network; exclude demo devices from clock-sync reconciliation.
Useful? React with 👍 / 👎.
| catch (SocketException ex) | ||
| { | ||
| if (!cancellationToken.IsCancellationRequested) | ||
| SetState(SntpClockServiceState.Faulted, $"SNTP broadcast failed: {ex.SocketErrorCode}."); | ||
| break; |
There was a problem hiding this comment.
Retry broadcasts after transient socket errors
If a directed-broadcast send raises any SocketException, for example during a temporary adapter outage, this break permanently terminates the broadcast task. The UDP service remains assigned to _udp, so subsequent connected-device reconciliations only set the immediate-broadcast flag and never recreate the task; mode-5 broadcasts therefore remain disabled even after the network recovers. Retry with backoff or restart the broadcast loop instead of exiting permanently.
Useful? React with 👍 / 👎.
What changed
request observedfrom merelybroadcast advertisedstratum 2/LOCLfor synchronized Mode 4 and Mode 5 packets; this is a compatibility advertisement, not a claim that the laptop is a GPS/PTP/stratum-1 referenceLI=3,stratum=0,INIT, zero server timestamps)SIPROTEC compatibility rationale
Siemens SIPROTEC PIXIT behavior treats high-stratum SNTP sources as questionable/unsynchronized. Field commissioning feedback also shows SIPROTEC installations that do not accept stratum 3 as the practical laptop clock source. ARSAS therefore uses stratum 2 by default while retaining
LOCLand explicit diagnostics that this is a local commissioning clock, not UTC/GNSS/PTP traceability.Integration footprint
The existing application is intentionally left almost untouched.
MainWindow.IoTesting.cshas one added initializer call; Clock Sync itself lives in new isolated files underServices,tests, anddocs.Validation
Previous head
65a5c4f6180956aa699d161e1764ee225ba6a90cpassed:Current head
d3efa96d93bf23cba7ec072dfcbe8a4704ce5110adds the SIPROTEC stratum-2 compatibility lock and is being revalidated by the same CI gates before merge.Field validation required on the release candidate
Capture UDP/123 in Wireshark and verify behavior with at least one real SIPROTEC IED:
P0 is intentionally IPv4 and first-station-bus-interface scoped. Multi-NIC raw/Npcap serving and PTP/IEC 61850-9-3 monitoring are separate future phases.