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 * 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
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("TcpPrrRecovery");
22NS_OBJECT_ENSURE_REGISTERED(TcpPrrRecovery);
23
24TypeId
26{
27 static TypeId tid = TypeId("ns3::TcpPrrRecovery")
29 .AddConstructor<TcpPrrRecovery>()
30 .SetGroupName("Internet");
31 return tid;
32}
33
39
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
53
54void
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;
64 m_recoveryFlightSize = tcb->m_bytesInFlight; // RFC 6675 pipe before recovery
65
66 DoRecovery(tcb, deliveredBytes, true);
67}
68
69void
70TcpPrrRecovery::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
117void
119{
120 NS_LOG_FUNCTION(this << tcb);
121 tcb->m_cWndInfl = tcb->m_cWnd;
122}
123
124void
126{
127 NS_LOG_FUNCTION(this << bytesSent);
128 m_prrOut += bytesSent;
129}
130
136
137std::string
139{
140 return "PrrRecovery";
141}
142
143} // namespace ns3
friend Ptr< T > CopyObject(Ptr< T > object)
Copy an Object.
Definition object.h:581
Smart pointer class similar to boost::intrusive_ptr.
The Classic recovery implementation.
An implementation of PRR.
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.
void DoRecovery(Ptr< TcpSocketState > tcb, uint32_t deliveredBytes, bool isDupAck) override
Performs recovery based on the recovery algorithm.
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.
uint32_t m_recoveryFlightSize
value of bytesInFlight at the start of recovery phase
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.