QuestionQuestion

Transcribed TextTranscribed Text

Section 2.A - Coding Write a program that uses STL container(s) and other features of STL. This program is a simulation test for network packets arriving to a router. The router uses a queue to prevent packet loss. The program should implement the following #-At each tick of time, 0 to 7 packets will arrive to the queue #-At each tick of time, the router would rout 4 packets or less, i.e. it’s maximum capability is 4 packets per tick of time. #-Create a simulation of 400 ticks of time for the router. #-At the end of each tick, display a line of asterisks with each asterisk represent 1 network packet. #-At the end of the simulation, report the following a- the number of tickets remain in the queue b- total number of packets routed by the router Your code should show that you can utilize STL features Here are 2 example of 2 separate run Example 1 - (shown only the last few lines) *** **** **** At the end, the queue has 3 packet(s) left in the queue Total packets processed is 1441 Example 2 (shown only the last few lines) **** **** **** At the end, the queue has 0 packet(s) left in the queue Total packets processed is 1348 Turn in instruction: Create a heading Section 2.A. Then include the C++ code and the output runs for this section. Make sure you have at least 3 different output runs. Section 2.B - Coding Revise the code so that the simulation will run 600 times. At the end of the simulation it will display as follows: Also, it will have additional report, (besides packets left, and total packets processed) it will display a- the number of time ticks the router was idle, b- the idle ratio and c- the maximum size of the queue happened in the simulation Below is 2 examples of the output run Example 2 (shown only the last few lines) **** **** ** **** At the end, the queue has 1 packets left in the queue Total packets processed is 2059 Number of time the router is idle: 31 idle ratio is : 0.0516667 Maximum size of the queue: 27 Example 2 (shown only the last few lines) **** **** **** **** At the end, the queue has 8 packet(s) left in the queue Total packets process is 2155 Number of time the router is idle: 15 idle ratio is : 0.025 Maximum size of the queue: 27 Turn in instruction: Create a heading Section 2.B. Then include the C++ code and the output runs for this section. Make sure you have at least 3 different output runs.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <queue>

using namespace std;


int main(int argc, char** argv) {

    queue<char> q;                         // queue for packets
    int totalPackets = 0;                   // counter for total packets
    srand((unsigned)time(0));               // seed the random number generator
    for (int tick = 0; tick < 400; tick++) // loop to simulate ticks
    {
       int arrived = rand() % 8;          // random number [0, 7] of arriving packets
       while (arrived > 0)                // loop to push arrived packets to queue
       {
            q.push('*');
            arrived--;
       }...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$18.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Computer Science - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats