-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support sending packets from misconfigured router #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a996644 to
6bc55cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the router view to track the ingress interface for each packet, adjust routing decisions (including TTL expiration), and display packets dropped by misconfiguration.
- Introduces an
ifaceparameter through the packet queuing and processing pipeline - Updates
processPacketto detect and drop packets sent back out the same interface and deduce next-hop MAC when misconfigured - Adds a new
PacketWithIfacetype and adjustsPacketQueueto store the ingress interface
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/view-devices/vRouter.ts | Track and enqueue packets with their ingress interface and adapt forwarding logic |
| src/types/view-devices/vNetworkDevice.ts | Removed an outdated // TODO comment |
| src/types/view-devices/vDevice.ts | Cleared an obsolete // TODO in interface definition |
| src/types/graphs/viewgraph.ts | Removed two stale // TODO comments |
| src/types/graphs/datagraph.ts | Deleted unneeded // TODO comments |
| src/packets/ip.ts | Removed a // TODO about checksum computation |
Comments suppressed due to low confidence (4)
src/types/view-devices/vRouter.ts:177
- [nitpick] The parameter name
ifaceis abbreviated and may be unclear; consider renaming tointerfaceIndexoringressInterfacefor better readability.
addPacketToQueue(datagram: IPv4Packet, iface: number) {
src/types/view-devices/vRouter.ts:299
- [nitpick] The type name
PacketWithIfaceis ambiguous; a more descriptive name likeQueuedPacketorPacketWithInterfacewould improve clarity.
interface PacketWithIface {
src/types/view-devices/vRouter.ts:179
- The TTL decrement and drop-on-zero branch is new behavior; consider adding a unit or integration test that enqueues a packet with TTL=1 and verifies it is dropped with the correct debug message.
datagram.timeToLive -= 1;
src/types/view-devices/vRouter.ts:299
- [nitpick] Add a brief JSDoc comment above
PacketWithIfaceexplaining its fields (packetandiface) and intended usage in the queue.
interface PacketWithIface {
This also causes the case of a Router sending the packet to a switch to fail
This PR allows sending packets from a misconfigured router, enabling us to show the TTL making routers discard packets.
When a router is misconfigured, the table entry matching with the packet doesn't lead to the destination. In those cases, routers now try to resolve the next hop from the interface configured on the entry, instead of dropping the packet. Packets will still be dropped if the next hop is not a
NetworkDevice.