0% found this document useful (0 votes)
8 views4 pages

Simulation des Systèmes MM1 en OMNeT++

This document contains code for simulating a queueing network model in OMNeT++. It defines classes for a generator, queue, and server. The generator creates messages and sends them to the queue. The server requests messages from the queue and processes them for an exponentially distributed service time. Connections between the modules are specified in the network definition, along with display properties.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Simulation des Systèmes MM1 en OMNeT++

This document contains code for simulating a queueing network model in OMNeT++. It defines classes for a generator, queue, and server. The generator creates messages and sends them to the queue. The server requests messages from the queue and processes them for an exponentially distributed service time. Connections between the modules are specified in the network definition, along with display properties.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Université Badji Mokhtar Annaba Haiahem Rahim Faculté de Technologie Évaluation des

performances des systèmes Département d’Informatique RSI M2

/*
* La classe Nom_de_Classe.ned
*/
simple attente
{
parameters:

@display("i=block/queue");

gates:
input in[];
output out;
}

simple gen
{
gates:

output out;
}

simple server
{
gates:
input in;
output out;

network MM1
{
@display("bgb=623.64,481.88");
submodules:

GEN: gen {
@display("p=62,162;i=block/source");
}

File: attente {
@display("p=183,162;is=l");

SER: server {
@display("p=294,162;is=l;i=block/sink");
}

connections:
//[Link] --> { delay = 100ms; } --> [Link];
//[Link] <-- { delay = 100ms; } <-- [Link];

[Link] --> {delay = 100ms;} --> [Link]++;


[Link] --> {delay = 100ms;} --> [Link];
[Link]++ <-- [Link];

}
Université Badji Mokhtar Annaba Haiahem Rahim Faculté de Technologie Évaluation des
performances des systèmes Département d’Informatique RSI M2

/*
* La classe Nom_de_Classe.h
*/

#ifndef txc1_H_
#define txc1_H_

#include <omnetpp.h>
#include <string.h>

using namespace omnetpp;

class gen : public cSimpleModule {

protected:
// The following redefined virtual function holds the algorithm. virtual void initialize()
override;
virtual void handleMessage(cMessage *msg) override;
// void sendDelayed(cMessage *msg, simtime_t delay, cGate *outputgate) override;
};

class attente : public cSimpleModule {

protected:
// The following redefined virtual function holds the algorithm. virtual void initialize()
override;
virtual void handleMessage(cMessage *msg) override;
// void sendDelayed(cMessage *msg, simtime_t delay, cGate *outputgate) override;
cQueue queue;
};

class server : public cSimpleModule {

protected:
// The following redefined virtual function holds the algorithm. virtual void initialize()
override;
virtual void handleMessage(cMessage *msg) override;
// void sendDelayed(cMessage *msg, simtime_t delay, cGate *outputgate) override;
};

#endif /*

_H_ */
Université Badji Mokhtar Annaba Haiahem Rahim Faculté de Technologie Évaluation des
performances des systèmes Département d’Informatique RSI M2

/*
* La classe Nom_de_Classe.cc
*/

#include "txc1.h"
#include <string.h>
#include <omnetpp.h>

using namespace omnetpp;


// The module class needs to be registered with OMNeT++
Define_Module(gen);
Define_Module(attente);
Define_Module(server);

void gen::initialize()
{

cMessage *msg = new cMessage();


scheduleAt(simTime(), msg);

void gen::handleMessage(cMessage *msg)


{
cMessage *msgk = new cMessage();
msgk->setName("new");
send(msgk, "out");

scheduleAt(simTime()+ exponential(1/0.25), new cMessage("new"));

EV << " générate new message at " << simTime() << endl; }

//---------------------------------------------
void attente::initialize()
{

EV << getName() << "the queue is ready to save objects " << simTime() << endl; }

void attente::handleMessage(cMessage *msg)


{

if (strcmp(msg->getName(), "new") == 0){


EV << " queue Igot a message to save At " << simTime() << endl; msg-
>setTimestamp(simTime());
[Link](msg);
EV << "**** the queue length become ** " << queue .length() << endl;
}
else if (strcmp(msg->getName(), "sch")== 0){

EV << " Serveur : Request Message from Queue At " << simTime() << endl; if(![Link]()){
cMessage *m ;
Université Badji Mokhtar Annaba Haiahem Rahim Faculté de Technologie Évaluation des
performances des systèmes Département d’Informatique RSI M2

m = (cMessage *)[Link]();
EV << "--------------------------------------------";
EV << " Le temps d'attente du message " << m->getId() << " est "<< simTime()- m-
>getTimestamp() << endl;

send(m, "out");

}else {
EV << " Queue is empty " <<endl;
}
scheduleAt(simTime() + exponential(1/0.08), new cMessage("sch")); }
}
//------------------------------------------------------
void server::initialize()
{
EV << getName() << "Serveur : I'am waitng for a message" << simTime() << endl;

cMessage *msgk = new cMessage();


msgk->setName("sch");
sendDelayed(msgk,1 , "out");

void server::handleMessage(cMessage *msg)


{
simtime_t sendt= msg->getCreationTime();

simtime_t arrival= msg->getArrivalTime();


EV << " Le message (Job) " << msg->getId() << " a été généré at "<< sendt << endl;

EV << " Le temps de début de service du job " << msg->getId() << " est "<< arrival << endl;

double temps_service= exponential(1/0.08);


EV << " Le temps de séjour du job " << msg->getId() << "est : "<< (arrival+ temps_service )- sendt << "
Avec un temps de service de "<<temps_service<< endl; delete msg;

/*
* La classe [Link]
*/
[General]
network = MM1

Common questions

Powered by AI

Message scheduling and timing in the simulation are managed using the OMNeT++ framework's scheduling functions. Each module schedules messages either to be sent or to check for new tasks at specific times calculated using exponential distributions. For example, the 'gen' module schedules messages based on the arrival rate of 0.25, while the 'attente' module checks the queue based on 0.08. This creates a stochastic process that mimics real queue dynamics. These scheduling functions ensure a realistic representation of random message generative processes and queue management .

The simulation setup supports performance analysis by logging key timing information such as message creation, queue waiting time, and service completion time, allowing for empirical evaluation of system efficiency. Key metrics include average queue length, system throughput, message waiting time, and overall system response time. These metrics provide insights into the capacity and behavior under various loads, assisting in evaluating performance and scalability of the queue system .

Potential improvements for the MM1 simulation could include adding variability in message sizes and different priority levels in queue handling to simulate more complex traffic scenarios. Moreover, incorporating additional servers or different queuing strategies (e.g., priority or round-robin queues) could extend the network capabilities, reflecting more diverse system architectures. Introducing user-defined traffic patterns instead of purely stochastic would also allow for simulating targeted performance testing and scenario modeling .

The MM1 simulation architecture, using simple modules in OMNeT++, ensures modularity by defining distinct responsibilities in each module, such as message generation, queuing, and service processing. This separation allows for easy adjustments, replacements, or extensions of individual modules without affecting the whole system. Flexibility in extending the model is achieved through defined interfaces and parameters, enabling diverse configurations and enhancements like adding new behaviors or additional modules, thus adhering to a scalable architecture .

The network configuration embodies a classic MM1 queue system by comprising a single message generator ('gen'), a queue ('attente'), and a single server ('server'). Messages are generated following a Poisson process with exponential inter-arrival times controlled by the arrival rate 0.25 in the 'gen' module. These are buffered in the 'attente' queue and served individually by the 'server' utilizing exponential service times, consistent with MM1 queue models where arrivals and service times are memoryless .

The simulation uses predefined constant delays for message transmission between modules. For instance, in the MM1 network definition, connections between the generator, queue, and server modules inherently apply a delay of 100ms for message transfers. These fixed delays simulate transmission time and ensure synchronization between different stages of message processing in the network .

The 'attente' module manages incoming messages by checking their names. If a message labeled 'new' is received, it timestamps the message and inserts it into a queue. This process includes logging the queue's current length. For messages labeled 'sch', it attempts to pop a message from the queue, calculate the waiting time, and send the message onward, scheduling the next check at intervals derived from an exponential distribution with a mean rate of 0.08 .

The 'gen' module in the MM1 network simulation is designed to generate messages at regular intervals. It achieves this functionality by using the OMNeT++ framework to initialize a cMessage and schedule it to be sent at the current simulation time. Subsequently, it sends a new message and schedules another message to be sent at an interval determined by an exponential distribution with mean arrival rate of 0.25 messages per time unit .

In the MM1 network simulation, the 'server' module acts as the processing unit for the messages. It initializes by sending a delayed 'sch' message. Upon receiving a message, it records the creation and arrival times, computes the service time using an exponential distribution with a mean of 0.08, and reports the service and total time spent by the message in the system. The module concludes its process by deleting the message, thus simulating the completion of service .

Exponential functions are crucial in the simulation as they model real-world stochastic processes where events occur continuously and independently over time. The use of exponential functions for scheduling message creation and queue checking introduces variability that mimics randomness in network traffic, an essential aspect of queuing theory. This ensures a realistic simulation of arrival and service times, aiding in understanding performance under uncertainty and fluctuation .

You might also like