INET Framework for OMNeT++/OMNEST
inet::SctpClient Class Reference

Implements the SctpClient simple module. More...

#include <SctpClient.h>

Inheritance diagram for inet::SctpClient:
inet::SctpSocket::ICallback inet::LifecycleUnsupported inet::ILifecycle

Classes

struct  PathStatus
 

Public Member Functions

 SctpClient ()
 
virtual ~SctpClient ()
 
- Public Member Functions inherited from inet::SctpSocket::ICallback
virtual ~ICallback ()
 
virtual void socketOptionsArrived (SctpSocket *socket, Indication *indication)
 
virtual void socketDeleted (SctpSocket *socket)
 
virtual void sendqueueFullArrived (SctpSocket *socket)
 
virtual void addressAddedArrived (SctpSocket *socket, L3Address localAddr, L3Address remoteAddr)
 
- Public Member Functions inherited from inet::LifecycleUnsupported
virtual bool handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Types

typedef std::map< L3Address, PathStatusSctpPathStatus
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void finish () override
 
virtual void refreshDisplay () const override
 
void connect ()
 
void close ()
 
void handleTimer (cMessage *msg)
 
virtual void socketAvailable (SctpSocket *socket, Indication *indication) override
 
void socketEstablished (SctpSocket *socket, unsigned long int buffer) override
 
void socketDataArrived (SctpSocket *socket, Packet *msg, bool urgent) override
 
void socketDataNotificationArrived (SctpSocket *socket, Message *msg) override
 
void socketPeerClosed (SctpSocket *socket) override
 
void socketClosed (SctpSocket *socket) override
 
void socketFailure (SctpSocket *socket, int code) override
 
void socketStatusArrived (SctpSocket *socket, SctpStatusReq *status) override
 
void setPrimaryPath (const char *addr)
 
void sendRequestArrived (SctpSocket *socket) override
 
void sendQueueRequest ()
 
void shutdownReceivedArrived (SctpSocket *socket) override
 
void sendqueueAbatedArrived (SctpSocket *socket, unsigned long int buffer) override
 
void msgAbandonedArrived (SctpSocket *socket) override
 
void sendStreamResetNotification ()
 
void sendRequest (bool last=true)
 

Protected Attributes

std::map< unsigned int, unsigned int > streamRequestLengthMap
 
std::map< unsigned int, unsigned int > streamRequestRatioMap
 
std::map< unsigned int, unsigned int > streamRequestRatioSendMap
 
int queueSize
 
unsigned int outStreams
 
unsigned int inStreams
 
bool echo
 
bool ordered
 
bool finishEndsSimulation
 
SctpSocket socket
 
SctpPathStatus sctpPathStatus
 
cMessage * timeMsg
 
cMessage * stopTimer
 
cMessage * primaryChangeTimer
 
int64_t bufferSize
 
bool timer
 
bool sendAllowed
 
const char * stateNameStr
 
unsigned long int packetsSent
 
unsigned long int packetsRcvd
 
unsigned long int bytesSent
 
unsigned long int echoedBytesSent
 
unsigned long int bytesRcvd
 
unsigned long int numRequestsToSend
 
unsigned long int numPacketsToReceive
 
int numSessions
 
int numBroken
 
int chunksAbandoned
 

Static Protected Attributes

static simsignal_t echoedPkSignal = registerSignal("echoedPk")
 

Detailed Description

Implements the SctpClient simple module.

See the NED file for more info.

Member Typedef Documentation

◆ SctpPathStatus

Constructor & Destructor Documentation

◆ SctpClient()

inet::SctpClient::SctpClient ( )
35 {
36  timeMsg = nullptr;
37  stopTimer = nullptr;
38  primaryChangeTimer = nullptr;
39  numSessions = 0;
40  numBroken = 0;
41  packetsSent = 0;
42  packetsRcvd = 0;
43  bytesSent = 0;
44  echoedBytesSent = 0;
45  bytesRcvd = 0;
46  queueSize = 0;
47  outStreams = 1;
48  inStreams = 17;
49  echo = false;
50  ordered = true;
51  finishEndsSimulation = false;
52  bufferSize = 0;
53  timer = false;
54  sendAllowed = true;
55  numRequestsToSend = 0; // requests to send in this session
57  chunksAbandoned = 0;
58 }

◆ ~SctpClient()

inet::SctpClient::~SctpClient ( )
virtual
61 {
62  cancelAndDelete(timeMsg);
63  cancelAndDelete(stopTimer);
64  cancelAndDelete(primaryChangeTimer);
65 }

Member Function Documentation

◆ close()

void inet::SctpClient::close ( )
protected
185 {
186  socket.close();
187 }

Referenced by handleTimer(), socketDataArrived(), and socketPeerClosed().

◆ connect()

void inet::SctpClient::connect ( )
protected
142 {
143  const char *connectAddress = par("connectAddress");
144  int connectPort = par("connectPort");
145  inStreams = par("inboundStreams");
146  outStreams = par("outboundStreams");
149  EV_INFO << "issuing OPEN command, connect to address " << connectAddress << "\n";
150  bool streamReset = par("streamReset");
151  L3Address destination;
152  L3AddressResolver().tryResolve(connectAddress, destination);
153  if (destination.isUnspecified())
154  EV << "cannot resolve destination address: " << connectAddress << endl;
155  else {
156  socket.connect(destination, connectPort, streamReset, par("prMethod"), (unsigned int)par("numRequestsPerSession"));
157  }
158 
159  if (streamReset) {
160  cMessage *cmsg = new cMessage("StreamReset", MSGKIND_RESET);
161  EV_INFO << "StreamReset Timer scheduled at " << simTime() + par("streamRequestTime") << "\n";
162  scheduleAfter(par("streamRequestTime"), cmsg);
163  }
164 
165  for (unsigned int i = 0; i < outStreams; i++) {
166  streamRequestLengthMap[i] = par("requestLength");
167  streamRequestRatioMap[i] = 1;
169  }
170 
171  unsigned int streamNum = 0;
172  cStringTokenizer ratioTokenizer(par("streamRequestRatio"));
173  while (ratioTokenizer.hasMoreTokens()) {
174  const char *token = ratioTokenizer.nextToken();
175  streamRequestRatioMap[streamNum] = atoi(token);
176  streamRequestRatioSendMap[streamNum] = atoi(token);
177 
178  streamNum++;
179  }
180 
181  numSessions++;
182 }

Referenced by handleTimer().

◆ finish()

void inet::SctpClient::finish ( )
overrideprotectedvirtual
607 {
608  EV_INFO << getFullPath() << ": opened " << numSessions << " sessions\n";
609  EV_INFO << getFullPath() << ": sent " << bytesSent << " bytes in " << packetsSent << " packets\n";
610  EV_INFO << getFullPath() << ": received " << bytesRcvd << " bytes in " << packetsRcvd << " packets\n";
611  EV_INFO << "Client finished\n";
612 }

◆ handleMessage()

void inet::SctpClient::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
132 {
133  if (msg->isSelfMessage()) {
134  handleTimer(msg);
135  }
136  else {
137  socket.processMessage(msg);
138  }
139 }

◆ handleTimer()

void inet::SctpClient::handleTimer ( cMessage *  msg)
protected
392 {
393  switch (msg->getKind()) {
394  case MSGKIND_CONNECT:
395  EV_DEBUG << "starting session call connect\n";
396  connect();
397  break;
398 
399  case MSGKIND_SEND:
400  if (((!timer && numRequestsToSend > 0) || timer)) {
401  if (sendAllowed) {
402  sendRequest();
403  if (!timer)
405  }
406  if (par("thinkTime").doubleValue() > 0)
407  scheduleAfter(par("thinkTime"), timeMsg);
408 
409  if ((!timer && numRequestsToSend == 0) && par("waitToClose").doubleValue() == 0) {
410  socket.shutdown();
411  if (timeMsg->isScheduled())
412  cancelEvent(timeMsg);
413 
414  if (finishEndsSimulation) {
415  endSimulation();
416  }
417  }
418  }
419  else if ((!timer && numRequestsToSend == 0) && par("waitToClose").doubleValue() == 0) {
420  socket.shutdown();
421  if (timeMsg->isScheduled())
422  cancelEvent(timeMsg);
423 
424  if (finishEndsSimulation) {
425  endSimulation();
426  }
427  }
428  break;
429 
430  case MSGKIND_ABORT:
431  close();
432  break;
433 
434  case MSGKIND_PRIMARY:
435  setPrimaryPath(par("newPrimary"));
436  break;
437 
438  case MSGKIND_RESET:
440  delete msg;
441  break;
442 
443  case MSGKIND_STOP:
444  numRequestsToSend = 0;
445  sendAllowed = false;
446  socket.abort();
447  socket.close();
448 
449  if (timeMsg->isScheduled())
450  cancelEvent(timeMsg);
451 
452  if (finishEndsSimulation) {
453  endSimulation();
454  }
455  break;
456 
457  default:
458  throw cRuntimeError("unknown selfmessage kind = %d ", msg->getKind());
459  break;
460  }
461 }

Referenced by handleMessage().

◆ initialize()

void inet::SctpClient::initialize ( int  stage)
overrideprotectedvirtual
68 {
69  cSimpleModule::initialize(stage);
70 
71  EV_DEBUG << "initialize SCTP Client stage " << stage << endl;
72  if (stage == INITSTAGE_LOCAL) {
73  echo = par("echo");
74  ordered = par("ordered");
75  finishEndsSimulation = par("finishEndsSimulation");
76  queueSize = par("queueSize");
77  WATCH(numRequestsToSend);
78  recordScalar("ums", par("requestLength").intValue());
79 
80  timeMsg = new cMessage("CliAppTimer", MSGKIND_CONNECT);
81  scheduleAt(par("startTime"), timeMsg);
82 
83  stopTimer = nullptr;
84  primaryChangeTimer = nullptr;
85 
86  WATCH(numSessions);
87  WATCH(numBroken);
88  WATCH(packetsSent);
89  WATCH(packetsRcvd);
90  WATCH(bytesSent);
91  WATCH(bytesRcvd);
92  }
93  else if (stage == INITSTAGE_APPLICATION_LAYER) {
94  cModule *node = findContainingNode(this);
95  NodeStatus *nodeStatus = node ? check_and_cast_nullable<NodeStatus *>(node->getSubmodule("status")) : nullptr;
96  bool isOperational = (!nodeStatus) || nodeStatus->getState() == NodeStatus::UP;
97  if (!isOperational)
98  throw cRuntimeError("This module doesn't support starting in node DOWN state");
99 
100  // parameters
101  const char *addressesString = par("localAddress");
102  AddressVector addresses = L3AddressResolver().resolve(cStringTokenizer(addressesString).asVector());
103  int port = par("localPort");
104  socket.setOutputGate(gate("socketOut"));
105  socket.setCallback(this);
106 
107  if (addresses.size() == 0) {
108  EV_INFO << "Call socket bind\n";
109  socket.bind(port);
110  EV_INFO << "Nach socket bind\n";
111  }
112  else {
113  socket.bindx(addresses, port);
114  }
115 
116  simtime_t stopTime = par("stopTime");
117  if (stopTime >= SIMTIME_ZERO) {
118  stopTimer = new cMessage("StopTimer", MSGKIND_STOP);
119  scheduleAt(par("stopTime"), stopTimer);
120  timer = true;
121  }
122 
123  simtime_t primaryTime = par("primaryTime");
124  if (primaryTime != SIMTIME_ZERO) {
125  primaryChangeTimer = new cMessage("PrimaryTime", MSGKIND_PRIMARY);
126  scheduleAt(primaryTime, primaryChangeTimer);
127  }
128  }
129 }

◆ msgAbandonedArrived()

void inet::SctpClient::msgAbandonedArrived ( SctpSocket socket)
overrideprotectedvirtual

Reimplemented from inet::SctpSocket::ICallback.

572 {
573  chunksAbandoned++;
574 }

◆ numInitStages()

virtual int inet::SctpClient::numInitStages ( ) const
inlineoverrideprotectedvirtual
72 { return NUM_INIT_STAGES; }

◆ refreshDisplay()

void inet::SctpClient::refreshDisplay ( ) const
overrideprotectedvirtual
190 {
191  getDisplayString().setTagArg("t", 0, SctpSocket::stateName(socket.getState()));
192 }

◆ sendqueueAbatedArrived()

void inet::SctpClient::sendqueueAbatedArrived ( SctpSocket socket,
unsigned long int  buffer 
)
overrideprotectedvirtual

Reimplemented from inet::SctpSocket::ICallback.

577 {
578  bufferSize = buffer;
579  sendAllowed = true;
580 
581  while ((((!timer && numRequestsToSend > 0) || timer) && sendAllowed && bufferSize > 0) ||
582  (((!timer && numRequestsToSend > 0) || timer) && sendAllowed && buffer == 0))
583  {
584  if (!timer && numRequestsToSend == 1)
585  sendRequest(true);
586  else
587  sendRequest(false);
588 
589  if (!timer && (--numRequestsToSend == 0))
590  sendAllowed = false;
591  }
592 
593  if ((!timer && numRequestsToSend == 0) && par("waitToClose").doubleValue() == 0) {
594  EV_INFO << "socketEstablished:no more packets to send, call shutdown\n";
595  socket->shutdown();
596 
597  if (timeMsg->isScheduled())
598  cancelEvent(timeMsg);
599 
600  if (finishEndsSimulation) {
601  endSimulation();
602  }
603  }
604 }

◆ sendQueueRequest()

void inet::SctpClient::sendQueueRequest ( )
protected
277 {
278  Request *cmsg = new Request("SCTP_C_QUEUE_MSGS_LIMIT", SCTP_C_QUEUE_MSGS_LIMIT);
279  auto qinfo = cmsg->addTag<SctpInfoReq>();
280  qinfo->setText(queueSize);
281  qinfo->setSocketId(socket.getSocketId());
282  socket.sendRequest(cmsg);
283 }

Referenced by socketEstablished().

◆ sendRequest()

void inet::SctpClient::sendRequest ( bool  last = true)
protected
343 {
344  // find next stream
345  unsigned int nextStream = 0;
346  for (unsigned int i = 0; i < outStreams; i++) {
348  nextStream = i;
349  }
350 
351  // no stream left, reset map
352  if (nextStream == 0 && streamRequestRatioSendMap[nextStream] == 0) {
353  for (unsigned int i = 0; i < outStreams; i++) {
356  nextStream = i;
357  }
358  }
359 
360  if (nextStream == 0 && streamRequestRatioSendMap[nextStream] == 0) {
361  throw cRuntimeError("Invalid setting of streamRequestRatio: only 0 weightings");
362  }
363 
364  unsigned int sendBytes = streamRequestLengthMap[nextStream];
365  streamRequestRatioSendMap[nextStream]--;
366 
367  if (sendBytes < 1)
368  sendBytes = 1;
369 
370  auto applicationPacket = new Packet("ApplicationPacket");
371  auto applicationData = makeShared<BytesChunk>();
372  std::vector<uint8_t> vec;
373  vec.resize(sendBytes);
374  for (uint32_t i = 0; i < sendBytes; i++)
375  vec[i] = (bytesSent + i) & 0xFF;
376  applicationData->setBytes(vec);
377  applicationData->addTag<CreationTimeTag>()->setCreationTime(simTime());
378  applicationPacket->insertAtBack(applicationData);
379  auto sctpSendReq = applicationPacket->addTag<SctpSendReq>();
380  sctpSendReq->setLast(last);
381  sctpSendReq->setPrMethod(par("prMethod"));
382  sctpSendReq->setPrValue(par("prValue"));
383  sctpSendReq->setSid(nextStream);
384  applicationPacket->setKind(ordered ? SCTP_C_SEND_ORDERED : SCTP_C_SEND_UNORDERED);
385  emit(packetSentSignal, applicationPacket);
386  socket.send(applicationPacket);
387 
388  bytesSent += sendBytes;
389 }

Referenced by handleTimer(), sendqueueAbatedArrived(), sendRequestArrived(), and socketEstablished().

◆ sendRequestArrived()

void inet::SctpClient::sendRequestArrived ( SctpSocket socket)
overrideprotectedvirtual

Reimplemented from inet::SctpSocket::ICallback.

286 {
287  int count = 0;
288 
289  EV_INFO << "sendRequestArrived numRequestsToSend=" << numRequestsToSend << "\n";
290 
291  while (((!timer && numRequestsToSend > 0) || timer) && count++ < queueSize && sendAllowed) {
293 
294  if (!timer)
296 
297  if ((!timer && numRequestsToSend == 0)) {
298  EV_INFO << "no more packets to send, call shutdown\n";
299  socket->shutdown();
300 
301  if (timeMsg->isScheduled())
302  cancelEvent(timeMsg);
303 
305  endSimulation();
306  }
307  }
308 }

◆ sendStreamResetNotification()

void inet::SctpClient::sendStreamResetNotification ( )
protected
557 {
558  unsigned short int type = par("streamResetType");
559  if (type >= 6 && type <= 9) {
560  Message *cmsg = new Message("SCTP_C_STREAM_RESET", SCTP_C_STREAM_RESET);
561  auto rinfo = cmsg->addTag<SctpResetReq>();
562  rinfo->setSocketId(socket.getSocketId());
563  rinfo->setRemoteAddr(socket.getRemoteAddr());
564  rinfo->setRequestType(type);
565  rinfo->setStreamsArraySize(1);
566  rinfo->setStreams(0, par("streamToReset"));
567  socket.sendNotification(cmsg);
568  }
569 }

Referenced by handleTimer().

◆ setPrimaryPath()

void inet::SctpClient::setPrimaryPath ( const char *  addr)
protected
535 {
536  Request *cmsg = new Request("SCTP_C_PRIMARY", SCTP_C_PRIMARY);
537  auto pinfo = cmsg->addTag<SctpPathInfoReq>();
538 
539  if (strcmp(str, "") != 0) {
540  pinfo->setRemoteAddress(L3Address(str));
541  }
542  else {
543  str = par("newPrimary");
544  if (strcmp(str, "") != 0)
545  pinfo->setRemoteAddress(L3Address(str));
546  else {
547  str = par("connectAddress");
548  pinfo->setRemoteAddress(L3Address(str));
549  }
550  }
551 
552  pinfo->setSocketId(socket.getSocketId());
553  socket.sendNotification(cmsg);
554 }

Referenced by handleTimer().

◆ shutdownReceivedArrived()

void inet::SctpClient::shutdownReceivedArrived ( SctpSocket socket)
overrideprotectedvirtual

Reimplemented from inet::SctpSocket::ICallback.

477 {
478  if (numRequestsToSend == 0) {
479  Message *cmsg = new Message("SCTP_C_NO_OUTSTANDING", SCTP_C_NO_OUTSTANDING);
480  auto qinfo = cmsg->addTag<SctpCommandReq>();
481  qinfo->setSocketId(socket->getSocketId());
482  socket->sendNotification(cmsg);
483  }
484 }

◆ socketAvailable()

virtual void inet::SctpClient::socketAvailable ( SctpSocket socket,
Indication indication 
)
inlineoverrideprotectedvirtual

Implements inet::SctpSocket::ICallback.

83 { throw cRuntimeError("Model error, this module doesn't use any listener SCTP sockets"); }

◆ socketClosed()

void inet::SctpClient::socketClosed ( SctpSocket socket)
overrideprotectedvirtual

Reimplemented from inet::SctpSocket::ICallback.

496 {
497  // *redefine* to start another session etc.
498  EV_INFO << "connection closed\n";
499 
500  if (primaryChangeTimer) {
501  cancelEvent(primaryChangeTimer);
502  delete primaryChangeTimer;
503  primaryChangeTimer = nullptr;
504  }
505 }

◆ socketDataArrived()

void inet::SctpClient::socketDataArrived ( SctpSocket socket,
Packet msg,
bool  urgent 
)
overrideprotectedvirtual

Implements inet::SctpSocket::ICallback.

311 {
312  packetsRcvd++;
313 
314  EV_INFO << "Client received packet Nr " << packetsRcvd << " from SCTP\n";
315  auto ind = msg->getTag<SctpRcvReq>();
316  emit(packetReceivedSignal, msg);
317  bytesRcvd += msg->getByteLength();
318 
319  if (echo) {
320  const auto& smsg = msg->peekData();
321  auto cmsg = new Packet("ApplicationPacket");
322  cmsg->insertAtBack(smsg);
323  auto cmd = cmsg->addTag<SctpSendReq>();
324  cmd->setLast(true);
325  cmd->setSocketId(ind->getSocketId());
326  cmd->setPrValue(0);
327  cmd->setSid(ind->getSid());
328  cmsg->setKind(ind->getSendUnordered() ? SCTP_C_SEND_UNORDERED : SCTP_C_SEND_ORDERED);
329  packetsSent++;
330  socket->send(cmsg);
331  }
332 
333  if (par("numPacketsToReceive").intValue() > 0) {
335  if (numPacketsToReceive == 0)
336  close();
337  }
338 
339  delete msg;
340 }

◆ socketDataNotificationArrived()

void inet::SctpClient::socketDataNotificationArrived ( SctpSocket socket,
Message msg 
)
overrideprotectedvirtual

Implements inet::SctpSocket::ICallback.

464 {
465  Message *message = check_and_cast<Message *>(msg);
466  auto& ind = message->findTag<SctpCommandReq>();
467  Request *cmesg = new Request("SCTP_C_RECEIVE", SCTP_C_RECEIVE);
468  auto cmd = cmesg->addTag<SctpSendReq>();
469  cmd->setSocketId(ind->getSocketId());
470  cmd->setSid(ind->getSid());
471  cmd->setNumMsgs(ind->getNumMsgs());
472  delete msg;
473  socket->sendNotification(cmesg);
474 }

◆ socketEstablished()

void inet::SctpClient::socketEstablished ( SctpSocket socket,
unsigned long int  buffer 
)
overrideprotectedvirtual

Reimplemented from inet::SctpSocket::ICallback.

195 {
196  int count = 0;
197  EV_INFO << "SctpClient: connected\n";
198  bufferSize = buffer;
199  // determine number of requests in this session
200  numRequestsToSend = par("numRequestsPerSession");
201  numPacketsToReceive = par("numPacketsToReceive");
202  if (numRequestsToSend == 0) {
203  sendAllowed = false;
204  }
205 
206  if (numRequestsToSend < 1)
207  numRequestsToSend = 0;
208 
209  EV_INFO << "SctpClient:numRequestsToSend=" << numRequestsToSend << " queueSize= " << queueSize << "\n";
210 
211  if (queueSize > 0) {
213  }
214 
215  // perform first request (next one will be sent when reply arrives)
216  if ((numRequestsToSend > 0 && !timer) || timer) {
217  if (par("thinkTime").doubleValue() > 0) {
218  if (sendAllowed) {
219  sendRequest();
220 
221  if (!timer)
223  }
224 
225  timeMsg->setKind(MSGKIND_SEND);
226  scheduleAfter(par("thinkTime"), timeMsg);
227  }
228  else {
229  if (queueSize > 0) {
230  while (((!timer && numRequestsToSend > 0) || timer) && count++ < queueSize * 2 && sendAllowed) {
231  if (count == queueSize * 2)
232  sendRequest();
233  else
234  sendRequest(false);
235 
236  if (!timer) {
237  if (--numRequestsToSend == 0)
238  sendAllowed = false;
239  }
240  }
241  }
242  else {
243  while ((((!timer && numRequestsToSend > 0) || timer) && sendAllowed && bufferSize > 0) ||
244  (((!timer && numRequestsToSend > 0) || timer) && sendAllowed && buffer == 0))
245  {
246  if (!timer && numRequestsToSend == 1)
247  sendRequest(true);
248  else
249  sendRequest(false);
250 
251  if (!timer && (--numRequestsToSend == 0))
252  sendAllowed = false;
253  }
254  }
255  }
256 
257  if ((!timer && numPacketsToReceive == 0) && par("waitToClose").doubleValue() > 0) {
258  timeMsg->setKind(MSGKIND_ABORT);
259  scheduleAfter(par("waitToClose"), timeMsg);
260  }
261 
262  if ((!timer && numRequestsToSend == 0) && par("waitToClose").doubleValue() == 0) {
263  EV_INFO << "socketEstablished:no more packets to send, call shutdown\n";
264  socket->shutdown();
265 
266  if (timeMsg->isScheduled())
267  cancelEvent(timeMsg);
268 
269  if (finishEndsSimulation) {
270  endSimulation();
271  }
272  }
273  }
274 }

◆ socketFailure()

void inet::SctpClient::socketFailure ( SctpSocket socket,
int  code 
)
overrideprotectedvirtual

Reimplemented from inet::SctpSocket::ICallback.

508 {
509  // subclasses may override this function, and add code try to reconnect after a delay.
510  EV_WARN << "connection broken\n";
511  numBroken++;
512  // reconnect after a delay
513  timeMsg->setKind(MSGKIND_CONNECT);
514  scheduleAfter(par("reconnectInterval"), timeMsg);
515 }

◆ socketPeerClosed()

void inet::SctpClient::socketPeerClosed ( SctpSocket socket)
overrideprotectedvirtual

Reimplemented from inet::SctpSocket::ICallback.

487 {
488  // close the connection (if not already closed)
490  EV_INFO << "remote SCTP closed, closing here as well\n";
491  close();
492  }
493 }

◆ socketStatusArrived()

void inet::SctpClient::socketStatusArrived ( SctpSocket socket,
SctpStatusReq status 
)
overrideprotectedvirtual

Reimplemented from inet::SctpSocket::ICallback.

518 {
519  struct PathStatus ps;
520  auto i = sctpPathStatus.find(status->getPathId());
521 
522  if (i != sctpPathStatus.end()) {
523  ps = i->second;
524  ps.active = status->getActive();
525  }
526  else {
527  ps.active = status->getActive();
528  ps.pid = status->getPathId();
529  ps.primaryPath = false;
530  sctpPathStatus[ps.pid] = ps;
531  }
532 }

Member Data Documentation

◆ bufferSize

int64_t inet::SctpClient::bufferSize
protected

◆ bytesRcvd

unsigned long int inet::SctpClient::bytesRcvd
protected

◆ bytesSent

unsigned long int inet::SctpClient::bytesSent
protected

◆ chunksAbandoned

int inet::SctpClient::chunksAbandoned
protected

Referenced by msgAbandonedArrived(), and SctpClient().

◆ echo

bool inet::SctpClient::echo
protected

◆ echoedBytesSent

unsigned long int inet::SctpClient::echoedBytesSent
protected

Referenced by SctpClient().

◆ echoedPkSignal

simsignal_t inet::SctpClient::echoedPkSignal = registerSignal("echoedPk")
staticprotected

◆ finishEndsSimulation

bool inet::SctpClient::finishEndsSimulation
protected

◆ inStreams

unsigned int inet::SctpClient::inStreams
protected

Referenced by connect(), and SctpClient().

◆ numBroken

int inet::SctpClient::numBroken
protected

◆ numPacketsToReceive

unsigned long int inet::SctpClient::numPacketsToReceive
protected

◆ numRequestsToSend

unsigned long int inet::SctpClient::numRequestsToSend
protected

◆ numSessions

int inet::SctpClient::numSessions
protected

◆ ordered

bool inet::SctpClient::ordered
protected

Referenced by initialize(), SctpClient(), and sendRequest().

◆ outStreams

unsigned int inet::SctpClient::outStreams
protected

Referenced by connect(), SctpClient(), and sendRequest().

◆ packetsRcvd

unsigned long int inet::SctpClient::packetsRcvd
protected

◆ packetsSent

unsigned long int inet::SctpClient::packetsSent
protected

◆ primaryChangeTimer

cMessage* inet::SctpClient::primaryChangeTimer
protected

◆ queueSize

int inet::SctpClient::queueSize
protected

◆ sctpPathStatus

SctpPathStatus inet::SctpClient::sctpPathStatus
protected

Referenced by socketStatusArrived().

◆ sendAllowed

bool inet::SctpClient::sendAllowed
protected

◆ socket

◆ stateNameStr

const char* inet::SctpClient::stateNameStr
protected

◆ stopTimer

cMessage* inet::SctpClient::stopTimer
protected

Referenced by initialize(), SctpClient(), and ~SctpClient().

◆ streamRequestLengthMap

std::map<unsigned int, unsigned int> inet::SctpClient::streamRequestLengthMap
protected

Referenced by connect(), and sendRequest().

◆ streamRequestRatioMap

std::map<unsigned int, unsigned int> inet::SctpClient::streamRequestRatioMap
protected

Referenced by connect(), and sendRequest().

◆ streamRequestRatioSendMap

std::map<unsigned int, unsigned int> inet::SctpClient::streamRequestRatioSendMap
protected

Referenced by connect(), and sendRequest().

◆ timeMsg

◆ timer

bool inet::SctpClient::timer
protected

The documentation for this class was generated from the following files:
inet::SCTP_C_STREAM_RESET
@ SCTP_C_STREAM_RESET
Definition: SctpCommand_m.h:144
inet::findContainingNode
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:31
inet::SctpSocket::processMessage
void processMessage(cMessage *msg) override
Examines the message (which should have arrived from SctpMain), updates socket state,...
Definition: SctpSocket.cc:461
inet::SCTP_C_SEND_UNORDERED
@ SCTP_C_SEND_UNORDERED
Definition: SctpCommand_m.h:138
inet::SctpClient::echoedBytesSent
unsigned long int echoedBytesSent
Definition: SctpClient.h:62
inet::AddressVector
std::vector< L3Address > AddressVector
Definition: SctpCommand_m.h:70
inet::SctpClient::timeMsg
cMessage * timeMsg
Definition: SctpClient.h:50
inet::SctpSocket::setOutputGate
void setOutputGate(cGate *toSctp)
Sets the gate on which to send to SCTP.
Definition: SctpSocket.h:174
MSGKIND_SEND
#define MSGKIND_SEND
Definition: SctpClient.cc:24
inet::SctpClient::queueSize
int queueSize
Definition: SctpClient.h:40
inet::SctpSocket::getSocketId
int getSocketId() const override
Returns the internal connection Id.
Definition: SctpSocket.h:138
inet::SctpClient::outStreams
unsigned int outStreams
Definition: SctpClient.h:41
inet::SCTP_C_PRIMARY
@ SCTP_C_PRIMARY
Definition: SctpCommand_m.h:139
MSGKIND_CONNECT
#define MSGKIND_CONNECT
Definition: SctpClient.cc:23
inet::count
int count(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:54
inet::SctpSocket::abort
void abort()
Aborts the association.
Definition: SctpSocket.cc:431
inet::SctpSocket::send
virtual void send(Packet *packet) override
Send data message.
Definition: SctpSocket.cc:355
inet::SctpSocket::shutdown
void shutdown(int id=-1)
Definition: SctpSocket.cc:408
inet::SctpClient::sctpPathStatus
SctpPathStatus sctpPathStatus
Definition: SctpClient.h:49
inet::SctpSocket::sendRequest
void sendRequest(cMessage *msg)
Send request.
Definition: SctpSocket.cc:389
inet::SctpSocket::getState
int getState() const
Returns the socket state, one of NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED,...
Definition: SctpSocket.h:151
inet::SctpSocket::setCallback
void setCallback(ICallback *cb)
Sets a callback object, to be used with processMessage().
Definition: SctpSocket.cc:456
inet::SctpClient::sendQueueRequest
void sendQueueRequest()
Definition: SctpClient.cc:276
MSGKIND_RESET
#define MSGKIND_RESET
Definition: SctpClient.cc:27
inet::packetSentSignal
simsignal_t packetSentSignal
Definition: Simsignals.cc:96
inet::SctpSocket::sendNotification
void sendNotification(cMessage *msg)
Send notification.
Definition: SctpSocket.cc:377
inet::SctpClient::sendRequest
void sendRequest(bool last=true)
Definition: SctpClient.cc:342
inet::SctpClient::streamRequestRatioSendMap
std::map< unsigned int, unsigned int > streamRequestRatioSendMap
Definition: SctpClient.h:39
inet::SctpClient::echo
bool echo
Definition: SctpClient.h:43
inet::SCTP_C_RECEIVE
@ SCTP_C_RECEIVE
Definition: SctpCommand_m.h:136
inet::SctpClient::socket
SctpSocket socket
Definition: SctpClient.h:48
inet::SctpSocket::stateName
static const char * stateName(int state)
Returns name of socket state code returned by state().
Definition: SctpSocket.cc:99
inet::SctpSocket::close
void close(int id)
Closes the local end of the connection.
Definition: SctpSocket.cc:394
inet::SctpClient::handleTimer
void handleTimer(cMessage *msg)
Definition: SctpClient.cc:391
inet::SCTP_C_SEND_ORDERED
@ SCTP_C_SEND_ORDERED
Definition: SctpCommand_m.h:137
inet::SctpSocket::setOutboundStreams
void setOutboundStreams(int streams)
Setter and getter methods for socket and API Parameters.
Definition: SctpSocket.h:179
inet::packetReceivedSignal
simsignal_t packetReceivedSignal
Definition: Simsignals.cc:97
inet::SCTP_C_NO_OUTSTANDING
@ SCTP_C_NO_OUTSTANDING
Definition: SctpCommand_m.h:143
inet::SctpClient::chunksAbandoned
int chunksAbandoned
Definition: SctpClient.h:68
inet::SctpClient::bytesSent
unsigned long int bytesSent
Definition: SctpClient.h:61
inet::SctpClient::numSessions
int numSessions
Definition: SctpClient.h:66
inet::SctpClient::timer
bool timer
Definition: SctpClient.h:54
inet::SctpClient::stopTimer
cMessage * stopTimer
Definition: SctpClient.h:51
type
removed type
Definition: IUdp-gates.txt:7
inet::SCTP_C_QUEUE_MSGS_LIMIT
@ SCTP_C_QUEUE_MSGS_LIMIT
Definition: SctpCommand_m.h:141
inet::SctpClient::connect
void connect()
Definition: SctpClient.cc:141
inet::SctpSocket::bindx
void bindx(AddressVector localAddr, int localPort)
Definition: SctpSocket.cc:171
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::SctpClient::primaryChangeTimer
cMessage * primaryChangeTimer
Definition: SctpClient.h:52
inet::SctpClient::bytesRcvd
unsigned long int bytesRcvd
Definition: SctpClient.h:63
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::SctpSocket::getRemoteAddr
L3Address getRemoteAddr() const
Definition: SctpSocket.h:164
inet::SctpClient::setPrimaryPath
void setPrimaryPath(const char *addr)
Definition: SctpClient.cc:534
inet::SctpClient::finishEndsSimulation
bool finishEndsSimulation
Definition: SctpClient.h:45
inet::SctpClient::bufferSize
int64_t bufferSize
Definition: SctpClient.h:53
inet::SctpSocket::connect
void connect(L3Address remoteAddress, int32_t remotePort, bool streamReset=false, int32_t prMethod=0, uint32_t numRequests=0)
Active OPEN to the given remote socket.
Definition: SctpSocket.cc:241
MSGKIND_STOP
#define MSGKIND_STOP
Definition: SctpClient.cc:28
inet::INITSTAGE_APPLICATION_LAYER
INET_API InitStage INITSTAGE_APPLICATION_LAYER
Initialization of applications.
inet::SctpClient::close
void close()
Definition: SctpClient.cc:184
inet::SctpClient::numRequestsToSend
unsigned long int numRequestsToSend
Definition: SctpClient.h:64
inet::NodeStatus::UP
@ UP
Definition: NodeStatus.h:28
inet::units::units::ps
pico< s >::type ps
Definition: Units.h:1073
inet::SctpClient::numBroken
int numBroken
Definition: SctpClient.h:67
inet::SctpClient::sendAllowed
bool sendAllowed
Definition: SctpClient.h:55
inet::SctpClient::inStreams
unsigned int inStreams
Definition: SctpClient.h:42
inet::SctpClient::sendStreamResetNotification
void sendStreamResetNotification()
Definition: SctpClient.cc:556
inet::SctpClient::streamRequestLengthMap
std::map< unsigned int, unsigned int > streamRequestLengthMap
Definition: SctpClient.h:37
inet::SctpClient::packetsRcvd
unsigned long int packetsRcvd
Definition: SctpClient.h:60
MSGKIND_PRIMARY
#define MSGKIND_PRIMARY
Definition: SctpClient.cc:26
MSGKIND_ABORT
#define MSGKIND_ABORT
Definition: SctpClient.cc:25
inet::SctpSocket::bind
void bind(int localPort)
Bind the socket to a local port number.
Definition: SctpSocket.cc:142
inet::SctpSocket::PEER_CLOSED
@ PEER_CLOSED
Definition: SctpSocket.h:80
inet::SctpSocket::setInboundStreams
void setInboundStreams(int streams)
Definition: SctpSocket.h:180
inet::SctpClient::numPacketsToReceive
unsigned long int numPacketsToReceive
Definition: SctpClient.h:65
inet::SctpClient::ordered
bool ordered
Definition: SctpClient.h:44
inet::SctpClient::streamRequestRatioMap
std::map< unsigned int, unsigned int > streamRequestRatioMap
Definition: SctpClient.h:38
inet::SctpClient::packetsSent
unsigned long int packetsSent
Definition: SctpClient.h:59