Question: Write a C++ program to simulate the behavior of the token bucket algorithm Token Bucket Algorithm Figure 2 shows the token bucket algorithm. Assume that
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 oft per tick sokons are discarded bucket is Bucket capacly is tokens One token removed and discarded perbyte transmitted Arrival Procesor Departure Yes we Discard Figure 2: Token bucket algorithm The following is the token bucket algorithm for variable-length packets Add tokens to the bucket at the rate of r tokens per tick (token rate) 2. For a packet of bytes, if at least tokens are available, send the packet and remove n tokens from the bucket. b. if fewer than tokens are available, hold the packet until sufficient tokens are available. 3. Go to step! 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 teser 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 cach 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 Tick# Arrived packets Departed packets Dropped packets Packets in queue 1 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
