A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-socket-base.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 Georgia Tech Research Corporation
3 * Copyright (c) 2010 Adrian Sai-wah Tam
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
8 */
9#ifndef TCP_SOCKET_BASE_H
10#define TCP_SOCKET_BASE_H
11
12#include "ipv4-header.h"
13#include "ipv6-header.h"
14#include "tcp-socket-state.h"
15#include "tcp-socket.h"
16
17#include "ns3/data-rate.h"
18#include "ns3/node.h"
19#include "ns3/sequence-number.h"
20#include "ns3/timer.h"
21#include "ns3/traced-value.h"
22
23#include <queue>
24#include <stdint.h>
25
26namespace ns3
27{
28
29class Ipv4EndPoint;
30class Ipv6EndPoint;
31class Node;
32class Packet;
33class TcpL4Protocol;
34class TcpHeader;
36class TcpRecoveryOps;
37class RttEstimator;
38class TcpRxBuffer;
39class TcpTxBuffer;
40class TcpOption;
41class Ipv4Interface;
42class Ipv6Interface;
43class TcpRateOps;
44
45/**
46 * @ingroup tcp
47 *
48 * @brief Helper class to store RTT measurements
49 */
51{
52 public:
53 /**
54 * @brief Constructor - builds an RttHistory with the given parameters
55 * @param s First sequence number in packet sent
56 * @param c Number of bytes sent
57 * @param t Time this one was sent
58 */
60 /**
61 * @brief Copy constructor
62 * @param h the object to copy
63 */
64 RttHistory(const RttHistory& h); // Copy constructor
65 public:
66 SequenceNumber32 seq; //!< First sequence number in packet sent
67 uint32_t count; //!< Number of bytes sent
68 Time time; //!< Time this one was sent
69 bool retx; //!< True if this has been retransmitted
70};
71
72/**
73 * @ingroup socket
74 * @ingroup tcp
75 *
76 * @brief A base class for implementation of a stream socket using TCP.
77 *
78 * This class contains the essential components of TCP, as well as a sockets
79 * interface for upper layers to call. This class provides connection orientation
80 * and sliding window flow control; congestion control is delegated to subclasses
81 * of TcpCongestionOps. Part of TcpSocketBase is modified from the original
82 * NS-3 TCP socket implementation (TcpSocketImpl) by
83 * Raj Bhattacharjea <raj.b@gatech.edu> of Georgia Tech.
84 *
85 * For IPv4 packets, the TOS set for the socket is used. The Bind and Connect
86 * operations set the TOS for the socket to the value specified in the provided
87 * address. A SocketIpTos tag is only added to the packet if the resulting
88 * TOS is non-null.
89 * Each packet is assigned the priority set for the socket. Setting a TOS
90 * for a socket also sets a priority for the socket (according to the
91 * Socket::IpTos2Priority function). A SocketPriority tag is only added to the
92 * packet if the priority is non-null.
93 *
94 * Congestion state machine
95 * ---------------------------
96 *
97 * The socket maintains two state machines; the TCP one, and another called
98 * "Congestion state machine", which keeps track of the phase we are in. Currently,
99 * ns-3 manages the states:
100 *
101 * - CA_OPEN
102 * - CA_DISORDER
103 * - CA_RECOVERY
104 * - CA_LOSS
105 * - CA_CWR
106 *
107 * For more information, see the TcpCongState_t documentation.
108 *
109 * Congestion control interface
110 * ---------------------------
111 *
112 * Congestion control, unlike older releases of ns-3, has been split from
113 * TcpSocketBase. In particular, each congestion control is now a subclass of
114 * the main TcpCongestionOps class. Switching between congestion algorithm is
115 * now a matter of setting a pointer into the TcpSocketBase class. The idea
116 * and the interfaces are inspired by the Linux operating system, and in
117 * particular from the structure tcp_congestion_ops. The reference paper is
118 * https://www.sciencedirect.com/science/article/abs/pii/S1569190X15300939.
119 *
120 * Transmission Control Block (TCB)
121 * --------------------------------
122 *
123 * The variables needed to congestion control classes to operate correctly have
124 * been moved inside the TcpSocketState class. It contains information on the
125 * congestion window, slow start threshold, segment size and the state of the
126 * Congestion state machine.
127 *
128 * To track the trace inside the TcpSocketState class, a "forward" technique is
129 * used, which consists in chaining callbacks from TcpSocketState to TcpSocketBase
130 * (see for example cWnd trace source).
131 *
132 * Fast retransmit
133 * ----------------
134 *
135 * The fast retransmit enhancement is introduced in RFC 2581 and updated in RFC
136 * 5681. It reduces the time a sender waits before retransmitting a lost segment,
137 * through the assumption that if it receives a certain number of duplicate ACKs,
138 * a segment has been lost and it can be retransmitted. Usually, it is coupled
139 * with the Limited Transmit algorithm, defined in RFC 3042. These algorithms
140 * are included in this class, and they are implemented inside the ProcessAck
141 * method. With the SACK option enabled, the LimitedTransmit algorithm will be
142 * always on, as a consequence of how the information in the received SACK block
143 * is managed.
144 *
145 * The attribute which manages the number of dup ACKs necessary to start the
146 * fast retransmit algorithm is named "ReTxThreshold", and by default is 3.
147 * The parameter is also used in TcpTxBuffer to determine if a packet is lost
148 * (please take a look at TcpTxBuffer documentation to see details) but,
149 * right now, it is assumed to be fixed. In future releases this parameter can
150 * be made dynamic, to reflect the reordering degree of the network. With SACK,
151 * the next sequence to transmit is given by the RFC 6675 algorithm. Without
152 * SACK option, the implementation adds "hints" to TcpTxBuffer to make sure it
153 * returns, as next transmittable sequence, the first lost (or presumed lost)
154 * segment.
155 *
156 * Fast recovery
157 * -------------
158 *
159 * The fast recovery algorithm is introduced RFC 2001, and it avoids to reset
160 * cWnd to 1 segment after sensing a loss on the channel. Instead, a new slow
161 * start threshold value is asked to the congestion control (for instance,
162 * with NewReno the returned amount is half of the previous), and the cWnd is
163 * set equal to such value. Ns-3 does not implement any inflation/deflation to
164 * the congestion window since it uses an evolved method (borrowed from Linux
165 * operating system) to calculate the number of bytes in flight. The fundamental
166 * idea is to subtract from the total bytes in flight the lost/sacked amount
167 * (the segments that have left the network) and to add the retransmitted count.
168 * In this way, congestion window represents the exact number of bytes that
169 * should be in flight. The implementation then decides what to transmit, it
170 * there is space, between new or already transmitted data portion. If a value
171 * of the congestion window with inflation and deflation is needed, there is a
172 * traced source named "CongestionWindowInflated". However, the variable behind
173 * it is not used in the code, but maintained for backward compatibility.
174 *
175 * RTO expiration
176 * --------------
177 *
178 * When the Retransmission Time Out expires, the TCP faces a significant
179 * performance drop. The expiration event is managed in the ReTxTimeout method,
180 * which set the cWnd to 1 segment and starts "from scratch" again. The list
181 * of sent packet is set as lost entirely, and the transmission is re-started
182 * from the SND.UNA sequence number.
183 *
184 * Options management
185 * ------------------
186 *
187 * SYN and SYN-ACK options, which are allowed only at the beginning of the
188 * connection, are managed in the DoForwardUp and SendEmptyPacket methods.
189 * To read all others, we have set up a cycle inside ReadOptions. For adding
190 * them, there is no a unique place, since the options (and the information
191 * available to build them) are scattered around the code. For instance,
192 * the SACK option is built in SendEmptyPacket only under certain conditions.
193 *
194 * SACK
195 * ----
196 *
197 * The SACK generation/management is delegated to the buffer classes, namely
198 * TcpTxBuffer and TcpRxBuffer. In TcpRxBuffer it is managed the creation
199 * of the SACK option from the receiver point of view. It must provide an
200 * accurate (and efficient) representation of the status of the receiver buffer.
201 * On the other side, inside TcpTxBuffer the received options (that contain
202 * the SACK block) are processed and a particular data structure, called Scoreboard,
203 * is filled. Please take a look at TcpTxBuffer and TcpRxBuffer documentation if
204 * you need more information. The reference paper is
205 * https://dl.acm.org/citation.cfm?id=3067666.
206 *
207 */
209{
210 public:
211 /**
212 * Get the type ID.
213 * @brief Get the type ID.
214 * @return the object TypeId
215 */
216 static TypeId GetTypeId();
217
218 /**
219 * @brief TcpGeneralTest friend class (for tests).
220 * @relates TcpGeneralTest
221 */
222 friend class TcpGeneralTest;
223
224 /**
225 * Create an unbound TCP socket
226 */
228
229 /**
230 * Clone a TCP socket, for use upon receiving a connection request in LISTEN state
231 *
232 * @param sock the original Tcp Socket
233 */
234 TcpSocketBase(const TcpSocketBase& sock);
235 ~TcpSocketBase() override;
236
237 /**
238 * @brief Tcp Packet Types
239 *
240 * Taxonomy referred from Table 1 of
241 * https://www.ietf.org/archive/id/draft-ietf-tcpm-generalized-ecn-15.txt
242 */
255
256 // Set associated Node, TcpL4Protocol, RttEstimator to this socket
257
258 /**
259 * @brief Set the associated node.
260 * @param node the node
261 */
262 virtual void SetNode(Ptr<Node> node);
263
264 /**
265 * @brief Set the associated TCP L4 protocol.
266 * @param tcp the TCP L4 protocol
267 */
268 virtual void SetTcp(Ptr<TcpL4Protocol> tcp);
269
270 /**
271 * @brief Set the associated RTT estimator.
272 * @param rtt the RTT estimator
273 */
274 virtual void SetRtt(Ptr<RttEstimator> rtt);
275
276 /**
277 * @brief Sets the Minimum RTO.
278 * @param minRto The minimum RTO.
279 */
280 void SetMinRto(Time minRto);
281
282 /**
283 * @brief Get the Minimum RTO.
284 * @return The minimum RTO.
285 */
286 Time GetMinRto() const;
287
288 /**
289 * @brief Sets the Clock Granularity (used in RTO calcs).
290 * @param clockGranularity The Clock Granularity
291 */
292 void SetClockGranularity(Time clockGranularity);
293
294 /**
295 * @brief Get the Clock Granularity (used in RTO calcs).
296 * @return The Clock Granularity.
297 */
299
300 /**
301 * @brief Get a pointer to the Tx buffer
302 * @return a pointer to the tx buffer
303 */
305
306 /**
307 * @brief Get a pointer to the Rx buffer
308 * @return a pointer to the rx buffer
309 */
311
312 /**
313 * @brief Set the retransmission threshold (dup ack threshold for a fast retransmit)
314 * @param retxThresh the threshold
315 */
316 void SetRetxThresh(uint32_t retxThresh);
317
318 /**
319 * @brief Get the retransmission threshold (dup ack threshold for a fast retransmit)
320 * @return the threshold
321 */
323 {
324 return m_retxThresh;
325 }
326
327 /**
328 * @brief Callback pointer for pacing rate trace chaining
329 */
331
332 /**
333 * @brief Callback pointer for cWnd trace chaining
334 */
336
337 /**
338 * @brief Callback pointer for cWndInfl trace chaining
339 */
341
342 /**
343 * @brief Callback pointer for ssTh trace chaining
344 */
346
347 /**
348 * @brief Callback pointer for congestion state trace chaining
349 */
351
352 /**
353 * @brief Callback pointer for ECN state trace chaining
354 */
356
357 /**
358 * @brief Callback pointer for high tx mark chaining
359 */
361
362 /**
363 * @brief Callback pointer for next tx sequence chaining
364 */
366
367 /**
368 * @brief Callback pointer for bytesInFlight trace chaining
369 */
371
372 /**
373 * @brief Callback pointer for RTT trace chaining
374 */
376
377 /**
378 * @brief Callback pointer for Last RTT trace chaining
379 */
381
382 /**
383 * @brief Callback function to hook to TcpSocketState pacing rate
384 * @param oldValue old pacing rate value
385 * @param newValue new pacing rate value
386 */
387 void UpdatePacingRateTrace(DataRate oldValue, DataRate newValue) const;
388
389 /**
390 * @brief Callback function to hook to TcpSocketState congestion window
391 * @param oldValue old cWnd value
392 * @param newValue new cWnd value
393 */
394 void UpdateCwnd(uint32_t oldValue, uint32_t newValue) const;
395
396 /**
397 * @brief Callback function to hook to TcpSocketState inflated congestion window
398 * @param oldValue old cWndInfl value
399 * @param newValue new cWndInfl value
400 */
401 void UpdateCwndInfl(uint32_t oldValue, uint32_t newValue) const;
402
403 /**
404 * @brief Callback function to hook to TcpSocketState slow start threshold
405 * @param oldValue old ssTh value
406 * @param newValue new ssTh value
407 */
408 void UpdateSsThresh(uint32_t oldValue, uint32_t newValue) const;
409
410 /**
411 * @brief Callback function to hook to TcpSocketState congestion state
412 * @param oldValue old congestion state value
413 * @param newValue new congestion state value
414 */
416 TcpSocketState::TcpCongState_t newValue) const;
417
418 /**
419 * @brief Callback function to hook to EcnState state
420 * @param oldValue old ecn state value
421 * @param newValue new ecn state value
422 */
424 TcpSocketState::EcnState_t newValue) const;
425
426 /**
427 * @brief Callback function to hook to TcpSocketState high tx mark
428 * @param oldValue old high tx mark
429 * @param newValue new high tx mark
430 */
431 void UpdateHighTxMark(SequenceNumber32 oldValue, SequenceNumber32 newValue) const;
432
433 /**
434 * @brief Callback function to hook to TcpSocketState next tx sequence
435 * @param oldValue old nextTxSeq value
436 * @param newValue new nextTxSeq value
437 */
438 void UpdateNextTxSequence(SequenceNumber32 oldValue, SequenceNumber32 newValue) const;
439
440 /**
441 * @brief Callback function to hook to TcpSocketState bytes inflight
442 * @param oldValue old bytesInFlight value
443 * @param newValue new bytesInFlight value
444 */
445 void UpdateBytesInFlight(uint32_t oldValue, uint32_t newValue) const;
446
447 /**
448 * @brief Callback function to hook to TcpSocketState rtt
449 * @param oldValue old rtt value
450 * @param newValue new rtt value
451 */
452 void UpdateRtt(Time oldValue, Time newValue) const;
453
454 /**
455 * @brief Callback function to hook to TcpSocketState lastRtt
456 * @param oldValue old lastRtt value
457 * @param newValue new lastRtt value
458 */
459 void UpdateLastRtt(Time oldValue, Time newValue) const;
460
461 /**
462 * @brief Install a congestion control algorithm on this socket
463 *
464 * @param algo Algorithm to be installed
465 */
467
468 /**
469 * @brief Install a recovery algorithm on this socket
470 *
471 * @param recovery Algorithm to be installed
472 */
474
475 /**
476 * @brief Mark ECT(0) codepoint
477 *
478 * @param tos the TOS byte to modify
479 * @return TOS with ECT(0) codepoint set
480 */
481 inline uint8_t MarkEcnEct0(uint8_t tos) const
482 {
483 return ((tos & 0xfc) | 0x02);
484 }
485
486 /**
487 * @brief Mark ECT(1) codepoint
488 *
489 * @param tos the TOS byte to modify
490 * @return TOS with ECT(1) codepoint set
491 */
492 inline uint8_t MarkEcnEct1(uint8_t tos) const
493 {
494 return ((tos & 0xfc) | 0x01);
495 }
496
497 /**
498 * @brief Mark CE codepoint
499 *
500 * @param tos the TOS byte to modify
501 * @return TOS with CE codepoint set
502 */
503 inline uint8_t MarkEcnCe(uint8_t tos) const
504 {
505 return ((tos & 0xfc) | 0x03);
506 }
507
508 /**
509 * @brief Clears ECN bits from TOS
510 *
511 * @param tos the TOS byte to modify
512 * @return TOS without ECN bits
513 */
514 inline uint8_t ClearEcnBits(uint8_t tos) const
515 {
516 return tos & 0xfc;
517 }
518
519 /**
520 * @brief Checks if TOS has no ECN codepoints
521 *
522 * @param tos the TOS byte to check
523 * @return true if TOS does not have any ECN codepoints set; otherwise false
524 */
525 inline bool CheckNoEcn(uint8_t tos) const
526 {
527 return ((tos & 0x03) == 0x00);
528 }
529
530 /**
531 * @brief Checks for ECT(0) codepoint
532 *
533 * @param tos the TOS byte to check
534 * @return true if TOS has ECT(0) codepoint set; otherwise false
535 */
536 inline bool CheckEcnEct0(uint8_t tos) const
537 {
538 return ((tos & 0x03) == 0x02);
539 }
540
541 /**
542 * @brief Checks for ECT(1) codepoint
543 *
544 * @param tos the TOS byte to check
545 * @return true if TOS has ECT(1) codepoint set; otherwise false
546 */
547 inline bool CheckEcnEct1(uint8_t tos) const
548 {
549 return ((tos & 0x03) == 0x01);
550 }
551
552 /**
553 * @brief Checks for CE codepoint
554 *
555 * @param tos the TOS byte to check
556 * @return true if TOS has CE codepoint set; otherwise false
557 */
558 inline bool CheckEcnCe(uint8_t tos) const
559 {
560 return ((tos & 0x03) == 0x03);
561 }
562
563 /**
564 * @brief mark ECN code point
565 *
566 * @param tos the TOS byte to modify
567 * @param codePoint the codepoint to use
568 * @return TOS with specified ECN code point
569 */
570 inline uint8_t MarkEcnCodePoint(const uint8_t tos,
571 const TcpSocketState::EcnCodePoint_t codePoint) const
572 {
573 return ((tos & 0xfc) | codePoint);
574 }
575
576 /**
577 * @brief Set ECN mode of use on the socket
578 *
579 * @param useEcn Mode of ECN to use.
580 */
582 /**
583 * @brief Set ABE mode of use on the socket
584 *
585 * @param useAbe Mode of ABE to use.
586 */
587 void SetUseAbe(bool useAbe);
588 /**
589 * @brief Get ABE mode of use on the socket
590 *
591 * @return true if ABE is enabled, false otherwise.
592 */
593 bool GetUseAbe() const;
594 /**
595 * @brief Enable or disable pacing
596 * @param pacing Boolean to enable or disable pacing
597 */
598 void SetPacingStatus(bool pacing);
599
600 /**
601 * @brief Enable or disable pacing of the initial window
602 * @param paceWindow Boolean to enable or disable pacing of the initial window
603 */
604 void SetPaceInitialWindow(bool paceWindow);
605
606 /**
607 * @brief Checks if a TCP packet should be ECN-capable (ECT) according to the TcpPacketType and
608 * ECN mode.
609 *
610 * Currently, only Classic ECN and DCTCP ECN modes are supported, with
611 * potential extensions for future modes (Ecnpp).
612 *
613 * @param packetType The type of the TCP packet, represented by an enum TcpPacketType.
614 * @return true if the packet is ECN-capable (ECT), false otherwise.
615 *
616 * Reference: https://www.ietf.org/archive/id/draft-ietf-tcpm-generalized-ecn-15.txt (Table 1)
617 */
618 bool IsEct(TcpPacketType_t packetType) const;
619
620 // Necessary implementations of null functions from ns3::Socket
621 SocketErrno GetErrno() const override; // returns m_errno
622 SocketType GetSocketType() const override; // returns socket type
623 Ptr<Node> GetNode() const override; // returns m_node
624 int Bind() override; // Bind a socket by setting up endpoint in TcpL4Protocol
625 int Bind6() override; // Bind a socket by setting up endpoint in TcpL4Protocol
626 int Bind(const Address& address) override; // ... endpoint of specific addr or port
627 int Connect(
628 const Address& address) override; // Setup endpoint and call ProcessAction() to connect
629 int Listen()
630 override; // Verify the socket is in a correct state and call ProcessAction() to listen
631 int Close() override; // Close by app: Kill socket upon tx buffer emptied
632 int ShutdownSend() override; // Assert the m_shutdownSend flag to prevent send to network
633 int ShutdownRecv() override; // Assert the m_shutdownRecv flag to prevent forward to app
634 int Send(Ptr<Packet> p, uint32_t flags) override; // Call by app to send data to network
635 int SendTo(Ptr<Packet> p,
636 uint32_t flags,
637 const Address& toAddress) override; // Same as Send(), toAddress is insignificant
638 Ptr<Packet> Recv(uint32_t maxSize,
639 uint32_t flags) override; // Return a packet to be forwarded to app
640 Ptr<Packet> RecvFrom(uint32_t maxSize, uint32_t flags, Address& fromAddress)
641 override; // ... and write the remote address at fromAddress
642 uint32_t GetTxAvailable() const override; // Available Tx buffer size
644 const override; // Available-to-read data size, i.e. value of m_rxAvailable
645 int GetSockName(Address& address) const override; // Return local addr:port in address
646 int GetPeerName(Address& address) const override;
647 void BindToNetDevice(Ptr<NetDevice> netdevice) override; // NetDevice with my m_endPoint
648
649 /**
650 * TracedCallback signature for TCP packet transmission or reception events.
651 *
652 * @param [in] packet The packet.
653 * @param [in] header The TcpHeader
654 * @param [in] socket This socket
655 */
656 typedef void (*TcpTxRxTracedCallback)(const Ptr<const Packet> packet,
657 const TcpHeader& header,
658 const Ptr<const TcpSocketBase> socket);
659
660 /**
661 * TracedCallback signature for TCP packet retransmission events.
662 *
663 * @param [in] packet The packet.
664 * @param [in] header The TcpHeader
665 * @param [in] localAddr The local address
666 * @param [in] peerAddr The peer/remote address
667 * @param [in] socket This socket
668 */
669 typedef void (*RetransmissionCallback)(const Ptr<const Packet> packet,
670 const TcpHeader& header,
671 const Address& localAddr,
672 const Address& peerAddr,
673 const Ptr<const TcpSocketBase> socket);
674
675 protected:
676 // Implementing ns3::TcpSocket -- Attribute get/set
677 // inherited, no need to doc
678
679 void SetSndBufSize(uint32_t size) override;
680 uint32_t GetSndBufSize() const override;
681 void SetRcvBufSize(uint32_t size) override;
682 uint32_t GetRcvBufSize() const override;
683 void SetSegSize(uint32_t size) override;
684 uint32_t GetSegSize() const override;
685 void SetInitialSSThresh(uint32_t threshold) override;
686 uint32_t GetInitialSSThresh() const override;
687 void SetInitialCwnd(uint32_t cwnd) override;
688 uint32_t GetInitialCwnd() const override;
689 void SetConnTimeout(Time timeout) override;
690 Time GetConnTimeout() const override;
691 void SetSynRetries(uint32_t count) override;
692 uint32_t GetSynRetries() const override;
693 void SetDataRetries(uint32_t retries) override;
694 uint32_t GetDataRetries() const override;
695 void SetDelAckTimeout(Time timeout) override;
696 Time GetDelAckTimeout() const override;
697 void SetDelAckMaxCount(uint32_t count) override;
698 uint32_t GetDelAckMaxCount() const override;
699 void SetTcpNoDelay(bool noDelay) override;
700 bool GetTcpNoDelay() const override;
701 void SetPersistTimeout(Time timeout) override;
702 Time GetPersistTimeout() const override;
703 bool SetAllowBroadcast(bool allowBroadcast) override;
704 bool GetAllowBroadcast() const override;
705 void NotifyConstructionCompleted() override;
706
707 // Helper functions: Connection set up
708
709 /**
710 * @brief Common part of the two Bind(), i.e. set callback and remembering local addr:port
711 *
712 * @returns 0 on success, -1 on failure
713 */
714 int SetupCallback();
715
716 /**
717 * @brief Perform the real connection tasks: Send SYN if allowed, RST if invalid
718 *
719 * @returns 0 on success
720 */
721 int DoConnect();
722
723 /**
724 * @brief Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
725 */
726 void ConnectionSucceeded();
727
728 /**
729 * @brief Configure the endpoint to a local address. Called by Connect() if Bind() didn't
730 * specify one.
731 *
732 * @returns 0 on success
733 */
734 int SetupEndpoint();
735
736 /**
737 * @brief Configure the endpoint v6 to a local address. Called by Connect() if Bind() didn't
738 * specify one.
739 *
740 * @returns 0 on success
741 */
742 int SetupEndpoint6();
743
744 /**
745 * @brief Complete a connection by forking the socket
746 *
747 * This function is called only if a SYN received in LISTEN state. After
748 * TcpSocketBase cloned, allocate a new end point to handle the incoming
749 * connection and send a SYN+ACK to complete the handshake.
750 *
751 * @param p the packet triggering the fork
752 * @param tcpHeader the TCP header of the triggering packet
753 * @param fromAddress the address of the remote host
754 * @param toAddress the address the connection is directed to
755 */
756 virtual void CompleteFork(Ptr<Packet> p,
757 const TcpHeader& tcpHeader,
758 const Address& fromAddress,
759 const Address& toAddress);
760
761 // Helper functions: Transfer operation
762
763 /**
764 * @brief Checks whether the given TCP segment is valid or not.
765 *
766 * @param seq the sequence number of packet's TCP header
767 * @param tcpHeaderSize the size of packet's TCP header
768 * @param tcpPayloadSize the size of TCP payload
769 * @return true if the TCP segment is valid
770 */
771 bool IsValidTcpSegment(const SequenceNumber32 seq,
772 const uint32_t tcpHeaderSize,
773 const uint32_t tcpPayloadSize);
774
775 /**
776 * @brief Called by the L3 protocol when it received a packet to pass on to TCP.
777 *
778 * @param packet the incoming packet
779 * @param header the packet's IPv4 header
780 * @param port the remote port
781 * @param incomingInterface the incoming interface
782 */
783 void ForwardUp(Ptr<Packet> packet,
784 Ipv4Header header,
785 uint16_t port,
786 Ptr<Ipv4Interface> incomingInterface);
787
788 /**
789 * @brief Called by the L3 protocol when it received a packet to pass on to TCP.
790 *
791 * @param packet the incoming packet
792 * @param header the packet's IPv6 header
793 * @param port the remote port
794 * @param incomingInterface the incoming interface
795 */
796 void ForwardUp6(Ptr<Packet> packet,
797 Ipv6Header header,
798 uint16_t port,
799 Ptr<Ipv6Interface> incomingInterface);
800
801 /**
802 * @brief Called by TcpSocketBase::ForwardUp{,6}().
803 *
804 * Get a packet from L3. This is the real function to handle the
805 * incoming packet from lower layers. This is
806 * wrapped by ForwardUp() so that this function can be overloaded by daughter
807 * classes.
808 *
809 * @param packet the incoming packet
810 * @param fromAddress the address of the sender of packet
811 * @param toAddress the address of the receiver of packet (hopefully, us)
812 */
813 virtual void DoForwardUp(Ptr<Packet> packet,
814 const Address& fromAddress,
815 const Address& toAddress);
816
817 /**
818 * @brief Called by the L3 protocol when it received an ICMP packet to pass on to TCP.
819 *
820 * @param icmpSource the ICMP source address
821 * @param icmpTtl the ICMP Time to Live
822 * @param icmpType the ICMP Type
823 * @param icmpCode the ICMP Code
824 * @param icmpInfo the ICMP Info
825 */
826 void ForwardIcmp(Ipv4Address icmpSource,
827 uint8_t icmpTtl,
828 uint8_t icmpType,
829 uint8_t icmpCode,
830 uint32_t icmpInfo);
831
832 /**
833 * @brief Called by the L3 protocol when it received an ICMPv6 packet to pass on to TCP.
834 *
835 * @param icmpSource the ICMP source address
836 * @param icmpTtl the ICMP Time to Live
837 * @param icmpType the ICMP Type
838 * @param icmpCode the ICMP Code
839 * @param icmpInfo the ICMP Info
840 */
841 void ForwardIcmp6(Ipv6Address icmpSource,
842 uint8_t icmpTtl,
843 uint8_t icmpType,
844 uint8_t icmpCode,
845 uint32_t icmpInfo);
846
847 /**
848 * @brief Send as much pending data as possible according to the Tx window.
849 *
850 * Note that this function did not implement the PSH flag.
851 *
852 * @param withAck forces an ACK to be sent
853 * @returns the number of packets sent
854 */
855 uint32_t SendPendingData(bool withAck = false);
856
857 /**
858 * @brief Extract at most maxSize bytes from the TxBuffer at sequence seq, add the
859 * TCP header, and send to TcpL4Protocol
860 *
861 * @param seq the sequence number
862 * @param maxSize the maximum data block to be transmitted (in bytes)
863 * @param withAck forces an ACK to be sent
864 * @returns the number of bytes sent
865 */
866 virtual uint32_t SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, bool withAck);
867
868 /**
869 * @brief Send a empty packet that carries a flag, e.g., ACK
870 *
871 * @param flags the packet's flags
872 */
873 virtual void SendEmptyPacket(uint8_t flags);
874
875 /**
876 * @brief Send reset and tear down this socket
877 */
878 void SendRST();
879
880 /**
881 * @brief Check if a sequence number range is within the rx window
882 *
883 * @param head start of the Sequence window
884 * @param tail end of the Sequence window
885 * @returns true if it is in range
886 */
887 bool OutOfRange(SequenceNumber32 head, SequenceNumber32 tail) const;
888
889 // Helper functions: Connection close
890
891 /**
892 * @brief Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state
893 *
894 * @returns 0 on success
895 */
896 int DoClose();
897
898 /**
899 * @brief Peacefully close the socket by notifying the upper layer and deallocate end point
900 */
901 void CloseAndNotify();
902
903 /**
904 * @brief Kill this socket by zeroing its attributes (IPv4)
905 *
906 * This is a callback function configured to m_endpoint in
907 * SetupCallback(), invoked when the endpoint is destroyed.
908 */
909 void Destroy();
910
911 /**
912 * @brief Kill this socket by zeroing its attributes (IPv6)
913 *
914 * This is a callback function configured to m_endpoint in
915 * SetupCallback(), invoked when the endpoint is destroyed.
916 */
917 void Destroy6();
918
919 /**
920 * @brief Deallocate m_endPoint and m_endPoint6
921 */
922 void DeallocateEndPoint();
923
924 /**
925 * @brief Received a FIN from peer, notify rx buffer
926 *
927 * @param p the packet
928 * @param tcpHeader the packet's TCP header
929 */
930 void PeerClose(Ptr<Packet> p, const TcpHeader& tcpHeader);
931
932 /**
933 * @brief FIN is in sequence, notify app and respond with a FIN
934 */
935 void DoPeerClose();
936
937 /**
938 * @brief Cancel all timer when endpoint is deleted
939 */
940 void CancelAllTimers();
941
942 /**
943 * @brief Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state
944 */
945 void TimeWait();
946
947 // State transition functions
948
949 /**
950 * @brief Received a packet upon ESTABLISHED state.
951 *
952 * This function is mimicking the role of tcp_rcv_established() in tcp_input.c in Linux kernel.
953 *
954 * @param packet the packet
955 * @param tcpHeader the packet's TCP header
956 */
958 const TcpHeader& tcpHeader); // Received a packet upon ESTABLISHED state
959
960 /**
961 * @brief Received a packet upon LISTEN state.
962 *
963 * @param packet the packet
964 * @param tcpHeader the packet's TCP header
965 * @param fromAddress the source address
966 * @param toAddress the destination address
967 */
968 void ProcessListen(Ptr<Packet> packet,
969 const TcpHeader& tcpHeader,
970 const Address& fromAddress,
971 const Address& toAddress);
972
973 /**
974 * @brief Received a packet upon SYN_SENT
975 *
976 * @param packet the packet
977 * @param tcpHeader the packet's TCP header
978 */
979 void ProcessSynSent(Ptr<Packet> packet, const TcpHeader& tcpHeader);
980
981 /**
982 * @brief Received a packet upon SYN_RCVD.
983 *
984 * @param packet the packet
985 * @param tcpHeader the packet's TCP header
986 * @param fromAddress the source address
987 * @param toAddress the destination address
988 */
989 void ProcessSynRcvd(Ptr<Packet> packet,
990 const TcpHeader& tcpHeader,
991 const Address& fromAddress,
992 const Address& toAddress);
993
994 /**
995 * @brief Received a packet upon CLOSE_WAIT, FIN_WAIT_1, FIN_WAIT_2
996 *
997 * @param packet the packet
998 * @param tcpHeader the packet's TCP header
999 */
1000 void ProcessWait(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1001
1002 /**
1003 * @brief Received a packet upon CLOSING
1004 *
1005 * @param packet the packet
1006 * @param tcpHeader the packet's TCP header
1007 */
1008 void ProcessClosing(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1009
1010 /**
1011 * @brief Received a packet upon LAST_ACK
1012 *
1013 * @param packet the packet
1014 * @param tcpHeader the packet's TCP header
1015 */
1016 void ProcessLastAck(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1017
1018 // Window management
1019
1020 /**
1021 * @brief Return count of number of unacked bytes
1022 *
1023 * The difference between SND.UNA and HighTx
1024 *
1025 * @returns count of number of unacked bytes
1026 */
1027 virtual uint32_t UnAckDataCount() const;
1028
1029 /**
1030 * @brief Return total bytes in flight
1031 *
1032 * Does not count segments lost and SACKed (or dupACKed)
1033 *
1034 * @returns total bytes in flight
1035 */
1036 virtual uint32_t BytesInFlight() const;
1037
1038 /**
1039 * @brief Return the max possible number of unacked bytes
1040 * @returns the max possible number of unacked bytes
1041 */
1042 virtual uint32_t Window() const;
1043
1044 /**
1045 * @brief Return unfilled portion of window
1046 * @return unfilled portion of window
1047 */
1048 virtual uint32_t AvailableWindow() const;
1049
1050 /**
1051 * @brief The amount of Rx window announced to the peer
1052 * @param scale indicate if the window should be scaled. True for
1053 * almost all cases, except when we are sending a SYN
1054 * @returns size of Rx window announced to the peer
1055 */
1056 virtual uint16_t AdvertisedWindowSize(bool scale = true) const;
1057
1058 /**
1059 * @brief Update the receiver window (RWND) based on the value of the
1060 * window field in the header.
1061 *
1062 * This method suppresses updates unless one of the following three
1063 * conditions holds: 1) segment contains new data (advancing the right
1064 * edge of the receive buffer), 2) segment does not contain new data
1065 * but the segment acks new data (highest sequence number acked advances),
1066 * or 3) the advertised window is larger than the current send window
1067 *
1068 * @param header TcpHeader from which to extract the new window value
1069 */
1070 void UpdateWindowSize(const TcpHeader& header);
1071
1072 // Manage data tx/rx
1073
1074 /**
1075 * @brief Call CopyObject<> to clone me
1076 * @returns a copy of the socket
1077 */
1078 virtual Ptr<TcpSocketBase> Fork();
1079
1080 /**
1081 * @brief Received an ACK packet
1082 * @param packet the packet
1083 * @param tcpHeader the packet's TCP header
1084 */
1085 virtual void ReceivedAck(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1086
1087 /**
1088 * @brief Process a received ack
1089 * @param ackNumber ack number
1090 * @param scoreboardUpdated if true indicates that the scoreboard has been
1091 * @param oldHeadSequence value of HeadSequence before ack
1092 * updated with SACK information
1093 * @param currentDelivered The number of bytes (S)ACKed
1094 * @param receivedData if true indicates that data is piggybacked with ACK
1095 */
1096 virtual void ProcessAck(const SequenceNumber32& ackNumber,
1097 bool scoreboardUpdated,
1098 uint32_t currentDelivered,
1099 const SequenceNumber32& oldHeadSequence,
1100 bool receivedData);
1101
1102 /**
1103 * @brief Recv of a data, put into buffer, call L7 to get it if necessary
1104 * @param packet the packet
1105 * @param tcpHeader the packet's TCP header
1106 */
1107 virtual void ReceivedData(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1108
1109 /**
1110 * @brief Calculate RTT sample for the ACKed packet
1111 *
1112 * Per RFC 6298 (Section 3),
1113 * If `m_timestampsEnabled` is true, calculate RTT using timestamps option.
1114 * Otherwise, return RTT as the elapsed time since the packet was transmitted.
1115 * If ACKed packed was a retrasmitted packet, return zero time.
1116 *
1117 * @param tcpHeader the packet's TCP header
1118 * @param rttHistory the ACKed packet's RTT History
1119 * @returns the RTT sample
1120 */
1121 virtual Time CalculateRttSample(const TcpHeader& tcpHeader, const RttHistory& rttHistory);
1122
1123 /**
1124 * @brief Take into account the packet for RTT estimation
1125 * @param tcpHeader the packet's TCP header
1126 */
1127 virtual void EstimateRtt(const TcpHeader& tcpHeader);
1128
1129 /**
1130 * @brief Update the RTT history, when we send TCP segments
1131 *
1132 * @param seq The sequence number of the TCP segment
1133 * @param sz The segment's size
1134 * @param isRetransmission Whether or not the segment is a retransmission
1135 */
1136
1137 virtual void UpdateRttHistory(const SequenceNumber32& seq, uint32_t sz, bool isRetransmission);
1138
1139 /**
1140 * @brief Update buffers w.r.t. ACK
1141 * @param seq the sequence number
1142 * @param resetRTO indicates if RTO should be reset
1143 */
1144 virtual void NewAck(const SequenceNumber32& seq, bool resetRTO);
1145
1146 /**
1147 * @brief Dupack management
1148 *
1149 * @param currentDelivered Current (S)ACKed bytes
1150 */
1151 void DupAck(uint32_t currentDelivered);
1152
1153 /**
1154 * @brief Enter CA_CWR state upon receipt of an ECN Echo
1155 *
1156 * @param currentDelivered Currently (S)ACKed bytes
1157 */
1158 void EnterCwr(uint32_t currentDelivered);
1159
1160 /**
1161 * @brief Enter the CA_RECOVERY, and retransmit the head
1162 *
1163 * @param currentDelivered Currently (S)ACKed bytes
1164 */
1165 void EnterRecovery(uint32_t currentDelivered);
1166
1167 /**
1168 * @brief An RTO event happened
1169 */
1170 virtual void ReTxTimeout();
1171
1172 /**
1173 * @brief Action upon delay ACK timeout, i.e. send an ACK
1174 */
1175 virtual void DelAckTimeout();
1176
1177 /**
1178 * @brief Timeout at LAST_ACK, close the connection
1179 */
1180 virtual void LastAckTimeout();
1181
1182 /**
1183 * @brief Send 1 byte probe to get an updated window size
1184 */
1185 virtual void PersistTimeout();
1186
1187 /**
1188 * @brief Retransmit the first segment marked as lost, without considering
1189 * available window nor pacing.
1190 */
1191 void DoRetransmit();
1192
1193 /**
1194 * @brief Add options to TcpHeader
1195 *
1196 * Test each option, and if it is enabled on our side, add it
1197 * to the header
1198 *
1199 * @param tcpHeader TcpHeader to add options to
1200 */
1201 void AddOptions(TcpHeader& tcpHeader);
1202
1203 /**
1204 * @brief Read TCP options before Ack processing
1205 *
1206 * Timestamp and Window scale are managed in other pieces of code.
1207 *
1208 * @param tcpHeader Header of the segment
1209 * @param [out] bytesSacked Number of bytes SACKed, or 0
1210 */
1211 void ReadOptions(const TcpHeader& tcpHeader, uint32_t* bytesSacked);
1212
1213 /**
1214 * @brief Return true if the specified option is enabled
1215 *
1216 * @param kind kind of TCP option
1217 * @return true if the option is enabled
1218 */
1219 bool IsTcpOptionEnabled(uint8_t kind) const;
1220
1221 /**
1222 * @brief Read and parse the Window scale option
1223 *
1224 * Read the window scale option (encoded logarithmically) and save it.
1225 * Per RFC 1323, the value can't exceed 14.
1226 *
1227 * @param option Window scale option read from the header
1228 */
1229 void ProcessOptionWScale(const Ptr<const TcpOption> option);
1230 /**
1231 * @brief Add the window scale option to the header
1232 *
1233 * Calculate our factor from the rxBuffer max size, and add it
1234 * to the header.
1235 *
1236 * @param header TcpHeader where the method should add the window scale option
1237 */
1238 void AddOptionWScale(TcpHeader& header);
1239
1240 /**
1241 * @brief Calculate window scale value based on receive buffer space
1242 *
1243 * Calculate our factor from the rxBuffer max size
1244 *
1245 * @returns the Window Scale factor
1246 */
1247 uint8_t CalculateWScale() const;
1248
1249 /**
1250 * @brief Read the SACK PERMITTED option
1251 *
1252 * Currently this is a placeholder, since no operations should be done
1253 * on such option.
1254 *
1255 * @param option SACK PERMITTED option from the header
1256 */
1258
1259 /**
1260 * @brief Read the SACK option
1261 *
1262 * @param option SACK option from the header
1263 * @returns the number of bytes sacked by this option
1264 */
1266
1267 /**
1268 * @brief Add the SACK PERMITTED option to the header
1269 *
1270 * @param header TcpHeader where the method should add the option
1271 */
1272 void AddOptionSackPermitted(TcpHeader& header);
1273
1274 /**
1275 * @brief Add the SACK option to the header
1276 *
1277 * @param header TcpHeader where the method should add the option
1278 */
1279 void AddOptionSack(TcpHeader& header);
1280
1281 /**
1282 * @brief Process the timestamp option from other side
1283 *
1284 * Get the timestamp and the echo, then save timestamp (which will
1285 * be the echo value in our out-packets) and save the echoed timestamp,
1286 * to utilize later to calculate RTT.
1287 *
1288 * @see EstimateRtt
1289 * @param option Option from the segment
1290 * @param seq Sequence number of the segment
1291 */
1292 void ProcessOptionTimestamp(const Ptr<const TcpOption> option, const SequenceNumber32& seq);
1293 /**
1294 * @brief Add the timestamp option to the header
1295 *
1296 * Set the timestamp as the lower bits of the Simulator::Now time,
1297 * and the echo value as the last seen timestamp from the other part.
1298 *
1299 * @param header TcpHeader to which add the option to
1300 */
1301 void AddOptionTimestamp(TcpHeader& header);
1302
1303 /**
1304 * @brief Performs a safe subtraction between a and b (a-b)
1305 *
1306 * Safe is used to indicate that, if b>a, the results returned is 0.
1307 *
1308 * @param a first number
1309 * @param b second number
1310 * @return 0 if b>0, (a-b) otherwise
1311 */
1313
1314 /**
1315 * @brief Notify Pacing
1316 */
1317 void NotifyPacingPerformed();
1318
1319 /**
1320 * @brief Return true if packets in the current window should be paced
1321 * @return true if pacing is currently enabled
1322 */
1323 bool IsPacingEnabled() const;
1324
1325 /**
1326 * @brief Dynamically update the pacing rate
1327 */
1328 void UpdatePacingRate();
1329
1330 /**
1331 * @brief Add Tags for the Socket
1332 * @param p Packet
1333 * @param isEct Whether the packet is allowed to be ECT capable
1334 */
1335 void AddSocketTags(const Ptr<Packet>& p, bool isEct) const;
1336
1337 /**
1338 * Get the current value of the receiver's offered window (RCV.WND)
1339 * @note This method exists to expose the value to the TcpTxBuffer
1340 * @return value of receiver's offered window
1341 */
1342 uint32_t GetRWnd() const;
1343
1344 /**
1345 * Get the current value of the receiver's highest (in-sequence) sequence number acked.
1346 * @note This method exists to expose the value to the TcpTxBuffer
1347 * @return value of receiver's highest sequence number acked.
1348 */
1350
1351 protected:
1352 // Counters and events
1353 EventId m_retxEvent{}; //!< Retransmission event
1354 EventId m_lastAckEvent{}; //!< Last ACK timeout event
1355 EventId m_delAckEvent{}; //!< Delayed ACK timeout event
1356 EventId m_persistEvent{}; //!< Persist event: Send 1 byte to probe for a non-zero Rx window
1357 EventId m_timewaitEvent{}; //!< TIME_WAIT expiration event: Move this socket to CLOSED state
1358
1359 // ACK management
1360 uint32_t m_dupAckCount{0}; //!< Dupack counter
1361 uint32_t m_delAckCount{0}; //!< Delayed ACK counter
1362 uint32_t m_delAckMaxCount{0}; //!< Number of packet to fire an ACK before delay timeout
1363
1364 // Nagle algorithm
1365 bool m_noDelay{false}; //!< Set to true to disable Nagle's algorithm
1366
1367 // Retries
1368 uint32_t m_synCount{0}; //!< Count of remaining connection retries
1369 uint32_t m_synRetries{0}; //!< Number of connection attempts
1370 uint32_t m_dataRetrCount{0}; //!< Count of remaining data retransmission attempts
1371 uint32_t m_dataRetries{0}; //!< Number of data retransmission attempts
1372
1373 // Timeouts
1374 TracedValue<Time> m_rto; //!< Retransmit timeout
1375 Time m_minRto{Time::Max()}; //!< minimum value of the Retransmit timeout
1376 Time m_clockGranularity{Seconds(0.001)}; //!< Clock Granularity used in RTO calcs
1377 Time m_delAckTimeout; //!< Time to delay an ACK
1378 Time m_persistTimeout; //!< Time between sending 1-byte probes
1379 Time m_cnTimeout; //!< Timeout for connection retry
1380
1381 // History of RTT
1382 std::deque<RttHistory> m_history; //!< List of sent packet
1383
1384 // Connections to other layers of TCP/IP
1385 Ipv4EndPoint* m_endPoint{nullptr}; //!< the IPv4 endpoint
1386 Ipv6EndPoint* m_endPoint6{nullptr}; //!< the IPv6 endpoint
1387 Ptr<Node> m_node; //!< the associated node
1388 Ptr<TcpL4Protocol> m_tcp; //!< the associated TCP L4 protocol
1390 m_icmpCallback; //!< ICMP callback
1392 m_icmpCallback6; //!< ICMPv6 callback
1393
1394 Ptr<RttEstimator> m_rtt; //!< Round trip time estimator
1395
1396 // Tx buffer management
1398
1399 // State-related attributes
1401
1402 mutable SocketErrno m_errno{ERROR_NOTERROR}; //!< Socket error code
1403
1404 bool m_closeNotified{false}; //!< Told app to close socket
1405 bool m_closeOnEmpty{false}; //!< Close socket upon tx buffer emptied
1406 bool m_shutdownSend{false}; //!< Send no longer allowed
1407 bool m_shutdownRecv{false}; //!< Receive no longer allowed
1408 bool m_connected{false}; //!< Connection established
1409 bool m_useAbe{false}; //!< ABE mode
1410 //!< It will override the UseEcn attribute
1411 //!< if it is 'Off' and set it to 'On', but
1412 //!< will leave it untouched if it is 'AcceptOnly'
1413 double m_msl{0.0}; //!< Max segment lifetime
1414
1415 // Window management
1416 uint16_t m_maxWinSize{0}; //!< Maximum window size to advertise
1417 uint32_t m_bytesAckedNotProcessed{0}; //!< Bytes acked, but not processed
1418 SequenceNumber32 m_highTxAck{0}; //!< Highest ack sent
1419 TracedValue<uint32_t> m_rWnd{0}; //!< Receiver window (RCV.WND in RFC793)
1420 TracedValue<uint32_t> m_advWnd{0}; //!< Advertised Window size
1421 TracedValue<SequenceNumber32> m_highRxMark{0}; //!< Highest seqno received
1423
1424 // Options
1425 bool m_sackEnabled{true}; //!< RFC SACK option enabled
1426 bool m_winScalingEnabled{true}; //!< Window Scale option enabled (RFC 7323)
1427 uint8_t m_rcvWindShift{0}; //!< Window shift to apply to outgoing segments
1428 uint8_t m_sndWindShift{0}; //!< Window shift to apply to incoming segments
1429 bool m_timestampEnabled{true}; //!< Timestamp option enabled
1430 uint32_t m_timestampToEcho{0}; //!< Timestamp to echo
1431
1432 EventId m_sendPendingDataEvent{}; //!< micro-delay event to send pending data
1433
1434 // Fast Retransmit and Recovery
1436 0}; //!< Previous highest Tx seqnum for fast recovery (set it to initial seq number)
1437 bool m_recoverActive{false}; //!< Whether "m_recover" has been set/activated
1438 //!< It is used to avoid comparing with the old m_recover value
1439 //!< which was set for handling previous congestion event.
1440 uint32_t m_retxThresh{3}; //!< Fast Retransmit threshold
1441 bool m_limitedTx{true}; //!< perform limited transmit
1442
1443 // Transmission Control Block
1444 Ptr<TcpSocketState> m_tcb; //!< Congestion control information
1446 Ptr<TcpRecoveryOps> m_recoveryOps; //!< Recovery Algorithm
1447 Ptr<TcpRateOps> m_rateOps; //!< Rate operations
1448
1449 // Guesses over the other connection end
1450 bool m_isFirstPartialAck{true}; //!< First partial ACK during RECOVERY
1451
1452 // The following three traces pass a packet with a TCP header
1454 const TcpHeader&,
1456 m_txTrace; //!< Trace of transmitted packets
1457
1459 const TcpHeader&,
1460 const Address&,
1461 const Address&,
1463 m_retransmissionTrace; //!< Trace of retransmitted packets
1464
1466 const TcpHeader&,
1468 m_rxTrace; //!< Trace of received packets
1469
1470 // Pacing related variable
1472
1473 // Parameters related to Explicit Congestion Notification
1475 0}; //!< Sequence number of the last received ECN Echo
1477 0}; //!< Sequence number of the last received Congestion Experienced
1478 TracedValue<SequenceNumber32> m_ecnCWRSeq{0}; //!< Sequence number of the last sent CWR
1479};
1480
1481/**
1482 * @ingroup tcp
1483 * TracedValue Callback signature for TcpCongState_t
1484 *
1485 * @param [in] oldValue original value of the traced variable
1486 * @param [in] newValue new value of the traced variable
1487 */
1489 const TcpSocketState::TcpCongState_t newValue);
1490
1491/**
1492 * @ingroup tcp
1493 * TracedValue Callback signature for ECN state trace
1494 *
1495 * @param [in] oldValue original value of the traced variable
1496 * @param [in] newValue new value of the traced variable
1497 */
1499 const TcpSocketState::EcnState_t newValue);
1500
1501} // namespace ns3
1502
1503#endif /* TCP_SOCKET_BASE_H */
a polymophic address class
Definition address.h:90
Callback template class.
Definition callback.h:422
Class for representing data rates.
Definition data-rate.h:78
An identifier for simulation events.
Definition event-id.h:44
Ipv4 addresses are stored in host order in this class.
A representation of an internet endpoint/connection.
Packet header for IPv4.
Definition ipv4-header.h:23
The IPv4 representation of a network interface.
Describes an IPv6 address.
A representation of an IPv6 endpoint/connection.
Packet header for IPv6.
Definition ipv6-header.h:24
The IPv6 representation of a network interface.
A network Node.
Definition node.h:46
network packets
Definition packet.h:228
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
Base class for all RTT Estimators.
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.
Ptr< Packet > Recv()
Read a single packet from the socket.
Definition socket.cc:163
SocketType
Enumeration of the possible socket types.
Definition socket.h:96
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition socket.h:73
@ ERROR_NOTERROR
Definition socket.h:74
Congestion control abstract class.
Header for the Transmission Control Protocol.
Definition tcp-header.h:36
TCP socket creation and multiplexing/demultiplexing.
Base class for all kinds of TCP options.
Definition tcp-option.h:27
Interface for all operations that involve a Rate monitoring for TCP.
recovery abstract class
Rx reordering buffer for 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.
bool CheckEcnEct1(uint8_t tos) const
Checks for ECT(1) codepoint.
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.
uint8_t MarkEcnEct1(uint8_t tos) const
Mark ECT(1) codepoint.
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.
uint8_t MarkEcnEct0(uint8_t tos) const
Mark ECT(0) codepoint.
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.
uint8_t MarkEcnCe(uint8_t tos) const
Mark CE codepoint.
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(* TcpTxRxTracedCallback)(const Ptr< const Packet > packet, const TcpHeader &header, const Ptr< const TcpSocketBase > socket)
TracedCallback signature for TCP packet transmission or reception events.
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.
friend class TcpGeneralTest
TcpGeneralTest friend class (for tests).
TracedValue< SequenceNumber32 > m_highRxMark
Highest seqno received.
uint8_t ClearEcnBits(uint8_t tos) const
Clears ECN bits from TOS.
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.
void SetUseAbe(bool useAbe)
Set ABE mode of use on the socket.
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.
bool m_useAbe
ABE mode It will override the UseEcn attribute if it is 'Off' and set it to 'On', but will leave it u...
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.
bool CheckEcnCe(uint8_t tos) const
Checks for CE codepoint.
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.
bool GetUseAbe() const
Get ABE mode of use on the socket.
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(* RetransmissionCallback)(const Ptr< const Packet > packet, const TcpHeader &header, const Address &localAddr, const Address &peerAddr, const Ptr< const TcpSocketBase > socket)
TracedCallback signature for TCP packet retransmission events.
void SetUseEcn(TcpSocketState::UseEcn_t useEcn)
Set ECN mode of use on the socket.
bool CheckEcnEct0(uint8_t tos) const
Checks for ECT(0) codepoint.
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 NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
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.
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.
EcnCodePoint_t
ECN code points.
UseEcn_t
Parameter value related to ECN enable/disable functionality similar to sysctl for tcp_ecn.
TcpCongState_t
Definition of the Congestion state machine.
EcnState_t
Definition of the Ecn state machine.
Tcp sender buffer.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:96
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Definition nstime.h:288
A simple virtual Timer class.
Definition timer.h:67
@ CANCEL_ON_DESTROY
This policy cancels the event from the destructor of the Timer or from Suspend().
Definition timer.h:86
Forward calls to a chain of Callback.
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:49
uint16_t port
Definition dsdv-manet.cc:33
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number.
void(* EcnStatesTracedValueCallback)(const TcpSocketState::EcnState_t oldValue, const TcpSocketState::EcnState_t newValue)
TracedValue Callback signature for ECN state trace.
void(* TcpCongStatesTracedValueCallback)(const TcpSocketState::TcpCongState_t oldValue, const TcpSocketState::TcpCongState_t newValue)
TracedValue Callback signature for TcpCongState_t.
@ CLOSED
Socket is finished.
Definition tcp-socket.h:56
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1369
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout