OverSim
SimpleTCP Class Reference

#include <SimpleTCP.h>

Public Member Functions

 SimpleTCP ()
virtual ~SimpleTCP ()
void setNodeEntry (SimpleNodeEntry *entry)

Public Attributes

StatisticsAndDelay sad

Protected Member Functions

void segmentArrivalWhileClosed (TCPSegment *tcpseg, IPvXAddress srcAddr, IPvXAddress destAddr)
SimpleTCPConnectioncreateConnection (int appGateIndex, int connId)
virtual void initialize (int stage)
virtual void handleMessage (cMessage *msg)
virtual int numInitStages () const
void finish ()

Detailed Description

Definition at line 98 of file SimpleTCP.h.

Constructor & Destructor Documentation

SimpleTCP::SimpleTCP ( )
inline

Definition at line 101 of file SimpleTCP.h.

{ sad.globalStatistics = NULL; };
virtual SimpleTCP::~SimpleTCP ( )
inlinevirtual

Definition at line 102 of file SimpleTCP.h.

{};

Member Function Documentation

SimpleTCPConnection * SimpleTCP::createConnection ( int  appGateIndex,
int  connId 
)
protected

Definition at line 235 of file SimpleTCP.cc.

Referenced by handleMessage().

{
return new SimpleTCPConnection(this, appGateIndex, connId);
}
void SimpleTCP::finish ( )
protected

Definition at line 131 of file SimpleTCP.cc.

{
sad.globalStatistics->addStdDev("SimpleTCP: Packets sent",
sad.globalStatistics->addStdDev("SimpleTCP: Packets dropped due to queue overflows",
sad.globalStatistics->addStdDev("SimpleTCP: Packets dropped due to network partitions",
sad.globalStatistics->addStdDev("SimpleTCP: Packets dropped due to unavailable destination",
}
void SimpleTCP::handleMessage ( cMessage *  msg)
protectedvirtual

Definition at line 143 of file SimpleTCP.cc.

{
if (msg->isSelfMessage())
{
SimpleTCPConnection *conn = (SimpleTCPConnection *) msg->getContextPointer();
bool ret = conn->processTimer(msg);
if (!ret)
removeConnection(conn);
}
else if (msg->arrivedOn("ipIn") || msg->arrivedOn("ipv6In"))
{
if (dynamic_cast<ICMPMessage *>(msg) || dynamic_cast<ICMPv6Message *>(msg))
{
tcpEV << "ICMP error received -- discarding\n"; // FIXME can ICMP packets really make it up to TCP???
delete msg;
}
else
{
// must be a TCPSegment
TCPSegment *tcpseg = check_and_cast<TCPSegment *>(msg);
// get src/dest addresses
IPvXAddress srcAddr, destAddr;
if (dynamic_cast<IPControlInfo *>(tcpseg->getControlInfo())!=NULL)
{
IPControlInfo *controlInfo = (IPControlInfo *)tcpseg->removeControlInfo();
srcAddr = controlInfo->getSrcAddr();
destAddr = controlInfo->getDestAddr();
delete controlInfo;
}
else if (dynamic_cast<IPv6ControlInfo *>(tcpseg->getControlInfo())!=NULL)
{
IPv6ControlInfo *controlInfo = (IPv6ControlInfo *)tcpseg->removeControlInfo();
srcAddr = controlInfo->getSrcAddr();
destAddr = controlInfo->getDestAddr();
delete controlInfo;
}
else
{
error("(%s)%s arrived without control info", tcpseg->getClassName(), tcpseg->getName());
}
// process segment
SimpleTCPConnection *conn = dynamic_cast<SimpleTCPConnection*>(findConnForSegment(tcpseg, srcAddr, destAddr));
if (conn)
{
bool ret = conn->processTCPSegment(tcpseg, srcAddr, destAddr);
if (!ret)
removeConnection(conn);
}
else
{
segmentArrivalWhileClosed(tcpseg, srcAddr, destAddr);
}
}
}
else // must be from app
{
TCPCommand *controlInfo = check_and_cast<TCPCommand *>(msg->getControlInfo());
int appGateIndex = msg->getArrivalGate()->getIndex();
int connId = controlInfo->getConnId();
SimpleTCPConnection *conn = (SimpleTCPConnection*)findConnForApp(appGateIndex, connId);
if (!conn)
{
conn = createConnection(appGateIndex, connId);
// add into appConnMap here; it'll be added to connMap during processing
// the OPEN command in SimpleTCPConnection's processAppCommand().
AppConnKey key;
key.appGateIndex = appGateIndex;
key.connId = connId;
tcpAppConnMap[key] = conn;
tcpEV << "TCP connection created for " << msg << "\n";
}
bool ret = conn->processAppCommand(msg);
if (!ret)
removeConnection(conn);
}
if (ev.isGUI())
updateDisplayString();
}
void SimpleTCP::initialize ( int  stage)
protectedvirtual

Definition at line 80 of file SimpleTCP.cc.

{
if (stage == MIN_STAGE_UNDERLAY) {
lastEphemeralPort = EPHEMERAL_PORTRANGE_START;
WATCH(lastEphemeralPort);
WATCH_PTRMAP(tcpConnMap);
WATCH_PTRMAP(tcpAppConnMap);
recordStatistics = par("recordStats");
cModule *netw = simulation.getSystemModule();
testing = netw->hasPar("testing") && netw->par("testing").boolValue();
logverbose = !testing && netw->hasPar("logverbose") && netw->par("logverbose").boolValue();
// start of modifications
sad.numSent = 0;
WATCH(sad.numQueueLost);
sad.constantDelay = par("constantDelay");
sad.useCoordinateBasedDelay = par("useCoordinateBasedDelay");
sad.delayFaultTypeString = par("delayFaultType").stdstringValue();
sad.faultyDelay = true;
break;
default:
sad.faultyDelay = false;
}
sad.jitter = par("jitter");
sad.nodeEntry = NULL;
WATCH_PTR(sad.nodeEntry);
}
}
virtual int SimpleTCP::numInitStages ( void  ) const
inlineprotectedvirtual

Definition at line 115 of file SimpleTCP.h.

{
return MAX_STAGE_UNDERLAY + 1;
}
void SimpleTCP::segmentArrivalWhileClosed ( TCPSegment *  tcpseg,
IPvXAddress  srcAddr,
IPvXAddress  destAddr 
)
protected

Definition at line 240 of file SimpleTCP.cc.

Referenced by handleMessage().

{
tmp->segmentArrivalWhileClosed(tcpseg, srcAddr, destAddr);
delete tmp;
delete tcpseg;
}
void SimpleTCP::setNodeEntry ( SimpleNodeEntry entry)

Definition at line 230 of file SimpleTCP.cc.

Referenced by SimpleUnderlayConfigurator::createNode().

{
sad.nodeEntry = entry;
}

Member Data Documentation

StatisticsAndDelay SimpleTCP::sad

Definition at line 106 of file SimpleTCP.h.

Referenced by finish(), initialize(), setNodeEntry(), and SimpleTCP().


The documentation for this class was generated from the following files: