INET Framework for OMNeT++/OMNEST
|
Implements the TCP protocol. More...
#include <TCP.h>
Classes | |
struct | AppConnKey |
struct | SockPair |
Public Member Functions | |
TCP () | |
virtual | ~TCP () |
virtual void | addSockPair (TCPConnection *conn, L3Address localAddr, L3Address remoteAddr, int localPort, int remotePort) |
To be called from TCPConnection when a new connection gets created, during processing of OPEN_ACTIVE or OPEN_PASSIVE. More... | |
virtual void | updateSockPair (TCPConnection *conn, L3Address localAddr, L3Address remoteAddr, int localPort, int remotePort) |
To be called from TCPConnection when socket pair (key for TcpConnMap) changes (e.g. More... | |
virtual void | addForkedConnection (TCPConnection *conn, TCPConnection *newConn, L3Address localAddr, L3Address remoteAddr, int localPort, int remotePort) |
Update conn's socket pair, and register newConn (which'll keep LISTENing). More... | |
virtual ushort | getEphemeralPort () |
To be called from TCPConnection: reserves an ephemeral port for the connection. More... | |
virtual TCPSendQueue * | createSendQueue (TCPDataTransferMode transferModeP) |
To be called from TCPConnection: create a new send queue. More... | |
virtual TCPReceiveQueue * | createReceiveQueue (TCPDataTransferMode transferModeP) |
To be called from TCPConnection: create a new receive queue. More... | |
virtual bool | handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override |
Perform one stage of a lifecycle operation. More... | |
virtual void | reset () |
Public Member Functions inherited from inet::ILifecycle | |
virtual | ~ILifecycle () |
Public Attributes | |
bool | recordStatistics = false |
bool | isOperational = false |
bool | useDataNotification = false |
Static Public Attributes | |
static simsignal_t | tcpConnectionAddedSignal = registerSignal("tcpConnectionAdded") |
static simsignal_t | tcpConnectionRemovedSignal = registerSignal("tcpConnectionRemoved") |
static bool | testing |
static bool | logverbose |
Protected Types | |
typedef std::map< AppConnKey, TCPConnection * > | TcpAppConnMap |
typedef std::map< SockPair, TCPConnection * > | TcpConnMap |
Protected Member Functions | |
virtual TCPConnection * | createConnection (int appGateIndex, int connId) |
Factory method; may be overriden for customizing TCP. More... | |
virtual TCPConnection * | findConnForSegment (TCPSegment *tcpseg, L3Address srcAddr, L3Address destAddr) |
virtual TCPConnection * | findConnForApp (int appGateIndex, int connId) |
virtual void | segmentArrivalWhileClosed (TCPSegment *tcpseg, L3Address src, L3Address dest) |
virtual void | removeConnection (TCPConnection *conn) |
virtual void | refreshDisplay () const override |
virtual void | initialize (int stage) override |
virtual int | numInitStages () const override |
virtual void | handleMessage (cMessage *msg) override |
virtual void | finish () override |
Protected Attributes | |
TcpAppConnMap | tcpAppConnMap |
TcpConnMap | tcpConnMap |
ushort | lastEphemeralPort = (ushort)-1 |
std::multiset< ushort > | usedEphemeralPorts |
Implements the TCP protocol.
This section describes the internal architecture of the TCP model.
Usage and compliance with various RFCs are discussed in the corresponding NED documentation for TCP. Also, you may want to check the TCPSocket class which makes it easier to use TCP from applications.
The TCP protocol implementation is composed of several classes (discussion follows below):
TCP subclassed from cSimpleModule. It manages socketpair-to-connection mapping, and dispatches segments and user commands to the appropriate TCPConnection object.
TCPConnection manages the connection, with the help of other objects. TCPConnection itself implements the basic TCP "machinery": takes care of the state machine, stores the state variables (TCB), sends/receives SYN, FIN, RST, ACKs, etc.
TCPConnection internally relies on 3 objects. The first two are subclassed from TCPSendQueue and TCPReceiveQueue. They manage the actual data stream, so TCPConnection itself only works with sequence number variables. This makes it possible to easily accomodate need for various types of simulated data transfer: real byte stream, "virtual" bytes (byte counts only), and sequence of cMessage objects (where every message object is mapped to a TCP sequence number range).
Currently implemented send queue and receive queue classes are TCPVirtualDataSendQueue and TCPVirtualDataRcvQueue which implement queues with "virtual" bytes (byte counts only).
The third object is subclassed from TCPAlgorithm. Control over retransmissions, congestion control and ACK sending are "outsourced" from TCPConnection into TCPAlgorithm: delayed acks, slow start, fast rexmit, etc. are all implemented in TCPAlgorithm subclasses. This simplifies the design of TCPConnection and makes it a lot easier to implement new TCP variations such as NewReno, Vegas or LinuxTCP as TCPAlgorithm subclasses.
Currently implemented TCPAlgorithm classes are TCPReno, TCPTahoe, TCPNewReno, TCPNoCongestionControl and DumbTCP.
The concrete TCPAlgorithm class to use can be chosen per connection (in OPEN) or in a module parameter.
|
protected |
|
protected |
|
virtual |
|
virtual |
Update conn's socket pair, and register newConn (which'll keep LISTENing).
Also, conn will get a new connId (and newConn will live on with its old connId).
Referenced by inet::tcp::TCPConnection::processSegmentInListen().
|
virtual |
To be called from TCPConnection when a new connection gets created, during processing of OPEN_ACTIVE or OPEN_PASSIVE.
Referenced by addForkedConnection(), inet::tcp::TCPConnection::process_OPEN_ACTIVE(), and inet::tcp::TCPConnection::process_OPEN_PASSIVE().
|
protectedvirtual |
Factory method; may be overriden for customizing TCP.
Referenced by handleMessage().
|
virtual |
To be called from TCPConnection: create a new receive queue.
Referenced by inet::tcp::TCPConnection::initConnection().
|
virtual |
To be called from TCPConnection: create a new send queue.
Referenced by inet::tcp::TCPConnection::initConnection().
|
protectedvirtual |
Referenced by handleMessage().
|
protectedvirtual |
Referenced by handleMessage().
|
overrideprotectedvirtual |
|
virtual |
To be called from TCPConnection: reserves an ephemeral port for the connection.
Referenced by inet::tcp::TCPConnection::process_OPEN_ACTIVE().
|
overrideprotectedvirtual |
|
overridevirtual |
Perform one stage of a lifecycle operation.
Processing may be done entirely within this method, or may be a longer process that involves nonzero simulation time or several events, and is triggered by this method call.
Return value: true = "done"; false = "not yet done, will invoke doneCallback when done"
Implements inet::ILifecycle.
|
overrideprotectedvirtual |
|
inlineoverrideprotectedvirtual |
|
overrideprotectedvirtual |
|
protectedvirtual |
Referenced by handleMessage().
|
virtual |
Referenced by handleOperationStage().
|
protectedvirtual |
Referenced by handleMessage().
|
virtual |
To be called from TCPConnection when socket pair (key for TcpConnMap) changes (e.g.
becomes fully qualified).
Referenced by addForkedConnection(), inet::tcp::TCPConnection::processSegmentInListen(), and inet::tcp::TCPConnection::processSegmentInSynSent().
bool inet::tcp::TCP::isOperational = false |
Referenced by handleMessage(), handleOperationStage(), initialize(), and refreshDisplay().
Referenced by getEphemeralPort(), initialize(), and reset().
|
static |
bool inet::tcp::TCP::recordStatistics = false |
Referenced by initialize(), and inet::tcp::TCPBaseAlg::initialize().
|
protected |
Referenced by addForkedConnection(), findConnForApp(), handleMessage(), initialize(), refreshDisplay(), removeConnection(), reset(), and ~TCP().
|
static |
|
static |
Referenced by removeConnection().
|
protected |
Referenced by addSockPair(), findConnForSegment(), finish(), initialize(), removeConnection(), reset(), and updateSockPair().
|
static |
bool inet::tcp::TCP::useDataNotification = false |
Referenced by initialize(), and inet::tcp::TCPConnection::processSegment1stThru8th().
|
protected |
Referenced by addSockPair(), getEphemeralPort(), removeConnection(), and reset().