Carleton University - SYSC 2006
packet_gen()
Assignment 2 - Spring 2025he goal of packet_gen() is to randomly generate a data packet in the format:
source;destination;sizeFor example:
nodeB;nodeD;734This means: create a packet that starts from nodeB, is going to nodeD, and is 734 bytes in size.
We’ll randomly pick both the source and destination nodes from the linked list, and also randomly pick a size between 100 and 1500 bytes.
How do we do this?
To generate the packet string, you need to:
Random Selection:
Pick two different nodes (source and destination) randomly from the linked list.
Make sure they are not the same node.
Packet Size:
Generate a random number between 100 and 1500, inclusive.
Formatting:
Use
sprintf()to format the string assrc;dest;size.
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.