feat(core): UDP sockets in the simulation core

engine.ts ports the UDP part of Swift's "UDP sockets and Router RIP": a
socket bound to a given port or to a free one drawn from 49152–65534 with
Java's random numbers on Swift's seed; sending, also as a limited broadcast
on every interface (or the bound one) with TTL 1; delivery into the queue
of every socket on the destination port, which then answers to the last
sender; receiving, with a timeout that advances the virtual clock; closing.
Stopping forgets sockets and queues. RIP stays not ported; Swift's DHCP
handling of a datagram has nothing to do until DHCP is in the snapshot.

The oracle gets the steps bindUdp, sendUdp, receiveUdp and closeSocket on
both sides and reports the sockets. Two new scenarios — a LAN, and two
networks through a router with a UDP firewall rule and a broadcast that
does not cross it — match the Swift engine trace for trace, the random
ports included. Swift's four UDP engine tests are ported, with a test for
stopping. 11 mutation probes were all caught (one only after the stop test
was added).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 09:54:04 +00:00
co-authored by Claude Opus 5.5
parent c8f2e9e225
commit e80be3bbdf
15 changed files with 5862 additions and 6 deletions
+6
View File
@@ -17,6 +17,12 @@ npm test # vergleicht mit den geschriebenen *.swift.json
die Tests ohne Docker und ohne Swift laufen.
* Vergleich: `packages/core/test/oracle.test.ts`. Er meldet das **erste**
abweichende Spurereignis mit Nummer.
* Schritte: `ping`, `traceroute`, `resolveMac`, `advance`, `packetLoss`,
`sat`, `speed`; UDP (seit F2): `bindUdp` (Knoten, optional Port, lokale
Adresse, Gegenstelle; Ergebnis die Socket-ID), `sendUdp` (Socket, Text,
optional Ziel und Port), `receiveUdp` (Socket, optional Wartezeit),
`closeSocket`. Das Ergebnis enthält die Sockets mit der Länge ihrer
Warteschlange.
## Korpus