Question
How to modify the simulation of this code to have a M/D/1 queue? #include ns3/core-module.h #include ns3/network-module.h #include ns3/internet-module.h #include ns3/point-to-point-module.h #include ns3/applications-module.h #include ns3/traffic-control-module.h
How to modify the simulation of this code to have a M/D/1 queue?
#include "ns3/core-module.h" #include "ns3/network-module.h" #include "ns3/internet-module.h" #include "ns3/point-to-point-module.h" #include "ns3/applications-module.h" #include "ns3/traffic-control-module.h" #include "ns3/flow-monitor-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("nineth");
void TcPacketsInQueue (QueueDiscContainer qdiscs, Ptr
static void GenerateTraffic (Ptr
Time pktInterval = Seconds(randomTime->GetValue ()); //Get random value for next packet generation time Simulator::Schedule (pktInterval, &GenerateTraffic, socket, randomSize, randomTime); //Schedule next packet generation }
int main (int argc, char *argv[]) { double simulationTime = 10; //seconds double mu = 100; double lambda = 150; std::string queueSize = "1000";
CommandLine cmd; cmd.AddValue ("simulationTime", "Simulation time [s]", simulationTime); cmd.AddValue ("queueSize", "Size of queue [no. of packets]", queueSize); cmd.AddValue ("lambda", "Arrival rate [packets/s]", lambda); cmd.AddValue ("mu", "Service rate [packets/s]", mu); cmd.Parse (argc, argv);
NodeContainer nodes; nodes.Create (2);
PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("1Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ms")); pointToPoint.SetQueue ("ns3::DropTailQueue", "MaxSize", StringValue ("1p"));
NetDeviceContainer devices; devices = pointToPoint.Install (nodes);
InternetStackHelper stack; stack.Install (nodes);
TrafficControlHelper tch; tch.SetRootQueueDisc ("ns3::FifoQueueDisc", "MaxSize", StringValue (queueSize+"p")); QueueDiscContainer qdiscs = tch.Install (devices);
AsciiTraceHelper asciiTraceHelper; Ptr
for (float t=1.0; t < simulationTime; t+=0.001) { Simulator::Schedule (Seconds(t), &TcPacketsInQueue, qdiscs, stream); }
Ptr
Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces = address.Assign (devices);
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
Ptr
Ptr
double mean = 1.0/lambda; Ptr
mean = (1000000.0/(8*mu)-30); // (1 000 000 [b/s])/(8 [b/B] * packet service rate [1/s]) - 30 [B (header bytes)] Ptr
Simulator::ScheduleWithContext (source->GetNode ()->GetId (), Seconds (1.0), &GenerateTraffic, source, randomSize, randomTime);
FlowMonitorHelper flowmon; Ptr
pointToPoint.EnablePcapAll ("ms-lab7");
Simulator::Stop (Seconds (simulationTime)); Simulator::Run ();
/* Calculation of experiment statistics, no need to analyze */ Ptr
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started