test: F2 acceptance — five of FILIUS' examples run as Java FILIUS runs them
ExampleRun opens an example as FILIUS opens it (SzenarioVerwaltung.laden into the window's lists), starts it as the action mode does, plays a story and writes every card's frames and tables, the calls, the addresses and the RIP tables' changes. examplesJava.test.ts reads the same file with this package's reader and runs it in the core (projectSnapshot, new): routing (internetwork_komplett), DHCP (einfaches_rechnernetz_komplett), DNS (dns_server), NAT (nat_with_mapped_port) and firewall (Internet_Komplett_..._DE) match card by card. Found and fixed: a host's ipForwardingEnabled, which Java saves and obeys, was unknown to the reader, the model, the core, the writer, the export and FlsOracle; and Java's ARP learns only from a request for its own address or a reply. Named Java bugs: a ping without a gateway throws a NullPointerException; a home router drops the answer of a second remote end. Open: Java picks between equally long RIP routes by thread timing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,11 @@ export type NodeKind =
|
||||
| 'remoteLink'
|
||||
| 'unsupported';
|
||||
|
||||
/** Whether a node of this kind forwards packets unless its settings say otherwise: routers and home routers (Java's constructors). */
|
||||
export function forwardsIPv4ByDefault(kind: NodeKind): boolean {
|
||||
return kind === 'router' || kind === 'gateway';
|
||||
}
|
||||
|
||||
export function isPcClassEndpoint(kind: NodeKind): boolean {
|
||||
return kind === 'pc' || kind === 'notebook';
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
// remote links.
|
||||
|
||||
import { compareIds, type Id } from '../ids.js';
|
||||
import { isPcClassEndpoint, stableGeneratedMacAddress } from '../model/node.js';
|
||||
import { forwardsIPv4ByDefault, isPcClassEndpoint, stableGeneratedMacAddress } from '../model/node.js';
|
||||
import type {
|
||||
DeviceConfiguration,
|
||||
DhcpServerConfiguration,
|
||||
@@ -4087,7 +4087,12 @@ export class NetworkRuntimeEngine {
|
||||
nodeId: Id,
|
||||
networkInterface: NetworkInterface,
|
||||
): void {
|
||||
if (packet.senderIPAddress !== UNSPECIFIED_IP_ADDRESS) {
|
||||
// Java's ARPThread: a packet from the network's own address is dropped; an entry comes from a
|
||||
// request for the card's address or from a reply (Swift, and swiftArp: from every packet).
|
||||
const network = maskAddress(parseIPv4(networkInterface.ipAddress) ?? 0, parseIPv4(networkInterface.subnetMask) ?? 0);
|
||||
if (!this.swiftArp && parseIPv4(packet.senderIPAddress) === network) return;
|
||||
const learns = this.swiftArp || packet.targetIPAddress === networkInterface.ipAddress || packet.operation === 'reply';
|
||||
if (packet.senderIPAddress !== UNSPECIFIED_IP_ADDRESS && learns) {
|
||||
getOrCreate(this.stateValue.arpCachesByNodeId, nodeId, () => new Map()).set(packet.senderIPAddress, {
|
||||
ipAddress: packet.senderIPAddress,
|
||||
macAddress: packet.senderMacAddress,
|
||||
@@ -4495,8 +4500,8 @@ export class NetworkRuntimeEngine {
|
||||
if (!this.deliverIPv4Locally(packetForProcessing, nodeId, networkInterface, finished)) finished();
|
||||
return;
|
||||
}
|
||||
// Java: routers and home routers forward (IpForwardingEnabled), nothing else.
|
||||
if (node.kind !== 'router' && node.kind !== 'gateway') {
|
||||
// Java: routers and home routers forward, a host when its IP forwarding is on (ipForwardingEnabled).
|
||||
if (!(this.stateValue.topologySnapshot.ipForwardingByNodeId.get(nodeId) ?? forwardsIPv4ByDefault(node.kind))) {
|
||||
this.recordTrace({
|
||||
frameIdentity,
|
||||
packetIdentity: packetForProcessing.identity,
|
||||
|
||||
@@ -63,6 +63,8 @@ export interface TopologySnapshot {
|
||||
/** A home router's port forwarding (Java GatewayFirmware.staticNAT), by node. */
|
||||
readonly portForwardingRowsByNodeId: ReadonlyMap<Id, readonly GatewayPortForwardingRow[]>;
|
||||
readonly switchConfigurationsByNodeId: ReadonlyMap<Id, SwitchConfiguration>;
|
||||
/** Nodes whose IP forwarding differs from their kind's (forwardsIPv4ByDefault): a host that forwards. */
|
||||
readonly ipForwardingByNodeId: ReadonlyMap<Id, boolean>;
|
||||
}
|
||||
|
||||
export interface TopologySnapshotInput {
|
||||
@@ -78,6 +80,7 @@ export interface TopologySnapshotInput {
|
||||
firewallConfigurationsByNodeId?: ReadonlyMap<Id, FirewallConfiguration>;
|
||||
portForwardingRowsByNodeId?: ReadonlyMap<Id, readonly GatewayPortForwardingRow[]>;
|
||||
switchConfigurationsByNodeId?: ReadonlyMap<Id, SwitchConfiguration>;
|
||||
ipForwardingByNodeId?: ReadonlyMap<Id, boolean>;
|
||||
}
|
||||
|
||||
export function topologySnapshot(input: TopologySnapshotInput): TopologySnapshot {
|
||||
@@ -94,6 +97,7 @@ export function topologySnapshot(input: TopologySnapshotInput): TopologySnapshot
|
||||
firewallConfigurationsByNodeId: input.firewallConfigurationsByNodeId ?? new Map(),
|
||||
portForwardingRowsByNodeId: input.portForwardingRowsByNodeId ?? new Map(),
|
||||
switchConfigurationsByNodeId: input.switchConfigurationsByNodeId ?? new Map(),
|
||||
ipForwardingByNodeId: input.ipForwardingByNodeId ?? new Map(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user