A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Viyom Mittal <viyommittal@gmail.com>
7
* Vivek Jain <jain.vivek.anand@gmail.com>
8
* Mohit P. Tahiliani <tahiliani@nitk.edu.in>
9
*
10
*/
11
12
#include "
tcp-prr-recovery.h
"
13
14
#include "
tcp-socket-state.h
"
15
16
#include "ns3/log.h"
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"TcpPrrRecovery"
);
22
NS_OBJECT_ENSURE_REGISTERED
(
TcpPrrRecovery
);
23
24
TypeId
25
TcpPrrRecovery::GetTypeId
()
26
{
27
static
TypeId
tid =
TypeId
(
"ns3::TcpPrrRecovery"
)
28
.
SetParent
<
TcpClassicRecovery
>()
29
.AddConstructor<TcpPrrRecovery>()
30
.SetGroupName(
"Internet"
);
31
return
tid;
32
}
33
34
TcpPrrRecovery::TcpPrrRecovery
()
35
:
TcpClassicRecovery
()
36
{
37
NS_LOG_FUNCTION
(
this
);
38
}
39
40
TcpPrrRecovery::TcpPrrRecovery
(
const
TcpPrrRecovery
& recovery)
41
:
TcpClassicRecovery
(recovery),
42
m_prrDelivered
(recovery.
m_prrDelivered
),
43
m_prrOut
(recovery.
m_prrOut
),
44
m_recoveryFlightSize
(recovery.
m_recoveryFlightSize
)
45
{
46
NS_LOG_FUNCTION
(
this
);
47
}
48
49
TcpPrrRecovery::~TcpPrrRecovery
()
50
{
51
NS_LOG_FUNCTION
(
this
);
52
}
53
54
void
55
TcpPrrRecovery::EnterRecovery
(
Ptr<TcpSocketState>
tcb,
56
uint32_t
dupAckCount [[maybe_unused]],
57
uint32_t
unAckDataCount,
58
uint32_t
deliveredBytes)
59
{
60
NS_LOG_FUNCTION
(
this
<< tcb << dupAckCount << unAckDataCount);
61
62
m_prrOut
= 0;
63
m_prrDelivered
= 0;
64
m_recoveryFlightSize
= tcb->m_bytesInFlight;
// RFC 6675 pipe before recovery
65
66
DoRecovery
(tcb, deliveredBytes,
true
);
67
}
68
69
void
70
TcpPrrRecovery::DoRecovery
(
Ptr<TcpSocketState>
tcb,
uint32_t
deliveredBytes,
bool
isDupAck)
71
{
72
NS_LOG_FUNCTION
(
this
<< tcb << deliveredBytes);
73
74
if
(isDupAck &&
m_prrDelivered
<
m_recoveryFlightSize
)
75
{
76
deliveredBytes += tcb->m_segmentSize;
77
}
78
if
(deliveredBytes == 0)
79
{
80
return
;
81
}
82
83
m_prrDelivered
+= deliveredBytes;
84
85
int
sendCount;
86
if
(tcb->m_bytesInFlight > tcb->m_ssThresh)
87
{
88
// Proportional Rate Reductions
89
sendCount =
90
std::ceil(
m_prrDelivered
* tcb->m_ssThresh * 1.0 /
m_recoveryFlightSize
) -
m_prrOut
;
91
}
92
else
93
{
94
// PRR-CRB by default
95
int
limit = std::max(
m_prrDelivered
-
m_prrOut
, deliveredBytes);
96
97
// safeACK should be true iff ACK advances SND.UNA with no further loss indicated.
98
// We approximate that here (given the current lack of RACK-TLP in ns-3)
99
bool
safeACK = tcb->m_isRetransDataAcked;
// retransmit cumulatively ACKed?
100
101
if
(safeACK)
102
{
103
// PRR-SSRB when recovery makes good progress
104
limit += tcb->m_segmentSize;
105
}
106
107
// Attempt to catch up, as permitted
108
sendCount = std::min(limit,
static_cast<
int
>
(tcb->m_ssThresh - tcb->m_bytesInFlight));
109
}
110
111
/* Force a fast retransmit upon entering fast recovery */
112
sendCount = std::max(sendCount,
static_cast<
int
>
(
m_prrOut
> 0 ? 0 : tcb->m_segmentSize));
113
tcb->m_cWnd = tcb->m_bytesInFlight + sendCount;
114
tcb->m_cWndInfl = tcb->m_cWnd;
115
}
116
117
void
118
TcpPrrRecovery::ExitRecovery
(
Ptr<TcpSocketState>
tcb)
119
{
120
NS_LOG_FUNCTION
(
this
<< tcb);
121
tcb->m_cWndInfl = tcb->m_cWnd;
122
}
123
124
void
125
TcpPrrRecovery::UpdateBytesSent
(
uint32_t
bytesSent)
126
{
127
NS_LOG_FUNCTION
(
this
<< bytesSent);
128
m_prrOut
+= bytesSent;
129
}
130
131
Ptr<TcpRecoveryOps>
132
TcpPrrRecovery::Fork
()
133
{
134
return
CopyObject<TcpPrrRecovery>
(
this
);
135
}
136
137
std::string
138
TcpPrrRecovery::GetName
()
const
139
{
140
return
"PrrRecovery"
;
141
}
142
143
}
// namespace ns3
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:66
ns3::TcpClassicRecovery::TcpClassicRecovery
TcpClassicRecovery()
Constructor.
Definition
tcp-recovery-ops.cc:68
ns3::TcpPrrRecovery
An implementation of PRR.
Definition
tcp-prr-recovery.h:32
ns3::TcpPrrRecovery::EnterRecovery
void EnterRecovery(Ptr< TcpSocketState > tcb, uint32_t dupAckCount, uint32_t unAckDataCount, uint32_t deliveredBytes) override
Performs variable initialization at the start of recovery.
Definition
tcp-prr-recovery.cc:55
ns3::TcpPrrRecovery::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
tcp-prr-recovery.cc:25
ns3::TcpPrrRecovery::UpdateBytesSent
void UpdateBytesSent(uint32_t bytesSent) override
Keeps track of bytes sent during recovery phase.
Definition
tcp-prr-recovery.cc:125
ns3::TcpPrrRecovery::DoRecovery
void DoRecovery(Ptr< TcpSocketState > tcb, uint32_t deliveredBytes, bool isDupAck) override
Performs recovery based on the recovery algorithm.
Definition
tcp-prr-recovery.cc:70
ns3::TcpPrrRecovery::ExitRecovery
void ExitRecovery(Ptr< TcpSocketState > tcb) override
Performs cwnd adjustments at the end of recovery.
Definition
tcp-prr-recovery.cc:118
ns3::TcpPrrRecovery::GetName
std::string GetName() const override
Get the name of the recovery algorithm.
Definition
tcp-prr-recovery.cc:138
ns3::TcpPrrRecovery::m_prrOut
uint32_t m_prrOut
total bytes sent during recovery phase
Definition
tcp-prr-recovery.h:70
ns3::TcpPrrRecovery::~TcpPrrRecovery
~TcpPrrRecovery() override
Definition
tcp-prr-recovery.cc:49
ns3::TcpPrrRecovery::TcpPrrRecovery
TcpPrrRecovery()
Create an unbound tcp socket.
Definition
tcp-prr-recovery.cc:34
ns3::TcpPrrRecovery::m_prrDelivered
uint32_t m_prrDelivered
total bytes delivered during recovery phase
Definition
tcp-prr-recovery.h:69
ns3::TcpPrrRecovery::Fork
Ptr< TcpRecoveryOps > Fork() override
Copy the recovery algorithm across socket.
Definition
tcp-prr-recovery.cc:132
ns3::TcpPrrRecovery::m_recoveryFlightSize
uint32_t m_recoveryFlightSize
value of bytesInFlight at the start of recovery phase
Definition
tcp-prr-recovery.h:71
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::CopyObject
Ptr< T > CopyObject(Ptr< const T > object)
Definition
object.h:581
tcp-prr-recovery.h
tcp-socket-state.h
src
internet
model
tcp-prr-recovery.cc
Generated on Wed Jun 11 2025 13:15:30 for ns-3 by
1.13.2