219 if (msg->isSelfMessage()) {
224 switch (msg->getKind()) {
237 SCTPCommand *ind = check_and_cast<SCTPCommand *>(msg->getControlInfo()->dup());
238 cMessage *cmsg =
new cMessage(
"Notification");
239 SCTPSendInfo *cmd =
new SCTPSendInfo();
240 id = ind->getAssocId();
242 cmd->setSid(ind->getSid());
243 cmd->setNumMsgs(ind->getNumMsgs());
244 cmsg->setControlInfo(cmd);
259 SCTPConnectInfo *connectInfo = check_and_cast<SCTPConnectInfo *>(msg->removeControlInfo());
268 sprintf(text,
"App: Received Bytes of assoc %d",
serverAssocId);
271 sprintf(text,
"App: EndToEndDelay of assoc %d",
serverAssocId);
273 sprintf(text,
"Hist: EndToEndDelay of assoc %d",
serverAssocId);
278 if ((
int64)(
long)par(
"numPacketsToSendPerClient") > 0) {
281 if ((simtime_t)par(
"thinkTime") > 0) {
284 scheduleAt(simTime() + (simtime_t)par(
"thinkTime"),
timeoutMsg);
303 cMessage *cmsg =
new cMessage(
"SCTP_C_QUEUE_MSGS_LIMIT");
304 SCTPInfo *qinfo =
new SCTPInfo();
307 qinfo->setAssocId(
id);
308 cmsg->setControlInfo(qinfo);
312 EV <<
"!!!!!!!!!!!!!!!All data sent from Peer !!!!!!!!!!\n";
315 if (j->second == 0 && (simtime_t)par(
"waitToClose") > 0) {
318 cMessage *abortMsg =
new cMessage(as);
320 scheduleAt(simTime() + (simtime_t)par(
"waitToClose"), abortMsg);
323 EV <<
"no more packets to send, call shutdown for assoc " <<
serverAssocId <<
"\n";
324 cMessage *cmsg =
new cMessage(
"SCTP_C_SHUTDOWN");
326 SCTPCommand *cmd =
new SCTPCommand();
328 cmd->setAssocId(serverAssocId);
331 cmsg->setControlInfo(cmd);
342 SCTPCommand *ind = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
343 cMessage *cmsg =
new cMessage(
"SCTP_C_RECEIVE");
344 SCTPSendInfo *cmd =
new SCTPSendInfo();
345 id = ind->getAssocId();
347 cmd->setSid(ind->getSid());
348 cmd->setNumMsgs(ind->getNumMsgs());
350 cmsg->setControlInfo(cmd);
353 if (!cmsg->isScheduled() &&
schedule ==
false) {
354 scheduleAt(simTime() + (simtime_t)par(
"delayFirstRead"), cmsg);
362 SCTPCommand *ind = check_and_cast<SCTPCommand *>(msg->getControlInfo());
363 id = ind->getAssocId();
365 SCTPSimpleMessage *smsg = check_and_cast<SCTPSimpleMessage *>(msg);
366 NatMessage *nat = check_and_cast<NatMessage *>(smsg->decapsulate());
368 if (nat->getMulti()) {
370 EV <<
"address 0: " << nat->getPeer2Addresses(0) << endl;
372 EV <<
"address 1: " << nat->getPeer2Addresses(1) << endl;
386 j->second +=
PK(msg)->getBitLength() / 8;
388 k->second->record(j->second);
391 if ((
int64)(
long)par(
"numPacketsToReceivePerClient") > 0) {
394 SCTPSimpleMessage *smsg = check_and_cast<SCTPSimpleMessage *>(msg);
396 j->second->record(simTime() - smsg->getCreationTime());
398 k->second->collect(simTime() - smsg->getCreationTime());
400 if (i->second == 0) {
401 cMessage *cmsg =
new cMessage(
"SCTP_C_NO_OUTSTANDING");
402 SCTPInfo *qinfo =
new SCTPInfo();
404 qinfo->setAssocId(
id);
405 cmsg->setControlInfo(qinfo);
412 SCTPSendInfo *cmd =
new SCTPSendInfo();
415 SCTPSimpleMessage *smsg = check_and_cast<SCTPSimpleMessage *>(msg->dup());
417 j->second->record(simTime() - smsg->getCreationTime());
419 k->second->collect(simTime() - smsg->getCreationTime());
420 cPacket *cmsg =
new cPacket(
"SCTP_C_SEND");
422 cmd->setSendUnordered(cmd->getSendUnordered());
427 cmsg->encapsulate(smsg);
429 cmsg->setControlInfo(cmd);
442 SCTPCommand *command = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
443 id = command->getAssocId();
444 EV <<
"peer: SCTP_I_SHUTDOWN_RECEIVED for assoc " <<
id <<
"\n";
449 if (i->second == 0) {
450 cMessage *cmsg =
new cMessage(
"SCTP_C_NO_OUTSTANDING");
451 SCTPInfo *qinfo =
new SCTPInfo();
453 qinfo->setAssocId(
id);
454 cmsg->setControlInfo(qinfo);
469 EV <<
"Streams have been resetted\n";
482 sprintf(buf,
"rcvd: %lld bytes\nsent: %lld bytes", (
long long int)l->second, (
long long int)
bytesSent);
483 getDisplayString().setTagArg(
"t", 0, buf);
cMessage * timeoutMsg
Definition: SCTPNatPeer.h:49
int32 numRequestsToSend
Definition: SCTPNatPeer.h:46
int32 numSessions
Definition: SCTPNatPeer.h:45
SentPacketsPerAssoc sentPacketsPerAssoc
Definition: SCTPNatPeer.h:68
Definition: SCTPCommand.h:80
BytesPerAssoc bytesPerAssoc
Definition: SCTPNatPeer.h:72
int32 packetsRcvd
Definition: SCTPNatPeer.h:44
void handleTimer(cMessage *msg)
Definition: SCTPNatPeer.cc:487
Definition: SCTPCommand.h:67
int count(const std::vector< T > &v, const T &a)
Definition: stlutils.h:58
int32 packetsSent
Definition: SCTPNatPeer.h:43
Definition: SCTPCommand.h:33
Definition: SCTPCommand.h:43
bool shutdownReceived
Definition: SCTPNatPeer.h:40
int32 lastStream
Definition: SCTPNatPeer.h:55
SCTPSocket clientSocket
Definition: SCTPNatPeer.h:34
static const char * indicationName(const int32 code)
Utility: returns name of SCTP_I_xxx constants.
Definition: SCTPAssociationUtil.cc:206
int32 queueSize
Definition: SCTPNatPeer.h:48
Definition: SCTPCommand.h:79
Definition: SCTPSocket.h:87
L3Address peerAddress
Definition: SCTPNatPeer.h:60
Definition: SCTPCommand.h:63
bool rendezvous
Definition: SCTPNatPeer.h:59
int32 inboundStreams
Definition: SCTPNatPeer.h:52
Definition: SCTPCommand.h:35
Definition: SCTPCommand.h:37
bool echo
Definition: SCTPNatPeer.h:38
RcvdPacketsPerAssoc rcvdPacketsPerAssoc
Definition: SCTPNatPeer.h:66
int getState()
Returns the socket state, one of NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED, etc.
Definition: SCTPSocket.h:154
Definition: SCTPCommand.h:65
Definition: SCTPCommand.h:42
Definition: SCTPCommand.h:75
bool schedule
Definition: SCTPNatPeer.h:39
Definition: SCTPCommand.h:44
HistEndToEndDelay histEndToEndDelay
Definition: SCTPNatPeer.h:74
RcvdBytesPerAssoc rcvdBytesPerAssoc
Definition: SCTPNatPeer.h:70
Definition: SCTPCommand.h:66
Definition: SCTPCommand.h:64
AddressVector peerAddressList
Definition: SCTPNatPeer.h:62
int32_t int32
Definition: Compat.h:31
Definition: SCTPCommand.h:72
int32 notifications
Definition: SCTPNatPeer.h:32
int64 bytesSent
Definition: SCTPNatPeer.h:42
#define PK(msg)
Definition: INETDefs.h:92
uint16_t id
Definition: TCP_NSC.cc:85
int32 outboundStreams
Definition: SCTPNatPeer.h:51
int64_t int64
Definition: Compat.h:29
const double k
Definition: QAM16Modulation.cc:24
EndToEndDelay endToEndDelay
Definition: SCTPNatPeer.h:76
void generateAndSend()
Definition: SCTPNatPeer.cc:121
void processMessage(cMessage *msg)
Examines the message (which should have arrived from SCTPMain), updates socket state, and if there is a callback object installed (see setCallbackObject(), class CallbackInterface), dispatches to the appropriate method of it with the same yourPtr that you gave in the setCallbackObject() call.
Definition: SCTPSocket.cc:479
void sendOrSchedule(cMessage *msg)
Definition: SCTPNatPeer.cc:111
int32 peerPort
Definition: SCTPNatPeer.h:61
Definition: SCTPSocket.h:87
Definition: SCTPCommand.h:82
int32 serverAssocId
Definition: SCTPNatPeer.h:33