22 #define NS_LOG_APPEND_CONTEXT \ 23 if (m_node) { std::clog << " [node " << m_node->GetId () << "] "; } 25 #include "ns3/abort.h" 27 #include "ns3/inet-socket-address.h" 28 #include "ns3/inet6-socket-address.h" 32 #include "ns3/ipv4-interface-address.h" 33 #include "ns3/ipv4-route.h" 34 #include "ns3/ipv6-route.h" 35 #include "ns3/ipv4-routing-protocol.h" 36 #include "ns3/ipv6-routing-protocol.h" 37 #include "ns3/simulation-singleton.h" 38 #include "ns3/simulator.h" 39 #include "ns3/packet.h" 40 #include "ns3/uinteger.h" 41 #include "ns3/double.h" 42 #include "ns3/pointer.h" 43 #include "ns3/trace-source-accessor.h" 44 #include "ns3/data-rate.h" 45 #include "ns3/object.h" 61 #include "ns3/tcp-rate-ops.h" 77 .SetGroupName (
"Internet")
84 .AddAttribute (
"MaxSegLifetime",
85 "Maximum segment lifetime in seconds, use for TIME_WAIT state transition to CLOSED state",
88 MakeDoubleChecker<double> (0))
89 .AddAttribute (
"MaxWindowSize",
"Max size of advertised window",
92 MakeUintegerChecker<uint16_t> ())
93 .AddAttribute (
"IcmpCallback",
"Callback invoked whenever an icmp error is received on this socket.",
97 .AddAttribute (
"IcmpCallback6",
"Callback invoked whenever an icmpv6 error is received on this socket.",
101 .AddAttribute (
"WindowScaling",
"Enable or disable Window Scaling option",
105 .AddAttribute (
"Sack",
"Enable or disable Sack option",
109 .AddAttribute (
"Timestamp",
"Enable or disable Timestamp option",
113 .AddAttribute (
"MinRto",
114 "Minimum retransmit timeout value",
120 .AddAttribute (
"ClockGranularity",
121 "Clock Granularity used in RTO calculations",
126 .AddAttribute (
"TxBuffer",
130 MakePointerChecker<TcpTxBuffer> ())
131 .AddAttribute (
"RxBuffer",
135 MakePointerChecker<TcpRxBuffer> ())
136 .AddAttribute (
"ReTxThreshold",
"Threshold for fast retransmit",
140 MakeUintegerChecker<uint32_t> ())
141 .AddAttribute (
"LimitedTransmit",
"Enable limited transmit",
145 .AddAttribute (
"UseEcn",
"Parameter to set ECN functionality",
151 .AddTraceSource (
"RTO",
152 "Retransmission timeout",
154 "ns3::TracedValueCallback::Time")
155 .AddTraceSource (
"RTT",
158 "ns3::TracedValueCallback::Time")
159 .AddTraceSource (
"NextTxSequence",
160 "Next sequence number to send (SND.NXT)",
162 "ns3::SequenceNumber32TracedValueCallback")
163 .AddTraceSource (
"HighestSequence",
164 "Highest sequence number ever sent in socket's life time",
166 "ns3::TracedValueCallback::SequenceNumber32")
167 .AddTraceSource (
"State",
170 "ns3::TcpStatesTracedValueCallback")
171 .AddTraceSource (
"CongState",
172 "TCP Congestion machine state",
174 "ns3::TcpSocketState::TcpCongStatesTracedValueCallback")
175 .AddTraceSource (
"EcnState",
176 "Trace ECN state change of socket",
178 "ns3::TcpSocketState::EcnStatesTracedValueCallback")
179 .AddTraceSource (
"AdvWND",
180 "Advertised Window Size",
182 "ns3::TracedValueCallback::Uint32")
183 .AddTraceSource (
"RWND",
184 "Remote side's flow control window",
186 "ns3::TracedValueCallback::Uint32")
187 .AddTraceSource (
"BytesInFlight",
188 "Socket estimation of bytes in flight",
190 "ns3::TracedValueCallback::Uint32")
191 .AddTraceSource (
"HighestRxSequence",
192 "Highest sequence number received from peer",
194 "ns3::TracedValueCallback::SequenceNumber32")
195 .AddTraceSource (
"HighestRxAck",
196 "Highest ack received from peer",
198 "ns3::TracedValueCallback::SequenceNumber32")
199 .AddTraceSource (
"PacingRate",
200 "The current TCP pacing rate",
202 "ns3::TracedValueCallback::DataRate")
203 .AddTraceSource (
"CongestionWindow",
204 "The TCP connection's congestion window",
206 "ns3::TracedValueCallback::Uint32")
207 .AddTraceSource (
"CongestionWindowInflated",
208 "The TCP connection's congestion window inflates as in older RFC",
210 "ns3::TracedValueCallback::Uint32")
211 .AddTraceSource (
"SlowStartThreshold",
212 "TCP slow start threshold (bytes)",
214 "ns3::TracedValueCallback::Uint32")
215 .AddTraceSource (
"Tx",
216 "Send tcp packet to IP protocol",
218 "ns3::TcpSocketBase::TcpTxRxTracedCallback")
219 .AddTraceSource (
"Rx",
220 "Receive tcp packet from IP protocol",
222 "ns3::TcpSocketBase::TcpTxRxTracedCallback")
223 .AddTraceSource (
"EcnEchoSeq",
224 "Sequence of last received ECN Echo",
226 "ns3::SequenceNumber32TracedValueCallback")
227 .AddTraceSource (
"EcnCeSeq",
228 "Sequence of last received CE ",
230 "ns3::SequenceNumber32TracedValueCallback")
231 .AddTraceSource (
"EcnCwrSeq",
232 "Sequence of last received CWR",
234 "ns3::SequenceNumber32TracedValueCallback")
251 m_tcb = CreateObject<TcpSocketState> ();
252 m_rateOps = CreateObject <TcpRateLinux> ();
307 m_dupAckCount (sock.m_dupAckCount),
309 m_delAckMaxCount (sock.m_delAckMaxCount),
310 m_noDelay (sock.m_noDelay),
311 m_synCount (sock.m_synCount),
312 m_synRetries (sock.m_synRetries),
313 m_dataRetrCount (sock.m_dataRetrCount),
314 m_dataRetries (sock.m_dataRetries),
316 m_minRto (sock.m_minRto),
317 m_clockGranularity (sock.m_clockGranularity),
318 m_delAckTimeout (sock.m_delAckTimeout),
319 m_persistTimeout (sock.m_persistTimeout),
320 m_cnTimeout (sock.m_cnTimeout),
321 m_endPoint (nullptr),
322 m_endPoint6 (nullptr),
323 m_node (sock.m_node),
325 m_state (sock.m_state),
326 m_errno (sock.m_errno),
327 m_closeNotified (sock.m_closeNotified),
328 m_closeOnEmpty (sock.m_closeOnEmpty),
329 m_shutdownSend (sock.m_shutdownSend),
330 m_shutdownRecv (sock.m_shutdownRecv),
331 m_connected (sock.m_connected),
333 m_maxWinSize (sock.m_maxWinSize),
334 m_bytesAckedNotProcessed (sock.m_bytesAckedNotProcessed),
335 m_rWnd (sock.m_rWnd),
336 m_highRxMark (sock.m_highRxMark),
337 m_highRxAckMark (sock.m_highRxAckMark),
338 m_sackEnabled (sock.m_sackEnabled),
339 m_winScalingEnabled (sock.m_winScalingEnabled),
340 m_rcvWindShift (sock.m_rcvWindShift),
341 m_sndWindShift (sock.m_sndWindShift),
342 m_timestampEnabled (sock.m_timestampEnabled),
343 m_timestampToEcho (sock.m_timestampToEcho),
344 m_recover (sock.m_recover),
345 m_recoverActive (sock.m_recoverActive),
346 m_retxThresh (sock.m_retxThresh),
347 m_limitedTx (sock.m_limitedTx),
348 m_isFirstPartialAck (sock.m_isFirstPartialAck),
349 m_txTrace (sock.m_txTrace),
350 m_rxTrace (sock.m_rxTrace),
351 m_pacingTimer (
Timer::CANCEL_ON_DESTROY),
352 m_ecnEchoSeq (sock.m_ecnEchoSeq),
353 m_ecnCESeq (sock.m_ecnCESeq),
354 m_ecnCWRSeq (sock.m_ecnCWRSeq)
390 m_rateOps = CreateObject <TcpRateLinux> ();
521 m_tcp->AddSocket (
this);
537 m_tcp->AddSocket (
this);
608 m_tcp->AddSocket (
this);
619 "TcpSocketBase::SetSSThresh() cannot change initial ssThresh after connection started.");
634 "TcpSocketBase::SetInitialCwnd() cannot change initial cwnd after connection started.");
671 NS_LOG_ERROR (
"Route to destination does not exist ?!");
702 NS_LOG_ERROR (
"Route to destination does not exist ?!");
749 NS_LOG_WARN (
"Socket " <<
this <<
" << unread rx data during close. Sending reset." <<
750 "This is probably due to a bad sink application; check its code");
816 NS_ABORT_MSG_IF (flags,
"use of flags is not supported in TcpSocketBase::Send()");
861 return Send (p, flags);
870 NS_ABORT_MSG_IF (flags,
"use of flags is not supported in TcpSocketBase::Recv()");
873 return Create<Packet> ();
886 if (packet !=
nullptr && packet->
GetSize () != 0)
1127 return (tail < m_tcb->m_rxBuffer->NextRxSequence () ||
m_tcb->
m_rxBuffer->MaxRxSequence () <= head);
1148 uint32_t bytesRemoved = packet->
PeekHeader (tcpHeader);
1151 packet->
GetSize () - bytesRemoved))
1187 uint32_t bytesRemoved = packet->
PeekHeader (tcpHeader);
1190 packet->
GetSize () - bytesRemoved))
1213 uint8_t icmpType, uint8_t icmpCode,
1216 NS_LOG_FUNCTION (
this << icmpSource << static_cast<uint32_t> (icmpTtl) <<
1217 static_cast<uint32_t> (icmpType) <<
1218 static_cast<uint32_t> (icmpCode) << icmpInfo);
1221 m_icmpCallback (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
1227 uint8_t icmpType, uint8_t icmpCode,
1230 NS_LOG_FUNCTION (
this << icmpSource << static_cast<uint32_t> (icmpTtl) <<
1231 static_cast<uint32_t> (icmpType) <<
1232 static_cast<uint32_t> (icmpCode) << icmpInfo);
1241 const uint32_t tcpPayloadSize)
1243 if (tcpHeaderSize == 0 || tcpHeaderSize > 60)
1245 NS_LOG_ERROR (
"Bytes removed: " << tcpHeaderSize <<
" invalid");
1248 else if (tcpPayloadSize > 0 &&
OutOfRange (seq, seq + tcpPayloadSize))
1252 " received packet of seq [" << seq <<
1253 ":" << seq + tcpPayloadSize <<
1352 " received packet of seq [" << seq <<
1353 ":" << seq + packet->
GetSize () <<
1354 ") without TS option. Silently discard it");
1371 NS_LOG_LOGIC (
this <<
" Enter zerowindow persist state");
1372 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
1436 NS_LOG_LOGIC (
this <<
" Leaving zerowindow persist state");
1461 " SND.UNA = " <<
m_txBuffer->HeadSequence ());
1504 else if (tcpflags == 0)
1547 TcpHeader::TcpOptionList::const_iterator it;
1550 for (it = options.begin (); it != options.end (); ++it)
1611 "Reset cwnd to " <<
m_tcb->
m_cWnd <<
", ssthresh to " <<
1613 " calculated in flight: " << bytesInFlight);
1742 uint32_t bytesSacked = 0;
1749 if (ackNumber < oldHeadSequence)
1751 NS_LOG_DEBUG (
"Possibly received a stale ACK (ack number < head sequence)");
1759 if ((ackNumber > oldHeadSequence) && (ackNumber <
m_recover)
1763 for (uint32_t i = 0; i < segAcked; i++)
1769 "is ACK of retransmitted packet.");
1794 NS_LOG_INFO (
"Update bytes in flight before processing the ACK.");
1799 ProcessAck (ackNumber, (bytesSacked > 0), currentDelivered, oldHeadSequence);
1804 uint32_t previousLost =
m_txBuffer->GetLost ();
1806 uint32_t currentLost =
m_txBuffer->GetLost ();
1807 uint32_t lost = (currentLost > previousLost) ?
1808 currentLost - previousLost :
1809 previousLost - currentLost;
1835 bool exitedFastRecovery =
false;
1838 uint32_t bytesAcked = 0;
1859 : ackNumber == oldHeadSequence &&
1863 " SND.UNA=" << oldHeadSequence <<
1876 DupAck (currentDelivered);
1879 if (ackNumber == oldHeadSequence
1885 else if (ackNumber == oldHeadSequence
1890 NS_LOG_DEBUG (
"Update nextTxSequence manually to " << ackNumber);
1893 else if (ackNumber == oldHeadSequence)
1898 else if (ackNumber > oldHeadSequence)
1902 bytesAcked = ackNumber - oldHeadSequence;
1943 NS_LOG_INFO (
"Partial ACK. Manually setting head as lost");
1970 " and this is the first (RTO will be reset);" 1979 " and this is NOT the first (RTO will not be reset)" 1999 "Some segment got dup-acked in CA_LOSS state: " <<
2002 NewAck (ackNumber,
true);
2012 if (segsAcked >= oldDupAckCount)
2023 NS_LOG_DEBUG (segsAcked <<
" segments acked in CA_DISORDER, ack of " <<
2024 ackNumber <<
" exiting CA_DISORDER -> CA_OPEN");
2028 NS_LOG_DEBUG (segsAcked <<
" segments acked in CA_DISORDER, ack of " <<
2029 ackNumber <<
" but still in CA_DISORDER");
2049 segsAcked =
static_cast<uint32_t
>(ackNumber - oldHeadSequence) /
m_tcb->
m_segmentSize;
2054 exitedFastRecovery =
true;
2057 NS_LOG_DEBUG (segsAcked <<
" segments acked in CA_RECOVER, ack of " <<
2058 ackNumber <<
", exiting CA_RECOVERY -> CA_OPEN");
2073 NS_LOG_DEBUG (segsAcked <<
" segments acked in CA_LOSS, ack of" <<
2074 ackNumber <<
", exiting CA_LOSS -> CA_OPEN");
2085 if (exitedFastRecovery)
2087 NewAck (ackNumber,
true);
2089 NS_LOG_DEBUG (
"Leaving Fast Recovery; BytesInFlight() = " <<
2101 " segsAcked: " << segsAcked);
2103 NewAck (ackNumber,
true);
2141 packet, tcpHeader, fromAddress, toAddress);
2231 " received in SYN_SENT. Reset packet is sent.");
2332 " received. Reset packet is sent.");
2389 " received. Reset packet is sent.");
2545 NS_LOG_LOGIC (
"TCP " <<
this <<
" calling NotifyNormalClose");
2560 NS_LOG_LOGIC (
"TcpSocketBase " <<
this <<
" scheduling LATO1");
2573 if (
m_tcp !=
nullptr)
2575 m_tcp->RemoveSocket (
this);
2577 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
2589 if (
m_tcp !=
nullptr)
2591 m_tcp->RemoveSocket (
this);
2593 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
2606 NS_LOG_WARN (
"Failed to send empty packet due to null endpoint");
2625 header.SetFlags (flags);
2626 header.SetSequenceNumber (s);
2686 header.SetWindowSize (windowSize);
2719 NS_LOG_LOGIC (
"Schedule retransmission timeout at time " 2746 m_tcp->RemoveSocket (
this);
2754 m_tcp->RemoveSocket (
this);
2765 if (ipv4->GetRoutingProtocol () ==
nullptr)
2776 route = ipv4->GetRoutingProtocol ()->RouteOutput (
Ptr<Packet> (), header, oif, errno_);
2795 if (ipv6->GetRoutingProtocol () ==
nullptr)
2806 route = ipv6->GetRoutingProtocol ()->RouteOutput (
Ptr<Packet> (), header, oif, errno_);
2807 if (route ==
nullptr)
2847 m_tcp->AddSocket (
this);
2981 bool isRetransmission = outItem->
IsRetrans ();
3002 NS_LOG_INFO (
"Timer is already in running state");
3019 NS_LOG_INFO (
"Backoff mechanism by reducing CWND by half because we've received ECN Echo");
3068 NS_LOG_LOGIC (
this <<
" SendDataPacket Schedule ReTxTimeout at time " <<
3080 NS_LOG_DEBUG (
"Send segment of size " << sz <<
" with remaining data " <<
3082 ". Header " << header);
3088 NS_LOG_DEBUG (
"Send segment of size " << sz <<
" with remaining data " <<
3090 ". Header " << header);
3102 if (!isRetransmission)
3114 bool isRetransmission)
3119 if (isRetransmission ==
false)
3125 for (std::deque<RttHistory>::iterator i =
m_history.begin (); i !=
m_history.end (); ++i)
3152 uint32_t nPacketsSent = 0;
3160 while (availableWindow > 0)
3176 NS_LOG_INFO (
"FIN_WAIT and OPEN state; no data to transmit");
3187 if (!
m_txBuffer->NextSeg (&next, &nextHigh, enableRule3))
3189 NS_LOG_INFO (
"no valid seq to transmit, or no data available");
3195 uint32_t availableData =
m_txBuffer->SizeFromSequence (next);
3199 if (availableData < availableWindow)
3206 if (availableWindow < m_tcb->m_segmentSize && availableData > availableWindow)
3208 NS_LOG_LOGIC (
"Preventing Silly Window Syndrome. Wait to send.");
3215 NS_LOG_DEBUG (
"Invoking Nagle's algorithm for seq " << next <<
3216 ", SFS: " <<
m_txBuffer->SizeFromSequence (next) <<
3223 uint32_t maxSizeToSend =
static_cast<uint32_t
> (nextHigh - next);
3247 " highestRxAck " <<
m_txBuffer->HeadSequence () <<
3281 if (nPacketsSent > 0)
3292 NS_LOG_DEBUG (
"SendPendingData sent " << nPacketsSent <<
" segments");
3298 return nPacketsSent;
3310 uint32_t bytesInFlight =
m_txBuffer->BytesInFlight ();
3315 NS_LOG_DEBUG (
"Returning calculated bytesInFlight: " << bytesInFlight);
3316 return bytesInFlight;
3328 uint32_t win =
Window ();
3330 return (inflight > win) ? 0 : win - inflight;
3348 "Unexpected sequence number values");
3365 NS_LOG_WARN (
"Adv window size truncated to " <<
m_maxWinSize <<
"; possibly to avoid overflow of the 16-bit integer");
3367 NS_LOG_LOGIC (
"Returning AdvertisedWindowSize of " << static_cast<uint16_t> (w));
3368 return static_cast<uint16_t
> (w);
3377 " pkt size=" << p->
GetSize () );
3396 if (expectedSeq < m_tcb->m_rxBuffer->NextRxSequence ())
3405 NS_LOG_WARN (
"Why TCP " <<
this <<
" got data after close notification?");
3511 m_rtt->Measurement (m);
3533 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
3540 NS_LOG_LOGIC (
this <<
" Schedule ReTxTimeout at time " <<
3548 " numberAck " << (ack -
m_txBuffer->HeadSequence ()));
3560 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
3602 NS_LOG_DEBUG (
"Checking if Connection is Established");
3612 NS_LOG_INFO (
"No more data retries available. Dropping connection");
3683 m_txBuffer->HeadSequence () <<
" doubled rto to " <<
3722 NS_LOG_INFO (
"LAST-ACK: No more data retries available. Dropping connection");
3729 NS_LOG_LOGIC (
"TcpSocketBase " <<
this <<
" rescheduling LATO1");
3797 uint32_t maxSizeToSend;
3801 res =
m_txBuffer->NextSeg (&seq, &seqHigh,
false);
3813 maxSizeToSend =
static_cast<uint32_t
> (seqHigh - seq);
4017 return (!allowBroadcast);
4067 maxSpace = maxSpace >> 1;
4073 NS_LOG_WARN (
"Possible error; scale exceeds 14: " << scale);
4078 static_cast<int> (scale) <<
" for buffer size " <<
m_tcb->
m_rxBuffer->MaxBufferSize ());
4140 uint8_t allowedSackBlocks = (optionLenAvail - 2) / 8;
4143 if (allowedSackBlocks == 0 || sackList.empty ())
4145 NS_LOG_LOGIC (
"No space available or sack list empty, not adding sack blocks");
4151 TcpOptionSack::SackList::iterator i;
4152 for (i = sackList.begin (); allowedSackBlocks > 0 && i != sackList.end (); ++i)
4154 option->AddSackBlock (*i);
4155 allowedSackBlocks--;
4212 NS_LOG_INFO (
"Received (scaled) window is " << receivedWindow <<
" bytes");
4226 bool update =
false;
4376 return CopyObject<TcpSocketBase> (
this);
4455 if (pacingRate < m_tcb->m_maxPacingRate)
4457 NS_LOG_DEBUG (
"Pacing rate updated to: " << pacingRate);
TracedCallback< SequenceNumber32, SequenceNumber32 > m_highTxMarkTrace
Callback pointer for high tx mark chaining.
void SetCongestionControlAlgorithm(Ptr< TcpCongestionOps > algo)
Install a congestion control algorithm on this socket.
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Ipv6Address GetLocalAddress()
Get the local address.
uint32_t m_rcvTimestampValue
Receiver Timestamp value.
void PeerClose(Ptr< Packet > p, const TcpHeader &tcpHeader)
Received a FIN from peer, notify rx buffer.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
log2() macro definition; to deal with Bug 1467.
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
bool m_limitedTx
perform limited transmit
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
void ProcessListen(Ptr< Packet > packet, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Received a packet upon LISTEN state.
TracedValue< uint32_t > m_advWnd
Advertised Window size.
virtual void SetInitialCwnd(uint32_t cwnd)
Set the initial Congestion Window.
virtual int Listen(void)
Listen for incoming connections.
Simulation virtual time values and global simulation resolution.
static Ipv4Address GetAny(void)
UseEcn_t
Parameter value related to ECN enable/disable functionality similar to sysctl for tcp_ecn...
virtual bool GetTcpNoDelay(void) const
Check if Nagle's algorithm is enabled or not.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void ProcessWait(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon CLOSE_WAIT, FIN_WAIT_1, FIN_WAIT_2.
Ipv4Address GetIpv4MappedAddress() const
Return the Ipv4 address.
Last ACK received had ECE bit set in TCP header.
Normal state, no dubious events.
uint32_t m_dataRetries
Number of data retransmission attempts.
virtual void SetInitialSSThresh(uint32_t threshold)
Set the initial Slow Start Threshold.
AttributeValue implementation for Boolean.
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number.
bool IsIpv4MappedAddress() const
If the address is an IPv4-mapped address.
bool m_noDelay
Set to true to disable Nagle's algorithm.
CWND was reduced, we are fast-retransmitting.
uint32_t GetId(void) const
In all the respects it is "Open", but requires a bit more attention.
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, and send to TcpL4Protocol.
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer...
virtual Time GetPersistTimeout(void) const
Get the timeout for persistent connection.
A simple virtual Timer class.
(abstract) base class of all TcpSockets
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
static Time ElapsedTimeFromTsValue(uint32_t echoTime)
Estimate the Time elapsed from a TS echo value.
bool m_pacing
Pacing status.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
TracedCallback< DataRate, DataRate > m_pacingRateTrace
Callback pointer for pacing rate trace chaining.
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
virtual ~TcpSocketBase(void)
uint32_t m_dataRetrCount
Count of remaining data retransmission attempts.
uint32_t m_synRetries
Number of connection attempts.
void NotifyDataRecv(void)
Notify through the callback (if set) that some data have been received.
TracedValue< SequenceNumber32 > m_highRxAckMark
Highest ack received.
uint32_t m_initialSsThresh
Initial Slow Start Threshold value.
virtual int ShutdownRecv(void)
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > callback)
Set the reception callback.
TcpSocketBase(void)
Create an unbound TCP socket.
void SetClockGranularity(Time clockGranularity)
Sets the Clock Granularity (used in RTO calcs).
EventId m_retxEvent
Retransmission event.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
IPv6 layer implementation.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
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.
uint32_t m_rcvTimestampEchoReply
Sender Timestamp echoed by the receiver.
void ProcessOptionSackPermitted(const Ptr< const TcpOption > option)
Read the SACK PERMITTED option.
uint8_t GetTos(void) const
virtual void SetPersistTimeout(Time timeout)
Set the timeout for persistent connection.
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
EventId m_timewaitEvent
TIME_WAIT expiration event: Move this socket to CLOSED state.
void UpdateEcnState(TcpSocketState::EcnState_t oldValue, TcpSocketState::EcnState_t newValue)
Callback function to hook to EcnState state.
std::list< SackBlock > SackList
SACK list definition.
uint32_t GetRetxThresh(void) const
Get the retransmission threshold (dup ack threshold for a fast retransmit)
void NotifyConnectionFailed(void)
Notify through the callback (if set) that the connection has not been established due to an error...
virtual uint32_t GetSndBufSize(void) const
Get the send buffer size.
static const char *const TcpCongStateName[TcpSocketState::CA_LAST_STATE]
Literal names of TCP states for use in log messages.
static TypeId GetTypeId(void)
Get the type ID.
uint8_t MarkEcnCodePoint(const uint8_t tos, const TcpSocketState::EcnCodePoint_t codePoint) const
mark ECN code point
void ProcessOptionTimestamp(const Ptr< const TcpOption > option, const SequenceNumber32 &seq)
Process the timestamp option from other side.
void SetUseEcn(TcpSocketState::UseEcn_t useEcn)
Set ECN mode of use on the socket.
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
Both sides have shutdown but we still have data we have to finish sending.
virtual Time GetDelAckTimeout(void) const
Get the time to delay an ACK.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
void UpdateHighTxMark(SequenceNumber32 oldValue, SequenceNumber32 newValue)
Callback function to hook to TcpSocketState high tx mark.
void SendRST(void)
Send reset and tear down this socket.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
Time GetDelayLeft(void) const
virtual uint32_t GetDelAckMaxCount(void) const
Get the number of packet to fire an ACK before delay timeout.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< TcpSocketState > m_tcb
Congestion control information.
virtual void ProcessAck(const SequenceNumber32 &ackNumber, bool scoreboardUpdated, uint32_t currentDelivered, const SequenceNumber32 &oldHeadSequence)
Process a received ack.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
bool m_winScalingEnabled
Window Scale option enabled (RFC 7323)
bool m_timestampEnabled
Timestamp option enabled.
Timer m_pacingTimer
Pacing Event.
uint16_t m_maxWinSize
Maximum window size to advertise.
#define NS_UNUSED(x)
Mark a local variable as unused.
bool retx
True if this has been retransmitted.
virtual void NewAck(SequenceNumber32 const &seq, bool resetRTO)
Update buffers w.r.t.
uint32_t m_segmentSize
Segment size.
Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback
ICMP callback.
void CancelAllTimers(void)
Cancel all timer when endpoint is deleted.
uint32_t count
Number of bytes sent.
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Time m_cnTimeout
Timeout for connection retry.
uint32_t m_initialCWnd
Initial cWnd value.
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
virtual Time GetConnTimeout(void) const
Get the connection timeout.
EventId m_lastAckEvent
Last ACK timeout event.
void ConnectionSucceeded(void)
Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
All buffered data sent, waiting for remote to shutdown.
void SetTos(uint8_t tos)
Set the tag's TOS.
TracedValue< SequenceNumber32 > m_ecnCESeq
Sequence number of the last received Congestion Experienced.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received an ACK packet.
void AddSocketTags(const Ptr< Packet > &p) const
Add Tags for the Socket.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
virtual uint32_t GetInitialSSThresh(void) const
Get the initial Slow Start Threshold.
bool m_isRetransDataAcked
Retransmitted data is ACKed if true.
virtual uint32_t BytesInFlight(void) const
Return total bytes in flight.
SocketErrno
Enumeration of the possible errors returned by a socket.
void DoPeerClose(void)
FIN is in sequence, notify app and respond with a FIN.
bool NotifyConnectionRequest(const Address &from)
Notify through the callback (if set) that an incoming connection is being requested by a remote host...
TracedCallback< TcpSocketState::EcnState_t, TcpSocketState::EcnState_t > m_ecnStateTrace
Callback pointer for ECN state trace chaining.
virtual void PersistTimeout(void)
Send 1 byte probe to get an updated window size.
virtual void SetSynRetries(uint32_t count)
Set the number of connection retries before giving up.
TracedValue< TcpStates_t > m_state
TCP state.
Time GetMinRto(void) const
Get the Minimum RTO.
uint32_t m_delAckMaxCount
Number of packet to fire an ACK before delay timeout.
bool m_paceInitialWindow
Enable/Disable pacing for the initial window.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Receiver sends an ACK with ECE bit set in TCP header.
a polymophic address class
void SetMinRto(Time minRto)
Sets the Minimum RTO.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
uint16_t GetPeerPort()
Get the peer port.
AttributeValue implementation for Callback.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint32_t m_delAckCount
Delayed ACK counter.
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
SequenceNumber32 m_recover
Previous highest Tx seqnum for fast recovery (set it to initial seq number)
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 int Bind(void)
Allocate a local IPv4 endpoint for this socket.
bool IsRetrans(void) const
Is the item retransmitted?
Class for representing data rates.
virtual bool GetAllowBroadcast(void) const
Query whether broadcast datagram transmissions are allowed.
Last packet received had CE bit set in IP header.
virtual uint32_t GetRcvBufSize(void) const
Get the receive buffer size.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound NetDevice, if any.
void SetLocalAddress(Ipv6Address addr)
Set the local address.