INET Framework for OMNeT++/OMNEST
|
#include <SCTPSocket.h>
Classes | |
class | CallbackInterface |
Abstract base class for your callback objects. More... | |
Public Types | |
enum | State { NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED, PEER_CLOSED, LOCALLY_CLOSED, SOCKERROR } |
Public Member Functions | |
SCTPSocket (bool type=true) | |
Constructor. More... | |
SCTPSocket (cMessage *msg) | |
Constructor, to be used with forked sockets (see listen()). More... | |
~SCTPSocket () | |
Destructor. More... | |
int | getConnectionId () const |
Returns the internal connection Id. More... | |
int | getState () |
Returns the socket state, one of NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED, etc. More... | |
void | setState (int state) |
Getter functions | |
AddressVector | getLocalAddresses () |
int | getLocalPort () |
AddressVector | getRemoteAddresses () |
int | getRemotePort () |
L3Address | getRemoteAddr () |
Opening and closing connections, sending data | |
void | setOutputGate (cGate *toSctp) |
Sets the gate on which to send to SCTP. More... | |
void | setOutboundStreams (int streams) |
Setter and getter methods for socket and API Parameters. More... | |
void | setInboundStreams (int streams) |
void | setAppLimited (bool option) |
void | setStreamReset (int option) |
void | setStreamPriority (uint32 stream, uint32 priority) |
void | setMaxInitRetrans (int option) |
void | setMaxInitRetransTimeout (int option) |
void | setRtoInitial (double option) |
void | setRtoMin (double option) |
void | setRtoMax (double option) |
void | setSackFrequency (int option) |
void | setSackPeriod (double option) |
void | setMaxBurst (int option) |
void | setFragPoint (int option) |
void | setNagle (int option) |
void | setPathMaxRetrans (int option) |
void | setEnableHeartbeats (bool option) |
void | setHbInterval (double option) |
void | setRtoInfo (double initial, double max, double min) |
void | setAssocMaxRtx (int option) |
void | setUserOptions (void *msg) |
int | getOutboundStreams () |
int | getInboundStreams () |
bool | getStreamReset () |
int | getLastStream () |
double | getRtoInitial () |
int | getMaxInitRetransTimeout () |
int | getMaxInitRetrans () |
int | getMaxBurst () |
int | getFragPoint () |
int | getAssocMaxRtx () |
void | getSocketOptions () |
void | bind (int localPort) |
Bind the socket to a local port number. More... | |
void | bind (L3Address localAddr, int localPort) |
Bind the socket to a local port number and IP address (useful with multi-homing). More... | |
void | bindx (AddressVector localAddr, int localPort) |
void | addAddress (L3Address addr) |
void | listen (bool fork=true, bool streamReset=false, uint32 requests=0, uint32 messagesToPush=0) |
Initiates passive OPEN. More... | |
void | listen (uint32 requests=0, bool fork=false, uint32 messagesToPush=0, bool options=false, int32 fd=-1) |
void | connect (L3Address remoteAddress, int32 remotePort, bool streamReset=false, int32 prMethod=0, uint32 numRequests=0) |
Active OPEN to the given remote socket. More... | |
void | connect (int32 fd, L3Address remoteAddress, int32 remotePort, uint32 numRequests, bool options=false) |
void | connectx (AddressVector remoteAddresses, int32 remotePort, bool streamReset=false, int32 prMethod=0, uint32 numRequests=0) |
Active OPEN to the given remote socket. More... | |
void | accept (int32 assocId, int32 fd) |
void | send (SCTPSimpleMessage *msg, int prMethod=0, double prValue=0.0, int32 streamId=0, bool last=true, bool primary=true) |
Send data message. More... | |
void | sendMsg (cMessage *cmsg) |
Send data message (provided within control message). More... | |
void | sendNotification (cMessage *msg) |
Send notification. More... | |
void | sendRequest (cMessage *msg) |
Send request. More... | |
void | close (int id=-1) |
Closes the local end of the connection. More... | |
void | abort () |
Aborts the association. More... | |
void | shutdown (int id=-1) |
void | requestStatus () |
Causes SCTP to reply with a fresh SCTPStatusInfo, attached to a dummy message as controlInfo(). More... | |
Static Public Member Functions | |
static int32 | getNewAssocId () |
Generates a new integer, to be used as assocId. More... | |
static const char * | stateName (int state) |
Returns name of socket state code returned by state(). More... | |
Public Attributes | |
cGate * | gateToSctp |
Protected Member Functions | |
void | sendToSCTP (cMessage *msg) |
Protected Attributes | |
int | assocId |
int | sockstate |
bool | oneToOne |
bool | appLimited |
L3Address | localAddr |
AddressVector | localAddresses |
int | localPrt |
L3Address | remoteAddr |
AddressVector | remoteAddresses |
int | remotePrt |
int | fsmStatus |
int | lastStream |
SocketOptions * | sOptions |
AppSocketOptions * | appOptions |
CallbackInterface * | cb |
void * | yourPtr |
Static Protected Attributes | |
static int32 | nextAssocId = 0 |
Handling of messages arriving from SCTP | |
bool | belongsToSocket (cMessage *msg) |
Returns true if the message belongs to this socket instance (message has a SCTPCommand as controlInfo(), and the assocId in it matches that of the socket.) More... | |
void | setCallbackObject (CallbackInterface *cb, void *yourPtr=nullptr) |
Sets a callback object, to be used with processMessage(). More... | |
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. More... | |
static bool | belongsToAnySCTPSocket (cMessage *msg) |
Returns true if the message belongs to any SCTPSocket instance. More... | |
Enumerator | |
---|---|
NOT_BOUND | |
CLOSED | |
LISTENING | |
CONNECTING | |
CONNECTED | |
PEER_CLOSED | |
LOCALLY_CLOSED | |
SOCKERROR |
inet::SCTPSocket::SCTPSocket | ( | bool | type = true | ) |
Constructor.
The connectionId() method returns a valid Id right after constructor call.
inet::SCTPSocket::SCTPSocket | ( | cMessage * | msg | ) |
Constructor, to be used with forked sockets (see listen()).
The assocId will be picked up from the message: it should have arrived from SCTPMain and contain SCTPCommmand control info.
inet::SCTPSocket::~SCTPSocket | ( | ) |
Destructor.
void inet::SCTPSocket::abort | ( | ) |
Aborts the association.
Referenced by inet::SCTPClient::handleTimer(), and inet::NetPerfMeter::successfullyEstablishedConnection().
void inet::SCTPSocket::addAddress | ( | L3Address | addr | ) |
|
static |
Returns true if the message belongs to any SCTPSocket instance.
(This basically checks if the message has a SCTPCommand attached to it as controlInfo().)
bool inet::SCTPSocket::belongsToSocket | ( | cMessage * | msg | ) |
Returns true if the message belongs to this socket instance (message has a SCTPCommand as controlInfo(), and the assocId in it matches that of the socket.)
void inet::SCTPSocket::bind | ( | int | localPort | ) |
Bind the socket to a local port number.
Referenced by connect(), inet::NetPerfMeter::createAndBindSocket(), inet::SCTPServer::initialize(), inet::SCTPClient::initialize(), and inet::SCTPPeer::initialize().
void inet::SCTPSocket::bind | ( | L3Address | localAddr, |
int | localPort | ||
) |
Bind the socket to a local port number and IP address (useful with multi-homing).
void inet::SCTPSocket::bindx | ( | AddressVector | localAddr, |
int | localPort | ||
) |
Referenced by inet::SCTPServer::initialize(), inet::SCTPClient::initialize(), and inet::SCTPPeer::initialize().
void inet::SCTPSocket::close | ( | int | id = -1 | ) |
Closes the local end of the connection.
With SCTP, a CLOSE operation means "I have no more data to send", and thus results in a one-way connection until the remote SCTP closes too (or the FIN_WAIT_1 timeout expires)
Referenced by inet::SCTPClient::close(), inet::NetPerfMeter::handleTimer(), inet::SCTPPeer::socketDataArrived(), inet::SCTPPeer::socketPeerClosed(), and inet::NetPerfMeter::teardownConnection().
void inet::SCTPSocket::connect | ( | L3Address | remoteAddress, |
int32 | remotePort, | ||
bool | streamReset = false , |
||
int32 | prMethod = 0 , |
||
uint32 | numRequests = 0 |
||
) |
Active OPEN to the given remote socket.
Referenced by inet::SCTPClient::connect(), inet::SCTPPeer::connect(), and connectx().
void inet::SCTPSocket::connect | ( | int32 | fd, |
L3Address | remoteAddress, | ||
int32 | remotePort, | ||
uint32 | numRequests, | ||
bool | options = false |
||
) |
void inet::SCTPSocket::connectx | ( | AddressVector | remoteAddresses, |
int32 | remotePort, | ||
bool | streamReset = false , |
||
int32 | prMethod = 0 , |
||
uint32 | numRequests = 0 |
||
) |
Active OPEN to the given remote socket.
The current implementation just calls connect() with the first address of the given list. This behaviour may be improved in the future.
Referenced by inet::NetPerfMeter::establishConnection().
|
inline |
|
inline |
Returns the internal connection Id.
SCTP uses the (gate index, assocId) pair to identify the connection when it receives a command from the application (or SCTPSocket).
Referenced by inet::SCTPSocketMap::addSocket(), inet::SCTPPeer::connect(), inet::SCTPSocketMap::removeSocket(), inet::SCTPClient::sendQueueRequest(), inet::SCTPPeer::sendQueueRequest(), inet::SCTPClient::sendStreamResetNotification(), and inet::SCTPClient::setPrimaryPath().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Generates a new integer, to be used as assocId.
(assocId is part of the key which associates connections with their apps).
Referenced by inet::sctp::SCTP::addForkedAssociation(), connect(), listen(), and SCTPSocket().
|
inline |
|
inline |
Referenced by inet::SCTPClient::sendStreamResetNotification().
|
inline |
|
inline |
|
inline |
void inet::SCTPSocket::getSocketOptions | ( | ) |
|
inline |
Returns the socket state, one of NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED, etc.
Messages received from SCTP must be routed through processMessage() in order to keep socket state up-to-date.
Referenced by inet::SCTPPeer::handleMessage(), inet::SCTPClient::socketPeerClosed(), and inet::SCTPPeer::socketPeerClosed().
|
inline |
void inet::SCTPSocket::listen | ( | bool | fork = true , |
bool | streamReset = false , |
||
uint32 | requests = 0 , |
||
uint32 | messagesToPush = 0 |
||
) |
Initiates passive OPEN.
If fork=true, you'll have to create a new SCTPSocket object for each incoming connection, and this socket will keep listening on the port. If fork=false, the first incoming connection will be accepted, and SCTP will refuse subsequent ones. See SCTPOpenCommand documentation (neddoc) for more info.
Referenced by inet::NetPerfMeter::createAndBindSocket(), inet::SCTPServer::initialize(), and inet::SCTPPeer::initialize().
void inet::SCTPSocket::listen | ( | uint32 | requests = 0 , |
bool | fork = false , |
||
uint32 | messagesToPush = 0 , |
||
bool | options = false , |
||
int32 | fd = -1 |
||
) |
void inet::SCTPSocket::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.
The method deletes the message, unless (1) there is a callback object installed AND (2) the message is payload (message kind SCTP_I_DATA or SCTP_I_URGENT_DATA) when the responsibility of destruction is on the socketDataArrived() callback method.
IMPORTANT: for performance reasons, this method doesn't check that the message belongs to this socket, i.e. belongsToSocket(msg) would return true!
Referenced by inet::SCTPClient::handleMessage(), and inet::SCTPPeer::handleMessage().
void inet::SCTPSocket::requestStatus | ( | ) |
Causes SCTP to reply with a fresh SCTPStatusInfo, attached to a dummy message as controlInfo().
The reply message can be recognized by its message kind SCTP_I_STATUS, or (if a callback object is used) the socketStatusArrived() method of the callback object will be called.
void inet::SCTPSocket::send | ( | SCTPSimpleMessage * | msg, |
int | prMethod = 0 , |
||
double | prValue = 0.0 , |
||
int32 | streamId = 0 , |
||
bool | last = true , |
||
bool | primary = true |
||
) |
Send data message.
Referenced by sendToSCTP().
void inet::SCTPSocket::sendMsg | ( | cMessage * | cmsg | ) |
Send data message (provided within control message).
Referenced by inet::SCTPPeer::sendRequest(), inet::SCTPClient::sendRequest(), inet::SCTPClient::socketDataArrived(), and inet::SCTPPeer::socketDataArrived().
void inet::SCTPSocket::sendNotification | ( | cMessage * | msg | ) |
Send notification.
Referenced by inet::SCTPClient::sendStreamResetNotification(), inet::SCTPClient::setPrimaryPath(), inet::SCTPClient::shutdownReceivedArrived(), inet::SCTPPeer::shutdownReceivedArrived(), inet::SCTPClient::socketDataNotificationArrived(), and inet::SCTPPeer::socketDataNotificationArrived().
void inet::SCTPSocket::sendRequest | ( | cMessage * | msg | ) |
Send request.
Referenced by inet::SCTPClient::sendQueueRequest(), inet::SCTPPeer::sendQueueRequest(), and inet::NetPerfMeter::sendSCTPQueueRequest().
|
protected |
Referenced by abort(), accept(), close(), connect(), getSocketOptions(), listen(), requestStatus(), send(), sendMsg(), sendNotification(), sendRequest(), setRtoInfo(), setStreamPriority(), and shutdown().
|
inline |
|
inline |
void inet::SCTPSocket::setCallbackObject | ( | CallbackInterface * | cb, |
void * | yourPtr = nullptr |
||
) |
Sets a callback object, to be used with processMessage().
This callback object may be your simple module itself (if it multiply inherits from CallbackInterface too, that is you declared it as
class MyAppModule : public cSimpleModule, public SCTPSocket::CallbackInterface
and redefined the necessary virtual functions; or you may use dedicated class (and objects) for this purpose.
SCTPSocket doesn't delete the callback object in the destructor or on any other occasion.
YourPtr is an optional pointer. It may contain any value you wish – SCTPSocket will not look at it or do anything with it except passing it back to you in the CallbackInterface calls. You may find it useful if you maintain additional per-connection information: in that case you don't have to look it up by assocId in the callbacks, you can have it passed to you as yourPtr.
Referenced by inet::SCTPClient::initialize(), and inet::SCTPPeer::initialize().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Setter and getter methods for socket and API Parameters.
Referenced by inet::SCTPClient::connect(), inet::SCTPPeer::connect(), inet::NetPerfMeter::createAndBindSocket(), inet::SCTPServer::initialize(), and inet::SCTPPeer::initialize().
|
inline |
Sets the gate on which to send to SCTP.
Must be invoked before socket can be used. Example: socket.setOutputGate(gate("sctpOut"));
Referenced by inet::NetPerfMeter::createAndBindSocket(), inet::SCTPServer::initialize(), inet::SCTPClient::initialize(), inet::SCTPPeer::initialize(), and inet::NetPerfMeter::successfullyEstablishedConnection().
|
inline |
void inet::SCTPSocket::setRtoInfo | ( | double | initial, |
double | max, | ||
double | min | ||
) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Referenced by inet::SCTPPeer::connect(), and inet::SCTPServer::initialize().
|
inline |
|
inline |
void inet::SCTPSocket::shutdown | ( | int | id = -1 | ) |
Referenced by inet::SCTPClient::handleTimer(), inet::SCTPClient::sendqueueAbatedArrived(), inet::SCTPClient::sendRequestArrived(), inet::SCTPPeer::sendRequestArrived(), inet::SCTPClient::socketEstablished(), and inet::SCTPPeer::socketEstablished().
|
static |
Returns name of socket state code returned by state().
Referenced by connect(), connectx(), and SCTPSocket().
|
protected |
Referenced by connect(), and SCTPSocket().
|
protected |
Referenced by connect(), listen(), processMessage(), SCTPSocket(), sendMsg(), and ~SCTPSocket().
|
protected |
Referenced by abort(), belongsToSocket(), close(), connect(), getSocketOptions(), listen(), processMessage(), requestStatus(), SCTPSocket(), send(), sendMsg(), setRtoInfo(), setStreamPriority(), shutdown(), and ~SCTPSocket().
|
protected |
Referenced by processMessage(), SCTPSocket(), setCallbackObject(), and ~SCTPSocket().
|
protected |
Referenced by processMessage(), and SCTPSocket().
cGate* inet::SCTPSocket::gateToSctp |
Referenced by SCTPSocket(), and sendToSCTP().
|
protected |
Referenced by SCTPSocket(), and sendMsg().
|
protected |
Referenced by processMessage(), and SCTPSocket().
|
protected |
Referenced by addAddress(), bind(), bindx(), connect(), and listen().
|
protected |
Referenced by accept(), bind(), bindx(), connect(), listen(), processMessage(), and SCTPSocket().
|
staticprotected |
|
protected |
Referenced by connect(), listen(), processMessage(), SCTPSocket(), send(), and sendNotification().
|
protected |
Referenced by accept(), connect(), processMessage(), and SCTPSocket().
|
protected |
Referenced by connectx().
|
protected |
Referenced by accept(), connect(), processMessage(), and SCTPSocket().
|
protected |
Referenced by abort(), bind(), bindx(), close(), connect(), connectx(), listen(), processMessage(), SCTPSocket(), send(), sendNotification(), and setRtoInfo().
|
protected |
Referenced by connect(), listen(), SCTPSocket(), setRtoInfo(), and ~SCTPSocket().
|
protected |
Referenced by processMessage(), SCTPSocket(), setCallbackObject(), and ~SCTPSocket().