10#define NS_LOG_APPEND_CONTEXT \
13 std::clog << " [node " << m_node->GetId() << "] "; \
40#include "ns3/data-rate.h"
41#include "ns3/double.h"
42#include "ns3/inet-socket-address.h"
43#include "ns3/inet6-socket-address.h"
46#include "ns3/object.h"
47#include "ns3/packet.h"
48#include "ns3/pointer.h"
49#include "ns3/simulation-singleton.h"
50#include "ns3/simulator.h"
51#include "ns3/trace-source-accessor.h"
52#include "ns3/uinteger.h"
64const std::map<std::pair<ns3::TcpSocketBase::TcpPacketType_t, ns3::TcpSocketState::EcnMode_t>,
bool>
97 TypeId(
"ns3::TcpSocketBase")
99 .SetGroupName(
"Internet")
106 .AddAttribute(
"MaxSegLifetime",
107 "Maximum segment lifetime in seconds, use for TIME_WAIT state transition "
112 .AddAttribute(
"MaxWindowSize",
113 "Max size of advertised window",
117 .AddAttribute(
"IcmpCallback",
118 "Callback invoked whenever an icmp error is received on this socket.",
122 .AddAttribute(
"IcmpCallback6",
123 "Callback invoked whenever an icmpv6 error is received on this socket.",
127 .AddAttribute(
"WindowScaling",
128 "Enable or disable Window Scaling option",
132 .AddAttribute(
"Sack",
133 "Enable or disable Sack option",
137 .AddAttribute(
"Timestamp",
138 "Enable or disable Timestamp option",
144 "Minimum retransmit timeout value",
151 "Clock Granularity used in RTO calculations",
156 .AddAttribute(
"TxBuffer",
161 .AddAttribute(
"RxBuffer",
166 .AddAttribute(
"CongestionOps",
167 "Pointer to TcpCongestionOps object",
171 .AddAttribute(
"RecoveryOps",
172 "Pointer to TcpRecoveryOps object",
178 "Threshold for fast retransmit",
182 .AddAttribute(
"LimitedTransmit",
183 "Enable limited transmit",
187 .AddAttribute(
"UseEcn",
188 "Parameter to set ECN functionality",
197 .AddTraceSource(
"RTO",
198 "Retransmission timeout",
200 "ns3::TracedValueCallback::Time")
201 .AddTraceSource(
"RTT",
204 "ns3::TracedValueCallback::Time")
205 .AddTraceSource(
"LastRTT",
206 "RTT of the last (S)ACKed packet",
208 "ns3::TracedValueCallback::Time")
209 .AddTraceSource(
"NextTxSequence",
210 "Next sequence number to send (SND.NXT)",
212 "ns3::SequenceNumber32TracedValueCallback")
213 .AddTraceSource(
"HighestSequence",
214 "Highest sequence number ever sent in socket's life time",
216 "ns3::TracedValueCallback::SequenceNumber32")
217 .AddTraceSource(
"State",
220 "ns3::TcpStatesTracedValueCallback")
221 .AddTraceSource(
"CongState",
222 "TCP Congestion machine state",
224 "ns3::TcpSocketState::TcpCongStatesTracedValueCallback")
225 .AddTraceSource(
"EcnState",
226 "Trace ECN state change of socket",
228 "ns3::TcpSocketState::EcnStatesTracedValueCallback")
229 .AddTraceSource(
"AdvWND",
230 "Advertised Window Size",
232 "ns3::TracedValueCallback::Uint32")
233 .AddTraceSource(
"RWND",
234 "Remote side's flow control window",
236 "ns3::TracedValueCallback::Uint32")
237 .AddTraceSource(
"BytesInFlight",
238 "Socket estimation of bytes in flight",
240 "ns3::TracedValueCallback::Uint32")
241 .AddTraceSource(
"HighestRxSequence",
242 "Highest sequence number received from peer",
244 "ns3::TracedValueCallback::SequenceNumber32")
245 .AddTraceSource(
"HighestRxAck",
246 "Highest ack received from peer",
248 "ns3::TracedValueCallback::SequenceNumber32")
249 .AddTraceSource(
"PacingRate",
250 "The current TCP pacing rate",
252 "ns3::TracedValueCallback::DataRate")
253 .AddTraceSource(
"CongestionWindow",
254 "The TCP connection's congestion window",
256 "ns3::TracedValueCallback::Uint32")
257 .AddTraceSource(
"CongestionWindowInflated",
258 "The TCP connection's congestion window inflates as in older RFC",
260 "ns3::TracedValueCallback::Uint32")
261 .AddTraceSource(
"SlowStartThreshold",
262 "TCP slow start threshold (bytes)",
264 "ns3::TracedValueCallback::Uint32")
265 .AddTraceSource(
"Tx",
266 "Send tcp packet to IP protocol",
268 "ns3::TcpSocketBase::TcpTxRxTracedCallback")
269 .AddTraceSource(
"Retransmission",
270 "Notification of a TCP retransmission",
272 "ns3::TcpSocketBase::RetransmissionCallback")
273 .AddTraceSource(
"Rx",
274 "Receive tcp packet from IP protocol",
276 "ns3::TcpSocketBase::TcpTxRxTracedCallback")
277 .AddTraceSource(
"EcnEchoSeq",
278 "Sequence of last received ECN Echo",
280 "ns3::SequenceNumber32TracedValueCallback")
281 .AddTraceSource(
"EcnCeSeq",
282 "Sequence of last received CE",
284 "ns3::SequenceNumber32TracedValueCallback")
285 .AddTraceSource(
"EcnCwrSeq",
286 "Sequence of last received CWR",
288 "ns3::SequenceNumber32TracedValueCallback");
310 ok =
m_tcb->TraceConnectWithoutContext(
315 ok =
m_tcb->TraceConnectWithoutContext(
"CongestionWindow",
319 ok =
m_tcb->TraceConnectWithoutContext(
"CongestionWindowInflated",
323 ok =
m_tcb->TraceConnectWithoutContext(
"SlowStartThreshold",
327 ok =
m_tcb->TraceConnectWithoutContext(
"CongState",
331 ok =
m_tcb->TraceConnectWithoutContext(
"EcnState",
336 m_tcb->TraceConnectWithoutContext(
"NextTxSequence",
340 ok =
m_tcb->TraceConnectWithoutContext(
"HighestSequence",
344 ok =
m_tcb->TraceConnectWithoutContext(
"BytesInFlight",
351 ok =
m_tcb->TraceConnectWithoutContext(
"LastRTT",
359 m_dupAckCount(sock.m_dupAckCount),
361 m_delAckMaxCount(sock.m_delAckMaxCount),
362 m_noDelay(sock.m_noDelay),
363 m_synCount(sock.m_synCount),
364 m_synRetries(sock.m_synRetries),
365 m_dataRetrCount(sock.m_dataRetrCount),
366 m_dataRetries(sock.m_dataRetries),
368 m_minRto(sock.m_minRto),
369 m_clockGranularity(sock.m_clockGranularity),
370 m_delAckTimeout(sock.m_delAckTimeout),
371 m_persistTimeout(sock.m_persistTimeout),
372 m_cnTimeout(sock.m_cnTimeout),
374 m_endPoint6(nullptr),
377 m_state(sock.m_state),
378 m_errno(sock.m_errno),
379 m_closeNotified(sock.m_closeNotified),
380 m_closeOnEmpty(sock.m_closeOnEmpty),
381 m_shutdownSend(sock.m_shutdownSend),
382 m_shutdownRecv(sock.m_shutdownRecv),
383 m_connected(sock.m_connected),
385 m_maxWinSize(sock.m_maxWinSize),
386 m_bytesAckedNotProcessed(sock.m_bytesAckedNotProcessed),
388 m_highRxMark(sock.m_highRxMark),
389 m_highRxAckMark(sock.m_highRxAckMark),
390 m_sackEnabled(sock.m_sackEnabled),
391 m_winScalingEnabled(sock.m_winScalingEnabled),
392 m_rcvWindShift(sock.m_rcvWindShift),
393 m_sndWindShift(sock.m_sndWindShift),
394 m_timestampEnabled(sock.m_timestampEnabled),
395 m_timestampToEcho(sock.m_timestampToEcho),
396 m_recover(sock.m_recover),
397 m_recoverActive(sock.m_recoverActive),
398 m_retxThresh(sock.m_retxThresh),
399 m_limitedTx(sock.m_limitedTx),
400 m_isFirstPartialAck(sock.m_isFirstPartialAck),
401 m_txTrace(sock.m_txTrace),
402 m_rxTrace(sock.m_rxTrace),
403 m_pacingTimer(
Timer::CANCEL_ON_DESTROY),
404 m_ecnEchoSeq(sock.m_ecnEchoSeq),
405 m_ecnCESeq(sock.m_ecnCESeq),
406 m_ecnCWRSeq(sock.m_ecnCWRSeq)
446 if (
m_tcb->m_sendEmptyPacketCallback.IsNull())
453 ok =
m_tcb->TraceConnectWithoutContext(
457 ok =
m_tcb->TraceConnectWithoutContext(
"CongestionWindow",
461 ok =
m_tcb->TraceConnectWithoutContext(
"CongestionWindowInflated",
465 ok =
m_tcb->TraceConnectWithoutContext(
"SlowStartThreshold",
469 ok =
m_tcb->TraceConnectWithoutContext(
"CongState",
473 ok =
m_tcb->TraceConnectWithoutContext(
"EcnState",
478 m_tcb->TraceConnectWithoutContext(
"NextTxSequence",
482 ok =
m_tcb->TraceConnectWithoutContext(
"HighestSequence",
486 ok =
m_tcb->TraceConnectWithoutContext(
"BytesInFlight",
493 ok =
m_tcb->TraceConnectWithoutContext(
"LastRTT",
581 m_tcp->AddSocket(
this);
597 m_tcp->AddSocket(
this);
668 m_tcp->AddSocket(
this);
680 "TcpSocketBase::SetSSThresh() cannot change initial ssThresh after connection started.");
682 m_tcb->m_initialSsThresh = threshold;
688 return m_tcb->m_initialSsThresh;
696 "TcpSocketBase::SetInitialCwnd() cannot change initial cwnd after connection started.");
698 m_tcb->m_initialCWnd = cwnd;
704 return m_tcb->m_initialCWnd;
810 if (
m_tcb->m_rxBuffer->Size() != 0)
812 NS_LOG_WARN(
"Socket " <<
this <<
" << unread rx data during close. Sending reset."
813 <<
"This is probably due to a bad sink application; check its code");
879 NS_ABORT_MSG_IF(flags,
"use of flags is not supported in TcpSocketBase::Send()");
895 m_tcb->m_bytesInFlight,
896 m_tcb->m_segmentSize,
898 m_tcb->m_nextTxSequence,
928 return Send(p, flags);
937 NS_ABORT_MSG_IF(flags,
"use of flags is not supported in TcpSocketBase::Recv()");
953 if (packet && packet->GetSize() != 0)
986 return m_tcb->m_rxBuffer->Available();
1195 return (
m_tcb->m_rxBuffer->NextRxSequence() != head);
1199 return (tail < m_tcb->m_rxBuffer->NextRxSequence() ||
1200 m_tcb->m_rxBuffer->MaxRxSequence() <= head);
1220 uint32_t bytesRemoved = packet->PeekHeader(tcpHeader);
1224 packet->GetSize() - bytesRemoved))
1260 uint32_t bytesRemoved = packet->PeekHeader(tcpHeader);
1264 packet->GetSize() - bytesRemoved))
1297 m_icmpCallback(icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
1322 if (tcpHeaderSize == 0 || tcpHeaderSize > 60)
1324 NS_LOG_ERROR(
"Bytes removed: " << tcpHeaderSize <<
" invalid");
1327 else if (tcpPayloadSize > 0 &&
OutOfRange(seq, seq + tcpPayloadSize))
1331 <<
":" << seq + tcpPayloadSize <<
") out of range ["
1332 <<
m_tcb->m_rxBuffer->NextRxSequence() <<
":"
1333 <<
m_tcb->m_rxBuffer->MaxRxSequence() <<
")");
1346 packet->RemovePacketTag(priorityTag);
1350 packet->RemoveHeader(tcpHeader);
1430 << seq <<
":" << seq + packet->GetSize()
1431 <<
") without TS option. Silently discard it");
1447 NS_LOG_LOGIC(
this <<
" Enter zerowindow persist state");
1449 this <<
" Cancelled ReTxTimeout event which was set to expire at "
1514 NS_LOG_LOGIC(
this <<
" Leaving zerowindow persist state");
1540 <<
" SND.UNA = " <<
m_txBuffer->HeadSequence());
1550 <<
" HighTxMark = " <<
m_tcb->m_highTxMark);
1559 <<
" -> ECN_SENDING_ECE");
1586 else if (tcpflags == 0)
1589 if (
m_tcb->m_rxBuffer->Finished())
1599 <<
" received. Reset packet is sent.");
1634 switch (option->GetKind())
1668 NS_LOG_INFO(
"Enter CWR recovery mode; set cwnd to " <<
m_tcb->m_cWnd <<
", ssthresh to "
1669 <<
m_tcb->m_ssThresh <<
", recover to "
1719 <<
"Reset cwnd to " <<
m_tcb->m_cWnd <<
", ssthresh to "
1721 <<
" calculated in flight: " << bytesInFlight);
1726 NS_ASSERT_MSG(sz > 0,
"SendDataPacket returned zero, indicating zero bytes were sent");
1760 "From OPEN->DISORDER but with " <<
m_dupAckCount <<
" dup ACKs");
1856 uint64_t previousDelivered =
m_rateOps->GetConnectionRate().m_delivered;
1862 if (ackNumber < oldHeadSequence)
1864 NS_LOG_DEBUG(
"Possibly received a stale ACK (ack number < head sequence)");
1866 if (packet->GetSize() > 0)
1872 if ((ackNumber > oldHeadSequence) && (ackNumber <
m_recover) &&
1875 uint32_t segAcked = (ackNumber - oldHeadSequence) /
m_tcb->m_segmentSize;
1876 for (
uint32_t i = 0; i < segAcked; i++)
1878 if (
m_txBuffer->IsRetransmittedDataAcked(ackNumber - (i *
m_tcb->m_segmentSize)))
1880 m_tcb->m_isRetransDataAcked =
true;
1881 NS_LOG_DEBUG(
"Ack Number " << ackNumber <<
"is ACK of retransmitted packet.");
1888 auto currentDelivered =
1889 static_cast<uint32_t>(
m_rateOps->GetConnectionRate().m_delivered - previousDelivered);
1890 m_tcb->m_lastAckedSackedBytes = currentDelivered;
1928 NS_LOG_INFO(
"Update bytes in flight before processing the ACK.");
1931 bool receivedData = packet->GetSize() > 0;
1935 ProcessAck(ackNumber, (bytesSacked > 0), currentDelivered, oldHeadSequence, receivedData);
1936 m_tcb->m_isRetransDataAcked =
false;
1942 (currentLost > previousLost) ? currentLost - previousLost : previousLost - currentLost;
1943 auto rateSample =
m_rateOps->GenerateSample(currentDelivered,
1948 auto rateConn =
m_rateOps->GetConnectionRate();
1965 bool scoreboardUpdated,
1970 NS_LOG_FUNCTION(
this << ackNumber << scoreboardUpdated << currentDelivered << oldHeadSequence);
1974 bool exitedFastRecovery =
false;
1976 m_tcb->m_lastAckedSeq = ackNumber;
2000 : (ackNumber == oldHeadSequence &&
2001 ackNumber <
m_tcb->m_highTxMark && !receivedData);
2003 NS_LOG_DEBUG(
"ACK of " << ackNumber <<
" SND.UNA=" << oldHeadSequence
2004 <<
" SND.NXT=" <<
m_tcb->m_nextTxSequence
2016 DupAck(currentDelivered);
2019 if (ackNumber == oldHeadSequence && ackNumber ==
m_tcb->m_highTxMark)
2024 else if (ackNumber == oldHeadSequence && ackNumber >
m_tcb->m_highTxMark)
2028 NS_LOG_DEBUG(
"Update nextTxSequence manually to " << ackNumber);
2029 m_tcb->m_nextTxSequence = ackNumber;
2031 else if (ackNumber == oldHeadSequence)
2036 else if (ackNumber > oldHeadSequence)
2040 bytesAcked = currentDelivered;
2043 bytesAcked -= bytesAcked %
m_tcb->m_segmentSize;
2048 bytesAcked +=
m_tcb->m_segmentSize;
2052 <<
" based on currentDelivered: " << currentDelivered);
2083 NS_LOG_INFO(
"Partial ACK. Manually setting head as lost");
2095 if (!
m_txBuffer->IsRetransmittedDataAcked(ackNumber +
m_tcb->m_segmentSize))
2110 <<
" and this is the first (RTO will be reset);"
2120 <<
" and this is NOT the first (RTO will not be reset)"
2136 <<
" ssTh=" <<
m_tcb->m_ssThresh);
2141 "Some segment got dup-acked in CA_LOSS state: " <<
m_txBuffer->GetSacked());
2164 if (segsAcked >= oldDupAckCount)
2167 segsAcked - oldDupAckCount,
2177 NS_LOG_DEBUG(segsAcked <<
" segments acked in CA_DISORDER, ack of " << ackNumber
2178 <<
" exiting CA_DISORDER -> CA_OPEN");
2182 NS_LOG_DEBUG(segsAcked <<
" segments acked in CA_DISORDER, ack of " << ackNumber
2183 <<
" but still in CA_DISORDER");
2204 static_cast<uint32_t>(ackNumber - oldHeadSequence) /
m_tcb->m_segmentSize;
2209 exitedFastRecovery =
true;
2212 NS_LOG_DEBUG(segsAcked <<
" segments acked in CA_RECOVER, ack of " << ackNumber
2213 <<
", exiting CA_RECOVERY -> CA_OPEN");
2228 NS_LOG_DEBUG(segsAcked <<
" segments acked in CA_LOSS, ack of" << ackNumber
2229 <<
", exiting CA_LOSS -> CA_OPEN");
2240 if (exitedFastRecovery)
2245 NS_LOG_DEBUG(
"Leaving Fast Recovery; BytesInFlight() = "
2255 <<
" ssTh: " <<
m_tcb->m_ssThresh
2256 <<
" segsAcked: " << segsAcked);
2365 m_tcb->m_highTxMark = ++
m_tcb->m_nextTxSequence;
2397 <<
" received in SYN_SENT. Reset packet is sent.");
2417 if (tcpflags == 0 ||
2429 m_tcb->m_highTxMark = ++
m_tcb->m_nextTxSequence;
2481 m_tcb->m_highTxMark = ++
m_tcb->m_nextTxSequence;
2502 <<
" received. Reset packet is sent.");
2560 <<
" received. Reset packet is sent.");
2618 <<
" received. Reset packet is sent.");
2656 <<
" received. Reset packet is sent.");
2685 if (!
m_tcb->m_rxBuffer->Finished())
2720 NS_LOG_LOGIC(
"TCP " <<
this <<
" calling NotifyNormalClose");
2735 NS_LOG_LOGIC(
"TcpSocketBase " <<
this <<
" scheduling LATO1");
2750 m_tcp->RemoveSocket(
this);
2752 NS_LOG_LOGIC(
this <<
" Cancelled ReTxTimeout event which was set to expire at "
2766 m_tcp->RemoveSocket(
this);
2768 NS_LOG_LOGIC(
this <<
" Cancelled ReTxTimeout event which was set to expire at "
2781 NS_LOG_WARN(
"Failed to send empty packet due to null endpoint");
2897 NS_LOG_INFO(
"Sending a pure ACK, acking seq " <<
m_tcb->m_rxBuffer->NextRxSequence());
2904 m_tcp->SendPacket(p,
2912 m_tcp->SendPacket(p,
2921 NS_LOG_LOGIC(
"Schedule retransmission timeout at time "
2953 m_tcp->RemoveSocket(
this);
2961 m_tcp->RemoveSocket(
this);
2972 if (!ipv4->GetRoutingProtocol())
2983 route = ipv4->GetRoutingProtocol()->RouteOutput(
Ptr<Packet>(), header, oif, errno_);
3002 if (!ipv6->GetRoutingProtocol())
3013 route = ipv6->GetRoutingProtocol()->RouteOutput(
Ptr<Packet>(), header, oif, errno_);
3055 m_tcp->AddSocket(
this);
3118 p->AddPacketTag(ipTosTag);
3127 p->AddPacketTag(ipTosTag);
3144 p->AddPacketTag(ipTclassTag);
3153 p->AddPacketTag(ipTclassTag);
3161 p->AddPacketTag(ipTtlTag);
3168 p->AddPacketTag(ipHopLimitTag);
3176 p->ReplacePacketTag(priorityTag);
3190 m_rateOps->SkbSent(outItem, isStartOfTransmission);
3192 bool isRetransmission = outItem->
IsRetrans();
3210 <<
m_tcb->m_pacingRate.Get().CalculateBytesTxTime(sz));
3277 NS_LOG_LOGIC(
this <<
" SendDataPacket Schedule ReTxTimeout at time "
3284 if (isRetransmission)
3306 m_tcp->SendPacket(p,
3312 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
3317 m_tcp->SendPacket(p,
3323 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
3344 if (!isRetransmission)
3348 (seq + sz -
m_tcb->m_highTxMark.Get()));
3351 m_tcb->m_highTxMark = std::max(seq + sz,
m_tcb->m_highTxMark.Get());
3361 if (!isRetransmission)
3391 "TcpSocketBase::SendPendingData: No endpoint; m_shutdownSend=" <<
m_shutdownSend);
3403 while (availableWindow > 0)
3418 NS_LOG_INFO(
"FIN_WAIT and OPEN state; no data to transmit");
3429 if (!
m_txBuffer->NextSeg(&next, &nextHigh, enableRule3))
3431 NS_LOG_INFO(
"no valid seq to transmit, or no data available");
3441 if (availableData < availableWindow)
3448 if (availableWindow < m_tcb->m_segmentSize && availableData > availableWindow)
3450 NS_LOG_LOGIC(
"Preventing Silly Window Syndrome. Wait to send.");
3458 << next <<
", SFS: " <<
m_txBuffer->SizeFromSequence(next)
3459 <<
". Wait to send.");
3463 uint32_t s = std::min(availableWindow,
m_tcb->m_segmentSize);
3465 auto maxSizeToSend =
static_cast<uint32_t>(nextHigh - next);
3466 s = std::min(s, maxSizeToSend);
3477 if (
m_tcb->m_nextTxSequence != next)
3479 m_tcb->m_nextTxSequence = next;
3481 if (
m_tcb->m_bytesInFlight.Get() == 0)
3488 <<
" highestRxAck " <<
m_txBuffer->HeadSequence() <<
" pd->Size "
3493 <<
" sent seq " <<
m_tcb->m_nextTxSequence <<
" size " << sz);
3494 m_tcb->m_nextTxSequence += sz;
3503 <<
m_tcb->m_pacingRate.Get().CalculateBytesTxTime(sz));
3521 if (nPacketsSent > 0)
3532 NS_LOG_DEBUG(
"SendPendingData sent " << nPacketsSent <<
" segments");
3538 return nPacketsSent;
3553 m_tcb->m_bytesInFlight = bytesInFlight;
3555 NS_LOG_DEBUG(
"Returning calculated bytesInFlight: " << bytesInFlight);
3556 return bytesInFlight;
3570 return (inflight > win) ? 0 : win - inflight;
3581 if (
m_tcb->m_rxBuffer->GotFin())
3588 "Unexpected sequence number values");
3589 w =
static_cast<uint32_t>(
m_tcb->m_rxBuffer->MaxRxSequence() -
3590 m_tcb->m_rxBuffer->NextRxSequence());
3607 <<
m_maxWinSize <<
"; possibly to avoid overflow of the 16-bit integer");
3609 NS_LOG_LOGIC(
"Returning AdvertisedWindowSize of " <<
static_cast<uint16_t
>(w));
3610 return static_cast<uint16_t
>(w);
3619 <<
" pkt size=" << p->GetSize());
3623 if (!
m_tcb->m_rxBuffer->Add(p, tcpHeader))
3639 if (expectedSeq < m_tcb->m_rxBuffer->NextRxSequence())
3648 NS_LOG_WARN(
"Why TCP " <<
this <<
" got data after close notification?");
3659 if (
m_tcb->m_rxBuffer->Size() >
m_tcb->m_rxBuffer->Available() ||
3660 m_tcb->m_rxBuffer->NextRxSequence() > expectedSeq + p->GetSize())
3688 <<
" -> ECN_SENDING_ECE");
3706 this <<
" scheduled delayed ACK at "
3736 NS_LOG_LOGIC(
"TcpSocketBase::EstimateRtt - RTT calculated from TcpOption::TS "
3737 "is zero, approximating to 1us.");
3738 NS_LOG_DEBUG(
"RTT calculated from TcpOption::TS is zero, updating rtt to 1us.");
3742 else if (!rttHistory.
retx)
3767 RttHistory latestTransmittedPktHistory = earliestTransmittedPktHistory;
3778 latestTransmittedPktHistory = rttHistory;
3788 NS_LOG_DEBUG(
"Last RTT sample updated to: " << lastRtt);
3789 m_tcb->m_lastRtt = lastRtt;
3795 m_rtt->Measurement(rtt);
3819 this <<
" Cancelled ReTxTimeout event which was set to expire at "
3828 <<
" to expire at time "
3834 NS_LOG_LOGIC(
"TCP " <<
this <<
" NewAck " << ack <<
" numberAck "
3841 if (ack >
m_tcb->m_nextTxSequence)
3843 m_tcb->m_nextTxSequence = ack;
3848 this <<
" Cancelled ReTxTimeout event which was set to expire at "
3896 <<
m_tcb->m_highTxMark);
3902 NS_LOG_INFO(
"No more data retries available. Dropping connection");
3972 <<
", restart from seqnum " <<
m_txBuffer->HeadSequence()
3973 <<
" doubled rto to " <<
m_rto.Get().GetSeconds() <<
" s");
3976 "There are some bytes in flight after an RTO: " <<
BytesInFlight());
3981 "In flight (" <<
BytesInFlight() <<
") there is more than one segment ("
3982 <<
m_tcb->m_segmentSize <<
")");
4012 NS_LOG_INFO(
"LAST-ACK: No more data retries available. Dropping connection");
4019 NS_LOG_LOGIC(
"TcpSocketBase " <<
this <<
" rescheduling LATO1");
4060 m_tcp->SendPacket(p,
4068 m_tcp->SendPacket(p,
4092 res =
m_txBuffer->NextSeg(&seq, &seqHigh,
false);
4099 maxSizeToSend =
m_tcb->m_segmentSize;
4104 maxSizeToSend =
static_cast<uint32_t>(seqHigh - seq);
4110 m_tcb->m_nextTxSequence = seq;
4169 m_tcb->m_rxBuffer->SetMaxBufferSize(size);
4193 return m_tcb->m_rxBuffer->MaxBufferSize();
4200 m_tcb->m_segmentSize = size;
4209 return m_tcb->m_segmentSize;
4308 return (!allowBroadcast);
4358 maxSpace = maxSpace >> 1;
4364 NS_LOG_WARN(
"Possible error; scale exceeds 14: " << scale);
4369 <<
static_cast<int>(scale) <<
" for buffer size "
4370 <<
m_tcb->m_rxBuffer->MaxBufferSize());
4432 uint8_t allowedSackBlocks = (optionLenAvail - 2) / 8;
4435 if (allowedSackBlocks == 0 || sackList.empty())
4437 NS_LOG_LOGIC(
"No space available or sack list empty, not adding sack blocks");
4444 for (
auto i = sackList.begin(); allowedSackBlocks > 0 && i != sackList.end(); ++i)
4446 option->AddSackBlock(*i);
4447 allowedSackBlocks--;
4464 if (
m_tcb->m_rcvTimestampValue > ts->GetTimestamp())
4470 m_tcb->m_rcvTimestampValue = ts->GetTimestamp();
4471 m_tcb->m_rcvTimestampEchoReply = ts->GetEcho();
4479 <<
" and Echo=" << ts->GetEcho());
4505 NS_LOG_INFO(
"Received (scaled) window is " << receivedWindow <<
" bytes");
4519 bool update =
false;
4577 return m_tcb->m_rxBuffer;
4700 if (!
m_tcb->m_pacing)
4706 if (
m_tcb->m_paceInitialWindow)
4745 <<
m_tcb->m_ssThresh);
4746 factor =
static_cast<double>(
m_tcb->m_pacingSsRatio) / 100;
4750 NS_LOG_DEBUG(
"Pacing according to congestion avoidance factor; " <<
m_tcb->m_cWnd <<
" "
4751 <<
m_tcb->m_ssThresh);
4752 factor =
static_cast<double>(
m_tcb->m_pacingCaRatio) / 100;
4760 if (pacingRate < m_tcb->m_maxPacingRate)
4762 NS_LOG_DEBUG(
"Pacing rate updated to: " << pacingRate);
4763 m_tcb->m_pacingRate = pacingRate;
4768 m_tcb->m_pacingRate =
m_tcb->m_maxPacingRate;
4776 m_tcb->m_pacing = pacing;
4783 m_tcb->m_paceInitialWindow = paceWindow;
4797 "Invalid packetType and ecnMode");
4799 return ECN_RESTRICTION_MAP.at(std::make_pair(packetType,
m_tcb->m_ecnMode));
4806 m_tcb->m_useEcn = useEcn;
a polymophic address class
AttributeValue implementation for Boolean.
AttributeValue implementation for Callback.
Class for representing data rates.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsPending() const
This method is syntactic sugar for !IsExpired().
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
uint16_t GetPort() const
Get the port.
static bool IsMatchingType(const Address &addr)
If the address match.
Ipv6Address GetIpv6() const
Get the IPv6 address.
static bool IsMatchingType(const Address &address)
Ipv4Address GetIpv4() const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetZero()
static Ipv4Address GetAny()
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
Ipv4Address GetLocalAddress() const
Get the local address.
void SetLocalAddress(Ipv4Address address)
Set the local address.
uint16_t GetPeerPort() const
Get the peer port.
uint16_t GetLocalPort() const
Get the local port.
Ipv4Address GetPeerAddress() const
Get the peer address.
void SetIcmpCallback(Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > callback)
Set the ICMP callback.
void SetPeer(Ipv4Address address, uint16_t port)
Set the peer information (address and port).
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > callback)
Set the reception callback.
Access to the IPv4 forwarding table, interfaces, and configuration.
Describes an IPv6 address.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
bool IsIpv4MappedAddress() const
If the address is an IPv4-mapped address.
Ipv4Address GetIpv4MappedAddress() const
Return the Ipv4 address.
uint16_t GetLocalPort() const
Get the local port.
void SetPeer(Ipv6Address addr, uint16_t port)
Set the peer information (address and port).
Ipv6Address GetPeerAddress() const
Get the peer address.
void SetIcmpCallback(Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > callback)
Set the ICMP callback.
Ipv6Address GetLocalAddress() const
Get the local address.
void SetLocalAddress(Ipv6Address addr)
Set the local address.
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv6Header, uint16_t, Ptr< Ipv6Interface > > callback)
Set the reception callback.
uint16_t GetPeerPort() const
Get the peer port.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
IPv6 layer implementation.
friend Ptr< T > CopyObject(Ptr< T > object)
Copy an Object.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
Helper class to store RTT measurements.
uint32_t count
Number of bytes sent.
RttHistory(SequenceNumber32 s, uint32_t c, Time t)
Constructor - builds an RttHistory with the given parameters.
bool retx
True if this has been retransmitted.
Time time
Time this one was sent.
SequenceNumber32 seq
First sequence number in packet sent.
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound NetDevice, if any.
Ptr< Packet > Recv()
Read a single packet from the socket.
void SetConnectCallback(Callback< void, Ptr< Socket > > connectionSucceeded, Callback< void, Ptr< Socket > > connectionFailed)
Specify callbacks to allow the caller to determine if the connection succeeds of fails.
bool IsManualIpTtl() const
Checks if the socket has a specific IPv4 TTL set.
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
void NotifyNewConnectionCreated(Ptr< Socket > socket, const Address &from)
Notify through the callback (if set) that a new connection has been created.
virtual uint8_t GetIpTtl() const
Query the value of IP Time to Live field of this socket.
bool NotifyConnectionRequest(const Address &from)
Notify through the callback (if set) that an incoming connection is being requested by a remote host.
uint8_t GetIpTos() const
Query the value of IP Type of Service of this socket.
SocketType
Enumeration of the possible socket types.
void SetDataSentCallback(Callback< void, Ptr< Socket >, uint32_t > dataSent)
Notify application when a packet has been sent from transport protocol (non-standard socket call)
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
void NotifyErrorClose()
Notify through the callback (if set) that the connection has been closed due to an error.
void NotifyDataRecv()
Notify through the callback (if set) that some data have been received.
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void NotifyNormalClose()
Notify through the callback (if set) that the connection has been closed.
virtual uint8_t GetIpv6HopLimit() const
Query the value of IP Hop Limit field of this socket.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
SocketErrno
Enumeration of the possible errors returned by a socket.
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
void NotifyConnectionSucceeded()
Notify through the callback (if set) that the connection has been established.
uint8_t GetPriority() const
Query the priority value of this socket.
uint8_t GetIpv6Tclass() const
Query the value of IPv6 Traffic Class field of this socket.
bool IsManualIpv6HopLimit() const
Checks if the socket has a specific IPv6 Hop Limit set.
bool IsManualIpv6Tclass() const
Checks if the socket has a specific IPv6 Tclass set.
void NotifyConnectionFailed()
Notify through the callback (if set) that the connection has not been established due to an error.
indicates whether the socket has IP_TOS set.
void SetTos(uint8_t tos)
Set the tag's TOS.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
indicates whether the socket has IPV6_TCLASS set.
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
indicates whether the socket has a priority set.
void SetPriority(uint8_t priority)
Set the tag's priority.
@ SACKPERMITTED
SACKPERMITTED.
std::list< SackBlock > SackList
SACK list definition.
static Time ElapsedTimeFromTsValue(uint32_t echoTime)
Estimate the Time elapsed from a TS echo value.
static uint32_t NowToTsValue()
Return an uint32_t value which represent "now".
virtual void SkbDelivered(TcpTxItem *skb)=0
Update the Rate information after an item is received.
A base class for implementation of a stream socket using TCP.
void AddOptionSack(TcpHeader &header)
Add the SACK option to the header.
int GetSockName(Address &address) const override
Get socket address.
Time m_persistTimeout
Time between sending 1-byte probes.
uint16_t m_maxWinSize
Maximum window size to advertise.
uint8_t m_rcvWindShift
Window shift to apply to outgoing segments.
void SetPaceInitialWindow(bool paceWindow)
Enable or disable pacing of the initial window.
int Bind6() override
Allocate a local IPv6 endpoint for this socket.
void TimeWait()
Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state.
Ptr< TcpCongestionOps > m_congestionControl
Congestion control.
void AddSocketTags(const Ptr< Packet > &p, bool isEct) const
Add Tags for the Socket.
Ptr< TcpTxBuffer > GetTxBuffer() const
Get a pointer to the Tx buffer.
int SetupEndpoint()
Configure the endpoint to a local address.
virtual void LastAckTimeout()
Timeout at LAST_ACK, close the connection.
void ProcessEstablished(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon ESTABLISHED state.
Time m_minRto
minimum value of the Retransmit timeout
uint32_t SendPendingData(bool withAck=false)
Send as much pending data as possible according to the Tx window.
TracedValue< uint32_t > m_advWnd
Advertised Window size.
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_txTrace
Trace of transmitted packets.
SequenceNumber32 m_recover
Previous highest Tx seqnum for fast recovery (set it to initial seq number)
bool m_recoverActive
Whether "m_recover" has been set/activated It is used to avoid comparing with the old m_recover value...
void DoRetransmit()
Retransmit the first segment marked as lost, without considering available window nor pacing.
bool CheckNoEcn(uint8_t tos) const
Checks if TOS has no ECN codepoints.
virtual void SetNode(Ptr< Node > node)
Set the associated node.
int ShutdownRecv() override
uint8_t m_sndWindShift
Window shift to apply to incoming segments.
Ptr< TcpL4Protocol > m_tcp
the associated TCP L4 protocol
Ptr< TcpSocketState > m_tcb
Congestion control information.
bool GetAllowBroadcast() const override
Query whether broadcast datagram transmissions are allowed.
void UpdateSsThresh(uint32_t oldValue, uint32_t newValue) const
Callback function to hook to TcpSocketState slow start threshold.
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_rxTrace
Trace of received packets.
virtual void SetTcp(Ptr< TcpL4Protocol > tcp)
Set the associated TCP L4 protocol.
void EnterRecovery(uint32_t currentDelivered)
Enter the CA_RECOVERY, and retransmit the head.
Time GetMinRto() const
Get the Minimum RTO.
void ProcessSynSent(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon SYN_SENT.
void ForwardUp(Ptr< Packet > packet, Ipv4Header header, uint16_t port, Ptr< Ipv4Interface > incomingInterface)
Called by the L3 protocol when it received a packet to pass on to TCP.
bool SetAllowBroadcast(bool allowBroadcast) override
Configure whether broadcast datagram transmissions are allowed.
void CancelAllTimers()
Cancel all timer when endpoint is deleted.
Time GetDelAckTimeout() const override
Get the time to delay an ACK.
Ptr< TcpRecoveryOps > m_recoveryOps
Recovery Algorithm.
TracedCallback< uint32_t, uint32_t > m_bytesInFlightTrace
Callback pointer for bytesInFlight trace chaining.
uint32_t GetInitialSSThresh() const override
Get the initial Slow Start Threshold.
void NotifyPacingPerformed()
Notify Pacing.
void SetDelAckTimeout(Time timeout) override
Set the time to delay an ACK.
void CloseAndNotify()
Peacefully close the socket by notifying the upper layer and deallocate end point.
Ptr< TcpRateOps > m_rateOps
Rate operations.
void PeerClose(Ptr< Packet > p, const TcpHeader &tcpHeader)
Received a FIN from peer, notify rx buffer.
int Close() override
Close a socket.
bool m_shutdownSend
Send no longer allowed.
bool IsPacingEnabled() const
Return true if packets in the current window should be paced.
void ProcessOptionWScale(const Ptr< const TcpOption > option)
Read and parse the Window scale option.
bool m_closeOnEmpty
Close socket upon tx buffer emptied.
virtual void ReTxTimeout()
An RTO event happened.
void AddOptionSackPermitted(TcpHeader &header)
Add the SACK PERMITTED option to the header.
TracedValue< Time > m_rto
Retransmit timeout.
uint32_t GetSndBufSize() const override
Get the send buffer size.
virtual void ReceivedData(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Recv of a data, put into buffer, call L7 to get it if necessary.
EventId m_timewaitEvent
TIME_WAIT expiration event: Move this socket to CLOSED state.
Ptr< TcpTxBuffer > m_txBuffer
Tx buffer.
static TypeId GetTypeId()
Get the type ID.
uint32_t m_dupAckCount
Dupack counter.
void SetRetxThresh(uint32_t retxThresh)
Set the retransmission threshold (dup ack threshold for a fast retransmit)
int Send(Ptr< Packet > p, uint32_t flags) override
Send data (or dummy data) to the remote host.
TracedCallback< SequenceNumber32, SequenceNumber32 > m_nextTxSequenceTrace
Callback pointer for next tx sequence chaining.
void UpdateBytesInFlight(uint32_t oldValue, uint32_t newValue) const
Callback function to hook to TcpSocketState bytes inflight.
EventId m_delAckEvent
Delayed ACK timeout event.
TracedCallback< Time, Time > m_lastRttTrace
Callback pointer for Last RTT trace chaining.
bool GetTcpNoDelay() const override
Check if Nagle's algorithm is enabled or not.
virtual void SetRtt(Ptr< RttEstimator > rtt)
Set the associated RTT estimator.
TracedCallback< uint32_t, uint32_t > m_cWndTrace
Callback pointer for cWnd trace chaining.
void UpdatePacingRateTrace(DataRate oldValue, DataRate newValue) const
Callback function to hook to TcpSocketState pacing rate.
void SetDataRetries(uint32_t retries) override
Set the number of data transmission retries before giving up.
void AddOptions(TcpHeader &tcpHeader)
Add options to TcpHeader.
TracedCallback< TcpSocketState::EcnState_t, TcpSocketState::EcnState_t > m_ecnStateTrace
Callback pointer for ECN state trace chaining.
void SetSynRetries(uint32_t count) override
Set the number of connection retries before giving up.
void ProcessWait(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon CLOSE_WAIT, FIN_WAIT_1, FIN_WAIT_2.
SequenceNumber32 m_highTxAck
Highest ack sent.
uint32_t GetTxAvailable() const override
Returns the number of bytes which can be sent in a single call to Send.
bool m_timestampEnabled
Timestamp option enabled.
virtual void PersistTimeout()
Send 1 byte probe to get an updated window size.
TracedValue< TcpStates_t > m_state
TCP state.
int SetupCallback()
Common part of the two Bind(), i.e.
Ptr< RttEstimator > m_rtt
Round trip time estimator.
Timer m_pacingTimer
Pacing Event.
EventId m_retxEvent
Retransmission event.
uint32_t m_bytesAckedNotProcessed
Bytes acked, but not processed.
void AddOptionTimestamp(TcpHeader &header)
Add the timestamp option to the header.
virtual uint32_t BytesInFlight() const
Return total bytes in flight.
uint32_t GetSegSize() const override
Get the segment size.
virtual void ProcessAck(const SequenceNumber32 &ackNumber, bool scoreboardUpdated, uint32_t currentDelivered, const SequenceNumber32 &oldHeadSequence, bool receivedData)
Process a received ack.
int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress) override
Send data to a specified peer.
uint32_t m_dataRetries
Number of data retransmission attempts.
double m_msl
Max segment lifetime.
void ProcessLastAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon LAST_ACK.
bool m_limitedTx
perform limited transmit
virtual uint32_t SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, bool withAck)
Extract at most maxSize bytes from the TxBuffer at sequence seq, add the TCP header,...
TracedCallback< TcpSocketState::TcpCongState_t, TcpSocketState::TcpCongState_t > m_congStateTrace
Callback pointer for congestion state trace chaining.
void ProcessSynRcvd(Ptr< Packet > packet, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Received a packet upon SYN_RCVD.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received an ACK packet.
SocketType GetSocketType() const override
int ShutdownSend() override
TracedValue< SequenceNumber32 > m_ecnCWRSeq
Sequence number of the last sent CWR.
Time GetPersistTimeout() const override
Get the timeout for persistent connection.
void UpdateCwnd(uint32_t oldValue, uint32_t newValue) const
Callback function to hook to TcpSocketState congestion window.
void UpdateLastRtt(Time oldValue, Time newValue) const
Callback function to hook to TcpSocketState lastRtt.
TracedCallback< Ptr< const Packet >, const TcpHeader &, const Address &, const Address &, Ptr< const TcpSocketBase > > m_retransmissionTrace
Trace of retransmitted packets.
uint32_t m_delAckCount
Delayed ACK counter.
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
TcpPacketType_t
Tcp Packet Types.
static uint32_t SafeSubtraction(uint32_t a, uint32_t b)
Performs a safe subtraction between a and b (a-b)
virtual void DelAckTimeout()
Action upon delay ACK timeout, i.e.
Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress) override
Read a single packet from the socket and retrieve the sender address.
Time m_cnTimeout
Timeout for connection retry.
Time GetClockGranularity() const
Get the Clock Granularity (used in RTO calcs).
bool m_winScalingEnabled
Window Scale option enabled (RFC 7323)
void UpdateEcnState(TcpSocketState::EcnState_t oldValue, TcpSocketState::EcnState_t newValue) const
Callback function to hook to EcnState state.
EventId m_sendPendingDataEvent
micro-delay event to send pending data
uint32_t m_delAckMaxCount
Number of packet to fire an ACK before delay timeout.
uint8_t CalculateWScale() const
Calculate window scale value based on receive buffer space.
virtual void NewAck(const SequenceNumber32 &seq, bool resetRTO)
Update buffers w.r.t.
bool m_closeNotified
Told app to close socket.
int Listen() override
Listen for incoming connections.
void Destroy6()
Kill this socket by zeroing its attributes (IPv6)
bool IsEct(TcpPacketType_t packetType) const
Checks if a TCP packet should be ECN-capable (ECT) according to the TcpPacketType and ECN mode.
TracedValue< SequenceNumber32 > m_ecnCESeq
Sequence number of the last received Congestion Experienced.
void SetClockGranularity(Time clockGranularity)
Sets the Clock Granularity (used in RTO calcs).
bool IsValidTcpSegment(const SequenceNumber32 seq, const uint32_t tcpHeaderSize, const uint32_t tcpPayloadSize)
Checks whether the given TCP segment is valid or not.
Time m_clockGranularity
Clock Granularity used in RTO calcs.
void DupAck(uint32_t currentDelivered)
Dupack management.
bool m_shutdownRecv
Receive no longer allowed.
void UpdateCongState(TcpSocketState::TcpCongState_t oldValue, TcpSocketState::TcpCongState_t newValue) const
Callback function to hook to TcpSocketState congestion state.
virtual uint32_t Window() const
Return the max possible number of unacked bytes.
Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback6
ICMPv6 callback.
std::deque< RttHistory > m_history
List of sent packet.
void ProcessOptionSackPermitted(const Ptr< const TcpOption > option)
Read the SACK PERMITTED option.
int Bind() override
Allocate a local IPv4 endpoint for this socket.
virtual uint32_t AvailableWindow() const
Return unfilled portion of window.
TracedValue< SequenceNumber32 > m_highRxMark
Highest seqno received.
void ReadOptions(const TcpHeader &tcpHeader, uint32_t *bytesSacked)
Read TCP options before Ack processing.
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
void ForwardUp6(Ptr< Packet > packet, Ipv6Header header, uint16_t port, Ptr< Ipv6Interface > incomingInterface)
Called by the L3 protocol when it received a packet to pass on to TCP.
bool m_connected
Connection established.
TracedValue< SequenceNumber32 > m_highRxAckMark
Highest ack received.
void AddOptionWScale(TcpHeader &header)
Add the window scale option to the header.
virtual void SendEmptyPacket(uint8_t flags)
Send a empty packet that carries a flag, e.g., ACK.
void UpdateWindowSize(const TcpHeader &header)
Update the receiver window (RWND) based on the value of the window field in the header.
uint32_t GetRxAvailable() const override
Return number of bytes which can be returned from one or multiple calls to Recv.
uint32_t GetDataRetries() const override
Get the number of data transmission retries before giving up.
int SetupEndpoint6()
Configure the endpoint v6 to a local address.
uint32_t GetRetxThresh() const
Get the retransmission threshold (dup ack threshold for a fast retransmit)
void DeallocateEndPoint()
Deallocate m_endPoint and m_endPoint6.
void Destroy()
Kill this socket by zeroing its attributes (IPv4)
void UpdateHighTxMark(SequenceNumber32 oldValue, SequenceNumber32 newValue) const
Callback function to hook to TcpSocketState high tx mark.
TcpSocketBase()
Create an unbound TCP socket.
void SetInitialSSThresh(uint32_t threshold) override
Set the initial Slow Start Threshold.
TracedCallback< DataRate, DataRate > m_pacingRateTrace
Callback pointer for pacing rate trace chaining.
uint32_t m_timestampToEcho
Timestamp to echo.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
void SetSndBufSize(uint32_t size) override
Set the send buffer size.
virtual Ptr< TcpSocketBase > Fork()
Call CopyObject<> to clone me.
TracedCallback< uint32_t, uint32_t > m_ssThTrace
Callback pointer for ssTh trace chaining.
SocketErrno m_errno
Socket error code.
SocketErrno GetErrno() const override
Get last error number.
virtual void CompleteFork(Ptr< Packet > p, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Complete a connection by forking the socket.
void ProcessClosing(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon CLOSING.
TracedCallback< SequenceNumber32, SequenceNumber32 > m_highTxMarkTrace
Callback pointer for high tx mark chaining.
int Connect(const Address &address) override
Initiate a connection to a remote host.
Ptr< Node > m_node
the associated node
void SetSegSize(uint32_t size) override
Set the segment size.
uint32_t m_synRetries
Number of connection attempts.
void SetConnTimeout(Time timeout) override
Set the connection timeout.
void SetDelAckMaxCount(uint32_t count) override
Set the number of packet to fire an ACK before delay timeout.
EventId m_lastAckEvent
Last ACK timeout event.
bool IsTcpOptionEnabled(uint8_t kind) const
Return true if the specified option is enabled.
void UpdatePacingRate()
Dynamically update the pacing rate.
EventId m_persistEvent
Persist event: Send 1 byte to probe for a non-zero Rx window.
void SetPacingStatus(bool pacing)
Enable or disable pacing.
void UpdateRtt(Time oldValue, Time newValue) const
Callback function to hook to TcpSocketState rtt.
void SetCongestionControlAlgorithm(Ptr< TcpCongestionOps > algo)
Install a congestion control algorithm on this socket.
int GetPeerName(Address &address) const override
Get the peer address of a connected socket.
virtual uint32_t UnAckDataCount() const
Return count of number of unacked bytes.
uint32_t m_dataRetrCount
Count of remaining data retransmission attempts.
void UpdateCwndInfl(uint32_t oldValue, uint32_t newValue) const
Callback function to hook to TcpSocketState inflated congestion window.
Ptr< TcpRxBuffer > GetRxBuffer() const
Get a pointer to the Rx buffer.
void SetPersistTimeout(Time timeout) override
Set the timeout for persistent connection.
void ConnectionSucceeded()
Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
bool m_noDelay
Set to true to disable Nagle's algorithm.
uint32_t GetDelAckMaxCount() const override
Get the number of packet to fire an ACK before delay timeout.
void ForwardIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
Called by the L3 protocol when it received an ICMP packet to pass on to TCP.
void ForwardIcmp6(Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
Called by the L3 protocol when it received an ICMPv6 packet to pass on to TCP.
virtual void DoForwardUp(Ptr< Packet > packet, const Address &fromAddress, const Address &toAddress)
Called by TcpSocketBase::ForwardUp{,6}().
bool m_isFirstPartialAck
First partial ACK during RECOVERY.
uint8_t MarkEcnCodePoint(const uint8_t tos, const TcpSocketState::EcnCodePoint_t codePoint) const
mark ECN code point
Time m_delAckTimeout
Time to delay an ACK.
Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback
ICMP callback.
TracedCallback< Time, Time > m_srttTrace
Callback pointer for RTT trace chaining.
void SetInitialCwnd(uint32_t cwnd) override
Set the initial Congestion Window.
void SetUseEcn(TcpSocketState::UseEcn_t useEcn)
Set ECN mode of use on the socket.
void ProcessListen(Ptr< Packet > packet, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Received a packet upon LISTEN state.
uint32_t m_synCount
Count of remaining connection retries.
int DoConnect()
Perform the real connection tasks: Send SYN if allowed, RST if invalid.
virtual Time CalculateRttSample(const TcpHeader &tcpHeader, const RttHistory &rttHistory)
Calculate RTT sample for the ACKed packet.
uint32_t GetSynRetries() const override
Get the number of connection retries before giving up.
void DoPeerClose()
FIN is in sequence, notify app and respond with a FIN.
void SendRST()
Send reset and tear down this socket.
bool OutOfRange(SequenceNumber32 head, SequenceNumber32 tail) const
Check if a sequence number range is within the rx window.
TracedValue< SequenceNumber32 > m_ecnEchoSeq
Sequence number of the last received ECN Echo.
uint32_t m_retxThresh
Fast Retransmit threshold.
uint32_t GetRWnd() const
Get the current value of the receiver's offered window (RCV.WND)
SequenceNumber32 GetHighRxAck() const
Get the current value of the receiver's highest (in-sequence) sequence number acked.
void BindToNetDevice(Ptr< NetDevice > netdevice) override
Bind a socket to specific device.
void EnterCwr(uint32_t currentDelivered)
Enter CA_CWR state upon receipt of an ECN Echo.
virtual void EstimateRtt(const TcpHeader &tcpHeader)
Take into account the packet for RTT estimation.
uint32_t GetInitialCwnd() const override
Get the initial Congestion Window.
TracedValue< uint32_t > m_rWnd
Receiver window (RCV.WND in RFC793)
void ProcessOptionTimestamp(const Ptr< const TcpOption > option, const SequenceNumber32 &seq)
Process the timestamp option from other side.
void SetRcvBufSize(uint32_t size) override
Set the receive buffer size.
void SetTcpNoDelay(bool noDelay) override
Enable/Disable Nagle's algorithm.
virtual void UpdateRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
Update the RTT history, when we send TCP segments.
bool m_sackEnabled
RFC SACK option enabled.
void UpdateNextTxSequence(SequenceNumber32 oldValue, SequenceNumber32 newValue) const
Callback function to hook to TcpSocketState next tx sequence.
void SetMinRto(Time minRto)
Sets the Minimum RTO.
Time GetConnTimeout() const override
Get the connection timeout.
Ptr< Node > GetNode() const override
Return the node this socket is associated with.
uint32_t ProcessOptionSack(const Ptr< const TcpOption > option)
Read the SACK option.
void SetRecoveryAlgorithm(Ptr< TcpRecoveryOps > recovery)
Install a recovery algorithm on this socket.
~TcpSocketBase() override
int DoClose()
Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state.
TracedCallback< uint32_t, uint32_t > m_cWndInflTrace
Callback pointer for cWndInfl trace chaining.
uint32_t GetRcvBufSize() const override
Get the receive buffer size.
(abstract) base class of all TcpSockets
static const char *const TcpStateName[TcpSocket::LAST_STATE]
Literal names of TCP states for use in log messages.
@ CA_EVENT_ECN_IS_CE
received CE marked IP packet.
@ CA_EVENT_ECN_NO_CE
ECT set, but not CE marked.
@ CA_EVENT_DELAYED_ACK
Delayed ack is sent.
@ CA_EVENT_NON_DELAYED_ACK
Non-delayed ack is sent.
@ CA_EVENT_COMPLETE_CWR
end of congestion recovery
@ CA_EVENT_LOSS
loss timeout
@ CA_EVENT_TX_START
first transmit when no packets in flight
UseEcn_t
Parameter value related to ECN enable/disable functionality similar to sysctl for tcp_ecn.
@ AcceptOnly
Enable only when the peer endpoint is ECN capable.
static INTERNET_EXPORT const char *const TcpCongStateName[TcpSocketState::CA_LAST_STATE]
Literal names of TCP states for use in log messages.
TcpCongState_t
Definition of the Congestion state machine.
@ CA_RECOVERY
CWND was reduced, we are fast-retransmitting.
@ CA_DISORDER
In all the respects it is "Open", but requires a bit more attention.
@ CA_CWR
cWnd was reduced due to some congestion notification event, such as ECN, ICMP source quench,...
@ CA_LOSS
CWND was reduced due to RTO timeout or SACK reneging.
@ CA_OPEN
Normal state, no dubious events.
@ DctcpEcn
ECN functionality as described in RFC 8257.
@ ClassicEcn
ECN functionality as described in RFC 3168.
EcnState_t
Definition of the Ecn state machine.
@ ECN_CWR_SENT
Sender has reduced the congestion window, and sent a packet with CWR bit set in TCP header.
@ ECN_DISABLED
ECN disabled traffic.
@ ECN_ECE_RCVD
Last ACK received had ECE bit set in TCP header.
@ ECN_IDLE
ECN is enabled but currently there is no action pertaining to ECE or CWR to be taken.
@ ECN_CE_RCVD
Last packet received had CE bit set in IP header.
@ ECN_SENDING_ECE
Receiver sends an ACK with ECE bit set in TCP header.
static INTERNET_EXPORT const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
Item that encloses the application packet and some flags for it.
Ptr< Packet > GetPacketCopy() const
Get a copy of the Packet underlying this item.
bool IsRetrans() const
Is the item retransmitted?
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
static Time FromDouble(double value, Unit unit)
Create a Time equal to value in unit unit.
bool IsZero() const
Exactly equivalent to t == 0.
AttributeValue implementation for Time.
A simple virtual Timer class.
Time GetDelayLeft() const
void Cancel()
Cancel the currently-running event if there is one.
void Schedule()
Schedule a new event using the currently-configured delay, function, and arguments.
T Get() const
Get the underlying value.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeCallbackAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeCallbackChecker()
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Callback< R, Args... > MakeNullCallback()
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number.
@ ESTABLISHED
Connection established
@ FIN_WAIT_2
All buffered data sent, waiting for remote to shutdown.
@ LISTEN
Listening for a connection
@ CLOSE_WAIT
Remote side has shutdown and is waiting for us to finish writing our data and to shutdown (we have to...
@ SYN_SENT
Sent a connection request, waiting for ack
@ CLOSED
Socket is finished
@ FIN_WAIT_1
Our side has shutdown, waiting to complete transmission of remaining buffered data
@ TIME_WAIT
Timeout to catch resent junk before entering closed, can only be entered from FIN_WAIT2 or CLOSING.
@ SYN_RCVD
Received a connection request, sent ack, waiting for final ack in three-way handshake.
@ LAST_ACK
Our side has shutdown after remote has shutdown.
@ CLOSING
Both sides have shutdown but we still have data we have to finish sending
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
log2() macro definition; to deal with Bug 1467 .
const std::map< std::pair< ns3::TcpSocketBase::TcpPacketType_t, ns3::TcpSocketState::EcnMode_t >, bool > ECN_RESTRICTION_MAP
map TcpPacketType and EcnMode to boolean value to check whether ECN-marking is allowed or not
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.