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 (
"CongestionOps",
137 "Pointer to TcpCongestionOps object",
140 MakePointerChecker<TcpCongestionOps> ())
141 .AddAttribute (
"ReTxThreshold",
"Threshold for fast retransmit",
145 MakeUintegerChecker<uint32_t> ())
146 .AddAttribute (
"LimitedTransmit",
"Enable limited transmit",
150 .AddAttribute (
"UseEcn",
"Parameter to set ECN functionality",
156 .AddTraceSource (
"RTO",
157 "Retransmission timeout",
159 "ns3::TracedValueCallback::Time")
160 .AddTraceSource (
"RTT",
163 "ns3::TracedValueCallback::Time")
164 .AddTraceSource (
"NextTxSequence",
165 "Next sequence number to send (SND.NXT)",
167 "ns3::SequenceNumber32TracedValueCallback")
168 .AddTraceSource (
"HighestSequence",
169 "Highest sequence number ever sent in socket's life time",
171 "ns3::TracedValueCallback::SequenceNumber32")
172 .AddTraceSource (
"State",
175 "ns3::TcpStatesTracedValueCallback")
176 .AddTraceSource (
"CongState",
177 "TCP Congestion machine state",
179 "ns3::TcpSocketState::TcpCongStatesTracedValueCallback")
180 .AddTraceSource (
"EcnState",
181 "Trace ECN state change of socket",
183 "ns3::TcpSocketState::EcnStatesTracedValueCallback")
184 .AddTraceSource (
"AdvWND",
185 "Advertised Window Size",
187 "ns3::TracedValueCallback::Uint32")
188 .AddTraceSource (
"RWND",
189 "Remote side's flow control window",
191 "ns3::TracedValueCallback::Uint32")
192 .AddTraceSource (
"BytesInFlight",
193 "Socket estimation of bytes in flight",
195 "ns3::TracedValueCallback::Uint32")
196 .AddTraceSource (
"HighestRxSequence",
197 "Highest sequence number received from peer",
199 "ns3::TracedValueCallback::SequenceNumber32")
200 .AddTraceSource (
"HighestRxAck",
201 "Highest ack received from peer",
203 "ns3::TracedValueCallback::SequenceNumber32")
204 .AddTraceSource (
"PacingRate",
205 "The current TCP pacing rate",
207 "ns3::TracedValueCallback::DataRate")
208 .AddTraceSource (
"CongestionWindow",
209 "The TCP connection's congestion window",
211 "ns3::TracedValueCallback::Uint32")
212 .AddTraceSource (
"CongestionWindowInflated",
213 "The TCP connection's congestion window inflates as in older RFC",
215 "ns3::TracedValueCallback::Uint32")
216 .AddTraceSource (
"SlowStartThreshold",
217 "TCP slow start threshold (bytes)",
219 "ns3::TracedValueCallback::Uint32")
220 .AddTraceSource (
"Tx",
221 "Send tcp packet to IP protocol",
223 "ns3::TcpSocketBase::TcpTxRxTracedCallback")
224 .AddTraceSource (
"Rx",
225 "Receive tcp packet from IP protocol",
227 "ns3::TcpSocketBase::TcpTxRxTracedCallback")
228 .AddTraceSource (
"EcnEchoSeq",
229 "Sequence of last received ECN Echo",
231 "ns3::SequenceNumber32TracedValueCallback")
232 .AddTraceSource (
"EcnCeSeq",
233 "Sequence of last received CE ",
235 "ns3::SequenceNumber32TracedValueCallback")
236 .AddTraceSource (
"EcnCwrSeq",
237 "Sequence of last received CWR",
239 "ns3::SequenceNumber32TracedValueCallback")
256 m_tcb = CreateObject<TcpSocketState> ();
257 m_rateOps = CreateObject <TcpRateLinux> ();
312 m_dupAckCount (sock.m_dupAckCount),
314 m_delAckMaxCount (sock.m_delAckMaxCount),
315 m_noDelay (sock.m_noDelay),
316 m_synCount (sock.m_synCount),
317 m_synRetries (sock.m_synRetries),
318 m_dataRetrCount (sock.m_dataRetrCount),
319 m_dataRetries (sock.m_dataRetries),
321 m_minRto (sock.m_minRto),
322 m_clockGranularity (sock.m_clockGranularity),
323 m_delAckTimeout (sock.m_delAckTimeout),
324 m_persistTimeout (sock.m_persistTimeout),
325 m_cnTimeout (sock.m_cnTimeout),
326 m_endPoint (nullptr),
327 m_endPoint6 (nullptr),
328 m_node (sock.m_node),
330 m_state (sock.m_state),
331 m_errno (sock.m_errno),
332 m_closeNotified (sock.m_closeNotified),
333 m_closeOnEmpty (sock.m_closeOnEmpty),
334 m_shutdownSend (sock.m_shutdownSend),
335 m_shutdownRecv (sock.m_shutdownRecv),
336 m_connected (sock.m_connected),
338 m_maxWinSize (sock.m_maxWinSize),
339 m_bytesAckedNotProcessed (sock.m_bytesAckedNotProcessed),
340 m_rWnd (sock.m_rWnd),
341 m_highRxMark (sock.m_highRxMark),
342 m_highRxAckMark (sock.m_highRxAckMark),
343 m_sackEnabled (sock.m_sackEnabled),
344 m_winScalingEnabled (sock.m_winScalingEnabled),
345 m_rcvWindShift (sock.m_rcvWindShift),
346 m_sndWindShift (sock.m_sndWindShift),
347 m_timestampEnabled (sock.m_timestampEnabled),
348 m_timestampToEcho (sock.m_timestampToEcho),
349 m_recover (sock.m_recover),
350 m_recoverActive (sock.m_recoverActive),
351 m_retxThresh (sock.m_retxThresh),
352 m_limitedTx (sock.m_limitedTx),
353 m_isFirstPartialAck (sock.m_isFirstPartialAck),
354 m_txTrace (sock.m_txTrace),
355 m_rxTrace (sock.m_rxTrace),
356 m_pacingTimer (
Timer::CANCEL_ON_DESTROY),
357 m_ecnEchoSeq (sock.m_ecnEchoSeq),
358 m_ecnCESeq (sock.m_ecnCESeq),
359 m_ecnCWRSeq (sock.m_ecnCWRSeq)
395 m_rateOps = CreateObject <TcpRateLinux> ();
526 m_tcp->AddSocket (
this);
542 m_tcp->AddSocket (
this);
613 m_tcp->AddSocket (
this);
624 "TcpSocketBase::SetSSThresh() cannot change initial ssThresh after connection started.");
639 "TcpSocketBase::SetInitialCwnd() cannot change initial cwnd after connection started.");
676 NS_LOG_ERROR (
"Route to destination does not exist ?!");
707 NS_LOG_ERROR (
"Route to destination does not exist ?!");
754 NS_LOG_WARN (
"Socket " <<
this <<
" << unread rx data during close. Sending reset." <<
755 "This is probably due to a bad sink application; check its code");
821 NS_ABORT_MSG_IF (flags,
"use of flags is not supported in TcpSocketBase::Send()");
865 return Send (p, flags);
874 NS_ABORT_MSG_IF (flags,
"use of flags is not supported in TcpSocketBase::Recv()");
877 return Create<Packet> ();
890 if (packet !=
nullptr && packet->
GetSize () != 0)
1131 return (tail < m_tcb->m_rxBuffer->NextRxSequence () ||
m_tcb->
m_rxBuffer->MaxRxSequence () <= head);
1152 uint32_t bytesRemoved = packet->
PeekHeader (tcpHeader);
1155 packet->
GetSize () - bytesRemoved))
1191 uint32_t bytesRemoved = packet->
PeekHeader (tcpHeader);
1194 packet->
GetSize () - bytesRemoved))
1217 uint8_t icmpType, uint8_t icmpCode,
1220 NS_LOG_FUNCTION (
this << icmpSource <<
static_cast<uint32_t
> (icmpTtl) <<
1221 static_cast<uint32_t
> (icmpType) <<
1222 static_cast<uint32_t
> (icmpCode) << icmpInfo);
1225 m_icmpCallback (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
1231 uint8_t icmpType, uint8_t icmpCode,
1234 NS_LOG_FUNCTION (
this << icmpSource <<
static_cast<uint32_t
> (icmpTtl) <<
1235 static_cast<uint32_t
> (icmpType) <<
1236 static_cast<uint32_t
> (icmpCode) << icmpInfo);
1245 const uint32_t tcpPayloadSize)
1247 if (tcpHeaderSize == 0 || tcpHeaderSize > 60)
1249 NS_LOG_ERROR (
"Bytes removed: " << tcpHeaderSize <<
" invalid");
1252 else if (tcpPayloadSize > 0 &&
OutOfRange (seq, seq + tcpPayloadSize))
1256 " received packet of seq [" << seq <<
1257 ":" << seq + tcpPayloadSize <<
1356 " received packet of seq [" << seq <<
1357 ":" << seq + packet->
GetSize () <<
1358 ") without TS option. Silently discard it");
1375 NS_LOG_LOGIC (
this <<
" Enter zerowindow persist state");
1376 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
1440 NS_LOG_LOGIC (
this <<
" Leaving zerowindow persist state");
1465 " SND.UNA = " <<
m_txBuffer->HeadSequence ());
1508 else if (tcpflags == 0)
1551 TcpHeader::TcpOptionList::const_iterator it;
1554 for (it = options.begin (); it != options.end (); ++it)
1644 "Reset cwnd to " <<
m_tcb->
m_cWnd <<
", ssthresh to " <<
1646 " calculated in flight: " << bytesInFlight);
1772 uint32_t previousLost =
m_txBuffer->GetLost ();
1778 uint32_t bytesSacked = 0;
1785 if (ackNumber < oldHeadSequence)
1787 NS_LOG_DEBUG (
"Possibly received a stale ACK (ack number < head sequence)");
1795 if ((ackNumber > oldHeadSequence) && (ackNumber <
m_recover)
1799 for (uint32_t i = 0; i < segAcked; i++)
1805 "is ACK of retransmitted packet.");
1849 NS_LOG_INFO (
"Update bytes in flight before processing the ACK.");
1854 ProcessAck (ackNumber, (bytesSacked > 0), currentDelivered, oldHeadSequence);
1859 uint32_t currentLost =
m_txBuffer->GetLost ();
1860 uint32_t lost = (currentLost > previousLost) ?
1861 currentLost - previousLost :
1862 previousLost - currentLost;
1888 bool exitedFastRecovery =
false;
1891 uint32_t bytesAcked = 0;
1912 : ackNumber == oldHeadSequence &&
1916 " SND.UNA=" << oldHeadSequence <<
1929 DupAck (currentDelivered);
1932 if (ackNumber == oldHeadSequence
1938 else if (ackNumber == oldHeadSequence
1943 NS_LOG_DEBUG (
"Update nextTxSequence manually to " << ackNumber);
1946 else if (ackNumber == oldHeadSequence)
1951 else if (ackNumber > oldHeadSequence)
1955 bytesAcked = ackNumber - oldHeadSequence;
1996 NS_LOG_INFO (
"Partial ACK. Manually setting head as lost");
2023 " and this is the first (RTO will be reset);"
2032 " and this is NOT the first (RTO will not be reset)"
2052 "Some segment got dup-acked in CA_LOSS state: " <<
2055 NewAck (ackNumber,
true);
2066 NewAck (ackNumber,
true);
2076 if (segsAcked >= oldDupAckCount)
2087 NS_LOG_DEBUG (segsAcked <<
" segments acked in CA_DISORDER, ack of " <<
2088 ackNumber <<
" exiting CA_DISORDER -> CA_OPEN");
2092 NS_LOG_DEBUG (segsAcked <<
" segments acked in CA_DISORDER, ack of " <<
2093 ackNumber <<
" but still in CA_DISORDER");
2113 segsAcked =
static_cast<uint32_t
>(ackNumber - oldHeadSequence) /
m_tcb->
m_segmentSize;
2118 exitedFastRecovery =
true;
2121 NS_LOG_DEBUG (segsAcked <<
" segments acked in CA_RECOVER, ack of " <<
2122 ackNumber <<
", exiting CA_RECOVERY -> CA_OPEN");
2137 NS_LOG_DEBUG (segsAcked <<
" segments acked in CA_LOSS, ack of" <<
2138 ackNumber <<
", exiting CA_LOSS -> CA_OPEN");
2149 if (exitedFastRecovery)
2151 NewAck (ackNumber,
true);
2154 NS_LOG_DEBUG (
"Leaving Fast Recovery; BytesInFlight() = " <<
2166 " segsAcked: " << segsAcked);
2168 NewAck (ackNumber,
true);
2206 packet, tcpHeader, fromAddress, toAddress);
2296 " received in SYN_SENT. Reset packet is sent.");
2307 [[maybe_unused]]
const Address& toAddress)
2397 " received. Reset packet is sent.");
2454 " received. Reset packet is sent.");
2610 NS_LOG_LOGIC (
"TCP " <<
this <<
" calling NotifyNormalClose");
2625 NS_LOG_LOGIC (
"TcpSocketBase " <<
this <<
" scheduling LATO1");
2638 if (
m_tcp !=
nullptr)
2640 m_tcp->RemoveSocket (
this);
2642 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
2654 if (
m_tcp !=
nullptr)
2656 m_tcp->RemoveSocket (
this);
2658 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
2671 NS_LOG_WARN (
"Failed to send empty packet due to null endpoint");
2784 NS_LOG_LOGIC (
"Schedule retransmission timeout at time "
2811 m_tcp->RemoveSocket (
this);
2819 m_tcp->RemoveSocket (
this);
2830 if (ipv4->GetRoutingProtocol () ==
nullptr)
2841 route = ipv4->GetRoutingProtocol ()->RouteOutput (
Ptr<Packet> (), header, oif, errno_);
2860 if (ipv6->GetRoutingProtocol () ==
nullptr)
2871 route = ipv6->GetRoutingProtocol ()->RouteOutput (
Ptr<Packet> (), header, oif, errno_);
2872 if (route ==
nullptr)
2911 m_tcp->AddSocket (
this);
3045 bool isRetransmission = outItem->
IsRetrans ();
3066 NS_LOG_INFO (
"Timer is already in running state");
3126 NS_LOG_LOGIC (
this <<
" SendDataPacket Schedule ReTxTimeout at time " <<
3138 NS_LOG_DEBUG (
"Send segment of size " << sz <<
" with remaining data " <<
3140 ". Header " << header);
3146 NS_LOG_DEBUG (
"Send segment of size " << sz <<
" with remaining data " <<
3148 ". Header " << header);
3160 if (!isRetransmission)
3172 bool isRetransmission)
3177 if (isRetransmission ==
false)
3183 for (std::deque<RttHistory>::iterator i =
m_history.begin (); i !=
m_history.end (); ++i)
3210 uint32_t nPacketsSent = 0;
3218 while (availableWindow > 0)
3234 NS_LOG_INFO (
"FIN_WAIT and OPEN state; no data to transmit");
3245 if (!
m_txBuffer->NextSeg (&next, &nextHigh, enableRule3))
3247 NS_LOG_INFO (
"no valid seq to transmit, or no data available");
3253 uint32_t availableData =
m_txBuffer->SizeFromSequence (next);
3257 if (availableData < availableWindow)
3264 if (availableWindow < m_tcb->m_segmentSize && availableData > availableWindow)
3266 NS_LOG_LOGIC (
"Preventing Silly Window Syndrome. Wait to send.");
3273 NS_LOG_DEBUG (
"Invoking Nagle's algorithm for seq " << next <<
3274 ", SFS: " <<
m_txBuffer->SizeFromSequence (next) <<
3281 uint32_t maxSizeToSend =
static_cast<uint32_t
> (nextHigh - next);
3305 " highestRxAck " <<
m_txBuffer->HeadSequence () <<
3339 if (nPacketsSent > 0)
3350 NS_LOG_DEBUG (
"SendPendingData sent " << nPacketsSent <<
" segments");
3356 return nPacketsSent;
3368 uint32_t bytesInFlight =
m_txBuffer->BytesInFlight ();
3373 NS_LOG_DEBUG (
"Returning calculated bytesInFlight: " << bytesInFlight);
3374 return bytesInFlight;
3386 uint32_t win =
Window ();
3388 return (inflight > win) ? 0 : win - inflight;
3406 "Unexpected sequence number values");
3423 NS_LOG_WARN (
"Adv window size truncated to " <<
m_maxWinSize <<
"; possibly to avoid overflow of the 16-bit integer");
3425 NS_LOG_LOGIC (
"Returning AdvertisedWindowSize of " <<
static_cast<uint16_t
> (w));
3426 return static_cast<uint16_t
> (w);
3435 " pkt size=" << p->
GetSize () );
3454 if (expectedSeq < m_tcb->m_rxBuffer->NextRxSequence ())
3463 NS_LOG_WARN (
"Why TCP " <<
this <<
" got data after close notification?");
3543 NS_LOG_LOGIC (
"TcpSocketBase::EstimateRtt - RTT calculated from TcpOption::TS is zero, approximating to 1us.");
3567 m_rtt->Measurement (m);
3589 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
3596 NS_LOG_LOGIC (
this <<
" Schedule ReTxTimeout at time " <<
3604 " numberAck " << (ack -
m_txBuffer->HeadSequence ()));
3616 NS_LOG_LOGIC (
this <<
" Cancelled ReTxTimeout event which was set to expire at " <<
3658 NS_LOG_DEBUG (
"Checking if Connection is Established");
3668 NS_LOG_INFO (
"No more data retries available. Dropping connection");
3739 m_txBuffer->HeadSequence () <<
" doubled rto to " <<
3778 NS_LOG_INFO (
"LAST-ACK: No more data retries available. Dropping connection");
3785 NS_LOG_LOGIC (
"TcpSocketBase " <<
this <<
" rescheduling LATO1");
3853 uint32_t maxSizeToSend;
3857 res =
m_txBuffer->NextSeg (&seq, &seqHigh,
false);
3869 maxSizeToSend =
static_cast<uint32_t
> (seqHigh - seq);
4073 return (!allowBroadcast);
4123 maxSpace = maxSpace >> 1;
4129 NS_LOG_WARN (
"Possible error; scale exceeds 14: " << scale);
4134 static_cast<int> (scale) <<
" for buffer size " <<
m_tcb->
m_rxBuffer->MaxBufferSize ());
4196 uint8_t allowedSackBlocks = (optionLenAvail - 2) / 8;
4199 if (allowedSackBlocks == 0 || sackList.empty ())
4201 NS_LOG_LOGIC (
"No space available or sack list empty, not adding sack blocks");
4207 TcpOptionSack::SackList::iterator i;
4208 for (i = sackList.begin (); allowedSackBlocks > 0 && i != sackList.end (); ++i)
4210 option->AddSackBlock (*i);
4211 allowedSackBlocks--;
4268 NS_LOG_INFO (
"Received (scaled) window is " << receivedWindow <<
" bytes");
4282 bool update =
false;
4432 return CopyObject<TcpSocketBase> (
this);
4511 if (pacingRate < m_tcb->m_maxPacingRate)
4513 NS_LOG_DEBUG (
"Pacing rate updated to: " << pacingRate);
a polymophic address class
AttributeValue implementation for Boolean.
bool IsNull(void) const
Check for null implementation.
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.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
static bool IsMatchingType(const Address &addr)
If the address match.
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
uint16_t GetPort(void) const
Get the port.
uint8_t GetTos(void) const
uint16_t GetPort(void) const
Ipv4Address GetIpv4(void) const
static bool IsMatchingType(const Address &address)
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 GetAny(void)
static Ipv4Address GetZero(void)
uint16_t GetPeerPort(void)
Get the peer port.
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
void SetLocalAddress(Ipv4Address address)
Set the local address.
Ipv4Address GetPeerAddress(void)
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).
uint16_t GetLocalPort(void)
Get the local port.
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > callback)
Set the reception callback.
Ipv4Address GetLocalAddress(void)
Get the local address.
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.
Ipv6Address GetLocalAddress()
Get the local address.
void SetPeer(Ipv6Address addr, uint16_t port)
Set the peer information (address and port).
uint16_t GetLocalPort()
Get the local port.
void SetIcmpCallback(Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > callback)
Set the ICMP callback.
void SetLocalAddress(Ipv6Address addr)
Set the local address.
Ipv6Address GetPeerAddress()
Get the peer address.
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
uint16_t GetPeerPort()
Get the peer port.
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv6Header, uint16_t, Ptr< Ipv6Interface > > callback)
Set the reception callback.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
IPv6 layer implementation.
uint32_t GetId(void) const
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
friend Ptr< T > CopyObject(Ptr< T > object)
Copy an Object.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Hold objects of type Ptr<T>.
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(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static Time Now(void)
Return the current simulation virtual time.
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.
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
uint8_t GetPriority(void) const
Query the priority value of this 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.
void SetIpTos(uint8_t ipTos)
Manually set IP Type of Service field.
void NotifyConnectionSucceeded(void)
Notify through the callback (if set) that the connection has been established.
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
void NotifyConnectionFailed(void)
Notify through the callback (if set) that the connection has not been established due to an error.
void NotifyNewConnectionCreated(Ptr< Socket > socket, const Address &from)
Notify through the callback (if set) that a new connection has been created.
bool NotifyConnectionRequest(const Address &from)
Notify through the callback (if set) that an incoming connection is being requested by a remote host.
SocketType
Enumeration of the possible socket types.
void NotifyNormalClose(void)
Notify through the callback (if set) that the connection has been closed.
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.
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
void NotifyDataRecv(void)
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 NotifyErrorClose(void)
Notify through the callback (if set) that the connection has been closed due to an error.
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
virtual uint8_t GetIpv6HopLimit(void) 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.
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
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.
uint8_t GetIpTos(void) const
Query the value of IP Type of Service of this socket.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
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.
virtual uint8_t GetKind(void) const =0
Get the ‘kind’ (as in RFC 793) of this option.
@ 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 SkbSent(TcpTxItem *skb, bool isStartOfTransmission)=0
Put the rate information inside the sent skb.
virtual const TcpRateConnection & GetConnectionRate()=0
virtual void CalculateAppLimited(uint32_t cWnd, uint32_t in_flight, uint32_t segmentSize, const SequenceNumber32 &tailSeq, const SequenceNumber32 &nextTx, const uint32_t lostOut, const uint32_t retransOut)=0
If a gap is detected between sends, it means we are app-limited.
virtual const TcpRateSample & GenerateSample(uint32_t delivered, uint32_t lost, bool is_sack_reneg, uint32_t priorInFlight, const Time &minRtt)=0
Generate a TcpRateSample to feed a congestion avoidance algorithm.
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.
Time m_persistTimeout
Time between sending 1-byte probes.
virtual void SetSegSize(uint32_t size)
Set the segment size.
void UpdateCwndInfl(uint32_t oldValue, uint32_t newValue)
Callback function to hook to TcpSocketState inflated congestion window.
void CloseAndNotify(void)
Peacefully close the socket by notifying the upper layer and deallocate end point.
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.
Ptr< TcpTxBuffer > GetTxBuffer(void) const
Get a pointer to the Tx buffer.
void SendRST(void)
Send reset and tear down this socket.
Ptr< TcpCongestionOps > m_congestionControl
Congestion control.
virtual void SetPersistTimeout(Time timeout)
Set the timeout for persistent 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.
virtual void NewAck(SequenceNumber32 const &seq, bool resetRTO)
Update buffers w.r.t.
void DoRetransmit(void)
Retransmit the first segment marked as lost, without considering available window nor pacing.
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
SequenceNumber32 m_recover
Previous highest Tx seqnum for fast recovery (set it to initial seq number)
int SetupCallback(void)
Common part of the two Bind(), i.e.
void Destroy6(void)
Kill this socket by zeroing its attributes (IPv6)
bool m_recoverActive
Whether "m_recover" has been set/activated It is used to avoid comparing with the old m_recover value...
bool CheckNoEcn(uint8_t tos) const
Checks if TOS has no ECN codepoints.
virtual void SetNode(Ptr< Node > node)
Set the associated node.
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.
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.
virtual void SetDelAckTimeout(Time timeout)
Set the time to delay an ACK.
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.
void ConnectionSucceeded(void)
Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
Ptr< TcpRecoveryOps > m_recoveryOps
Recovery Algorithm.
TracedCallback< uint32_t, uint32_t > m_bytesInFlightTrace
Callback pointer for bytesInFlight trace chaining.
void UpdatePacingRateTrace(DataRate oldValue, DataRate newValue)
Callback function to hook to TcpSocketState pacing rate.
virtual uint32_t GetSndBufSize(void) const
Get the send buffer size.
virtual void SetConnTimeout(Time timeout)
Set the connection timeout.
virtual uint32_t GetSynRetries(void) const
Get the number of connection retries before giving up.
virtual void SetRcvBufSize(uint32_t size)
Set the receive buffer size.
Ptr< TcpRateOps > m_rateOps
Rate operations.
void PeerClose(Ptr< Packet > p, const TcpHeader &tcpHeader)
Received a FIN from peer, notify rx buffer.
virtual uint32_t GetRcvBufSize(void) const
Get the receive buffer size.
bool m_shutdownSend
Send no longer allowed.
void ProcessOptionWScale(const Ptr< const TcpOption > option)
Read and parse the Window scale option.
bool m_closeOnEmpty
Close socket upon tx buffer emptied.
void AddOptionSackPermitted(TcpHeader &header)
Add the SACK PERMITTED option to the header.
TracedValue< Time > m_rto
Retransmit timeout.
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.
void UpdateHighTxMark(SequenceNumber32 oldValue, SequenceNumber32 newValue)
Callback function to hook to TcpSocketState high tx mark.
virtual ~TcpSocketBase(void)
uint32_t m_dupAckCount
Dupack counter.
void SetRetxThresh(uint32_t retxThresh)
Set the retransmission threshold (dup ack threshold for a fast retransmit)
virtual int Listen(void)
Listen for incoming connections.
virtual uint32_t GetDelAckMaxCount(void) const
Get the number of packet to fire an ACK before delay timeout.
virtual uint32_t BytesInFlight(void) const
Return total bytes in flight.
TracedCallback< SequenceNumber32, SequenceNumber32 > m_nextTxSequenceTrace
Callback pointer for next tx sequence chaining.
EventId m_delAckEvent
Delayed ACK timeout event.
TracedCallback< Time, Time > m_lastRttTrace
Callback pointer for RTT trace chaining.
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 DeallocateEndPoint(void)
Deallocate m_endPoint and m_endPoint6.
virtual uint32_t GetTxAvailable(void) const
Returns the number of bytes which can be sent in a single call to Send.
void AddOptions(TcpHeader &tcpHeader)
Add options to TcpHeader.
TracedCallback< TcpSocketState::EcnState_t, TcpSocketState::EcnState_t > m_ecnStateTrace
Callback pointer for ECN state trace chaining.
virtual enum SocketType GetSocketType(void) const
bool IsPacingEnabled(void) const
Return true if packets in the current window should be paced.
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.
bool m_timestampEnabled
Timestamp option enabled.
TracedValue< TcpStates_t > m_state
TCP state.
virtual void SetTcpNoDelay(bool noDelay)
Enable/Disable Nagle's algorithm.
virtual uint32_t UnAckDataCount(void) const
Return count of number of unacked bytes.
void UpdateEcnState(TcpSocketState::EcnState_t oldValue, TcpSocketState::EcnState_t newValue)
Callback function to hook to EcnState state.
Ptr< RttEstimator > m_rtt
Round trip time estimator.
virtual int GetPeerName(Address &address) const
Get the peer address of a connected socket.
virtual void ReTxTimeout(void)
An RTO event happened.
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 GetSegSize(void) const
Get the segment size.
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.
virtual void SetDataRetries(uint32_t retries)
Set the number of data transmission retries before giving up.
virtual void DelAckTimeout(void)
Action upon delay ACK timeout, i.e.
TracedValue< SequenceNumber32 > m_ecnCWRSeq
Sequence number of the last sent CWR.
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback6
ICMPv6 callback.
uint32_t m_delAckCount
Delayed ACK counter.
virtual int ShutdownRecv(void)
virtual Time GetPersistTimeout(void) const
Get the timeout for persistent connection.
virtual uint32_t GetInitialSSThresh(void) const
Get the initial Slow Start Threshold.
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
static uint32_t SafeSubtraction(uint32_t a, uint32_t b)
Performs a safe subtraction between a and b (a-b)
virtual void SetSynRetries(uint32_t count)
Set the number of connection retries before giving up.
virtual int Bind(void)
Allocate a local IPv4 endpoint for this socket.
static TypeId GetTypeId(void)
Get the type ID.
Time m_cnTimeout
Timeout for connection retry.
virtual void PersistTimeout(void)
Send 1 byte probe to get an updated window size.
bool m_winScalingEnabled
Window Scale option enabled (RFC 7323)
virtual uint32_t AvailableWindow(void) const
Return unfilled portion of window.
EventId m_sendPendingDataEvent
micro-delay event to send pending data
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
TcpSocketBase(void)
Create an unbound TCP socket.
uint32_t m_delAckMaxCount
Number of packet to fire an ACK before delay timeout.
void DoPeerClose(void)
FIN is in sequence, notify app and respond with a FIN.
uint8_t CalculateWScale() const
Calculate window scale value based on receive buffer space.
bool m_closeNotified
Told app to close socket.
void UpdateRtt(Time oldValue, Time newValue)
Callback function to hook to TcpSocketState rtt.
void UpdateCongState(TcpSocketState::TcpCongState_t oldValue, TcpSocketState::TcpCongState_t newValue)
Callback function to hook to TcpSocketState congestion state.
void CancelAllTimers(void)
Cancel all timer when endpoint is deleted.
TracedValue< SequenceNumber32 > m_ecnCESeq
Sequence number of the last received Congestion Experienced.
virtual Time GetDelAckTimeout(void) const
Get the time to delay an ACK.
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.
virtual enum SocketErrno GetErrno(void) const
Get last error number.
uint32_t GetRWnd(void) const
Get the current value of the receiver's offered window (RCV.WND)
void DupAck(uint32_t currentDelivered)
Dupack management.
bool m_shutdownRecv
Receive no longer allowed.
virtual Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
std::deque< RttHistory > m_history
List of sent packet.
void ProcessOptionSackPermitted(const Ptr< const TcpOption > option)
Read the SACK PERMITTED option.
TracedValue< SequenceNumber32 > m_highRxMark
Highest seqno received.
void ReadOptions(const TcpHeader &tcpHeader, uint32_t *bytesSacked)
Read TCP options before Ack processing.
void Destroy(void)
Kill this socket by zeroing its attributes (IPv4)
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.
void UpdatePacingRate(void)
Dynamically update the pacing rate.
void UpdateSsThresh(uint32_t oldValue, uint32_t newValue)
Callback function to hook to TcpSocketState slow start threshold.
int SetupEndpoint(void)
Configure the endpoint to a local address.
virtual uint32_t GetRxAvailable(void) const
Return number of bytes which can be returned from one or multiple calls to Recv.
virtual void SetInitialCwnd(uint32_t cwnd)
Set the initial Congestion Window.
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.
virtual bool GetAllowBroadcast(void) const
Query whether broadcast datagram transmissions are allowed.
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
virtual void SetDelAckMaxCount(uint32_t count)
Set the number of packet to fire an ACK before delay timeout.
TracedCallback< DataRate, DataRate > m_pacingRateTrace
Callback pointer for pacing rate trace chaining.
virtual uint32_t GetDataRetries(void) const
Get the number of data transmission retries before giving up.
virtual bool GetTcpNoDelay(void) const
Check if Nagle's algorithm is enabled or not.
uint32_t m_timestampToEcho
Timestamp to echo.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
virtual int ShutdownSend(void)
TracedCallback< uint32_t, uint32_t > m_ssThTrace
Callback pointer for ssTh trace chaining.
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.
virtual int Bind6(void)
Allocate a local IPv6 endpoint for this socket.
Ptr< Node > m_node
the associated node
int DoConnect(void)
Perform the real connection tasks: Send SYN if allowed, RST if invalid.
uint32_t GetRetxThresh(void) const
Get the retransmission threshold (dup ack threshold for a fast retransmit)
SequenceNumber32 GetHighRxAck(void) const
Get the current value of the receiver's highest (in-sequence) sequence number acked.
uint32_t m_synRetries
Number of connection attempts.
virtual uint32_t Window(void) const
Return the max possible number of unacked bytes.
EventId m_lastAckEvent
Last ACK timeout event.
bool IsTcpOptionEnabled(uint8_t kind) const
Return true if the specified option is enabled.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
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 SetCongestionControlAlgorithm(Ptr< TcpCongestionOps > algo)
Install a congestion control algorithm on this socket.
void TimeWait(void)
Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state.
uint32_t m_dataRetrCount
Count of remaining data retransmission attempts.
bool m_noDelay
Set to true to disable Nagle's algorithm.
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.
virtual void ProcessAck(const SequenceNumber32 &ackNumber, bool scoreboardUpdated, uint32_t currentDelivered, const SequenceNumber32 &oldHeadSequence)
Process a received ack.
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
virtual void SetSndBufSize(uint32_t size)
Set the send buffer size.
Time m_delAckTimeout
Time to delay an ACK.
void UpdateNextTxSequence(SequenceNumber32 oldValue, SequenceNumber32 newValue)
Callback function to hook to TcpSocketState next tx sequence.
void SetUseEcn(TcpSocketState::UseEcn_t useEcn)
Set ECN mode of use on the socket.
virtual int Close(void)
Close a 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.
virtual int GetSockName(Address &address) const
Get socket address.
virtual void SetInitialSSThresh(uint32_t threshold)
Set the initial Slow Start Threshold.
int DoClose(void)
Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state.
Time GetClockGranularity(void) const
Get the Clock Granularity (used in RTO calcs).
void UpdateBytesInFlight(uint32_t oldValue, uint32_t newValue)
Callback function to hook to TcpSocketState bytes inflight.
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.
void NotifyPacingPerformed(void)
Notify Pacing.
Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback
ICMP callback.
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.
Ptr< TcpRxBuffer > GetRxBuffer(void) const
Get a pointer to the Rx buffer.
TracedValue< uint32_t > m_rWnd
Receiver window (RCV.WND in RFC793)
void UpdateCwnd(uint32_t oldValue, uint32_t newValue)
Callback function to hook to TcpSocketState congestion window.
void ProcessOptionTimestamp(const Ptr< const TcpOption > option, const SequenceNumber32 &seq)
Process the timestamp option from other side.
virtual TypeId GetInstanceTypeId() const
Get the instance TypeId.
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 SetMinRto(Time minRto)
Sets the Minimum RTO.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)
Read a single packet from the socket and retrieve the sender address.
uint32_t ProcessOptionSack(const Ptr< const TcpOption > option)
Read the SACK option.
void SetRecoveryAlgorithm(Ptr< TcpRecoveryOps > recovery)
Install a recovery algorithm on this socket.
virtual Time GetConnTimeout(void) const
Get the connection timeout.
virtual uint32_t GetInitialCwnd(void) const
Get the initial Congestion Window.
Time GetMinRto(void) const
Get the Minimum RTO.
int SetupEndpoint6(void)
Configure the endpoint v6 to a local address.
void AddSocketTags(const Ptr< Packet > &p) const
Add Tags for the Socket.
TracedCallback< uint32_t, uint32_t > m_cWndInflTrace
Callback pointer for cWndInfl trace chaining.
virtual void LastAckTimeout(void)
Timeout at LAST_ACK, close the connection.
(abstract) base class of all TcpSockets
static const char *const TcpStateName[TcpSocket::LAST_STATE]
Literal names of TCP states for use in log messages.
uint32_t m_segmentSize
Segment size.
@ 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
Time m_minRtt
Minimum RTT observed throughout the connection.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
uint32_t m_initialSsThresh
Initial Slow Start Threshold value.
EcnMode_t m_ecnMode
ECN mode.
Callback< void, uint8_t > m_sendEmptyPacketCallback
Callback to send an empty packet.
TracedValue< DataRate > m_pacingRate
Current Pacing rate.
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.
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
bool m_paceInitialWindow
Enable/Disable pacing for the initial window.
DataRate m_maxPacingRate
Max Pacing rate.
UseEcn_t m_useEcn
Socket ECN capability.
bool m_pacing
Pacing status.
bool m_isRetransDataAcked
Retransmitted data is ACKed if true.
static 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.
SequenceNumber32 m_lastAckedSeq
Last sequence ACKed.
@ DctcpEcn
ECN functionality as described in RFC 8257.
TracedValue< uint32_t > m_cWnd
Congestion window.
uint32_t m_initialCWnd
Initial cWnd value.
uint32_t m_rcvTimestampEchoReply
Sender Timestamp echoed by the receiver.
TracedValue< Time > m_lastRtt
Last RTT sample collected.
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
TracedValue< uint32_t > m_bytesInFlight
Bytes in flight.
TracedValue< uint32_t > m_cWndInfl
Inflated congestion window trace (used only for backward compatibility purpose)
uint16_t m_pacingCaRatio
CA pacing ratio.
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.
uint32_t m_lastAckedSackedBytes
The number of bytes acked and sacked as indicated by the current ACK received.
uint16_t m_pacingSsRatio
SS pacing ratio.
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
uint32_t m_rcvTimestampValue
Receiver Timestamp value.
EcnCodePoint_t m_ectCodePoint
ECT code point to use.
Item that encloses the application packet and some flags for it.
bool IsRetrans(void) const
Is the item retransmitted?
Ptr< Packet > GetPacketCopy(void) const
Get a copy of the Packet underlying this item.
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static Time FromDouble(double value, enum Unit unit)
Create a Time equal to value in unit unit.
bool IsZero(void) const
Exactly equivalent to t == 0.
AttributeValue implementation for Time.
A simple virtual Timer class.
bool IsExpired(void) const
bool IsRunning(void) const
Time GetDelayLeft(void) const
void Schedule(void)
Schedule a new event using the currently-configured delay, function, and arguments.
void Cancel(void)
Cancel the currently-running event if there is one.
T Get(void) 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(void)
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(void)
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< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
#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.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
uint64_t m_delivered
The total amount of data in bytes delivered so far.