|
INET Framework for OMNeT++/OMNEST
|
Implements the SctpClient simple module.
More...
#include <SctpClient.h>
Implements the SctpClient simple module.
See the NED file for more info.
◆ SctpPathStatus
◆ SctpClient()
| inet::SctpClient::SctpClient |
( |
| ) |
|
◆ ~SctpClient()
| inet::SctpClient::~SctpClient |
( |
| ) |
|
|
virtual |
◆ close()
| void inet::SctpClient::close |
( |
| ) |
|
|
protected |
◆ connect()
| void inet::SctpClient::connect |
( |
| ) |
|
|
protected |
143 const char *connectAddress = par(
"connectAddress");
144 int connectPort = par(
"connectPort");
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;
156 socket.
connect(destination, connectPort, streamReset, par(
"prMethod"), (
unsigned int)par(
"numRequestsPerSession"));
161 EV_INFO <<
"StreamReset Timer scheduled at " << simTime() + par(
"streamRequestTime") <<
"\n";
162 scheduleAfter(par(
"streamRequestTime"), cmsg);
165 for (
unsigned int i = 0; i <
outStreams; i++) {
171 unsigned int streamNum = 0;
172 cStringTokenizer ratioTokenizer(par(
"streamRequestRatio"));
173 while (ratioTokenizer.hasMoreTokens()) {
174 const char *token = ratioTokenizer.nextToken();
Referenced by handleTimer().
◆ finish()
| void inet::SctpClient::finish |
( |
| ) |
|
|
overrideprotectedvirtual |
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";
◆ handleMessage()
| void inet::SctpClient::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
133 if (msg->isSelfMessage()) {
◆ handleTimer()
| void inet::SctpClient::handleTimer |
( |
cMessage * |
msg | ) |
|
|
protected |
393 switch (msg->getKind()) {
395 EV_DEBUG <<
"starting session call connect\n";
406 if (par(
"thinkTime").doubleValue() > 0)
407 scheduleAfter(par(
"thinkTime"),
timeMsg);
458 throw cRuntimeError(
"unknown selfmessage kind = %d ", msg->getKind());
Referenced by handleMessage().
◆ initialize()
| void inet::SctpClient::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
69 cSimpleModule::initialize(stage);
71 EV_DEBUG <<
"initialize SCTP Client stage " << stage << endl;
78 recordScalar(
"ums", par(
"requestLength").intValue());
81 scheduleAt(par(
"startTime"),
timeMsg);
95 NodeStatus *nodeStatus = node ? check_and_cast_nullable<NodeStatus *>(node->getSubmodule(
"status")) : nullptr;
96 bool isOperational = (!nodeStatus) || nodeStatus->getState() ==
NodeStatus::UP;
98 throw cRuntimeError(
"This module doesn't support starting in node DOWN state");
101 const char *addressesString = par(
"localAddress");
102 AddressVector addresses = L3AddressResolver().resolve(cStringTokenizer(addressesString).asVector());
103 int port = par(
"localPort");
107 if (addresses.size() == 0) {
108 EV_INFO <<
"Call socket bind\n";
110 EV_INFO <<
"Nach socket bind\n";
116 simtime_t stopTime = par(
"stopTime");
117 if (stopTime >= SIMTIME_ZERO) {
123 simtime_t primaryTime = par(
"primaryTime");
124 if (primaryTime != SIMTIME_ZERO) {
◆ msgAbandonedArrived()
| void inet::SctpClient::msgAbandonedArrived |
( |
SctpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ numInitStages()
| virtual int inet::SctpClient::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ refreshDisplay()
| void inet::SctpClient::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
◆ sendqueueAbatedArrived()
| void inet::SctpClient::sendqueueAbatedArrived |
( |
SctpSocket * |
socket, |
|
|
unsigned long int |
buffer |
|
) |
| |
|
overrideprotectedvirtual |
◆ sendQueueRequest()
| void inet::SctpClient::sendQueueRequest |
( |
| ) |
|
|
protected |
◆ sendRequest()
| void inet::SctpClient::sendRequest |
( |
bool |
last = true | ) |
|
|
protected |
345 unsigned int nextStream = 0;
346 for (
unsigned int i = 0; i <
outStreams; i++) {
353 for (
unsigned int i = 0; i <
outStreams; i++) {
361 throw cRuntimeError(
"Invalid setting of streamRequestRatio: only 0 weightings");
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++)
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);
Referenced by handleTimer(), sendqueueAbatedArrived(), sendRequestArrived(), and socketEstablished().
◆ sendRequestArrived()
| void inet::SctpClient::sendRequestArrived |
( |
SctpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ sendStreamResetNotification()
| void inet::SctpClient::sendStreamResetNotification |
( |
| ) |
|
|
protected |
558 unsigned short int type = par(
"streamResetType");
561 auto rinfo = cmsg->addTag<SctpResetReq>();
564 rinfo->setRequestType(
type);
565 rinfo->setStreamsArraySize(1);
566 rinfo->setStreams(0, par(
"streamToReset"));
Referenced by handleTimer().
◆ setPrimaryPath()
| void inet::SctpClient::setPrimaryPath |
( |
const char * |
addr | ) |
|
|
protected |
537 auto pinfo = cmsg->addTag<SctpPathInfoReq>();
539 if (strcmp(str,
"") != 0) {
540 pinfo->setRemoteAddress(L3Address(str));
543 str = par(
"newPrimary");
544 if (strcmp(str,
"") != 0)
545 pinfo->setRemoteAddress(L3Address(str));
547 str = par(
"connectAddress");
548 pinfo->setRemoteAddress(L3Address(str));
Referenced by handleTimer().
◆ shutdownReceivedArrived()
| void inet::SctpClient::shutdownReceivedArrived |
( |
SctpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketAvailable()
|
|
inlineoverrideprotectedvirtual |
◆ socketClosed()
| void inet::SctpClient::socketClosed |
( |
SctpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketDataArrived()
| void inet::SctpClient::socketDataArrived |
( |
SctpSocket * |
socket, |
|
|
Packet * |
msg, |
|
|
bool |
urgent |
|
) |
| |
|
overrideprotectedvirtual |
Implements inet::SctpSocket::ICallback.
314 EV_INFO <<
"Client received packet Nr " <<
packetsRcvd <<
" from SCTP\n";
315 auto ind = msg->getTag<SctpRcvReq>();
320 const auto& smsg = msg->peekData();
321 auto cmsg =
new Packet(
"ApplicationPacket");
322 cmsg->insertAtBack(smsg);
323 auto cmd = cmsg->addTag<SctpSendReq>();
325 cmd->setSocketId(ind->getSocketId());
327 cmd->setSid(ind->getSid());
333 if (par(
"numPacketsToReceive").intValue() > 0) {
◆ socketDataNotificationArrived()
| void inet::SctpClient::socketDataNotificationArrived |
( |
SctpSocket * |
socket, |
|
|
Message * |
msg |
|
) |
| |
|
overrideprotectedvirtual |
Implements inet::SctpSocket::ICallback.
465 Message *message = check_and_cast<Message *>(msg);
466 auto& ind = message->findTag<SctpCommandReq>();
468 auto cmd = cmesg->addTag<SctpSendReq>();
469 cmd->setSocketId(ind->getSocketId());
470 cmd->setSid(ind->getSid());
471 cmd->setNumMsgs(ind->getNumMsgs());
◆ socketEstablished()
| void inet::SctpClient::socketEstablished |
( |
SctpSocket * |
socket, |
|
|
unsigned long int |
buffer |
|
) |
| |
|
overrideprotectedvirtual |
Reimplemented from inet::SctpSocket::ICallback.
197 EV_INFO <<
"SctpClient: connected\n";
217 if (par(
"thinkTime").doubleValue() > 0) {
226 scheduleAfter(par(
"thinkTime"),
timeMsg);
259 scheduleAfter(par(
"waitToClose"),
timeMsg);
263 EV_INFO <<
"socketEstablished:no more packets to send, call shutdown\n";
◆ socketFailure()
| void inet::SctpClient::socketFailure |
( |
SctpSocket * |
socket, |
|
|
int |
code |
|
) |
| |
|
overrideprotectedvirtual |
◆ socketPeerClosed()
| void inet::SctpClient::socketPeerClosed |
( |
SctpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketStatusArrived()
Reimplemented from inet::SctpSocket::ICallback.
519 struct PathStatus
ps;
524 ps.active = status->getActive();
527 ps.active = status->getActive();
528 ps.pid = status->getPathId();
529 ps.primaryPath =
false;
◆ 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 |
◆ echo
| bool inet::SctpClient::echo |
|
protected |
◆ echoedBytesSent
| unsigned long int inet::SctpClient::echoedBytesSent |
|
protected |
◆ echoedPkSignal
| simsignal_t inet::SctpClient::echoedPkSignal = registerSignal("echoedPk") |
|
staticprotected |
◆ finishEndsSimulation
| bool inet::SctpClient::finishEndsSimulation |
|
protected |
◆ inStreams
| unsigned int inet::SctpClient::inStreams |
|
protected |
◆ 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 |
◆ outStreams
| unsigned int inet::SctpClient::outStreams |
|
protected |
◆ 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
◆ sendAllowed
| bool inet::SctpClient::sendAllowed |
|
protected |
◆ socket
Referenced by close(), connect(), handleMessage(), handleTimer(), initialize(), refreshDisplay(), sendqueueAbatedArrived(), sendQueueRequest(), sendRequest(), sendRequestArrived(), sendStreamResetNotification(), setPrimaryPath(), shutdownReceivedArrived(), socketDataArrived(), socketDataNotificationArrived(), socketEstablished(), and socketPeerClosed().
◆ stateNameStr
| const char* inet::SctpClient::stateNameStr |
|
protected |
◆ stopTimer
| cMessage* inet::SctpClient::stopTimer |
|
protected |
◆ streamRequestLengthMap
| std::map<unsigned int, unsigned int> inet::SctpClient::streamRequestLengthMap |
|
protected |
◆ streamRequestRatioMap
| std::map<unsigned int, unsigned int> inet::SctpClient::streamRequestRatioMap |
|
protected |
◆ streamRequestRatioSendMap
| std::map<unsigned int, unsigned int> inet::SctpClient::streamRequestRatioSendMap |
|
protected |
◆ timeMsg
| cMessage* inet::SctpClient::timeMsg |
|
protected |
◆ timer
| bool inet::SctpClient::timer |
|
protected |
The documentation for this class was generated from the following files:
@ SCTP_C_STREAM_RESET
Definition: SctpCommand_m.h:144
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:31
void processMessage(cMessage *msg) override
Examines the message (which should have arrived from SctpMain), updates socket state,...
Definition: SctpSocket.cc:461
@ SCTP_C_SEND_UNORDERED
Definition: SctpCommand_m.h:138
unsigned long int echoedBytesSent
Definition: SctpClient.h:62
std::vector< L3Address > AddressVector
Definition: SctpCommand_m.h:70
cMessage * timeMsg
Definition: SctpClient.h:50
void setOutputGate(cGate *toSctp)
Sets the gate on which to send to SCTP.
Definition: SctpSocket.h:174
#define MSGKIND_SEND
Definition: SctpClient.cc:24
int queueSize
Definition: SctpClient.h:40
int getSocketId() const override
Returns the internal connection Id.
Definition: SctpSocket.h:138
unsigned int outStreams
Definition: SctpClient.h:41
@ SCTP_C_PRIMARY
Definition: SctpCommand_m.h:139
#define MSGKIND_CONNECT
Definition: SctpClient.cc:23
int count(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:54
void abort()
Aborts the association.
Definition: SctpSocket.cc:431
virtual void send(Packet *packet) override
Send data message.
Definition: SctpSocket.cc:355
void shutdown(int id=-1)
Definition: SctpSocket.cc:408
SctpPathStatus sctpPathStatus
Definition: SctpClient.h:49
void sendRequest(cMessage *msg)
Send request.
Definition: SctpSocket.cc:389
int getState() const
Returns the socket state, one of NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED,...
Definition: SctpSocket.h:151
void setCallback(ICallback *cb)
Sets a callback object, to be used with processMessage().
Definition: SctpSocket.cc:456
void sendQueueRequest()
Definition: SctpClient.cc:276
#define MSGKIND_RESET
Definition: SctpClient.cc:27
simsignal_t packetSentSignal
Definition: Simsignals.cc:96
void sendNotification(cMessage *msg)
Send notification.
Definition: SctpSocket.cc:377
void sendRequest(bool last=true)
Definition: SctpClient.cc:342
std::map< unsigned int, unsigned int > streamRequestRatioSendMap
Definition: SctpClient.h:39
bool echo
Definition: SctpClient.h:43
@ SCTP_C_RECEIVE
Definition: SctpCommand_m.h:136
SctpSocket socket
Definition: SctpClient.h:48
static const char * stateName(int state)
Returns name of socket state code returned by state().
Definition: SctpSocket.cc:99
void close(int id)
Closes the local end of the connection.
Definition: SctpSocket.cc:394
void handleTimer(cMessage *msg)
Definition: SctpClient.cc:391
@ SCTP_C_SEND_ORDERED
Definition: SctpCommand_m.h:137
void setOutboundStreams(int streams)
Setter and getter methods for socket and API Parameters.
Definition: SctpSocket.h:179
simsignal_t packetReceivedSignal
Definition: Simsignals.cc:97
@ SCTP_C_NO_OUTSTANDING
Definition: SctpCommand_m.h:143
int chunksAbandoned
Definition: SctpClient.h:68
unsigned long int bytesSent
Definition: SctpClient.h:61
int numSessions
Definition: SctpClient.h:66
bool timer
Definition: SctpClient.h:54
cMessage * stopTimer
Definition: SctpClient.h:51
removed type
Definition: IUdp-gates.txt:7
@ SCTP_C_QUEUE_MSGS_LIMIT
Definition: SctpCommand_m.h:141
void connect()
Definition: SctpClient.cc:141
void bindx(AddressVector localAddr, int localPort)
Definition: SctpSocket.cc:171
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
cMessage * primaryChangeTimer
Definition: SctpClient.h:52
unsigned long int bytesRcvd
Definition: SctpClient.h:63
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
L3Address getRemoteAddr() const
Definition: SctpSocket.h:164
void setPrimaryPath(const char *addr)
Definition: SctpClient.cc:534
bool finishEndsSimulation
Definition: SctpClient.h:45
int64_t bufferSize
Definition: SctpClient.h:53
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
#define MSGKIND_STOP
Definition: SctpClient.cc:28
INET_API InitStage INITSTAGE_APPLICATION_LAYER
Initialization of applications.
void close()
Definition: SctpClient.cc:184
unsigned long int numRequestsToSend
Definition: SctpClient.h:64
@ UP
Definition: NodeStatus.h:28
pico< s >::type ps
Definition: Units.h:1073
int numBroken
Definition: SctpClient.h:67
bool sendAllowed
Definition: SctpClient.h:55
unsigned int inStreams
Definition: SctpClient.h:42
void sendStreamResetNotification()
Definition: SctpClient.cc:556
std::map< unsigned int, unsigned int > streamRequestLengthMap
Definition: SctpClient.h:37
unsigned long int packetsRcvd
Definition: SctpClient.h:60
#define MSGKIND_PRIMARY
Definition: SctpClient.cc:26
#define MSGKIND_ABORT
Definition: SctpClient.cc:25
void bind(int localPort)
Bind the socket to a local port number.
Definition: SctpSocket.cc:142
@ PEER_CLOSED
Definition: SctpSocket.h:80
void setInboundStreams(int streams)
Definition: SctpSocket.h:180
unsigned long int numPacketsToReceive
Definition: SctpClient.h:65
bool ordered
Definition: SctpClient.h:44
std::map< unsigned int, unsigned int > streamRequestRatioMap
Definition: SctpClient.h:38
unsigned long int packetsSent
Definition: SctpClient.h:59