A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-prr-recovery.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 NITK Surathkal
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Viyom Mittal <viyommittal@gmail.com>
18 * Vivek Jain <jain.vivek.anand@gmail.com>
19 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
20 *
21 */
22
23#include "tcp-prr-recovery.h"
24
25#include "tcp-socket-state.h"
26
27#include "ns3/log.h"
28
29namespace ns3
30{
31
32NS_LOG_COMPONENT_DEFINE("TcpPrrRecovery");
33NS_OBJECT_ENSURE_REGISTERED(TcpPrrRecovery);
34
35TypeId
37{
38 static TypeId tid =
39 TypeId("ns3::TcpPrrRecovery")
41 .AddConstructor<TcpPrrRecovery>()
42 .SetGroupName("Internet")
43 .AddAttribute("ReductionBound",
44 "Type of Reduction Bound",
46 MakeEnumAccessor<ReductionBound_t>(&TcpPrrRecovery::m_reductionBoundMode),
47 MakeEnumChecker(CRB, "CRB", SSRB, "SSRB"));
48 return tid;
49}
50
53{
54 NS_LOG_FUNCTION(this);
55}
56
58 : TcpClassicRecovery(recovery),
59 m_prrDelivered(recovery.m_prrDelivered),
60 m_prrOut(recovery.m_prrOut),
61 m_recoveryFlightSize(recovery.m_recoveryFlightSize),
62 m_reductionBoundMode(recovery.m_reductionBoundMode)
63{
64 NS_LOG_FUNCTION(this);
65}
66
68{
69 NS_LOG_FUNCTION(this);
70}
71
72void
74 uint32_t dupAckCount [[maybe_unused]],
75 uint32_t unAckDataCount,
76 uint32_t deliveredBytes)
77{
78 NS_LOG_FUNCTION(this << tcb << dupAckCount << unAckDataCount);
79
80 m_prrOut = 0;
82 m_recoveryFlightSize = unAckDataCount;
83
84 DoRecovery(tcb, deliveredBytes);
85}
86
87void
89{
90 NS_LOG_FUNCTION(this << tcb << deliveredBytes);
91 m_prrDelivered += deliveredBytes;
92
93 int sendCount;
94 if (tcb->m_bytesInFlight > tcb->m_ssThresh)
95 {
96 sendCount =
97 std::ceil(m_prrDelivered * tcb->m_ssThresh * 1.0 / m_recoveryFlightSize) - m_prrOut;
98 }
99 else
100 {
101 int limit = static_cast<int>(tcb->m_ssThresh - tcb->m_bytesInFlight);
103 {
104 limit = m_prrDelivered - m_prrOut;
105 }
106 else if (m_reductionBoundMode == SSRB)
107 {
108 if (tcb->m_isRetransDataAcked)
109 {
110 limit = std::max(m_prrDelivered - m_prrOut, deliveredBytes) + tcb->m_segmentSize;
111 }
112 else
113 {
114 limit = deliveredBytes;
115 }
116 }
117 sendCount = std::min(limit, static_cast<int>(tcb->m_ssThresh - tcb->m_bytesInFlight));
118 }
119
120 /* Force a fast retransmit upon entering fast recovery */
121 sendCount = std::max(sendCount, static_cast<int>(m_prrOut > 0 ? 0 : tcb->m_segmentSize));
122 tcb->m_cWnd = tcb->m_bytesInFlight + sendCount;
123 tcb->m_cWndInfl = tcb->m_cWnd;
124}
125
126void
128{
129 NS_LOG_FUNCTION(this << tcb);
130 tcb->m_cWndInfl = tcb->m_cWnd;
131}
132
133void
135{
136 NS_LOG_FUNCTION(this << bytesSent);
137 m_prrOut += bytesSent;
138}
139
142{
143 return CopyObject<TcpPrrRecovery>(this);
144}
145
146std::string
148{
149 return "PrrRecovery";
150}
151
152} // namespace ns3
Hold variables of type enum.
Definition: enum.h:62
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
The Classic recovery implementation.
An implementation of PRR.
ReductionBound_t m_reductionBoundMode
mode of Reduction Bound to be used
void EnterRecovery(Ptr< TcpSocketState > tcb, uint32_t dupAckCount, uint32_t unAckDataCount, uint32_t deliveredBytes) override
Performs variable initialization at the start of recovery.
static TypeId GetTypeId()
Get the type ID.
void UpdateBytesSent(uint32_t bytesSent) override
Keeps track of bytes sent during recovery phase.
@ CRB
Conservative Reduction Bound.
@ SSRB
Slow Start Reduction Bound.
void ExitRecovery(Ptr< TcpSocketState > tcb) override
Performs cwnd adjustments at the end of recovery.
std::string GetName() const override
Get the name of the recovery algorithm.
uint32_t m_prrOut
total bytes sent during recovery phase
TcpPrrRecovery()
Create an unbound tcp socket.
uint32_t m_prrDelivered
total bytes delivered during recovery phase
Ptr< TcpRecoveryOps > Fork() override
Copy the recovery algorithm across socket.
void DoRecovery(Ptr< TcpSocketState > tcb, uint32_t deliveredBytes) override
Performs recovery based on the recovery algorithm.
uint32_t m_recoveryFlightSize
value of bytesInFlight at the start of recovery phase
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:189