189 if (msg->isSelfMessage())
192 switch (msg->getKind()) {
195 SCTPCommand *command = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
196 assocId = command->getAssocId();
198 if (par(
"numPacketsToReceivePerClient").longValue() == 0) {
205 if (
serverAssocStatMap[assocId].rcvdPackets == (
unsigned int)par(
"numPacketsToReceivePerClient")
223 SCTPConnectInfo *connectInfo = check_and_cast<SCTPConnectInfo *>(msg->removeControlInfo());
225 assocId = connectInfo->getAssocId();
237 sprintf(text,
"App: Received Bytes of assoc %d", assocId);
239 sprintf(text,
"App: EndToEndDelay of assoc %d", assocId);
244 if (par(
"numPacketsToSendPerClient").longValue() > 0) {
247 if (par(
"thinkTime").doubleValue() > 0) {
250 scheduleAt(simTime() + par(
"thinkTime"),
timeoutMsg);
269 cMessage *cmsg =
new cMessage(
"SCTP_C_QUEUE_MSGS_LIMIT");
270 SCTPInfo *qinfo =
new SCTPInfo(
"Info1");
273 qinfo->setAssocId(
id);
274 cmsg->setControlInfo(qinfo);
278 if (j->second.rcvdPackets == 0 && par(
"waitToClose").doubleValue() > 0) {
280 sprintf(as,
"%d", assocId);
281 cMessage *abortMsg =
new cMessage(as);
283 scheduleAt(simTime() + par(
"waitToClose"), abortMsg);
286 EV_INFO <<
"no more packets to send, call shutdown for assoc " << assocId <<
"\n";
287 cMessage *cmsg =
new cMessage(
"ShutdownRequest");
288 SCTPCommand *cmd =
new SCTPCommand(
"Send5");
290 cmd->setAssocId(assocId);
291 cmsg->setControlInfo(cmd);
311 scheduleAt(simTime() + par(
"readingInterval"),
delayTimer);
320 EV_INFO << simTime() <<
" makeReceiveRequest\n";
331 EV_INFO << simTime() <<
" server: data arrived. " <<
packetsRcvd <<
" Packets received now\n";
332 SCTPRcvInfo *ind = check_and_cast<SCTPRcvInfo *>(msg->removeControlInfo());
333 id = ind->getAssocId();
336 if (j->second.rcvdBytes == 0)
337 j->second.start = simTime();
339 j->second.rcvdBytes +=
PK(msg)->getByteLength();
340 k->second->record(j->second.rcvdBytes);
343 if (par(
"numPacketsToReceivePerClient").longValue() > 0) {
344 j->second.rcvdPackets--;
345 SCTPSimpleMessage *smsg = check_and_cast<SCTPSimpleMessage *>(msg);
347 m->second->record(simTime() - smsg->getCreationTime());
348 EV_INFO <<
"server: Data received. Left packets to receive=" << j->second.rcvdPackets <<
"\n";
350 if (j->second.rcvdPackets == 0) {
354 j->second.stop = simTime();
355 j->second.lifeTime = j->second.stop - j->second.start;
360 cMessage *cmsg =
new cMessage(
"SCTP_C_NO_OUTSTANDING");
361 SCTPInfo *qinfo =
new SCTPInfo(
"Info2");
363 qinfo->setAssocId(
id);
364 cmsg->setControlInfo(qinfo);
366 j->second.stop = simTime();
367 j->second.lifeTime = j->second.stop - j->second.start;
374 SCTPSendInfo *cmd =
new SCTPSendInfo(
"SCTP_C_SEND");
376 SCTPSimpleMessage *smsg = check_and_cast<SCTPSimpleMessage *>(msg);
378 n->second->record(simTime() - smsg->getCreationTime());
379 cPacket *cmsg =
new cPacket(
"SCTP_C_SEND");
381 cmd->setSendUnordered(cmd->getSendUnordered());
386 cmsg->encapsulate(smsg);
388 cmsg->setControlInfo(cmd);
397 SCTPCommand *command = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
398 id = command->getAssocId();
399 EV_INFO <<
"server: SCTP_I_SHUTDOWN_RECEIVED for assoc " <<
id <<
"\n";
401 if (i->second.sentPackets == 0 || par(
"numPacketsToSendPerClient").longValue() == 0) {
402 cMessage *cmsg =
new cMessage(
"SCTP_C_NO_OUTSTANDING");
403 SCTPInfo *qinfo =
new SCTPInfo(
"Info3");
405 qinfo->setAssocId(
id);
406 cmsg->setControlInfo(qinfo);
408 i->second.stop = simTime();
409 i->second.lifeTime = i->second.stop - i->second.start;
419 EV_INFO <<
"Streams have been resetted\n";
425 SCTPCommand *command = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
426 id = command->getAssocId();
427 EV_INFO <<
"server: SCTP_I_CLOSED for assoc " <<
id << endl;
429 i->second.stop = simTime();
430 i->second.lifeTime = i->second.stop - i->second.start;
void sendOrSchedule(cMessage *msg)
Definition: SCTPServer.cc:101
cMessage * timeoutMsg
Definition: SCTPServer.h:63
void generateAndSend()
Definition: SCTPServer.cc:109
int queueSize
Definition: SCTPServer.h:54
int numSessions
Definition: SCTPServer.h:76
Definition: SCTPCommand.h:80
bool shutdownReceived
Definition: SCTPServer.h:71
int outboundStreams
Definition: SCTPServer.h:53
bool firstData
Definition: SCTPServer.h:70
unsigned long int packetsRcvd
Definition: SCTPServer.h:81
Definition: SCTPCommand.h:67
int count
Definition: SCTPServer.h:77
Definition: SCTPCommand.h:33
Definition: SCTPCommand.h:43
Definition: SCTPCommand.h:79
Definition: SCTPCommand.h:63
bool readInt
Definition: SCTPServer.h:68
bool echo
Definition: SCTPServer.h:58
double delayFirstRead
Definition: SCTPServer.h:56
Definition: SCTPCommand.h:65
void handleTimer(cMessage *msg)
Definition: SCTPServer.cc:447
Definition: SCTPCommand.h:42
BytesPerAssoc bytesPerAssoc
Definition: SCTPServer.h:83
Definition: SCTPCommand.h:75
Definition: SCTPCommand.h:44
unsigned long int bytesSent
Definition: SCTPServer.h:79
Definition: SCTPCommand.h:66
cMessage * makeAbortNotification(SCTPCommand *msg)
Definition: SCTPServer.cc:169
Definition: SCTPCommand.h:64
unsigned long int numRequestsToSend
Definition: SCTPServer.h:82
unsigned long int packetsSent
Definition: SCTPServer.h:80
Definition: SCTPCommand.h:72
bool finishEndsSimulation
Definition: SCTPServer.h:57
int assocId
Definition: SCTPServer.h:67
int inboundStreams
Definition: SCTPServer.h:52
int notificationsReceived
Definition: SCTPServer.h:78
#define PK(msg)
Definition: INETDefs.h:92
cMessage * delayFirstReadTimer
Definition: SCTPServer.h:65
cMessage * makeReceiveRequest(cMessage *msg)
Definition: SCTPServer.cc:143
bool schedule
Definition: SCTPServer.h:69
int lastStream
Definition: SCTPServer.h:66
bool abortSent
Definition: SCTPServer.h:72
const double k
Definition: QAM16Modulation.cc:24
ServerAssocStatMap serverAssocStatMap
Definition: SCTPServer.h:84
cMessage * delayTimer
Definition: SCTPServer.h:64
EndToEndDelay endToEndDelay
Definition: SCTPServer.h:73
value< double, units::m > m
Definition: Units.h:1047