DumbTCP Class Reference

#include <DumbTCP.h>

Inheritance diagram for DumbTCP:

TCPAlgorithm

List of all members.


Detailed Description

A very-very basic TCPAlgorithm implementation, with hardcoded retransmission timeout and no other sophistication. It can be used to demonstrate what happened if there was no adaptive timeout calculation, delayed acks, silly window avoidance, congestion control, etc.

Public Member Functions

 DumbTCP ()
virtual ~DumbTCP ()
virtual void initialize ()
virtual void established (bool active)
virtual void connectionClosed ()
virtual void processTimer (cMessage *timer, TCPEventCode &event)
virtual void sendCommandInvoked ()
virtual void receivedOutOfOrderSegment ()
virtual void receiveSeqChanged ()
virtual void receivedDataAck (uint32 firstSeqAcked)
virtual void receivedDuplicateAck ()
virtual void receivedAckForDataNotYetSent (uint32 seq)
virtual void ackSent ()
virtual void dataSent (uint32 fromseq)

Protected Member Functions

virtual TCPStateVariablescreateStateVariables ()

Protected Attributes

DumbTCPStateVariables *& state
cMessage * rexmitTimer

Constructor & Destructor Documentation

DumbTCP::DumbTCP (  ) 

Ctor

00028                  : TCPAlgorithm(),
00029   state((DumbTCPStateVariables *&)TCPAlgorithm::state)
00030 {
00031     rexmitTimer = NULL;
00032 }

DumbTCP::~DumbTCP (  )  [virtual]

00035 {
00036     // cancel and delete timers
00037     if (rexmitTimer)
00038         delete conn->getTcpMain()->cancelEvent(rexmitTimer);
00039 }


Member Function Documentation

virtual TCPStateVariables* DumbTCP::createStateVariables (  )  [inline, protected, virtual]

Creates and returns a DumbTCPStateVariables object.

Implements TCPAlgorithm.

00051                                                       {
00052         return new DumbTCPStateVariables();
00053     }

void DumbTCP::initialize (  )  [virtual]

Should be redefined to initialize the object: create timers, etc. This method is necessary because the TCPConnection ptr is not available in the constructor yet.

Reimplemented from TCPAlgorithm.

00042 {
00043     TCPAlgorithm::initialize();
00044 
00045     rexmitTimer = new cMessage("REXMIT");
00046 }

void DumbTCP::established ( bool  active  )  [virtual]

Called when the connection is going to ESTABLISHED from SYN_SENT or SYN_RCVD. This is a place to initialize some variables (e.g. set cwnd to the MSS learned during connection setup). If we are on the active side, here we also have to finish the 3-way connection setup procedure by sending an ACK, possibly piggybacked on data.

Implements TCPAlgorithm.

00049 {
00050     if (active)
00051     {
00052         // finish connection setup with ACK (possibly piggybacked on data)
00053         tcpEV << "Completing connection setup by sending ACK (possibly piggybacked on data)\n";
00054         if (!conn->sendData(false))
00055             conn->sendAck();
00056     }
00057 }

void DumbTCP::connectionClosed (  )  [virtual]

Called when the connection closes, it should cancel all running timers.

Implements TCPAlgorithm.

00060 {
00061     conn->getTcpMain()->cancelEvent(rexmitTimer);
00062 }

void DumbTCP::processTimer ( cMessage *  timer,
TCPEventCode event 
) [virtual]

Place to process timers specific to this TCPAlgorithm class. TCPConnection will invoke this method on any timer (self-message) it doesn't recognize (that is, any timer other than the 2MSL, CONN-ESTAB and FIN-WAIT-2 timers).

Method may also change the event code (by default set to TCP_E_IGNORE) to cause the state transition of TCP FSM.

Implements TCPAlgorithm.

00065 {
00066     if (timer!=rexmitTimer)
00067         throw cRuntimeError(timer, "unrecognized timer");
00068 
00069     conn->retransmitData();
00070     conn->scheduleTimeout(rexmitTimer, REXMIT_TIMEOUT);
00071 }

void DumbTCP::sendCommandInvoked (  )  [virtual]

Called after user sent TCP_C_SEND command to us.

Implements TCPAlgorithm.

00074 {
00075     // start sending
00076     conn->sendData(false);
00077 }

void DumbTCP::receivedOutOfOrderSegment (  )  [virtual]

Called after receiving data which are in the window, but not at its left edge (seq!=rcv_nxt). This indicates that either segments got re-ordered in the way, or one segment was lost. RFC1122 and RFC2001 recommend sending an immediate ACK here (Fast Retransmit relies on that).

Implements TCPAlgorithm.

00080 {
00081     tcpEV << "Out-of-order segment, sending immediate ACK\n";
00082     conn->sendAck();
00083 }

void DumbTCP::receiveSeqChanged (  )  [virtual]

Called after rcv_nxt got advanced, either because we received in-sequence data ("text" in RFC 793 lingo) or a FIN. At this point, rcv_nxt has already been updated. This method should take care to send or schedule an ACK some time.

Implements TCPAlgorithm.

00086 {
00087     // new data received, ACK immediately (more sophisticated algs should
00088     // wait a little to see if piggybacking is possible)
00089     tcpEV << "rcv_nxt changed to " << state->rcv_nxt << ", sending immediate ACK\n";
00090     conn->sendAck();
00091 }

void DumbTCP::receivedDataAck ( uint32  firstSeqAcked  )  [virtual]

Called after we received an ACK which acked some data (that is, we could advance snd_una). At this point the state variables (snd_una, snd_wnd) have already been updated. The argument firstSeqAcked is the previous snd_una value, that is, the number of bytes acked is (snd_una-firstSeqAcked). The dupack counter still reflects the old value (needed for Reno and NewReno); it'll be reset to 0 after this call returns.

Implements TCPAlgorithm.

00094 {
00095     // ack may have freed up some room in the window, try sending.
00096     // small segments also OK (Nagle off)
00097     conn->sendData(false);
00098 }

void DumbTCP::receivedDuplicateAck (  )  [virtual]

Called after we received a duplicate ACK (that is: ackNo==snd_una, no data in segment, segment doesn't carry window update, and also, we have unacked data). The dupack counter got already updated when calling this method (i.e. dupack==1 on first duplicate ACK.)

Implements TCPAlgorithm.

00101 {
00102     tcpEV << "Duplicate ACK #" << state->dupacks << "\n";
00103 }

void DumbTCP::receivedAckForDataNotYetSent ( uint32  seq  )  [virtual]

Called after we received an ACK for data not yet sent. According to RFC 793 this function should send an ACK.

Implements TCPAlgorithm.

00106 {
00107     tcpEV << "ACK acks something not yet sent, sending immediate ACK\n";
00108     conn->sendAck();
00109 }

void DumbTCP::ackSent (  )  [virtual]

Called after we sent an ACK. This hook can be used to cancel the delayed-ACK timer.

Implements TCPAlgorithm.

00112 {
00113 }

void DumbTCP::dataSent ( uint32  fromseq  )  [virtual]

Called after we sent data. This hook can be used to schedule the retransmission timer, to start round-trip time measurement, etc. The argument is the seqno of the first byte sent.

Implements TCPAlgorithm.

00116 {
00117     if (rexmitTimer->isScheduled())
00118         conn->getTcpMain()->cancelEvent(rexmitTimer);
00119     conn->scheduleTimeout(rexmitTimer, REXMIT_TIMEOUT);
00120 }


Member Data Documentation

Reimplemented from TCPAlgorithm.

Referenced by receivedDuplicateAck(), and receiveSeqChanged().

cMessage* DumbTCP::rexmitTimer [protected]


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

Generated on Fri Mar 20 18:51:18 2009 for INET Framework for OMNeT++/OMNEST by  doxygen 1.5.5