Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/types/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions src/types/view-devices/vNetworkDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -181,16 +182,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;
}
Expand Down