A Discrete-Event Network Simulator
API
tcp-recovery-ops.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2018 NITK Surathkal
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Viyom Mittal <viyommittal@gmail.com>
19  * Vivek Jain <jain.vivek.anand@gmail.com>
20  * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
21  *
22  */
23 #include "tcp-recovery-ops.h"
24 #include "tcp-socket-state.h"
25 #include "ns3/log.h"
26 
27 namespace ns3 {
28 
29 NS_LOG_COMPONENT_DEFINE ("TcpRecoveryOps");
30 
31 NS_OBJECT_ENSURE_REGISTERED (TcpRecoveryOps);
32 
33 TypeId
35 {
36  static TypeId tid = TypeId ("ns3::TcpRecoveryOps")
37  .SetParent<Object> ()
38  .SetGroupName ("Internet")
39  ;
40  return tid;
41 }
42 
44 {
45  NS_LOG_FUNCTION (this);
46 }
47 
49 {
50  NS_LOG_FUNCTION (this);
51 }
52 
54 {
55  NS_LOG_FUNCTION (this);
56 }
57 
58 void
59 TcpRecoveryOps::UpdateBytesSent (uint32_t bytesSent)
60 {
61  NS_LOG_FUNCTION (this << bytesSent);
62 }
63 
64 // Classic recovery
65 
67 
68 TypeId
70 {
71  static TypeId tid = TypeId ("ns3::TcpClassicRecovery")
73  .SetGroupName ("Internet")
74  .AddConstructor<TcpClassicRecovery> ()
75  ;
76  return tid;
77 }
78 
80 {
81  NS_LOG_FUNCTION (this);
82 }
83 
85  : TcpRecoveryOps (sock)
86 {
87  NS_LOG_FUNCTION (this);
88 }
89 
91 {
92  NS_LOG_FUNCTION (this);
93 }
94 
95 void
97  uint32_t unAckDataCount, uint32_t deliveredBytes)
98 {
99  NS_LOG_FUNCTION (this << tcb << dupAckCount << unAckDataCount);
100  NS_UNUSED (unAckDataCount);
101  NS_UNUSED (deliveredBytes);
102  tcb->m_cWnd = tcb->m_ssThresh;
103  tcb->m_cWndInfl = tcb->m_ssThresh + (dupAckCount * tcb->m_segmentSize);
104 }
105 
106 void
108 {
109  NS_LOG_FUNCTION (this << tcb << deliveredBytes);
110  NS_UNUSED (deliveredBytes);
111  tcb->m_cWndInfl += tcb->m_segmentSize;
112 }
113 
114 void
116 {
117  NS_LOG_FUNCTION (this << tcb);
118  // Follow NewReno procedures to exit FR if SACK is disabled
119  // (RFC2582 sec.3 bullet #5 paragraph 2, option 2)
120  // For SACK connections, we maintain the cwnd = ssthresh. In fact,
121  // this ACK was received in RECOVERY phase, not in OPEN. So we
122  // are not allowed to increase the window
123  tcb->m_cWndInfl = tcb->m_ssThresh.Get ();
124 }
125 
126 std::string
128 {
129  return "TcpClassicRecovery";
130 }
131 
134 {
135  return CopyObject<TcpClassicRecovery> (this);
136 }
137 
138 } // namespace ns3
139 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
uint32_t m_segmentSize
Segment size.
recovery abstract class
static TypeId GetTypeId(void)
Get the type ID.
virtual void UpdateBytesSent(uint32_t bytesSent)
Keeps track of bytes sent during recovery phase.
TracedValue< uint32_t > m_cWndInfl
Inflated congestion window trace (used only for backward compatibility purpose)
static TypeId GetTypeId(void)
Get the type ID.
TcpClassicRecovery()
Constructor.
virtual void ExitRecovery(Ptr< TcpSocketState > tcb) override
Performs cwnd adjustments at the end of recovery.
virtual ~TcpClassicRecovery() override
Constructor.
virtual Ptr< TcpRecoveryOps > Fork() override
Copy the recovery algorithm across socket.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
virtual void DoRecovery(Ptr< TcpSocketState > tcb, uint32_t deliveredBytes) override
Performs recovery based on the recovery algorithm.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void EnterRecovery(Ptr< TcpSocketState > tcb, uint32_t dupAckCount, uint32_t unAckDataCount, uint32_t deliveredBytes) override
Performs variable initialization at the start of recovery.
TracedValue< uint32_t > m_cWnd
Congestion window.
TcpRecoveryOps()
Constructor.
T Get(void) const
Get the underlying value.
Definition: traced-value.h:218
The Classic recovery implementation.
A base class which provides memory management and object aggregation.
Definition: object.h:87
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
virtual ~TcpRecoveryOps()
Deconstructor.
virtual std::string GetName() const override
Get the name of the recovery algorithm.