write a program in matlab to produce a discrete event simulation of a switching element with 10 inputs and 3 outputs. Time is slotted on all inputs and outputs. Each input packet follows a Bernoulli process. In a given slot, the independent probability that a packet arrives in a slot is p and the probability that a slot is empty is (1– p). One packet fills one slot. For a switching element if 3 or less packets arrives to some inputs, they are forwarded to the switching element outputs without a loss. If more than 3 packets arrive to the inputs of the switching element, only 3 packets are randomly chosen to be forwarded to the switching element outputs and the remaining ones are discarded. In your simulation the program will mimic the operation of the switch and collect statistics. That is, in each time slot the program randomly generates packets for all inputs of the switching element and counts how many packets can be passed to the output of the switching element (causing throughput) and, alternatively counts how many packets are dropped (when the switching element has more than 3 input packets at a given time slot) . Your task is to collect throughput statistics for different values of p (p = 0.05, 0.1 up to 1.0 in steps of 0.05), by running the procedure described above for each value of p and for many slots (at least a thousand slots per value of p). The more simulated slots, the more accurate the results will be. Based on this statistics, plot two graphs: 1) the average number of busy outputs versus p, and 2) the average number of dropped packets versus p.
ANSWER
Screenshot of the code:
Sample output:
Code to copy:
//Include the required header files.
#include <iostream>
#include <random>
#include <iomanip>
#include<time.h>
using namespace std;
//Define the array and variables
float p1[10]={};
float d1[10]={};
int l=0;
//Define the function BernoulliProcess()
int BernoulliProcess(float p, int packetGen)
{
//Define the variables
int passed =0;
int count=0, drop =0;
//Use the bernoulli's distribution.
default_random_engine generator;
bernoulli_distribution distribution(p);
//Iterate and generate the distribution.
//Increase the count.
for (int i=0; i<packetGen; ++i)
{
if (distribution(generator))
{
++count;
}
}
//Evaluate the passed packets from the count.
if(count >3)
passed = 3;
else
passed =count;
//Evaluate the dropped packets from the passed packets.
drop = packetGen-passed;
//Display the Probability, passed and dropped packets.
cout<<"Probability:"<<p<<endl;
cout<<"passed:"<<passed<<endl;
cout<<"Drop:"<<drop<<endl<<endl;
//Return the passed packets.
return passed;
}
//Define the main function.
int main()
{
//Generate the numbewr of packets in range 1 to 10.
srand(time(NULL));
int packetGen = rand() % (10 - 1 + 1) + 1;
//Dispaly the packet generated.
cout<<"Packet generated:"<<packetGen<<endl<<endl;
//Define the variables and array.
float p =0.02,d=0.8;
int p2[50]={},d2[50]={};
//collect throughput statistics for different values
//of p (p = 0.02, 0.04 up to 1.0 in steps of 0.02),
for(int j=0; j<50;j++)
{
//Evaluate the passed and dropped packets.
//and Probabilities.
p2[j]=BernoulliProcess(p, packetGen);
d2[j]= 10-p2[j];
p= p+0.02;
d =1-p;
}
int k=0;
//Display the average number of busy outputs versus p.
cout<<"The average number of busy outputs versus p:"<<endl;
for (float i=0.02; i<0.98; i=i+0.02)
{
k++;
cout <<setprecision(2)<<fixed<< i << "-" << (i+0.02) << ": ";
for(int j=0;j<p2[k];j++)
cout<<"*";
cout<<endl;
}
cout<<endl;
k=0;
//Display the average number of dropped packets versus p.
cout<<"The average number of dropped packets versus p:"<<endl;
for (float i=0.02; i<0.98; i=i+0.02 )
{
k++;
cout <<setprecision(2)<<fixed<< i << "-" << (i+0.02) << ": ";
for(int j=0;j<d2[k];j++)
cout<<"*";
cout<<endl;
}
//Return the value 0.
return 0;
}
write a program in matlab to produce a discrete event simulation of a switching element with...
Have to show work for every problem
4. A company uses three plants to produce a new computer chip. Plant A produces 30% of the chips. Plant B produces 45% of the chips. The rest of the chips are produced by plant C. Each plant has its own defectiv rate. These are: plant A produces 3% defective chips, plant B produces 1% defective chips, plant C produces 5% defective chips. Hint: draw a tree diagram. (a) Construct a tree diagram...
Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...
Q1 Error detection/correction Can these schemes correct bit errors: Internet checksums, two-dimendional parity, cyclic redundancy check (CRC) A. Yes, No, No B. No, Yes, Yes c. No, Yes, No D. No, No, Yes E. Ho, hum, ha Q2 CRC vs Internet checksums Which of these is not true? A. CRC's are commonly used at the link layer B. CRC's can detect any bit error of up to r bits with an r-bit EDC. c. CRC's are more resilient to bursty...
summatize the following info and break them into differeng key points. write them in yojr own words
apartus
6.1 Introduction—The design of a successful hot box appa- ratus is influenced by many factors. Before beginning the design of an apparatus meeting this standard, the designer shall review the discussion on the limitations and accuracy, Section 13, discussions of the energy flows in a hot box, Annex A2, the metering box wall loss flow, Annex A3, and flanking loss, Annex...