From 2f511cca5531a1c86c100e359a8bd05a22b2ebe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Sun, 22 Jun 2025 16:01:28 -0300 Subject: [PATCH 1/3] fix: send reply through correct interface --- src/types/view-devices/vNetworkDevice.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/types/view-devices/vNetworkDevice.ts b/src/types/view-devices/vNetworkDevice.ts index cdca924e..1cf9836d 100644 --- a/src/types/view-devices/vNetworkDevice.ts +++ b/src/types/view-devices/vNetworkDevice.ts @@ -181,16 +181,17 @@ export abstract class ViewNetworkDevice extends ViewDevice { case ICMP_PROTOCOL_NUMBER: { const request: EchoRequest = datagram.payload as EchoRequest; if (dstDevice && request.type === ICMP_REQUEST_TYPE_NUMBER) { - const { src, nextHop, dst } = ViewNetworkDevice.getForwardingData( - this.id, - dstDevice.id, - this.viewgraph, - ); + const { src, nextHop, dst, sendingIface } = + ViewNetworkDevice.getForwardingData( + this.id, + dstDevice.id, + this.viewgraph, + ); const echoReply = new EchoReply(0); const ipPacket = new IPv4Packet(src.ip, dst.ip, echoReply); const frame = new EthernetFrame(src.mac, nextHop.mac, ipPacket); console.debug(`Sending EchoReply to ${dstDevice}`); - sendViewPacket(this.viewgraph, this.id, frame, iface); + sendViewPacket(this.viewgraph, this.id, frame, sendingIface); } break; } From bfd21d2508819840bdb781070e58617063c918b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Sun, 22 Jun 2025 16:01:54 -0300 Subject: [PATCH 2/3] fix: make parameter not optional --- src/types/packet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/packet.ts b/src/types/packet.ts index caa4060e..45043308 100644 --- a/src/types/packet.ts +++ b/src/types/packet.ts @@ -365,7 +365,7 @@ export function sendViewPacket( viewgraph: ViewGraph, srcId: DeviceId, rawPacket: EthernetFrame, - sendingIface?: number, + sendingIface: number, ) { const srcMac = rawPacket.source; const dstMac = rawPacket.destination; From 32ffd7482b56a8b8cc7e1656d8a5363dd35ed612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Sun, 22 Jun 2025 16:09:57 -0300 Subject: [PATCH 3/3] chore: ignore linter warning --- src/types/view-devices/vNetworkDevice.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/view-devices/vNetworkDevice.ts b/src/types/view-devices/vNetworkDevice.ts index 1cf9836d..90031493 100644 --- a/src/types/view-devices/vNetworkDevice.ts +++ b/src/types/view-devices/vNetworkDevice.ts @@ -168,6 +168,7 @@ export abstract class ViewNetworkDevice extends ViewDevice { : undefined; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars handleDatagram(datagram: IPv4Packet, iface: number) { console.debug("Packet has reach its destination!"); const dstDevice = this.viewgraph.getDeviceByIP(datagram.sourceAddress);