feat(core): Java's IP and ICMP threads, measured with Java FILIUS

Every packet that comes in goes through its node's IP thread (UDP, TCP) or
ICMP thread (ICMP), as Java's IPThread and ICMPThread: deliver, answer an
echo request or forward, one after the other; while one waits for ARP, the
next wait behind it. A packet a node sends to itself is delivered at once,
as Java's IP.senden does. The transport send threads and these are one
mechanism now (handToProtocolThread).

ArpRun has three stories through the router (routedUdpBehind,
routedPingBesideUdp, routedPingBehindPing); the oracle writes ICMP frames
with type, code, addresses and sequence number. All seven ArpRun stories
match Java FILIUS.

Measured and not taken: Java's ARP wakes one waiter with notify, not the
one whose answer came; the core wakes all that wait for the address.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 18:32:48 +00:00
co-authored by Claude Opus 5.5
parent 7e0348636c
commit f5c61cdce7
13 changed files with 950 additions and 97 deletions
+37
View File
@@ -10,8 +10,19 @@
// pingRouted 10.0.0.2 pings 20.0.0.9: the router's ARP fails
// udpTwice 10.0.0.2 sends two UDP datagrams to 10.0.0.9 at once
// udpBehind 10.0.0.2 sends a UDP datagram to 10.0.0.9, then one to 20.0.0.2
// routedUdpBehind 10.0.0.2 sends a UDP datagram to 20.0.0.9, then one
// to 20.0.0.2: the router forwards both
// routedPingBesideUdp a ping to 20.0.0.2 (the router learns it), a UDP
// datagram to 20.0.0.9, 100 ms later (the UDP thread
// sends first) a ping to 20.0.0.2 again: only
// one thread waits for ARP at a time. Two would meet
// ARP's notify, which wakes one waiter, not the one
// whose answer came (a Java bug the core does not take)
// routedPingBehindPing an echo request to 20.0.0.9 (sent, not waited for),
// then a ping to 20.0.0.2
import filius.software.transportschicht.UDPSocket;
import filius.software.vermittlungsschicht.ICMP;
import filius.software.vermittlungsschicht.IcmpPaket;
import java.util.ArrayList;
@@ -83,6 +94,32 @@ public class ArpRun {
return "";
});
break;
case "routedUdpBehind":
call("senden verloren", () -> {
send("20.0.0.9", "verloren");
return "";
});
call("senden dahinter", () -> {
send("20.0.0.2", "dahinter");
return "";
});
break;
case "routedPingBesideUdp":
call("sendProbe 20.0.0.2", () -> icmp(network.system(HOST).holeICMP().sendProbe("20.0.0.2", 64, 1, 1)));
call("senden verloren", () -> {
send("20.0.0.9", "verloren");
return "";
});
Thread.sleep(100);
call("sendProbe 20.0.0.2", () -> icmp(network.system(HOST).holeICMP().sendProbe("20.0.0.2", 64, 1, 2)));
break;
case "routedPingBehindPing":
call("sendeICMP 20.0.0.9", () -> {
network.system(HOST).holeICMP().sendeICMP(ICMP.TYPE_ECHO_REQUEST, ICMP.CODE_ECHO, 2, 2, null, "20.0.0.9");
return "";
});
call("sendProbe 20.0.0.2", () -> icmp(network.system(HOST).holeICMP().sendProbe("20.0.0.2", 64, 1, 1)));
break;
default:
throw new IllegalArgumentException("unknown story " + story);
}