#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) |
SimpleTCPConnection * | createConnection (int appGateIndex, int connId) |
virtual void | initialize (int stage) |
virtual void | handleMessage (cMessage *msg) |
virtual int | numInitStages () const |
void | finish () |
Definition at line 98 of file SimpleTCP.h.
SimpleTCP::SimpleTCP | ( | ) | [inline] |
Definition at line 101 of file SimpleTCP.h.
{ sad.globalStatistics = NULL; };
virtual SimpleTCP::~SimpleTCP | ( | ) | [inline, virtual] |
Definition at line 102 of file SimpleTCP.h.
{};
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.numSent); sad.globalStatistics->addStdDev("SimpleTCP: Packets dropped due to queue overflows", sad.numQueueLost); sad.globalStatistics->addStdDev("SimpleTCP: Packets dropped due to network partitions", sad.numPartitionLost); sad.globalStatistics->addStdDev("SimpleTCP: Packets dropped due to unavailable destination", sad.numDestUnavailableLost); }
void SimpleTCP::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
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 | ) | [protected, virtual] |
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; sad.numQueueLost = 0; sad.numPartitionLost = 0; sad.numDestUnavailableLost = 0; WATCH(sad.numQueueLost); WATCH(sad.numPartitionLost); WATCH(sad.numDestUnavailableLost); sad.globalNodeList = GlobalNodeListAccess().get(); sad.globalStatistics = GlobalStatisticsAccess().get(); sad.constantDelay = par("constantDelay"); sad.useCoordinateBasedDelay = par("useCoordinateBasedDelay"); sad.delayFaultTypeString = par("delayFaultType").stdstringValue(); sad.delayFaultTypeMap["live_all"] = sad.delayFaultLiveAll; sad.delayFaultTypeMap["live_planetlab"] = sad.delayFaultLivePlanetlab; sad.delayFaultTypeMap["simulation"] = sad.delayFaultSimulation; switch (sad.delayFaultTypeMap[sad.delayFaultTypeString]) { case StatisticsAndDelay::delayFaultLiveAll: case StatisticsAndDelay::delayFaultLivePlanetlab: case StatisticsAndDelay::delayFaultSimulation: 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 [inline, protected, virtual] |
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().
{ SimpleTCPConnection *tmp = new SimpleTCPConnection(); 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().
Definition at line 106 of file SimpleTCP.h.
Referenced by finish(), initialize(), setNodeEntry(), and SimpleTCP().