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

A very-very basic TCPAlgorithm implementation, with hardcoded retransmission timeout and no other sophistication. More...

#include <DumbTCP.h>

Inheritance diagram for inet::tcp::DumbTCP:
inet::tcp::TCPAlgorithm

Public Member Functions

 DumbTCP ()
 Ctor. More...
 
virtual ~DumbTCP ()
 
virtual void initialize () override
 Should be redefined to initialize the object: 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
 Place to process timers specific to this TCPAlgorithm class. 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 receivedDataAck (uint32 firstSeqAcked) override
 Called after we received an ACK which acked some data (that is, we could advance snd_una). More...
 
virtual void receivedDuplicateAck () override
 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). 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...
 
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...
 
- 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
 Creates and returns a DumbTCPStateVariables object. More...
 

Protected Attributes

DumbTCPStateVariables *& state
 
cMessage * rexmitTimer
 
- Protected Attributes inherited from inet::tcp::TCPAlgorithm
TCPConnectionconn
 
TCPStateVariablesstate
 

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.

Constructor & Destructor Documentation

inet::tcp::DumbTCP::DumbTCP ( )

Ctor.

30  : TCPAlgorithm(),
31  state((DumbTCPStateVariables *&)TCPAlgorithm::state)
32 {
33  rexmitTimer = nullptr;
34 }
cMessage * rexmitTimer
Definition: DumbTCP.h:50
TCPStateVariables * state
Definition: TCPAlgorithm.h:41
TCPAlgorithm()
Ctor.
Definition: TCPAlgorithm.h:55
DumbTCPStateVariables *& state
Definition: DumbTCP.h:48
inet::tcp::DumbTCP::~DumbTCP ( )
virtual
37 {
38  // cancel and delete timers
39  if (rexmitTimer)
40  delete conn->getTcpMain()->cancelEvent(rexmitTimer);
41 }
cMessage * rexmitTimer
Definition: DumbTCP.h:50
TCP * getTcpMain()
Definition: TCPConnection.h:609
TCPConnection * conn
Definition: TCPAlgorithm.h:40

Member Function Documentation

void inet::tcp::DumbTCP::ackSent ( )
overridevirtual

Called after we sent an ACK.

This hook can be used to cancel the delayed-ACK timer.

Implements inet::tcp::TCPAlgorithm.

115 {
116 }
void inet::tcp::DumbTCP::connectionClosed ( )
overridevirtual

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

Implements inet::tcp::TCPAlgorithm.

63 {
64  conn->getTcpMain()->cancelEvent(rexmitTimer);
65 }
cMessage * rexmitTimer
Definition: DumbTCP.h:50
TCP * getTcpMain()
Definition: TCPConnection.h:609
TCPConnection * conn
Definition: TCPAlgorithm.h:40
virtual TCPStateVariables* inet::tcp::DumbTCP::createStateVariables ( )
inlineoverrideprotectedvirtual

Creates and returns a DumbTCPStateVariables object.

Implements inet::tcp::TCPAlgorithm.

55  {
56  return new DumbTCPStateVariables();
57  }
void inet::tcp::DumbTCP::dataSent ( uint32  fromseq)
overridevirtual

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 inet::tcp::TCPAlgorithm.

119 {
120  if (rexmitTimer->isScheduled())
121  conn->getTcpMain()->cancelEvent(rexmitTimer);
122 
124 }
cMessage * rexmitTimer
Definition: DumbTCP.h:50
TCP * getTcpMain()
Definition: TCPConnection.h:609
void scheduleTimeout(cMessage *msg, simtime_t timeout)
Utility: start a timer.
Definition: TCPConnection.h:524
#define REXMIT_TIMEOUT
Definition: DumbTCP.cc:28
TCPConnection * conn
Definition: TCPAlgorithm.h:40
void inet::tcp::DumbTCP::established ( bool  active)
overridevirtual

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 inet::tcp::TCPAlgorithm.

52 {
53  if (active) {
54  // finish connection setup with ACK (possibly piggybacked on data)
55  EV_INFO << "Completing connection setup by sending ACK (possibly piggybacked on data)\n";
56 
57  if (!conn->sendData(false, 65535))
58  conn->sendAck();
59  }
60 }
virtual void sendAck()
Utility: send ACK.
Definition: TCPConnectionUtil.cc:543
virtual bool sendData(bool fullSegmentsOnly, uint32 congestionWindow)
Utility: Send data from sendQueue, at most congestionWindow.
Definition: TCPConnectionUtil.cc:662
TCPConnection * conn
Definition: TCPAlgorithm.h:40
void inet::tcp::DumbTCP::initialize ( )
overridevirtual

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 inet::tcp::TCPAlgorithm.

44 {
46 
47  rexmitTimer = new cMessage("REXMIT");
48  rexmitTimer->setContextPointer(conn);
49 }
virtual void initialize()
Should be redefined to initialize the object: create timers, etc.
Definition: TCPAlgorithm.h:84
cMessage * rexmitTimer
Definition: DumbTCP.h:50
TCPConnection * conn
Definition: TCPAlgorithm.h:40
void inet::tcp::DumbTCP::processTimer ( cMessage *  timer,
TCPEventCode event 
)
overridevirtual

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 inet::tcp::TCPAlgorithm.

68 {
69  if (timer != rexmitTimer)
70  throw cRuntimeError(timer, "unrecognized timer");
71 
74 }
cMessage * rexmitTimer
Definition: DumbTCP.h:50
virtual void retransmitData()
Utility: retransmit all from snd_una to snd_max.
Definition: TCPConnectionUtil.cc:849
void scheduleTimeout(cMessage *msg, simtime_t timeout)
Utility: start a timer.
Definition: TCPConnection.h:524
#define REXMIT_TIMEOUT
Definition: DumbTCP.cc:28
TCPConnection * conn
Definition: TCPAlgorithm.h:40
void inet::tcp::DumbTCP::receivedAckForDataNotYetSent ( uint32  seq)
overridevirtual

Called after we received an ACK for data not yet sent.

According to RFC 793 this function should send an ACK.

Implements inet::tcp::TCPAlgorithm.

109 {
110  EV_INFO << "ACK acks something not yet sent, sending immediate ACK\n";
111  conn->sendAck();
112 }
virtual void sendAck()
Utility: send ACK.
Definition: TCPConnectionUtil.cc:543
TCPConnection * conn
Definition: TCPAlgorithm.h:40
void inet::tcp::DumbTCP::receivedDataAck ( uint32  firstSeqAcked)
overridevirtual

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 inet::tcp::TCPAlgorithm.

97 {
98  // ack may have freed up some room in the window, try sending.
99  // small segments also OK (Nagle off)
100  conn->sendData(false, 65535);
101 }
virtual bool sendData(bool fullSegmentsOnly, uint32 congestionWindow)
Utility: Send data from sendQueue, at most congestionWindow.
Definition: TCPConnectionUtil.cc:662
TCPConnection * conn
Definition: TCPAlgorithm.h:40
void inet::tcp::DumbTCP::receivedDuplicateAck ( )
overridevirtual

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. dupacks == 1 on first duplicate ACK.)

Implements inet::tcp::TCPAlgorithm.

104 {
105  EV_INFO << "Duplicate ACK #" << state->dupacks << "\n";
106 }
uint32 dupacks
Definition: TCPConnection.h:255
DumbTCPStateVariables *& state
Definition: DumbTCP.h:48
void inet::tcp::DumbTCP::receivedOutOfOrderSegment ( )
overridevirtual

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. RFC 1122 and RFC 2001 recommend sending an immediate ACK here (Fast Retransmit relies on that).

Implements inet::tcp::TCPAlgorithm.

83 {
84  EV_INFO << "Out-of-order segment, sending immediate ACK\n";
85  conn->sendAck();
86 }
virtual void sendAck()
Utility: send ACK.
Definition: TCPConnectionUtil.cc:543
TCPConnection * conn
Definition: TCPAlgorithm.h:40
void inet::tcp::DumbTCP::receiveSeqChanged ( )
overridevirtual

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 inet::tcp::TCPAlgorithm.

89 {
90  // new data received, ACK immediately (more sophisticated algs should
91  // wait a little to see if piggybacking is possible)
92  EV_INFO << "rcv_nxt changed to " << state->rcv_nxt << ", sending immediate ACK\n";
93  conn->sendAck();
94 }
virtual void sendAck()
Utility: send ACK.
Definition: TCPConnectionUtil.cc:543
uint32 rcv_nxt
Definition: TCPConnection.h:174
DumbTCPStateVariables *& state
Definition: DumbTCP.h:48
TCPConnection * conn
Definition: TCPAlgorithm.h:40
void inet::tcp::DumbTCP::restartRexmitTimer ( )
overridevirtual

Restart REXMIT timer.

Implements inet::tcp::TCPAlgorithm.

131 {
132 }
void inet::tcp::DumbTCP::rttMeasurementCompleteUsingTS ( uint32  echoedTS)
overridevirtual

Converting uint32 echoedTS to simtime_t and calling rttMeasurementComplete() to update state vars with new measured RTT value.

Implements inet::tcp::TCPAlgorithm.

135 {
136 }
void inet::tcp::DumbTCP::segmentRetransmitted ( uint32  fromseq,
uint32  toseq 
)
overridevirtual

Called after we retransmitted segment.

The argument fromseq is the seqno of the first byte sent. The argument toseq is the seqno of the last byte sent+1.

Implements inet::tcp::TCPAlgorithm.

127 {
128 }
void inet::tcp::DumbTCP::sendCommandInvoked ( )
overridevirtual

Called after user sent TCP_C_SEND command to us.

Implements inet::tcp::TCPAlgorithm.

77 {
78  // start sending
79  conn->sendData(false, 65535);
80 }
virtual bool sendData(bool fullSegmentsOnly, uint32 congestionWindow)
Utility: Send data from sendQueue, at most congestionWindow.
Definition: TCPConnectionUtil.cc:662
TCPConnection * conn
Definition: TCPAlgorithm.h:40

Member Data Documentation

cMessage* inet::tcp::DumbTCP::rexmitTimer
protected
DumbTCPStateVariables*& inet::tcp::DumbTCP::state
protected

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