Carleton University - SYSC 2006
packet_forwrd()
Assignment 1 - Spring 2025The goal of packet_forwrd() is to simulate the step-by-step delivery of a data packet across the network using the routing table we’ve built. The function takes a packet (formatted like src;dest;size) and "forwards" it from node to node using the routing paths until it reaches the final destination.
The function should print each step as the packet moves from one node to the next.
How do we do this?
To forward the packet through the routing table, you need to:
Parse the Packet:
Use
sscanf()to extract the source node, destination node, and size from the packet string.
Simulate Forwarding:
Start at the source node.
Use the routing table to look up the next hop for the destination.
At each step:
Print the current node and where it's forwarding the packet.
Move to the next hop.
Repeat until the current node equals the destination.
Output:
Print each step clearly. For example:
Node nodeA sends to node nodeB (cost: 8) Node nodeB sends to node nodeC (cost: 3) Node nodeC is the destination. Done forwarding for the packet. Current packet size: 928 bytes
Return:
Return
0on success.
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 25 more lessons in Carleton University - SYSC 2006.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.