-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.cc
50 lines (39 loc) · 1010 Bytes
/
Server.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* server.cc
*
* Created on: 27 Sep 2020
* Author: smondal
*/
#include "Header.h"
using namespace std;
using namespace omnetpp;
class ServerMMc : public cSimpleModule
{
private:
double ServiceRate;
bool IsBusy;
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
Define_Module(ServerMMc);
void ServerMMc::initialize()
{
IsBusy = 0; /* Initially the server is idle */
ServiceRate = ServiceRateVec[getIndex()]; /* getIndex() == Index of the server */
}
void ServerMMc::handleMessage(cMessage *msg)
{
if(IsBusy == 0) /* Service request arrives from queue */
{
IsBusy = 1;
scheduleAt(simTime()+exponential(1.0/ServiceRate), msg);
}
else
{
IsBusy = 0; /*Service completes*/
delete msg;
cMessage *ServACK = new cMessage("ServiceIsComplete");
send(ServACK,"inQue$o");
}
}