Question: Write a C++ program to simulate the behavior of the leaky bucket and token bucket algorithms. When the program is executed, the user should select

Write a C++ program to simulate the behavior of the leaky bucket and token bucket algorithms. When the program is executed, the user should select to run either the leaky bucket algorithm or the token bucket algorithm. Use the following format when you ask the user to select one of the algorithms to run:

Write a C++ program to simulate the behavior of the leaky bucket

Token Bucket Algorithm Figure 2 shows the token bucket algorithm. Assume that the arriving packets have a variable size and the queue has a finite buffer. At each clock tick, the program randomly selects the number of arriving packets and the size of each packet, and using the token bucket algorithm, the program tries to send the packets out of the queue. Tokens added at the rate of r per tick. tokens are discarded if bucket is full. Bucket capaciy is c tokens. i One token removed | and discarded per byte transmitted Queue is full? No Arrival Processor Departure Yes Queue Discard Figure 2: Token bucket algorithm The following is the token bucket algorithm for variable-length packets: 1. Add tokens to the bucket at the rate of r tokens per tick (token rate). 2. For a packet of n bytes, a. if at least n tokens are available, send the packet and remove n tokens from the bucket. b. if fewer than n tokens are available, hold the packet until sufficient tokens are available. 3. Go to step 1. The program inputs are the number of clock ticks for simulation, the maximum packet arrival rate (maximum number of arriving packets at each tick), the maximum packet size (in bytes), the size of the queue (in bytes), the token rate (number of tokens added at each tick), and the bucket capacity (maximum number of tokens in the bucket). Assume the number of ticks for simulation is fixed to 15. Use the following format when you ask the user to enter the inputs of the token bucket algorithm: Maximum packet arrival rate: Maximum packet size: Size of the queue: Token rate: Bucket capacity: The program outputs, at each tick, are the number of arrived packets, number of departed packets, number of dropped packets, and number of packets in the queue. Use the following format to display the outputs of the token bucket algorithm: Arrived packets Departed packets Dropped packets Packets in queue Tick # 1 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!