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;
35class TcpCongestionOps;
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 /**
584 * @brief Enable or disable pacing
585 * @param pacing Boolean to enable or disable pacing
586 */
587 void SetPacingStatus(bool pacing);
588
589 /**
590 * @brief Enable or disable pacing of the initial window
591 * @param paceWindow Boolean to enable or disable pacing of the initial window
592 */
593 void SetPaceInitialWindow(bool paceWindow);
594
595 /**
596 * @brief Checks if a TCP packet should be ECN-capable (ECT) according to the TcpPacketType and
597 * ECN mode.
598 *
599 * Currently, only Classic ECN and DCTCP ECN modes are supported, with
600 * potential extensions for future modes (Ecnpp).
601 *
602 * @param packetType The type of the TCP packet, represented by an enum TcpPacketType.
603 * @return true if the packet is ECN-capable (ECT), false otherwise.
604 *
605 * Reference: https://www.ietf.org/archive/id/draft-ietf-tcpm-generalized-ecn-15.txt (Table 1)
606 */
607 bool IsEct(TcpPacketType_t packetType) const;
608
609 // Necessary implementations of null functions from ns3::Socket
610 SocketErrno GetErrno() const override; // returns m_errno
611 SocketType GetSocketType() const override; // returns socket type
612 Ptr<Node> GetNode() const override; // returns m_node
613 int Bind() override; // Bind a socket by setting up endpoint in TcpL4Protocol
614 int Bind6() override; // Bind a socket by setting up endpoint in TcpL4Protocol
615 int Bind(const Address& address) override; // ... endpoint of specific addr or port
616 int Connect(
617 const Address& address) override; // Setup endpoint and call ProcessAction() to connect
618 int Listen()
619 override; // Verify the socket is in a correct state and call ProcessAction() to listen
620 int Close() override; // Close by app: Kill socket upon tx buffer emptied
621 int ShutdownSend() override; // Assert the m_shutdownSend flag to prevent send to network
622 int ShutdownRecv() override; // Assert the m_shutdownRecv flag to prevent forward to app
623 int Send(Ptr<Packet> p, uint32_t flags) override; // Call by app to send data to network
624 int SendTo(Ptr<Packet> p,
625 uint32_t flags,
626 const Address& toAddress) override; // Same as Send(), toAddress is insignificant
627 Ptr<Packet> Recv(uint32_t maxSize,
628 uint32_t flags) override; // Return a packet to be forwarded to app
629 Ptr<Packet> RecvFrom(uint32_t maxSize, uint32_t flags, Address& fromAddress)
630 override; // ... and write the remote address at fromAddress
631 uint32_t GetTxAvailable() const override; // Available Tx buffer size
633 const override; // Available-to-read data size, i.e. value of m_rxAvailable
634 int GetSockName(Address& address) const override; // Return local addr:port in address
635 int GetPeerName(Address& address) const override;
636 void BindToNetDevice(Ptr<NetDevice> netdevice) override; // NetDevice with my m_endPoint
637
638 /**
639 * TracedCallback signature for TCP packet transmission or reception events.
640 *
641 * @param [in] packet The packet.
642 * @param [in] header The TcpHeader
643 * @param [in] socket This socket
644 */
645 typedef void (*TcpTxRxTracedCallback)(const Ptr<const Packet> packet,
646 const TcpHeader& header,
647 const Ptr<const TcpSocketBase> socket);
648
649 /**
650 * TracedCallback signature for TCP packet retransmission events.
651 *
652 * @param [in] packet The packet.
653 * @param [in] header The TcpHeader
654 * @param [in] localAddr The local address
655 * @param [in] peerAddr The peer/remote address
656 * @param [in] socket This socket
657 */
658 typedef void (*RetransmissionCallback)(const Ptr<const Packet> packet,
659 const TcpHeader& header,
660 const Address& localAddr,
661 const Address& peerAddr,
662 const Ptr<const TcpSocketBase> socket);
663
664 protected:
665 // Implementing ns3::TcpSocket -- Attribute get/set
666 // inherited, no need to doc
667
668 void SetSndBufSize(uint32_t size) override;
669 uint32_t GetSndBufSize() const override;
670 void SetRcvBufSize(uint32_t size) override;
671 uint32_t GetRcvBufSize() const override;
672 void SetSegSize(uint32_t size) override;
673 uint32_t GetSegSize() const override;
674 void SetInitialSSThresh(uint32_t threshold) override;
675 uint32_t GetInitialSSThresh() const override;
676 void SetInitialCwnd(uint32_t cwnd) override;
677 uint32_t GetInitialCwnd() const override;
678 void SetConnTimeout(Time timeout) override;
679 Time GetConnTimeout() const override;
680 void SetSynRetries(uint32_t count) override;
681 uint32_t GetSynRetries() const override;
682 void SetDataRetries(uint32_t retries) override;
683 uint32_t GetDataRetries() const override;
684 void SetDelAckTimeout(Time timeout) override;
685 Time GetDelAckTimeout() const override;
686 void SetDelAckMaxCount(uint32_t count) override;
687 uint32_t GetDelAckMaxCount() const override;
688 void SetTcpNoDelay(bool noDelay) override;
689 bool GetTcpNoDelay() const override;
690 void SetPersistTimeout(Time timeout) override;
691 Time GetPersistTimeout() const override;
692 bool SetAllowBroadcast(bool allowBroadcast) override;
693 bool GetAllowBroadcast() const override;
694
695 // Helper functions: Connection set up
696
697 /**
698 * @brief Common part of the two Bind(), i.e. set callback and remembering local addr:port
699 *
700 * @returns 0 on success, -1 on failure
701 */
702 int SetupCallback();
703
704 /**
705 * @brief Perform the real connection tasks: Send SYN if allowed, RST if invalid
706 *
707 * @returns 0 on success
708 */
709 int DoConnect();
710
711 /**
712 * @brief Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
713 */
714 void ConnectionSucceeded();
715
716 /**
717 * @brief Configure the endpoint to a local address. Called by Connect() if Bind() didn't
718 * specify one.
719 *
720 * @returns 0 on success
721 */
722 int SetupEndpoint();
723
724 /**
725 * @brief Configure the endpoint v6 to a local address. Called by Connect() if Bind() didn't
726 * specify one.
727 *
728 * @returns 0 on success
729 */
730 int SetupEndpoint6();
731
732 /**
733 * @brief Complete a connection by forking the socket
734 *
735 * This function is called only if a SYN received in LISTEN state. After
736 * TcpSocketBase cloned, allocate a new end point to handle the incoming
737 * connection and send a SYN+ACK to complete the handshake.
738 *
739 * @param p the packet triggering the fork
740 * @param tcpHeader the TCP header of the triggering packet
741 * @param fromAddress the address of the remote host
742 * @param toAddress the address the connection is directed to
743 */
744 virtual void CompleteFork(Ptr<Packet> p,
745 const TcpHeader& tcpHeader,
746 const Address& fromAddress,
747 const Address& toAddress);
748
749 // Helper functions: Transfer operation
750
751 /**
752 * @brief Checks whether the given TCP segment is valid or not.
753 *
754 * @param seq the sequence number of packet's TCP header
755 * @param tcpHeaderSize the size of packet's TCP header
756 * @param tcpPayloadSize the size of TCP payload
757 * @return true if the TCP segment is valid
758 */
759 bool IsValidTcpSegment(const SequenceNumber32 seq,
760 const uint32_t tcpHeaderSize,
761 const uint32_t tcpPayloadSize);
762
763 /**
764 * @brief Called by the L3 protocol when it received a packet to pass on to TCP.
765 *
766 * @param packet the incoming packet
767 * @param header the packet's IPv4 header
768 * @param port the remote port
769 * @param incomingInterface the incoming interface
770 */
771 void ForwardUp(Ptr<Packet> packet,
772 Ipv4Header header,
773 uint16_t port,
774 Ptr<Ipv4Interface> incomingInterface);
775
776 /**
777 * @brief Called by the L3 protocol when it received a packet to pass on to TCP.
778 *
779 * @param packet the incoming packet
780 * @param header the packet's IPv6 header
781 * @param port the remote port
782 * @param incomingInterface the incoming interface
783 */
784 void ForwardUp6(Ptr<Packet> packet,
785 Ipv6Header header,
786 uint16_t port,
787 Ptr<Ipv6Interface> incomingInterface);
788
789 /**
790 * @brief Called by TcpSocketBase::ForwardUp{,6}().
791 *
792 * Get a packet from L3. This is the real function to handle the
793 * incoming packet from lower layers. This is
794 * wrapped by ForwardUp() so that this function can be overloaded by daughter
795 * classes.
796 *
797 * @param packet the incoming packet
798 * @param fromAddress the address of the sender of packet
799 * @param toAddress the address of the receiver of packet (hopefully, us)
800 */
801 virtual void DoForwardUp(Ptr<Packet> packet,
802 const Address& fromAddress,
803 const Address& toAddress);
804
805 /**
806 * @brief Called by the L3 protocol when it received an ICMP packet to pass on to TCP.
807 *
808 * @param icmpSource the ICMP source address
809 * @param icmpTtl the ICMP Time to Live
810 * @param icmpType the ICMP Type
811 * @param icmpCode the ICMP Code
812 * @param icmpInfo the ICMP Info
813 */
814 void ForwardIcmp(Ipv4Address icmpSource,
815 uint8_t icmpTtl,
816 uint8_t icmpType,
817 uint8_t icmpCode,
818 uint32_t icmpInfo);
819
820 /**
821 * @brief Called by the L3 protocol when it received an ICMPv6 packet to pass on to TCP.
822 *
823 * @param icmpSource the ICMP source address
824 * @param icmpTtl the ICMP Time to Live
825 * @param icmpType the ICMP Type
826 * @param icmpCode the ICMP Code
827 * @param icmpInfo the ICMP Info
828 */
829 void ForwardIcmp6(Ipv6Address icmpSource,
830 uint8_t icmpTtl,
831 uint8_t icmpType,
832 uint8_t icmpCode,
833 uint32_t icmpInfo);
834
835 /**
836 * @brief Send as much pending data as possible according to the Tx window.
837 *
838 * Note that this function did not implement the PSH flag.
839 *
840 * @param withAck forces an ACK to be sent
841 * @returns the number of packets sent
842 */
843 uint32_t SendPendingData(bool withAck = false);
844
845 /**
846 * @brief Extract at most maxSize bytes from the TxBuffer at sequence seq, add the
847 * TCP header, and send to TcpL4Protocol
848 *
849 * @param seq the sequence number
850 * @param maxSize the maximum data block to be transmitted (in bytes)
851 * @param withAck forces an ACK to be sent
852 * @returns the number of bytes sent
853 */
854 virtual uint32_t SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, bool withAck);
855
856 /**
857 * @brief Send a empty packet that carries a flag, e.g., ACK
858 *
859 * @param flags the packet's flags
860 */
861 virtual void SendEmptyPacket(uint8_t flags);
862
863 /**
864 * @brief Send reset and tear down this socket
865 */
866 void SendRST();
867
868 /**
869 * @brief Check if a sequence number range is within the rx window
870 *
871 * @param head start of the Sequence window
872 * @param tail end of the Sequence window
873 * @returns true if it is in range
874 */
875 bool OutOfRange(SequenceNumber32 head, SequenceNumber32 tail) const;
876
877 // Helper functions: Connection close
878
879 /**
880 * @brief Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state
881 *
882 * @returns 0 on success
883 */
884 int DoClose();
885
886 /**
887 * @brief Peacefully close the socket by notifying the upper layer and deallocate end point
888 */
889 void CloseAndNotify();
890
891 /**
892 * @brief Kill this socket by zeroing its attributes (IPv4)
893 *
894 * This is a callback function configured to m_endpoint in
895 * SetupCallback(), invoked when the endpoint is destroyed.
896 */
897 void Destroy();
898
899 /**
900 * @brief Kill this socket by zeroing its attributes (IPv6)
901 *
902 * This is a callback function configured to m_endpoint in
903 * SetupCallback(), invoked when the endpoint is destroyed.
904 */
905 void Destroy6();
906
907 /**
908 * @brief Deallocate m_endPoint and m_endPoint6
909 */
910 void DeallocateEndPoint();
911
912 /**
913 * @brief Received a FIN from peer, notify rx buffer
914 *
915 * @param p the packet
916 * @param tcpHeader the packet's TCP header
917 */
918 void PeerClose(Ptr<Packet> p, const TcpHeader& tcpHeader);
919
920 /**
921 * @brief FIN is in sequence, notify app and respond with a FIN
922 */
923 void DoPeerClose();
924
925 /**
926 * @brief Cancel all timer when endpoint is deleted
927 */
928 void CancelAllTimers();
929
930 /**
931 * @brief Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state
932 */
933 void TimeWait();
934
935 // State transition functions
936
937 /**
938 * @brief Received a packet upon ESTABLISHED state.
939 *
940 * This function is mimicking the role of tcp_rcv_established() in tcp_input.c in Linux kernel.
941 *
942 * @param packet the packet
943 * @param tcpHeader the packet's TCP header
944 */
946 const TcpHeader& tcpHeader); // Received a packet upon ESTABLISHED state
947
948 /**
949 * @brief Received a packet upon LISTEN state.
950 *
951 * @param packet the packet
952 * @param tcpHeader the packet's TCP header
953 * @param fromAddress the source address
954 * @param toAddress the destination address
955 */
956 void ProcessListen(Ptr<Packet> packet,
957 const TcpHeader& tcpHeader,
958 const Address& fromAddress,
959 const Address& toAddress);
960
961 /**
962 * @brief Received a packet upon SYN_SENT
963 *
964 * @param packet the packet
965 * @param tcpHeader the packet's TCP header
966 */
967 void ProcessSynSent(Ptr<Packet> packet, const TcpHeader& tcpHeader);
968
969 /**
970 * @brief Received a packet upon SYN_RCVD.
971 *
972 * @param packet the packet
973 * @param tcpHeader the packet's TCP header
974 * @param fromAddress the source address
975 * @param toAddress the destination address
976 */
977 void ProcessSynRcvd(Ptr<Packet> packet,
978 const TcpHeader& tcpHeader,
979 const Address& fromAddress,
980 const Address& toAddress);
981
982 /**
983 * @brief Received a packet upon CLOSE_WAIT, FIN_WAIT_1, FIN_WAIT_2
984 *
985 * @param packet the packet
986 * @param tcpHeader the packet's TCP header
987 */
988 void ProcessWait(Ptr<Packet> packet, const TcpHeader& tcpHeader);
989
990 /**
991 * @brief Received a packet upon CLOSING
992 *
993 * @param packet the packet
994 * @param tcpHeader the packet's TCP header
995 */
996 void ProcessClosing(Ptr<Packet> packet, const TcpHeader& tcpHeader);
997
998 /**
999 * @brief Received a packet upon LAST_ACK
1000 *
1001 * @param packet the packet
1002 * @param tcpHeader the packet's TCP header
1003 */
1004 void ProcessLastAck(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1005
1006 // Window management
1007
1008 /**
1009 * @brief Return count of number of unacked bytes
1010 *
1011 * The difference between SND.UNA and HighTx
1012 *
1013 * @returns count of number of unacked bytes
1014 */
1015 virtual uint32_t UnAckDataCount() const;
1016
1017 /**
1018 * @brief Return total bytes in flight
1019 *
1020 * Does not count segments lost and SACKed (or dupACKed)
1021 *
1022 * @returns total bytes in flight
1023 */
1024 virtual uint32_t BytesInFlight() const;
1025
1026 /**
1027 * @brief Return the max possible number of unacked bytes
1028 * @returns the max possible number of unacked bytes
1029 */
1030 virtual uint32_t Window() const;
1031
1032 /**
1033 * @brief Return unfilled portion of window
1034 * @return unfilled portion of window
1035 */
1036 virtual uint32_t AvailableWindow() const;
1037
1038 /**
1039 * @brief The amount of Rx window announced to the peer
1040 * @param scale indicate if the window should be scaled. True for
1041 * almost all cases, except when we are sending a SYN
1042 * @returns size of Rx window announced to the peer
1043 */
1044 virtual uint16_t AdvertisedWindowSize(bool scale = true) const;
1045
1046 /**
1047 * @brief Update the receiver window (RWND) based on the value of the
1048 * window field in the header.
1049 *
1050 * This method suppresses updates unless one of the following three
1051 * conditions holds: 1) segment contains new data (advancing the right
1052 * edge of the receive buffer), 2) segment does not contain new data
1053 * but the segment acks new data (highest sequence number acked advances),
1054 * or 3) the advertised window is larger than the current send window
1055 *
1056 * @param header TcpHeader from which to extract the new window value
1057 */
1058 void UpdateWindowSize(const TcpHeader& header);
1059
1060 // Manage data tx/rx
1061
1062 /**
1063 * @brief Call CopyObject<> to clone me
1064 * @returns a copy of the socket
1065 */
1066 virtual Ptr<TcpSocketBase> Fork();
1067
1068 /**
1069 * @brief Received an ACK packet
1070 * @param packet the packet
1071 * @param tcpHeader the packet's TCP header
1072 */
1073 virtual void ReceivedAck(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1074
1075 /**
1076 * @brief Process a received ack
1077 * @param ackNumber ack number
1078 * @param scoreboardUpdated if true indicates that the scoreboard has been
1079 * @param oldHeadSequence value of HeadSequence before ack
1080 * updated with SACK information
1081 * @param currentDelivered The number of bytes (S)ACKed
1082 * @param receivedData if true indicates that data is piggybacked with ACK
1083 */
1084 virtual void ProcessAck(const SequenceNumber32& ackNumber,
1085 bool scoreboardUpdated,
1086 uint32_t currentDelivered,
1087 const SequenceNumber32& oldHeadSequence,
1088 bool receivedData);
1089
1090 /**
1091 * @brief Recv of a data, put into buffer, call L7 to get it if necessary
1092 * @param packet the packet
1093 * @param tcpHeader the packet's TCP header
1094 */
1095 virtual void ReceivedData(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1096
1097 /**
1098 * @brief Calculate RTT sample for the ACKed packet
1099 *
1100 * Per RFC 6298 (Section 3),
1101 * If `m_timestampsEnabled` is true, calculate RTT using timestamps option.
1102 * Otherwise, return RTT as the elapsed time since the packet was transmitted.
1103 * If ACKed packed was a retrasmitted packet, return zero time.
1104 *
1105 * @param tcpHeader the packet's TCP header
1106 * @param rttHistory the ACKed packet's RTT History
1107 * @returns the RTT sample
1108 */
1109 virtual Time CalculateRttSample(const TcpHeader& tcpHeader, const RttHistory& rttHistory);
1110
1111 /**
1112 * @brief Take into account the packet for RTT estimation
1113 * @param tcpHeader the packet's TCP header
1114 */
1115 virtual void EstimateRtt(const TcpHeader& tcpHeader);
1116
1117 /**
1118 * @brief Update the RTT history, when we send TCP segments
1119 *
1120 * @param seq The sequence number of the TCP segment
1121 * @param sz The segment's size
1122 * @param isRetransmission Whether or not the segment is a retransmission
1123 */
1124
1125 virtual void UpdateRttHistory(const SequenceNumber32& seq, uint32_t sz, bool isRetransmission);
1126
1127 /**
1128 * @brief Update buffers w.r.t. ACK
1129 * @param seq the sequence number
1130 * @param resetRTO indicates if RTO should be reset
1131 */
1132 virtual void NewAck(const SequenceNumber32& seq, bool resetRTO);
1133
1134 /**
1135 * @brief Dupack management
1136 *
1137 * @param currentDelivered Current (S)ACKed bytes
1138 */
1139 void DupAck(uint32_t currentDelivered);
1140
1141 /**
1142 * @brief Enter CA_CWR state upon receipt of an ECN Echo
1143 *
1144 * @param currentDelivered Currently (S)ACKed bytes
1145 */
1146 void EnterCwr(uint32_t currentDelivered);
1147
1148 /**
1149 * @brief Enter the CA_RECOVERY, and retransmit the head
1150 *
1151 * @param currentDelivered Currently (S)ACKed bytes
1152 */
1153 void EnterRecovery(uint32_t currentDelivered);
1154
1155 /**
1156 * @brief An RTO event happened
1157 */
1158 virtual void ReTxTimeout();
1159
1160 /**
1161 * @brief Action upon delay ACK timeout, i.e. send an ACK
1162 */
1163 virtual void DelAckTimeout();
1164
1165 /**
1166 * @brief Timeout at LAST_ACK, close the connection
1167 */
1168 virtual void LastAckTimeout();
1169
1170 /**
1171 * @brief Send 1 byte probe to get an updated window size
1172 */
1173 virtual void PersistTimeout();
1174
1175 /**
1176 * @brief Retransmit the first segment marked as lost, without considering
1177 * available window nor pacing.
1178 */
1179 void DoRetransmit();
1180
1181 /**
1182 * @brief Add options to TcpHeader
1183 *
1184 * Test each option, and if it is enabled on our side, add it
1185 * to the header
1186 *
1187 * @param tcpHeader TcpHeader to add options to
1188 */
1189 void AddOptions(TcpHeader& tcpHeader);
1190
1191 /**
1192 * @brief Read TCP options before Ack processing
1193 *
1194 * Timestamp and Window scale are managed in other pieces of code.
1195 *
1196 * @param tcpHeader Header of the segment
1197 * @param [out] bytesSacked Number of bytes SACKed, or 0
1198 */
1199 void ReadOptions(const TcpHeader& tcpHeader, uint32_t* bytesSacked);
1200
1201 /**
1202 * @brief Return true if the specified option is enabled
1203 *
1204 * @param kind kind of TCP option
1205 * @return true if the option is enabled
1206 */
1207 bool IsTcpOptionEnabled(uint8_t kind) const;
1208
1209 /**
1210 * @brief Read and parse the Window scale option
1211 *
1212 * Read the window scale option (encoded logarithmically) and save it.
1213 * Per RFC 1323, the value can't exceed 14.
1214 *
1215 * @param option Window scale option read from the header
1216 */
1217 void ProcessOptionWScale(const Ptr<const TcpOption> option);
1218 /**
1219 * @brief Add the window scale option to the header
1220 *
1221 * Calculate our factor from the rxBuffer max size, and add it
1222 * to the header.
1223 *
1224 * @param header TcpHeader where the method should add the window scale option
1225 */
1226 void AddOptionWScale(TcpHeader& header);
1227
1228 /**
1229 * @brief Calculate window scale value based on receive buffer space
1230 *
1231 * Calculate our factor from the rxBuffer max size
1232 *
1233 * @returns the Window Scale factor
1234 */
1235 uint8_t CalculateWScale() const;
1236
1237 /**
1238 * @brief Read the SACK PERMITTED option
1239 *
1240 * Currently this is a placeholder, since no operations should be done
1241 * on such option.
1242 *
1243 * @param option SACK PERMITTED option from the header
1244 */
1246
1247 /**
1248 * @brief Read the SACK option
1249 *
1250 * @param option SACK option from the header
1251 * @returns the number of bytes sacked by this option
1252 */
1254
1255 /**
1256 * @brief Add the SACK PERMITTED option to the header
1257 *
1258 * @param header TcpHeader where the method should add the option
1259 */
1260 void AddOptionSackPermitted(TcpHeader& header);
1261
1262 /**
1263 * @brief Add the SACK option to the header
1264 *
1265 * @param header TcpHeader where the method should add the option
1266 */
1267 void AddOptionSack(TcpHeader& header);
1268
1269 /**
1270 * @brief Process the timestamp option from other side
1271 *
1272 * Get the timestamp and the echo, then save timestamp (which will
1273 * be the echo value in our out-packets) and save the echoed timestamp,
1274 * to utilize later to calculate RTT.
1275 *
1276 * @see EstimateRtt
1277 * @param option Option from the segment
1278 * @param seq Sequence number of the segment
1279 */
1280 void ProcessOptionTimestamp(const Ptr<const TcpOption> option, const SequenceNumber32& seq);
1281 /**
1282 * @brief Add the timestamp option to the header
1283 *
1284 * Set the timestamp as the lower bits of the Simulator::Now time,
1285 * and the echo value as the last seen timestamp from the other part.
1286 *
1287 * @param header TcpHeader to which add the option to
1288 */
1289 void AddOptionTimestamp(TcpHeader& header);
1290
1291 /**
1292 * @brief Performs a safe subtraction between a and b (a-b)
1293 *
1294 * Safe is used to indicate that, if b>a, the results returned is 0.
1295 *
1296 * @param a first number
1297 * @param b second number
1298 * @return 0 if b>0, (a-b) otherwise
1299 */
1301
1302 /**
1303 * @brief Notify Pacing
1304 */
1305 void NotifyPacingPerformed();
1306
1307 /**
1308 * @brief Return true if packets in the current window should be paced
1309 * @return true if pacing is currently enabled
1310 */
1311 bool IsPacingEnabled() const;
1312
1313 /**
1314 * @brief Dynamically update the pacing rate
1315 */
1316 void UpdatePacingRate();
1317
1318 /**
1319 * @brief Add Tags for the Socket
1320 * @param p Packet
1321 * @param isEct Whether the packet is allowed to be ECT capable
1322 */
1323 void AddSocketTags(const Ptr<Packet>& p, bool isEct) const;
1324
1325 /**
1326 * Get the current value of the receiver's offered window (RCV.WND)
1327 * @note This method exists to expose the value to the TcpTxBuffer
1328 * @return value of receiver's offered window
1329 */
1330 uint32_t GetRWnd() const;
1331
1332 /**
1333 * Get the current value of the receiver's highest (in-sequence) sequence number acked.
1334 * @note This method exists to expose the value to the TcpTxBuffer
1335 * @return value of receiver's highest sequence number acked.
1336 */
1338
1339 protected:
1340 // Counters and events
1341 EventId m_retxEvent{}; //!< Retransmission event
1342 EventId m_lastAckEvent{}; //!< Last ACK timeout event
1343 EventId m_delAckEvent{}; //!< Delayed ACK timeout event
1344 EventId m_persistEvent{}; //!< Persist event: Send 1 byte to probe for a non-zero Rx window
1345 EventId m_timewaitEvent{}; //!< TIME_WAIT expiration event: Move this socket to CLOSED state
1346
1347 // ACK management
1348 uint32_t m_dupAckCount{0}; //!< Dupack counter
1349 uint32_t m_delAckCount{0}; //!< Delayed ACK counter
1350 uint32_t m_delAckMaxCount{0}; //!< Number of packet to fire an ACK before delay timeout
1351
1352 // Nagle algorithm
1353 bool m_noDelay{false}; //!< Set to true to disable Nagle's algorithm
1354
1355 // Retries
1356 uint32_t m_synCount{0}; //!< Count of remaining connection retries
1357 uint32_t m_synRetries{0}; //!< Number of connection attempts
1358 uint32_t m_dataRetrCount{0}; //!< Count of remaining data retransmission attempts
1359 uint32_t m_dataRetries{0}; //!< Number of data retransmission attempts
1360
1361 // Timeouts
1362 TracedValue<Time> m_rto; //!< Retransmit timeout
1363 Time m_minRto{Time::Max()}; //!< minimum value of the Retransmit timeout
1364 Time m_clockGranularity{Seconds(0.001)}; //!< Clock Granularity used in RTO calcs
1365 Time m_delAckTimeout; //!< Time to delay an ACK
1366 Time m_persistTimeout; //!< Time between sending 1-byte probes
1367 Time m_cnTimeout; //!< Timeout for connection retry
1368
1369 // History of RTT
1370 std::deque<RttHistory> m_history; //!< List of sent packet
1371
1372 // Connections to other layers of TCP/IP
1373 Ipv4EndPoint* m_endPoint{nullptr}; //!< the IPv4 endpoint
1374 Ipv6EndPoint* m_endPoint6{nullptr}; //!< the IPv6 endpoint
1375 Ptr<Node> m_node; //!< the associated node
1376 Ptr<TcpL4Protocol> m_tcp; //!< the associated TCP L4 protocol
1378 m_icmpCallback; //!< ICMP callback
1380 m_icmpCallback6; //!< ICMPv6 callback
1381
1382 Ptr<RttEstimator> m_rtt; //!< Round trip time estimator
1383
1384 // Tx buffer management
1386
1387 // State-related attributes
1389
1390 mutable SocketErrno m_errno{ERROR_NOTERROR}; //!< Socket error code
1391
1392 bool m_closeNotified{false}; //!< Told app to close socket
1393 bool m_closeOnEmpty{false}; //!< Close socket upon tx buffer emptied
1394 bool m_shutdownSend{false}; //!< Send no longer allowed
1395 bool m_shutdownRecv{false}; //!< Receive no longer allowed
1396 bool m_connected{false}; //!< Connection established
1397 double m_msl{0.0}; //!< Max segment lifetime
1398
1399 // Window management
1400 uint16_t m_maxWinSize{0}; //!< Maximum window size to advertise
1401 uint32_t m_bytesAckedNotProcessed{0}; //!< Bytes acked, but not processed
1402 SequenceNumber32 m_highTxAck{0}; //!< Highest ack sent
1403 TracedValue<uint32_t> m_rWnd{0}; //!< Receiver window (RCV.WND in RFC793)
1404 TracedValue<uint32_t> m_advWnd{0}; //!< Advertised Window size
1405 TracedValue<SequenceNumber32> m_highRxMark{0}; //!< Highest seqno received
1407
1408 // Options
1409 bool m_sackEnabled{true}; //!< RFC SACK option enabled
1410 bool m_winScalingEnabled{true}; //!< Window Scale option enabled (RFC 7323)
1411 uint8_t m_rcvWindShift{0}; //!< Window shift to apply to outgoing segments
1412 uint8_t m_sndWindShift{0}; //!< Window shift to apply to incoming segments
1413 bool m_timestampEnabled{true}; //!< Timestamp option enabled
1414 uint32_t m_timestampToEcho{0}; //!< Timestamp to echo
1415
1416 EventId m_sendPendingDataEvent{}; //!< micro-delay event to send pending data
1417
1418 // Fast Retransmit and Recovery
1420 0}; //!< Previous highest Tx seqnum for fast recovery (set it to initial seq number)
1421 bool m_recoverActive{false}; //!< Whether "m_recover" has been set/activated
1422 //!< It is used to avoid comparing with the old m_recover value
1423 //!< which was set for handling previous congestion event.
1424 uint32_t m_retxThresh{3}; //!< Fast Retransmit threshold
1425 bool m_limitedTx{true}; //!< perform limited transmit
1426
1427 // Transmission Control Block
1428 Ptr<TcpSocketState> m_tcb; //!< Congestion control information
1430 Ptr<TcpRecoveryOps> m_recoveryOps; //!< Recovery Algorithm
1431 Ptr<TcpRateOps> m_rateOps; //!< Rate operations
1432
1433 // Guesses over the other connection end
1434 bool m_isFirstPartialAck{true}; //!< First partial ACK during RECOVERY
1435
1436 // The following three traces pass a packet with a TCP header
1438 const TcpHeader&,
1440 m_txTrace; //!< Trace of transmitted packets
1441
1443 const TcpHeader&,
1444 const Address&,
1445 const Address&,
1447 m_retransmissionTrace; //!< Trace of retransmitted packets
1448
1450 const TcpHeader&,
1452 m_rxTrace; //!< Trace of received packets
1453
1454 // Pacing related variable
1456
1457 // Parameters related to Explicit Congestion Notification
1459 0}; //!< Sequence number of the last received ECN Echo
1461 0}; //!< Sequence number of the last received Congestion Experienced
1462 TracedValue<SequenceNumber32> m_ecnCWRSeq{0}; //!< Sequence number of the last sent CWR
1463};
1464
1465/**
1466 * @ingroup tcp
1467 * TracedValue Callback signature for TcpCongState_t
1468 *
1469 * @param [in] oldValue original value of the traced variable
1470 * @param [in] newValue new value of the traced variable
1471 */
1473 const TcpSocketState::TcpCongState_t newValue);
1474
1475/**
1476 * @ingroup tcp
1477 * TracedValue Callback signature for ECN state trace
1478 *
1479 * @param [in] oldValue original value of the traced variable
1480 * @param [in] newValue new value of the traced variable
1481 */
1483 const TcpSocketState::EcnState_t newValue);
1484
1485} // namespace ns3
1486
1487#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:45
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
Describes an IPv6 address.
A representation of an IPv6 endpoint/connection.
Packet header for IPv6.
Definition ipv6-header.h:24
Smart pointer class similar to boost::intrusive_ptr.
Helper class to store RTT measurements.
uint32_t count
Number of bytes sent.
RttHistory(SequenceNumber32 s, uint32_t c, Time t)
Constructor - builds an RttHistory with the given parameters.
bool retx
True if this has been retransmitted.
Time time
Time this one was sent.
SequenceNumber32 seq
First sequence number in packet sent.
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
General infrastructure for TCP testing.
Header for the Transmission Control Protocol.
Definition tcp-header.h:36
A base class for implementation of a stream socket using TCP.
void AddOptionSack(TcpHeader &header)
Add the SACK option to the header.
int GetSockName(Address &address) const override
Get socket address.
Time m_persistTimeout
Time between sending 1-byte probes.
uint16_t m_maxWinSize
Maximum window size to advertise.
uint8_t m_rcvWindShift
Window shift to apply to outgoing segments.
void SetPaceInitialWindow(bool paceWindow)
Enable or disable pacing of the initial window.
int Bind6() override
Allocate a local IPv6 endpoint for this socket.
void TimeWait()
Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state.
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.
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.
bool m_connected
Connection established.
TracedValue< SequenceNumber32 > m_highRxAckMark
Highest ack received.
void AddOptionWScale(TcpHeader &header)
Add the window scale option to the header.
virtual void SendEmptyPacket(uint8_t flags)
Send a empty packet that carries a flag, e.g., ACK.
void UpdateWindowSize(const TcpHeader &header)
Update the receiver window (RWND) based on the value of the window field in the header.
uint32_t GetRxAvailable() const override
Return number of bytes which can be returned from one or multiple calls to Recv.
uint32_t GetDataRetries() const override
Get the number of data transmission retries before giving up.
int SetupEndpoint6()
Configure the endpoint v6 to a local address.
uint32_t GetRetxThresh() const
Get the retransmission threshold (dup ack threshold for a fast retransmit)
void DeallocateEndPoint()
Deallocate m_endPoint and m_endPoint6.
void Destroy()
Kill this socket by zeroing its attributes (IPv4)
void UpdateHighTxMark(SequenceNumber32 oldValue, SequenceNumber32 newValue) const
Callback function to hook to TcpSocketState high tx mark.
TcpSocketBase()
Create an unbound TCP socket.
void SetInitialSSThresh(uint32_t threshold) override
Set the initial Slow Start Threshold.
TracedCallback< DataRate, DataRate > m_pacingRateTrace
Callback pointer for pacing rate trace chaining.
uint32_t m_timestampToEcho
Timestamp to echo.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
void SetSndBufSize(uint32_t size) override
Set the send buffer size.
virtual Ptr< TcpSocketBase > Fork()
Call CopyObject<> to clone me.
TracedCallback< uint32_t, uint32_t > m_ssThTrace
Callback pointer for ssTh trace chaining.
SocketErrno m_errno
Socket error code.
SocketErrno GetErrno() const override
Get last error number.
virtual void CompleteFork(Ptr< Packet > p, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Complete a connection by forking the socket.
void ProcessClosing(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon CLOSING.
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.
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 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.
(abstract) base class of all TcpSockets
Definition tcp-socket.h:37
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.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Definition nstime.h:286
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
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:1345
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout