INET Framework for OMNeT++/OMNEST
inet::tcp::TCPTahoe Class Reference

Implements Tahoe. More...

#include <TCPTahoe.h>

Inheritance diagram for inet::tcp::TCPTahoe:
inet::tcp::TCPTahoeRenoFamily inet::tcp::TCPBaseAlg inet::tcp::TCPAlgorithm

Public Member Functions

 TCPTahoe ()
 Ctor. More...
 
virtual void receivedDataAck (uint32 firstSeqAcked) override
 Redefine what should happen when data got acked, to add congestion window management. More...
 
virtual void receivedDuplicateAck () override
 Redefine what should happen when dupAck was received, to add congestion window management. More...
 
- Public Member Functions inherited from inet::tcp::TCPTahoeRenoFamily
 TCPTahoeRenoFamily ()
 Ctor. More...
 
- Public Member Functions inherited from inet::tcp::TCPBaseAlg
 TCPBaseAlg ()
 Ctor. More...
 
virtual ~TCPBaseAlg ()
 Virtual dtor. More...
 
virtual void initialize () override
 Create timers, etc. More...
 
virtual void established (bool active) override
 Called when the connection is going to ESTABLISHED from SYN_SENT or SYN_RCVD. More...
 
virtual void connectionClosed () override
 Called when the connection closes, it should cancel all running timers. More...
 
virtual void processTimer (cMessage *timer, TCPEventCode &event) override
 Process REXMIT, PERSIST, DELAYED-ACK and KEEP-ALIVE timers. More...
 
virtual void sendCommandInvoked () override
 Called after user sent TCP_C_SEND command to us. More...
 
virtual void receivedOutOfOrderSegment () override
 Called after receiving data which are in the window, but not at its left edge (seq != rcv_nxt). More...
 
virtual void receiveSeqChanged () override
 Called after rcv_nxt got advanced, either because we received in-sequence data ("text" in RFC 793 lingo) or a FIN. More...
 
virtual void receivedAckForDataNotYetSent (uint32 seq) override
 Called after we received an ACK for data not yet sent. More...
 
virtual void ackSent () override
 Called after we sent an ACK. More...
 
virtual void dataSent (uint32 fromseq) override
 Called after we sent data. More...
 
virtual void segmentRetransmitted (uint32 fromseq, uint32 toseq) override
 Called after we retransmitted segment. More...
 
virtual void restartRexmitTimer () override
 Restart REXMIT timer. More...
 
- Public Member Functions inherited from inet::tcp::TCPAlgorithm
 TCPAlgorithm ()
 Ctor. More...
 
virtual ~TCPAlgorithm ()
 Virtual dtor. More...
 
void setConnection (TCPConnection *_conn)
 Assign this object to a TCPConnection. More...
 
TCPStateVariablesgetStateVariables ()
 Creates and returns the TCP state variables. More...
 

Protected Member Functions

virtual TCPStateVariablescreateStateVariables () override
 Create and return a TCPTahoeStateVariables object. More...
 
virtual void recalculateSlowStartThreshold ()
 Utility function to recalculate ssthresh. More...
 
virtual void processRexmitTimer (TCPEventCode &event) override
 Redefine what should happen on retransmission. More...
 
- Protected Member Functions inherited from inet::tcp::TCPBaseAlg
virtual void startRexmitTimer ()
 Start REXMIT timer and initialize retransmission variables. More...
 
virtual void rttMeasurementComplete (simtime_t tSent, simtime_t tAcked)
 Update state vars with new measured RTT value. More...
 
virtual void rttMeasurementCompleteUsingTS (uint32 echoedTS) override
 Converting uint32 echoedTS to simtime_t and calling rttMeasurementComplete() to update state vars with new measured RTT value. More...
 
virtual bool sendData (bool sendCommandInvoked)
 Send data, observing Nagle's algorithm and congestion window. More...
 
cMessage * cancelEvent (cMessage *msg)
 Utility function. More...
 
virtual void processPersistTimer (TCPEventCode &event)
 
virtual void processDelayedAckTimer (TCPEventCode &event)
 
virtual void processKeepAliveTimer (TCPEventCode &event)
 

Protected Attributes

TCPTahoeStateVariables *& state
 
- Protected Attributes inherited from inet::tcp::TCPTahoeRenoFamily
TCPTahoeRenoFamilyStateVariables *& state
 
- Protected Attributes inherited from inet::tcp::TCPBaseAlg
TCPBaseAlgStateVariables *& state
 
cMessage * rexmitTimer
 
cMessage * persistTimer
 
cMessage * delayedAckTimer
 
cMessage * keepAliveTimer
 
cOutVector * cwndVector
 
cOutVector * ssthreshVector
 
cOutVector * rttVector
 
cOutVector * srttVector
 
cOutVector * rttvarVector
 
cOutVector * rtoVector
 
cOutVector * numRtosVector
 
- Protected Attributes inherited from inet::tcp::TCPAlgorithm
TCPConnectionconn
 
TCPStateVariablesstate
 

Detailed Description

Implements Tahoe.

Constructor & Destructor Documentation

inet::tcp::TCPTahoe::TCPTahoe ( )

Ctor.

30 {
31 }
TCPStateVariables * state
Definition: TCPAlgorithm.h:41
TCPTahoeRenoFamily()
Ctor.
Definition: TCPTahoeRenoFamily.cc:58
TCPTahoeRenoFamilyStateVariables TCPTahoeStateVariables
State variables for TCPTahoe.
Definition: TCPTahoe.h:32
TCPTahoeStateVariables *& state
Definition: TCPTahoe.h:40

Member Function Documentation

virtual TCPStateVariables* inet::tcp::TCPTahoe::createStateVariables ( )
inlineoverrideprotectedvirtual

Create and return a TCPTahoeStateVariables object.

Implements inet::tcp::TCPAlgorithm.

45  {
46  return new TCPTahoeStateVariables();
47  }
TCPTahoeRenoFamilyStateVariables TCPTahoeStateVariables
State variables for TCPTahoe.
Definition: TCPTahoe.h:32
void inet::tcp::TCPTahoe::processRexmitTimer ( TCPEventCode event)
overrideprotectedvirtual

Redefine what should happen on retransmission.

Reimplemented from inet::tcp::TCPBaseAlg.

46 {
48 
49  if (event == TCP_E_ABORT)
50  return;
51 
52  // begin Slow Start (RFC 2581)
55 
56  if (cwndVector)
57  cwndVector->record(state->snd_cwnd);
58 
59  EV_INFO << "Begin Slow Start: resetting cwnd to " << state->snd_cwnd
60  << ", ssthresh=" << state->ssthresh << "\n";
61 
62  state->afterRto = true;
63 
64  // Tahoe retransmits only one segment at the front of the queue
66 }
virtual void retransmitOneSegment(bool called_at_rto)
Utility: retransmit one segment from snd_una.
Definition: TCPConnectionUtil.cc:802
cOutVector * cwndVector
Definition: TCPBaseAlg.h:115
virtual void processRexmitTimer(TCPEventCode &event)
Definition: TCPBaseAlg.cc:231
uint32 snd_mss
Definition: TCPConnection.h:159
Definition: TCPConnection.h:90
bool afterRto
Definition: TCPConnection.h:213
TCPConnection * conn
Definition: TCPAlgorithm.h:40
uint32 ssthresh
slow start threshold
Definition: TCPTahoeRenoFamily.h:40
virtual void recalculateSlowStartThreshold()
Utility function to recalculate ssthresh.
Definition: TCPTahoe.cc:33
TCPTahoeStateVariables *& state
Definition: TCPTahoe.h:40
uint32 snd_cwnd
congestion window
Definition: TCPBaseAlg.h:54
void inet::tcp::TCPTahoe::recalculateSlowStartThreshold ( )
protectedvirtual

Utility function to recalculate ssthresh.

Referenced by processRexmitTimer(), and receivedDuplicateAck().

34 {
35  // set ssthresh to flight size / 2, but at least 2 MSS
36  // (the formula below practically amounts to ssthresh = cwnd / 2 most of the time)
37  uint32 flight_size = std::min(state->snd_cwnd, state->snd_wnd); // FIXME TODO - Does this formula computes the amount of outstanding data?
38  // uint32 flight_size = state->snd_max - state->snd_una;
39  state->ssthresh = std::max(flight_size / 2, 2 * state->snd_mss);
40 
41  if (ssthreshVector)
42  ssthreshVector->record(state->ssthresh);
43 }
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
uint32 snd_wnd
Definition: TCPConnection.h:167
uint32 snd_mss
Definition: TCPConnection.h:159
uint32_t uint32
Definition: Compat.h:30
cOutVector * ssthreshVector
Definition: TCPBaseAlg.h:116
uint32 ssthresh
slow start threshold
Definition: TCPTahoeRenoFamily.h:40
TCPTahoeStateVariables *& state
Definition: TCPTahoe.h:40
uint32 snd_cwnd
congestion window
Definition: TCPBaseAlg.h:54
void inet::tcp::TCPTahoe::receivedDataAck ( uint32  firstSeqAcked)
overridevirtual

Redefine what should happen when data got acked, to add congestion window management.

Reimplemented from inet::tcp::TCPBaseAlg.

69 {
71 
72  //
73  // Perform slow start and congestion avoidance.
74  //
75  if (state->snd_cwnd < state->ssthresh) {
76  EV_DETAIL << "cwnd <= ssthresh: Slow Start: increasing cwnd by SMSS bytes to ";
77 
78  // perform Slow Start. RFC 2581: "During slow start, a TCP increments cwnd
79  // by at most SMSS bytes for each ACK received that acknowledges new data."
81 
82  // Note: we could increase cwnd based on the number of bytes being
83  // acknowledged by each arriving ACK, rather than by the number of ACKs
84  // that arrive. This is called "Appropriate Byte Counting" (ABC) and is
85  // described in RFC 3465 (experimental).
86  //
87  // int bytesAcked = state->snd_una - firstSeqAcked;
88  // state->snd_cwnd += bytesAcked;
89 
90  if (cwndVector)
91  cwndVector->record(state->snd_cwnd);
92 
93  EV_DETAIL << "cwnd=" << state->snd_cwnd << "\n";
94  }
95  else {
96  // perform Congestion Avoidance (RFC 2581)
97  int incr = state->snd_mss * state->snd_mss / state->snd_cwnd;
98 
99  if (incr == 0)
100  incr = 1;
101 
102  state->snd_cwnd += incr;
103 
104  if (cwndVector)
105  cwndVector->record(state->snd_cwnd);
106 
107  //
108  // Note: some implementations use extra additive constant mss / 8 here
109  // which is known to be incorrect (RFC 2581 p5)
110  //
111  // Note 2: RFC 3465 (experimental) "Appropriate Byte Counting" (ABC)
112  // would require maintaining a bytes_acked variable here which we don't do
113  //
114 
115  EV_DETAIL << "cwnd>ssthresh: Congestion Avoidance: increasing cwnd linearly, to " << state->snd_cwnd << "\n";
116  }
117 
118  // ack and/or cwnd increase may have freed up some room in the window, try sending
119  sendData(false);
120 }
cOutVector * cwndVector
Definition: TCPBaseAlg.h:115
virtual void receivedDataAck(uint32 firstSeqAcked) override
Called after we received an ACK which acked some data (that is, we could advance snd_una).
Definition: TCPBaseAlg.cc:529
uint32 snd_mss
Definition: TCPConnection.h:159
uint32 ssthresh
slow start threshold
Definition: TCPTahoeRenoFamily.h:40
TCPTahoeStateVariables *& state
Definition: TCPTahoe.h:40
uint32 snd_cwnd
congestion window
Definition: TCPBaseAlg.h:54
virtual bool sendData(bool sendCommandInvoked)
Send data, observing Nagle&#39;s algorithm and congestion window.
Definition: TCPBaseAlg.cc:429
void inet::tcp::TCPTahoe::receivedDuplicateAck ( )
overridevirtual

Redefine what should happen when dupAck was received, to add congestion window management.

Reimplemented from inet::tcp::TCPBaseAlg.

123 {
125 
126  if (state->dupacks == DUPTHRESH) { // DUPTHRESH = 3
127  EV_DETAIL << "Tahoe on dupAcks == DUPTHRESH(=3): perform Fast Retransmit, and enter Slow Start:\n";
128 
129  // enter Slow Start
132 
133  if (cwndVector)
134  cwndVector->record(state->snd_cwnd);
135 
136  EV_DETAIL << "Set cwnd=" << state->snd_cwnd << ", ssthresh=" << state->ssthresh << "\n";
137 
138  // Fast Retransmission: retransmit missing segment without waiting
139  // for the REXMIT timer to expire
140  conn->retransmitOneSegment(false);
141 
142  // Do not restart REXMIT timer.
143  // Note: Restart of REXMIT timer on retransmission is not part of RFC 2581, however optional in RFC 3517 if sent during recovery.
144  // Resetting the REXMIT timer is discussed in RFC 2582/3782 (NewReno) and RFC 2988.
145  }
146 }
virtual void retransmitOneSegment(bool called_at_rto)
Utility: retransmit one segment from snd_una.
Definition: TCPConnectionUtil.cc:802
cOutVector * cwndVector
Definition: TCPBaseAlg.h:115
uint32 snd_mss
Definition: TCPConnection.h:159
uint32 dupacks
Definition: TCPConnection.h:255
#define DUPTHRESH
Definition: TCPConnection.h:126
virtual void receivedDuplicateAck() override
Called after we received a duplicate ACK (that is: ackNo == snd_una, no data in segment, segment doesn&#39;t carry window update, and also, we have unacked data).
Definition: TCPBaseAlg.cc:611
TCPConnection * conn
Definition: TCPAlgorithm.h:40
uint32 ssthresh
slow start threshold
Definition: TCPTahoeRenoFamily.h:40
virtual void recalculateSlowStartThreshold()
Utility function to recalculate ssthresh.
Definition: TCPTahoe.cc:33
TCPTahoeStateVariables *& state
Definition: TCPTahoe.h:40
uint32 snd_cwnd
congestion window
Definition: TCPBaseAlg.h:54

Member Data Documentation


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