Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "DumbTCP.h"
00019 #include "TCP.h"
00020
00021 Register_Class(DumbTCP);
00022
00023
00024
00025 #define REXMIT_TIMEOUT 2
00026
00027
00028 DumbTCP::DumbTCP() : TCPAlgorithm(),
00029 state((DumbTCPStateVariables *&)TCPAlgorithm::state)
00030 {
00031 rexmitTimer = NULL;
00032 }
00033
00034 DumbTCP::~DumbTCP()
00035 {
00036
00037 if (rexmitTimer)
00038 delete conn->getTcpMain()->cancelEvent(rexmitTimer);
00039 }
00040
00041 void DumbTCP::initialize()
00042 {
00043 TCPAlgorithm::initialize();
00044
00045 rexmitTimer = new cMessage("REXMIT");
00046 rexmitTimer->setContextPointer(conn);
00047 }
00048
00049 void DumbTCP::established(bool active)
00050 {
00051 if (active)
00052 {
00053
00054 tcpEV << "Completing connection setup by sending ACK (possibly piggybacked on data)\n";
00055 if (!conn->sendData(false,65535))
00056 conn->sendAck();
00057 }
00058 }
00059
00060 void DumbTCP::connectionClosed()
00061 {
00062 conn->getTcpMain()->cancelEvent(rexmitTimer);
00063 }
00064
00065 void DumbTCP::processTimer(cMessage *timer, TCPEventCode& event)
00066 {
00067 if (timer!=rexmitTimer)
00068 throw cRuntimeError(timer, "unrecognized timer");
00069
00070 conn->retransmitData();
00071 conn->scheduleTimeout(rexmitTimer, REXMIT_TIMEOUT);
00072 }
00073
00074 void DumbTCP::sendCommandInvoked()
00075 {
00076
00077 conn->sendData(false,65535);
00078 }
00079
00080 void DumbTCP::receivedOutOfOrderSegment()
00081 {
00082 tcpEV << "Out-of-order segment, sending immediate ACK\n";
00083 conn->sendAck();
00084 }
00085
00086 void DumbTCP::receiveSeqChanged()
00087 {
00088
00089
00090 tcpEV << "rcv_nxt changed to " << state->rcv_nxt << ", sending immediate ACK\n";
00091 conn->sendAck();
00092 }
00093
00094 void DumbTCP::receivedDataAck(uint32)
00095 {
00096
00097
00098 conn->sendData(false,65535);
00099 }
00100
00101 void DumbTCP::receivedDuplicateAck()
00102 {
00103 tcpEV << "Duplicate ACK #" << state->dupacks << "\n";
00104 }
00105
00106 void DumbTCP::receivedAckForDataNotYetSent(uint32 seq)
00107 {
00108 tcpEV << "ACK acks something not yet sent, sending immediate ACK\n";
00109 conn->sendAck();
00110 }
00111
00112 void DumbTCP::ackSent()
00113 {
00114 }
00115
00116 void DumbTCP::dataSent(uint32 fromseq)
00117 {
00118 if (rexmitTimer->isScheduled())
00119 conn->getTcpMain()->cancelEvent(rexmitTimer);
00120 conn->scheduleTimeout(rexmitTimer, REXMIT_TIMEOUT);
00121 }
00122
00123 void DumbTCP::restartRexmitTimer()
00124 {
00125 }
00126
00127 void DumbTCP::rttMeasurementCompleteUsingTS(uint32 echoedTS)
00128 {
00129 }