Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an e-mail simulator that processes mail at an average of 30 messages per minute. As messages are received, they are placed in a queue.

Write an e-mail simulator that processes mail at an average of 30 messages per minute. As messages are received, they are placed in a queue. For the simulation, assume that the messages arrive at an average rate of 30 messages per minute. Remember, the messages must arrive randomly, so you will need to use a random number generator to determine when messages are received.

Each minute, you can dequeue up to 30 messages and send them. Assume that 25% of the messages in the queue cannot be sent in any processing cycle. Again, you will need to use a random number to determine whether a given message can be sent. If it cannot be sent, put it back at the end of the queue or enqueue it.

Run the simulator for 15 minutes, tracking the number of times each message had to be requeued. At the end of the simulation, print the statistics that show:

1 The total messages processed.

2 The average arrival rate, that is, the average number of messages arriving per minute.

3 The average number of messages sent per minute.

4 The average number of messages in the queue in a minute.

5 The number of messages sent on the first attempt, the number of messages sent on the second attempt, and so forth.

6 The average number of times messages had to be requeued (do not include the messages sent the first time in this average.)

NOTE: Since the question is to assess your understanding of the concept of Queue, you are NOT allowed to use the library of the language that implement queue. You need to write the codes (implementation) of Queue for this exercise.

And also for one loop, take as one min.

To be precise;

[ Each minute (loop)

1. Simulate the arrival of emails

a. Randomly generate a number (depending on your choice of implementation) between 0 and 60. Lets say x number of emails.

b. Push x number of email into the queue Q.

2. Simulate the processing of emails

a. Randomly generate a number representing 25% of the emails in the queue cannot be sent out. The number can be generated as a number between 0 and x where x is the number of emails in the queue at the minute. Mark or identify those emails (25%) that cannot be sent out.

b. Randomly generate a number (depending on your choice of implementation) between 0 and 30. Lets say y number of emails.

c. Dequeue y number of emails from the queue. If a particular email is marked as cannot be sent, then that email must be enqueue back to the queue, otherwise, the email can be delivered.)

d. Enqueue or dequeue accordingly.

3. Accumulate your statistics. E.g., number email sent in this minute, number of email requeued in this minutes, the number of emails left in the queue in this minutes, etc.

When the simulation completed (reach the simulation minutes), Print the statistics. ]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

5-8 What are the advantages and disadvantages of the BYOD movement?

Answered: 1 week ago