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 Get the instance TypeId
220 * @return the instance TypeId
221 */
222 TypeId GetInstanceTypeId() const override;
223
224 /**
225 * @brief TcpGeneralTest friend class (for tests).
226 * @relates TcpGeneralTest
227 */
228 friend class TcpGeneralTest;
229
230 /**
231 * Create an unbound TCP socket
232 */
234
235 /**
236 * Clone a TCP socket, for use upon receiving a connection request in LISTEN state
237 *
238 * @param sock the original Tcp Socket
239 */
240 TcpSocketBase(const TcpSocketBase& sock);
241 ~TcpSocketBase() override;
242
243 /**
244 * @brief Tcp Packet Types
245 *
246 * Taxonomy referred from Table 1 of
247 * https://www.ietf.org/archive/id/draft-ietf-tcpm-generalized-ecn-15.txt
248 */
261
262 // Set associated Node, TcpL4Protocol, RttEstimator to this socket
263
264 /**
265 * @brief Set the associated node.
266 * @param node the node
267 */
268 virtual void SetNode(Ptr<Node> node);
269
270 /**
271 * @brief Set the associated TCP L4 protocol.
272 * @param tcp the TCP L4 protocol
273 */
274 virtual void SetTcp(Ptr<TcpL4Protocol> tcp);
275
276 /**
277 * @brief Set the associated RTT estimator.
278 * @param rtt the RTT estimator
279 */
280 virtual void SetRtt(Ptr<RttEstimator> rtt);
281
282 /**
283 * @brief Sets the Minimum RTO.
284 * @param minRto The minimum RTO.
285 */
286 void SetMinRto(Time minRto);
287
288 /**
289 * @brief Get the Minimum RTO.
290 * @return The minimum RTO.
291 */
292 Time GetMinRto() const;
293
294 /**
295 * @brief Sets the Clock Granularity (used in RTO calcs).
296 * @param clockGranularity The Clock Granularity
297 */
298 void SetClockGranularity(Time clockGranularity);
299
300 /**
301 * @brief Get the Clock Granularity (used in RTO calcs).
302 * @return The Clock Granularity.
303 */
305
306 /**
307 * @brief Get a pointer to the Tx buffer
308 * @return a pointer to the tx buffer
309 */
311
312 /**
313 * @brief Get a pointer to the Rx buffer
314 * @return a pointer to the rx buffer
315 */
317
318 /**
319 * @brief Set the retransmission threshold (dup ack threshold for a fast retransmit)
320 * @param retxThresh the threshold
321 */
322 void SetRetxThresh(uint32_t retxThresh);
323
324 /**
325 * @brief Get the retransmission threshold (dup ack threshold for a fast retransmit)
326 * @return the threshold
327 */
329 {
330 return m_retxThresh;
331 }
332
333 /**
334 * @brief Callback pointer for pacing rate trace chaining
335 */
337
338 /**
339 * @brief Callback pointer for cWnd trace chaining
340 */
342
343 /**
344 * @brief Callback pointer for cWndInfl trace chaining
345 */
347
348 /**
349 * @brief Callback pointer for ssTh trace chaining
350 */
352
353 /**
354 * @brief Callback pointer for congestion state trace chaining
355 */
357
358 /**
359 * @brief Callback pointer for ECN state trace chaining
360 */
362
363 /**
364 * @brief Callback pointer for high tx mark chaining
365 */
367
368 /**
369 * @brief Callback pointer for next tx sequence chaining
370 */
372
373 /**
374 * @brief Callback pointer for bytesInFlight trace chaining
375 */
377
378 /**
379 * @brief Callback pointer for RTT trace chaining
380 */
382
383 /**
384 * @brief Callback pointer for Last RTT trace chaining
385 */
387
388 /**
389 * @brief Callback function to hook to TcpSocketState pacing rate
390 * @param oldValue old pacing rate value
391 * @param newValue new pacing rate value
392 */
393 void UpdatePacingRateTrace(DataRate oldValue, DataRate newValue) const;
394
395 /**
396 * @brief Callback function to hook to TcpSocketState congestion window
397 * @param oldValue old cWnd value
398 * @param newValue new cWnd value
399 */
400 void UpdateCwnd(uint32_t oldValue, uint32_t newValue) const;
401
402 /**
403 * @brief Callback function to hook to TcpSocketState inflated congestion window
404 * @param oldValue old cWndInfl value
405 * @param newValue new cWndInfl value
406 */
407 void UpdateCwndInfl(uint32_t oldValue, uint32_t newValue) const;
408
409 /**
410 * @brief Callback function to hook to TcpSocketState slow start threshold
411 * @param oldValue old ssTh value
412 * @param newValue new ssTh value
413 */
414 void UpdateSsThresh(uint32_t oldValue, uint32_t newValue) const;
415
416 /**
417 * @brief Callback function to hook to TcpSocketState congestion state
418 * @param oldValue old congestion state value
419 * @param newValue new congestion state value
420 */
422 TcpSocketState::TcpCongState_t newValue) const;
423
424 /**
425 * @brief Callback function to hook to EcnState state
426 * @param oldValue old ecn state value
427 * @param newValue new ecn state value
428 */
430 TcpSocketState::EcnState_t newValue) const;
431
432 /**
433 * @brief Callback function to hook to TcpSocketState high tx mark
434 * @param oldValue old high tx mark
435 * @param newValue new high tx mark
436 */
437 void UpdateHighTxMark(SequenceNumber32 oldValue, SequenceNumber32 newValue) const;
438
439 /**
440 * @brief Callback function to hook to TcpSocketState next tx sequence
441 * @param oldValue old nextTxSeq value
442 * @param newValue new nextTxSeq value
443 */
444 void UpdateNextTxSequence(SequenceNumber32 oldValue, SequenceNumber32 newValue) const;
445
446 /**
447 * @brief Callback function to hook to TcpSocketState bytes inflight
448 * @param oldValue old bytesInFlight value
449 * @param newValue new bytesInFlight value
450 */
451 void UpdateBytesInFlight(uint32_t oldValue, uint32_t newValue) const;
452
453 /**
454 * @brief Callback function to hook to TcpSocketState rtt
455 * @param oldValue old rtt value
456 * @param newValue new rtt value
457 */
458 void UpdateRtt(Time oldValue, Time newValue) const;
459
460 /**
461 * @brief Callback function to hook to TcpSocketState lastRtt
462 * @param oldValue old lastRtt value
463 * @param newValue new lastRtt value
464 */
465 void UpdateLastRtt(Time oldValue, Time newValue) const;
466
467 /**
468 * @brief Install a congestion control algorithm on this socket
469 *
470 * @param algo Algorithm to be installed
471 */
473
474 /**
475 * @brief Install a recovery algorithm on this socket
476 *
477 * @param recovery Algorithm to be installed
478 */
480
481 /**
482 * @brief Mark ECT(0) codepoint
483 *
484 * @param tos the TOS byte to modify
485 * @return TOS with ECT(0) codepoint set
486 */
487 inline uint8_t MarkEcnEct0(uint8_t tos) const
488 {
489 return ((tos & 0xfc) | 0x02);
490 }
491
492 /**
493 * @brief Mark ECT(1) codepoint
494 *
495 * @param tos the TOS byte to modify
496 * @return TOS with ECT(1) codepoint set
497 */
498 inline uint8_t MarkEcnEct1(uint8_t tos) const
499 {
500 return ((tos & 0xfc) | 0x01);
501 }
502
503 /**
504 * @brief Mark CE codepoint
505 *
506 * @param tos the TOS byte to modify
507 * @return TOS with CE codepoint set
508 */
509 inline uint8_t MarkEcnCe(uint8_t tos) const
510 {
511 return ((tos & 0xfc) | 0x03);
512 }
513
514 /**
515 * @brief Clears ECN bits from TOS
516 *
517 * @param tos the TOS byte to modify
518 * @return TOS without ECN bits
519 */
520 inline uint8_t ClearEcnBits(uint8_t tos) const
521 {
522 return tos & 0xfc;
523 }
524
525 /**
526 * @brief Checks if TOS has no ECN codepoints
527 *
528 * @param tos the TOS byte to check
529 * @return true if TOS does not have any ECN codepoints set; otherwise false
530 */
531 inline bool CheckNoEcn(uint8_t tos) const
532 {
533 return ((tos & 0x03) == 0x00);
534 }
535
536 /**
537 * @brief Checks for ECT(0) codepoint
538 *
539 * @param tos the TOS byte to check
540 * @return true if TOS has ECT(0) codepoint set; otherwise false
541 */
542 inline bool CheckEcnEct0(uint8_t tos) const
543 {
544 return ((tos & 0x03) == 0x02);
545 }
546
547 /**
548 * @brief Checks for ECT(1) codepoint
549 *
550 * @param tos the TOS byte to check
551 * @return true if TOS has ECT(1) codepoint set; otherwise false
552 */
553 inline bool CheckEcnEct1(uint8_t tos) const
554 {
555 return ((tos & 0x03) == 0x01);
556 }
557
558 /**
559 * @brief Checks for CE codepoint
560 *
561 * @param tos the TOS byte to check
562 * @return true if TOS has CE codepoint set; otherwise false
563 */
564 inline bool CheckEcnCe(uint8_t tos) const
565 {
566 return ((tos & 0x03) == 0x03);
567 }
568
569 /**
570 * @brief mark ECN code point
571 *
572 * @param tos the TOS byte to modify
573 * @param codePoint the codepoint to use
574 * @return TOS with specified ECN code point
575 */
576 inline uint8_t MarkEcnCodePoint(const uint8_t tos,
577 const TcpSocketState::EcnCodePoint_t codePoint) const
578 {
579 return ((tos & 0xfc) | codePoint);
580 }
581
582 /**
583 * @brief Set ECN mode of use on the socket
584 *
585 * @param useEcn Mode of ECN to use.
586 */
588
589 /**
590 * @brief Enable or disable pacing
591 * @param pacing Boolean to enable or disable pacing
592 */
593 void SetPacingStatus(bool pacing);
594
595 /**
596 * @brief Enable or disable pacing of the initial window
597 * @param paceWindow Boolean to enable or disable pacing of the initial window
598 */
599 void SetPaceInitialWindow(bool paceWindow);
600
601 /**
602 * @brief Checks if a TCP packet should be ECN-capable (ECT) according to the TcpPacketType and
603 * ECN mode.
604 *
605 * Currently, only Classic ECN and DCTCP ECN modes are supported, with
606 * potential extensions for future modes (Ecnpp).
607 *
608 * @param packetType The type of the TCP packet, represented by an enum TcpPacketType.
609 * @return true if the packet is ECN-capable (ECT), false otherwise.
610 *
611 * Reference: https://www.ietf.org/archive/id/draft-ietf-tcpm-generalized-ecn-15.txt (Table 1)
612 */
613 bool IsEct(TcpPacketType_t packetType) const;
614
615 // Necessary implementations of null functions from ns3::Socket
616 SocketErrno GetErrno() const override; // returns m_errno
617 SocketType GetSocketType() const override; // returns socket type
618 Ptr<Node> GetNode() const override; // returns m_node
619 int Bind() override; // Bind a socket by setting up endpoint in TcpL4Protocol
620 int Bind6() override; // Bind a socket by setting up endpoint in TcpL4Protocol
621 int Bind(const Address& address) override; // ... endpoint of specific addr or port
622 int Connect(
623 const Address& address) override; // Setup endpoint and call ProcessAction() to connect
624 int Listen()
625 override; // Verify the socket is in a correct state and call ProcessAction() to listen
626 int Close() override; // Close by app: Kill socket upon tx buffer emptied
627 int ShutdownSend() override; // Assert the m_shutdownSend flag to prevent send to network
628 int ShutdownRecv() override; // Assert the m_shutdownRecv flag to prevent forward to app
629 int Send(Ptr<Packet> p, uint32_t flags) override; // Call by app to send data to network
630 int SendTo(Ptr<Packet> p,
631 uint32_t flags,
632 const Address& toAddress) override; // Same as Send(), toAddress is insignificant
633 Ptr<Packet> Recv(uint32_t maxSize,
634 uint32_t flags) override; // Return a packet to be forwarded to app
635 Ptr<Packet> RecvFrom(uint32_t maxSize, uint32_t flags, Address& fromAddress)
636 override; // ... and write the remote address at fromAddress
637 uint32_t GetTxAvailable() const override; // Available Tx buffer size
639 const override; // Available-to-read data size, i.e. value of m_rxAvailable
640 int GetSockName(Address& address) const override; // Return local addr:port in address
641 int GetPeerName(Address& address) const override;
642 void BindToNetDevice(Ptr<NetDevice> netdevice) override; // NetDevice with my m_endPoint
643
644 /**
645 * TracedCallback signature for TCP packet transmission or reception events.
646 *
647 * @param [in] packet The packet.
648 * @param [in] header The TcpHeader
649 * @param [in] socket This socket
650 */
651 typedef void (*TcpTxRxTracedCallback)(const Ptr<const Packet> packet,
652 const TcpHeader& header,
653 const Ptr<const TcpSocketBase> socket);
654
655 /**
656 * TracedCallback signature for TCP packet retransmission events.
657 *
658 * @param [in] packet The packet.
659 * @param [in] header The TcpHeader
660 * @param [in] localAddr The local address
661 * @param [in] peerAddr The peer/remote address
662 * @param [in] socket This socket
663 */
664 typedef void (*RetransmissionCallback)(const Ptr<const Packet> packet,
665 const TcpHeader& header,
666 const Address& localAddr,
667 const Address& peerAddr,
668 const Ptr<const TcpSocketBase> socket);
669
670 protected:
671 // Implementing ns3::TcpSocket -- Attribute get/set
672 // inherited, no need to doc
673
674 void SetSndBufSize(uint32_t size) override;
675 uint32_t GetSndBufSize() const override;
676 void SetRcvBufSize(uint32_t size) override;
677 uint32_t GetRcvBufSize() const override;
678 void SetSegSize(uint32_t size) override;
679 uint32_t GetSegSize() const override;
680 void SetInitialSSThresh(uint32_t threshold) override;
681 uint32_t GetInitialSSThresh() const override;
682 void SetInitialCwnd(uint32_t cwnd) override;
683 uint32_t GetInitialCwnd() const override;
684 void SetConnTimeout(Time timeout) override;
685 Time GetConnTimeout() const override;
686 void SetSynRetries(uint32_t count) override;
687 uint32_t GetSynRetries() const override;
688 void SetDataRetries(uint32_t retries) override;
689 uint32_t GetDataRetries() const override;
690 void SetDelAckTimeout(Time timeout) override;
691 Time GetDelAckTimeout() const override;
692 void SetDelAckMaxCount(uint32_t count) override;
693 uint32_t GetDelAckMaxCount() const override;
694 void SetTcpNoDelay(bool noDelay) override;
695 bool GetTcpNoDelay() const override;
696 void SetPersistTimeout(Time timeout) override;
697 Time GetPersistTimeout() const override;
698 bool SetAllowBroadcast(bool allowBroadcast) override;
699 bool GetAllowBroadcast() const override;
700
701 // Helper functions: Connection set up
702
703 /**
704 * @brief Common part of the two Bind(), i.e. set callback and remembering local addr:port
705 *
706 * @returns 0 on success, -1 on failure
707 */
708 int SetupCallback();
709
710 /**
711 * @brief Perform the real connection tasks: Send SYN if allowed, RST if invalid
712 *
713 * @returns 0 on success
714 */
715 int DoConnect();
716
717 /**
718 * @brief Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
719 */
720 void ConnectionSucceeded();
721
722 /**
723 * @brief Configure the endpoint to a local address. Called by Connect() if Bind() didn't
724 * specify one.
725 *
726 * @returns 0 on success
727 */
728 int SetupEndpoint();
729
730 /**
731 * @brief Configure the endpoint v6 to a local address. Called by Connect() if Bind() didn't
732 * specify one.
733 *
734 * @returns 0 on success
735 */
736 int SetupEndpoint6();
737
738 /**
739 * @brief Complete a connection by forking the socket
740 *
741 * This function is called only if a SYN received in LISTEN state. After
742 * TcpSocketBase cloned, allocate a new end point to handle the incoming
743 * connection and send a SYN+ACK to complete the handshake.
744 *
745 * @param p the packet triggering the fork
746 * @param tcpHeader the TCP header of the triggering packet
747 * @param fromAddress the address of the remote host
748 * @param toAddress the address the connection is directed to
749 */
750 virtual void CompleteFork(Ptr<Packet> p,
751 const TcpHeader& tcpHeader,
752 const Address& fromAddress,
753 const Address& toAddress);
754
755 // Helper functions: Transfer operation
756
757 /**
758 * @brief Checks whether the given TCP segment is valid or not.
759 *
760 * @param seq the sequence number of packet's TCP header
761 * @param tcpHeaderSize the size of packet's TCP header
762 * @param tcpPayloadSize the size of TCP payload
763 * @return true if the TCP segment is valid
764 */
765 bool IsValidTcpSegment(const SequenceNumber32 seq,
766 const uint32_t tcpHeaderSize,
767 const uint32_t tcpPayloadSize);
768
769 /**
770 * @brief Called by the L3 protocol when it received a packet to pass on to TCP.
771 *
772 * @param packet the incoming packet
773 * @param header the packet's IPv4 header
774 * @param port the remote port
775 * @param incomingInterface the incoming interface
776 */
777 void ForwardUp(Ptr<Packet> packet,
778 Ipv4Header header,
779 uint16_t port,
780 Ptr<Ipv4Interface> incomingInterface);
781
782 /**
783 * @brief Called by the L3 protocol when it received a packet to pass on to TCP.
784 *
785 * @param packet the incoming packet
786 * @param header the packet's IPv6 header
787 * @param port the remote port
788 * @param incomingInterface the incoming interface
789 */
790 void ForwardUp6(Ptr<Packet> packet,
791 Ipv6Header header,
792 uint16_t port,
793 Ptr<Ipv6Interface> incomingInterface);
794
795 /**
796 * @brief Called by TcpSocketBase::ForwardUp{,6}().
797 *
798 * Get a packet from L3. This is the real function to handle the
799 * incoming packet from lower layers. This is
800 * wrapped by ForwardUp() so that this function can be overloaded by daughter
801 * classes.
802 *
803 * @param packet the incoming packet
804 * @param fromAddress the address of the sender of packet
805 * @param toAddress the address of the receiver of packet (hopefully, us)
806 */
807 virtual void DoForwardUp(Ptr<Packet> packet,
808 const Address& fromAddress,
809 const Address& toAddress);
810
811 /**
812 * @brief Called by the L3 protocol when it received an ICMP packet to pass on to TCP.
813 *
814 * @param icmpSource the ICMP source address
815 * @param icmpTtl the ICMP Time to Live
816 * @param icmpType the ICMP Type
817 * @param icmpCode the ICMP Code
818 * @param icmpInfo the ICMP Info
819 */
820 void ForwardIcmp(Ipv4Address icmpSource,
821 uint8_t icmpTtl,
822 uint8_t icmpType,
823 uint8_t icmpCode,
824 uint32_t icmpInfo);
825
826 /**
827 * @brief Called by the L3 protocol when it received an ICMPv6 packet to pass on to TCP.
828 *
829 * @param icmpSource the ICMP source address
830 * @param icmpTtl the ICMP Time to Live
831 * @param icmpType the ICMP Type
832 * @param icmpCode the ICMP Code
833 * @param icmpInfo the ICMP Info
834 */
835 void ForwardIcmp6(Ipv6Address icmpSource,
836 uint8_t icmpTtl,
837 uint8_t icmpType,
838 uint8_t icmpCode,
839 uint32_t icmpInfo);
840
841 /**
842 * @brief Send as much pending data as possible according to the Tx window.
843 *
844 * Note that this function did not implement the PSH flag.
845 *
846 * @param withAck forces an ACK to be sent
847 * @returns the number of packets sent
848 */
849 uint32_t SendPendingData(bool withAck = false);
850
851 /**
852 * @brief Extract at most maxSize bytes from the TxBuffer at sequence seq, add the
853 * TCP header, and send to TcpL4Protocol
854 *
855 * @param seq the sequence number
856 * @param maxSize the maximum data block to be transmitted (in bytes)
857 * @param withAck forces an ACK to be sent
858 * @returns the number of bytes sent
859 */
860 virtual uint32_t SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, bool withAck);
861
862 /**
863 * @brief Send a empty packet that carries a flag, e.g., ACK
864 *
865 * @param flags the packet's flags
866 */
867 virtual void SendEmptyPacket(uint8_t flags);
868
869 /**
870 * @brief Send reset and tear down this socket
871 */
872 void SendRST();
873
874 /**
875 * @brief Check if a sequence number range is within the rx window
876 *
877 * @param head start of the Sequence window
878 * @param tail end of the Sequence window
879 * @returns true if it is in range
880 */
881 bool OutOfRange(SequenceNumber32 head, SequenceNumber32 tail) const;
882
883 // Helper functions: Connection close
884
885 /**
886 * @brief Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state
887 *
888 * @returns 0 on success
889 */
890 int DoClose();
891
892 /**
893 * @brief Peacefully close the socket by notifying the upper layer and deallocate end point
894 */
895 void CloseAndNotify();
896
897 /**
898 * @brief Kill this socket by zeroing its attributes (IPv4)
899 *
900 * This is a callback function configured to m_endpoint in
901 * SetupCallback(), invoked when the endpoint is destroyed.
902 */
903 void Destroy();
904
905 /**
906 * @brief Kill this socket by zeroing its attributes (IPv6)
907 *
908 * This is a callback function configured to m_endpoint in
909 * SetupCallback(), invoked when the endpoint is destroyed.
910 */
911 void Destroy6();
912
913 /**
914 * @brief Deallocate m_endPoint and m_endPoint6
915 */
916 void DeallocateEndPoint();
917
918 /**
919 * @brief Received a FIN from peer, notify rx buffer
920 *
921 * @param p the packet
922 * @param tcpHeader the packet's TCP header
923 */
924 void PeerClose(Ptr<Packet> p, const TcpHeader& tcpHeader);
925
926 /**
927 * @brief FIN is in sequence, notify app and respond with a FIN
928 */
929 void DoPeerClose();
930
931 /**
932 * @brief Cancel all timer when endpoint is deleted
933 */
934 void CancelAllTimers();
935
936 /**
937 * @brief Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state
938 */
939 void TimeWait();
940
941 // State transition functions
942
943 /**
944 * @brief Received a packet upon ESTABLISHED state.
945 *
946 * This function is mimicking the role of tcp_rcv_established() in tcp_input.c in Linux kernel.
947 *
948 * @param packet the packet
949 * @param tcpHeader the packet's TCP header
950 */
952 const TcpHeader& tcpHeader); // Received a packet upon ESTABLISHED state
953
954 /**
955 * @brief Received a packet upon LISTEN state.
956 *
957 * @param packet the packet
958 * @param tcpHeader the packet's TCP header
959 * @param fromAddress the source address
960 * @param toAddress the destination address
961 */
962 void ProcessListen(Ptr<Packet> packet,
963 const TcpHeader& tcpHeader,
964 const Address& fromAddress,
965 const Address& toAddress);
966
967 /**
968 * @brief Received a packet upon SYN_SENT
969 *
970 * @param packet the packet
971 * @param tcpHeader the packet's TCP header
972 */
973 void ProcessSynSent(Ptr<Packet> packet, const TcpHeader& tcpHeader);
974
975 /**
976 * @brief Received a packet upon SYN_RCVD.
977 *
978 * @param packet the packet
979 * @param tcpHeader the packet's TCP header
980 * @param fromAddress the source address
981 * @param toAddress the destination address
982 */
983 void ProcessSynRcvd(Ptr<Packet> packet,
984 const TcpHeader& tcpHeader,
985 const Address& fromAddress,
986 const Address& toAddress);
987
988 /**
989 * @brief Received a packet upon CLOSE_WAIT, FIN_WAIT_1, FIN_WAIT_2
990 *
991 * @param packet the packet
992 * @param tcpHeader the packet's TCP header
993 */
994 void ProcessWait(Ptr<Packet> packet, const TcpHeader& tcpHeader);
995
996 /**
997 * @brief Received a packet upon CLOSING
998 *
999 * @param packet the packet
1000 * @param tcpHeader the packet's TCP header
1001 */
1002 void ProcessClosing(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1003
1004 /**
1005 * @brief Received a packet upon LAST_ACK
1006 *
1007 * @param packet the packet
1008 * @param tcpHeader the packet's TCP header
1009 */
1010 void ProcessLastAck(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1011
1012 // Window management
1013
1014 /**
1015 * @brief Return count of number of unacked bytes
1016 *
1017 * The difference between SND.UNA and HighTx
1018 *
1019 * @returns count of number of unacked bytes
1020 */
1021 virtual uint32_t UnAckDataCount() const;
1022
1023 /**
1024 * @brief Return total bytes in flight
1025 *
1026 * Does not count segments lost and SACKed (or dupACKed)
1027 *
1028 * @returns total bytes in flight
1029 */
1030 virtual uint32_t BytesInFlight() const;
1031
1032 /**
1033 * @brief Return the max possible number of unacked bytes
1034 * @returns the max possible number of unacked bytes
1035 */
1036 virtual uint32_t Window() const;
1037
1038 /**
1039 * @brief Return unfilled portion of window
1040 * @return unfilled portion of window
1041 */
1042 virtual uint32_t AvailableWindow() const;
1043
1044 /**
1045 * @brief The amount of Rx window announced to the peer
1046 * @param scale indicate if the window should be scaled. True for
1047 * almost all cases, except when we are sending a SYN
1048 * @returns size of Rx window announced to the peer
1049 */
1050 virtual uint16_t AdvertisedWindowSize(bool scale = true) const;
1051
1052 /**
1053 * @brief Update the receiver window (RWND) based on the value of the
1054 * window field in the header.
1055 *
1056 * This method suppresses updates unless one of the following three
1057 * conditions holds: 1) segment contains new data (advancing the right
1058 * edge of the receive buffer), 2) segment does not contain new data
1059 * but the segment acks new data (highest sequence number acked advances),
1060 * or 3) the advertised window is larger than the current send window
1061 *
1062 * @param header TcpHeader from which to extract the new window value
1063 */
1064 void UpdateWindowSize(const TcpHeader& header);
1065
1066 // Manage data tx/rx
1067
1068 /**
1069 * @brief Call CopyObject<> to clone me
1070 * @returns a copy of the socket
1071 */
1072 virtual Ptr<TcpSocketBase> Fork();
1073
1074 /**
1075 * @brief Received an ACK packet
1076 * @param packet the packet
1077 * @param tcpHeader the packet's TCP header
1078 */
1079 virtual void ReceivedAck(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1080
1081 /**
1082 * @brief Process a received ack
1083 * @param ackNumber ack number
1084 * @param scoreboardUpdated if true indicates that the scoreboard has been
1085 * @param oldHeadSequence value of HeadSequence before ack
1086 * updated with SACK information
1087 * @param currentDelivered The number of bytes (S)ACKed
1088 * @param receivedData if true indicates that data is piggybacked with ACK
1089 */
1090 virtual void ProcessAck(const SequenceNumber32& ackNumber,
1091 bool scoreboardUpdated,
1092 uint32_t currentDelivered,
1093 const SequenceNumber32& oldHeadSequence,
1094 bool receivedData);
1095
1096 /**
1097 * @brief Recv of a data, put into buffer, call L7 to get it if necessary
1098 * @param packet the packet
1099 * @param tcpHeader the packet's TCP header
1100 */
1101 virtual void ReceivedData(Ptr<Packet> packet, const TcpHeader& tcpHeader);
1102
1103 /**
1104 * @brief Calculate RTT sample for the ACKed packet
1105 *
1106 * Per RFC 6298 (Section 3),
1107 * If `m_timestampsEnabled` is true, calculate RTT using timestamps option.
1108 * Otherwise, return RTT as the elapsed time since the packet was transmitted.
1109 * If ACKed packed was a retrasmitted packet, return zero time.
1110 *
1111 * @param tcpHeader the packet's TCP header
1112 * @param rttHistory the ACKed packet's RTT History
1113 * @returns the RTT sample
1114 */
1115 virtual Time CalculateRttSample(const TcpHeader& tcpHeader, const RttHistory& rttHistory);
1116
1117 /**
1118 * @brief Take into account the packet for RTT estimation
1119 * @param tcpHeader the packet's TCP header
1120 */
1121 virtual void EstimateRtt(const TcpHeader& tcpHeader);
1122
1123 /**
1124 * @brief Update the RTT history, when we send TCP segments
1125 *
1126 * @param seq The sequence number of the TCP segment
1127 * @param sz The segment's size
1128 * @param isRetransmission Whether or not the segment is a retransmission
1129 */
1130
1131 virtual void UpdateRttHistory(const SequenceNumber32& seq, uint32_t sz, bool isRetransmission);
1132
1133 /**
1134 * @brief Update buffers w.r.t. ACK
1135 * @param seq the sequence number
1136 * @param resetRTO indicates if RTO should be reset
1137 */
1138 virtual void NewAck(const SequenceNumber32& seq, bool resetRTO);
1139
1140 /**
1141 * @brief Dupack management
1142 *
1143 * @param currentDelivered Current (S)ACKed bytes
1144 */
1145 void DupAck(uint32_t currentDelivered);
1146
1147 /**
1148 * @brief Enter CA_CWR state upon receipt of an ECN Echo
1149 *
1150 * @param currentDelivered Currently (S)ACKed bytes
1151 */
1152 void EnterCwr(uint32_t currentDelivered);
1153
1154 /**
1155 * @brief Enter the CA_RECOVERY, and retransmit the head
1156 *
1157 * @param currentDelivered Currently (S)ACKed bytes
1158 */
1159 void EnterRecovery(uint32_t currentDelivered);
1160
1161 /**
1162 * @brief An RTO event happened
1163 */
1164 virtual void ReTxTimeout();
1165
1166 /**
1167 * @brief Action upon delay ACK timeout, i.e. send an ACK
1168 */
1169 virtual void DelAckTimeout();
1170
1171 /**
1172 * @brief Timeout at LAST_ACK, close the connection
1173 */
1174 virtual void LastAckTimeout();
1175
1176 /**
1177 * @brief Send 1 byte probe to get an updated window size
1178 */
1179 virtual void PersistTimeout();
1180
1181 /**
1182 * @brief Retransmit the first segment marked as lost, without considering
1183 * available window nor pacing.
1184 */
1185 void DoRetransmit();
1186
1187 /**
1188 * @brief Add options to TcpHeader
1189 *
1190 * Test each option, and if it is enabled on our side, add it
1191 * to the header
1192 *
1193 * @param tcpHeader TcpHeader to add options to
1194 */
1195 void AddOptions(TcpHeader& tcpHeader);
1196
1197 /**
1198 * @brief Read TCP options before Ack processing
1199 *
1200 * Timestamp and Window scale are managed in other pieces of code.
1201 *
1202 * @param tcpHeader Header of the segment
1203 * @param [out] bytesSacked Number of bytes SACKed, or 0
1204 */
1205 void ReadOptions(const TcpHeader& tcpHeader, uint32_t* bytesSacked);
1206
1207 /**
1208 * @brief Return true if the specified option is enabled
1209 *
1210 * @param kind kind of TCP option
1211 * @return true if the option is enabled
1212 */
1213 bool IsTcpOptionEnabled(uint8_t kind) const;
1214
1215 /**
1216 * @brief Read and parse the Window scale option
1217 *
1218 * Read the window scale option (encoded logarithmically) and save it.
1219 * Per RFC 1323, the value can't exceed 14.
1220 *
1221 * @param option Window scale option read from the header
1222 */
1223 void ProcessOptionWScale(const Ptr<const TcpOption> option);
1224 /**
1225 * @brief Add the window scale option to the header
1226 *
1227 * Calculate our factor from the rxBuffer max size, and add it
1228 * to the header.
1229 *
1230 * @param header TcpHeader where the method should add the window scale option
1231 */
1232 void AddOptionWScale(TcpHeader& header);
1233
1234 /**
1235 * @brief Calculate window scale value based on receive buffer space
1236 *
1237 * Calculate our factor from the rxBuffer max size
1238 *
1239 * @returns the Window Scale factor
1240 */
1241 uint8_t CalculateWScale() const;
1242
1243 /**
1244 * @brief Read the SACK PERMITTED option
1245 *
1246 * Currently this is a placeholder, since no operations should be done
1247 * on such option.
1248 *
1249 * @param option SACK PERMITTED option from the header
1250 */
1252
1253 /**
1254 * @brief Read the SACK option
1255 *
1256 * @param option SACK option from the header
1257 * @returns the number of bytes sacked by this option
1258 */
1260
1261 /**
1262 * @brief Add the SACK PERMITTED option to the header
1263 *
1264 * @param header TcpHeader where the method should add the option
1265 */
1266 void AddOptionSackPermitted(TcpHeader& header);
1267
1268 /**
1269 * @brief Add the SACK option to the header
1270 *
1271 * @param header TcpHeader where the method should add the option
1272 */
1273 void AddOptionSack(TcpHeader& header);
1274
1275 /**
1276 * @brief Process the timestamp option from other side
1277 *
1278 * Get the timestamp and the echo, then save timestamp (which will
1279 * be the echo value in our out-packets) and save the echoed timestamp,
1280 * to utilize later to calculate RTT.
1281 *
1282 * @see EstimateRtt
1283 * @param option Option from the segment
1284 * @param seq Sequence number of the segment
1285 */
1286 void ProcessOptionTimestamp(const Ptr<const TcpOption> option, const SequenceNumber32& seq);
1287 /**
1288 * @brief Add the timestamp option to the header
1289 *
1290 * Set the timestamp as the lower bits of the Simulator::Now time,
1291 * and the echo value as the last seen timestamp from the other part.
1292 *
1293 * @param header TcpHeader to which add the option to
1294 */
1295 void AddOptionTimestamp(TcpHeader& header);
1296
1297 /**
1298 * @brief Performs a safe subtraction between a and b (a-b)
1299 *
1300 * Safe is used to indicate that, if b>a, the results returned is 0.
1301 *
1302 * @param a first number
1303 * @param b second number
1304 * @return 0 if b>0, (a-b) otherwise
1305 */
1307
1308 /**
1309 * @brief Notify Pacing
1310 */
1311 void NotifyPacingPerformed();
1312
1313 /**
1314 * @brief Return true if packets in the current window should be paced
1315 * @return true if pacing is currently enabled
1316 */
1317 bool IsPacingEnabled() const;
1318
1319 /**
1320 * @brief Dynamically update the pacing rate
1321 */
1322 void UpdatePacingRate();
1323
1324 /**
1325 * @brief Add Tags for the Socket
1326 * @param p Packet
1327 * @param isEct Whether the packet is allowed to be ECT capable
1328 */
1329 void AddSocketTags(const Ptr<Packet>& p, bool isEct) const;
1330
1331 /**
1332 * Get the current value of the receiver's offered window (RCV.WND)
1333 * @note This method exists to expose the value to the TcpTxBuffer
1334 * @return value of receiver's offered window
1335 */
1336 uint32_t GetRWnd() const;
1337
1338 /**
1339 * Get the current value of the receiver's highest (in-sequence) sequence number acked.
1340 * @note This method exists to expose the value to the TcpTxBuffer
1341 * @return value of receiver's highest sequence number acked.
1342 */
1344
1345 protected:
1346 // Counters and events
1347 EventId m_retxEvent{}; //!< Retransmission event
1348 EventId m_lastAckEvent{}; //!< Last ACK timeout event
1349 EventId m_delAckEvent{}; //!< Delayed ACK timeout event
1350 EventId m_persistEvent{}; //!< Persist event: Send 1 byte to probe for a non-zero Rx window
1351 EventId m_timewaitEvent{}; //!< TIME_WAIT expiration event: Move this socket to CLOSED state
1352
1353 // ACK management
1354 uint32_t m_dupAckCount{0}; //!< Dupack counter
1355 uint32_t m_delAckCount{0}; //!< Delayed ACK counter
1356 uint32_t m_delAckMaxCount{0}; //!< Number of packet to fire an ACK before delay timeout
1357
1358 // Nagle algorithm
1359 bool m_noDelay{false}; //!< Set to true to disable Nagle's algorithm
1360
1361 // Retries
1362 uint32_t m_synCount{0}; //!< Count of remaining connection retries
1363 uint32_t m_synRetries{0}; //!< Number of connection attempts
1364 uint32_t m_dataRetrCount{0}; //!< Count of remaining data retransmission attempts
1365 uint32_t m_dataRetries{0}; //!< Number of data retransmission attempts
1366
1367 // Timeouts
1368 TracedValue<Time> m_rto; //!< Retransmit timeout
1369 Time m_minRto{Time::Max()}; //!< minimum value of the Retransmit timeout
1370 Time m_clockGranularity{Seconds(0.001)}; //!< Clock Granularity used in RTO calcs
1371 Time m_delAckTimeout; //!< Time to delay an ACK
1372 Time m_persistTimeout; //!< Time between sending 1-byte probes
1373 Time m_cnTimeout; //!< Timeout for connection retry
1374
1375 // History of RTT
1376 std::deque<RttHistory> m_history; //!< List of sent packet
1377
1378 // Connections to other layers of TCP/IP
1379 Ipv4EndPoint* m_endPoint{nullptr}; //!< the IPv4 endpoint
1380 Ipv6EndPoint* m_endPoint6{nullptr}; //!< the IPv6 endpoint
1381 Ptr<Node> m_node; //!< the associated node
1382 Ptr<TcpL4Protocol> m_tcp; //!< the associated TCP L4 protocol
1384 m_icmpCallback; //!< ICMP callback
1386 m_icmpCallback6; //!< ICMPv6 callback
1387
1388 Ptr<RttEstimator> m_rtt; //!< Round trip time estimator
1389
1390 // Tx buffer management
1392
1393 // State-related attributes
1395
1396 mutable SocketErrno m_errno{ERROR_NOTERROR}; //!< Socket error code
1397
1398 bool m_closeNotified{false}; //!< Told app to close socket
1399 bool m_closeOnEmpty{false}; //!< Close socket upon tx buffer emptied
1400 bool m_shutdownSend{false}; //!< Send no longer allowed
1401 bool m_shutdownRecv{false}; //!< Receive no longer allowed
1402 bool m_connected{false}; //!< Connection established
1403 double m_msl{0.0}; //!< Max segment lifetime
1404
1405 // Window management
1406 uint16_t m_maxWinSize{0}; //!< Maximum window size to advertise
1407 uint32_t m_bytesAckedNotProcessed{0}; //!< Bytes acked, but not processed
1408 SequenceNumber32 m_highTxAck{0}; //!< Highest ack sent
1409 TracedValue<uint32_t> m_rWnd{0}; //!< Receiver window (RCV.WND in RFC793)
1410 TracedValue<uint32_t> m_advWnd{0}; //!< Advertised Window size
1411 TracedValue<SequenceNumber32> m_highRxMark{0}; //!< Highest seqno received
1413
1414 // Options
1415 bool m_sackEnabled{true}; //!< RFC SACK option enabled
1416 bool m_winScalingEnabled{true}; //!< Window Scale option enabled (RFC 7323)
1417 uint8_t m_rcvWindShift{0}; //!< Window shift to apply to outgoing segments
1418 uint8_t m_sndWindShift{0}; //!< Window shift to apply to incoming segments
1419 bool m_timestampEnabled{true}; //!< Timestamp option enabled
1420 uint32_t m_timestampToEcho{0}; //!< Timestamp to echo
1421
1422 EventId m_sendPendingDataEvent{}; //!< micro-delay event to send pending data
1423
1424 // Fast Retransmit and Recovery
1426 0}; //!< Previous highest Tx seqnum for fast recovery (set it to initial seq number)
1427 bool m_recoverActive{false}; //!< Whether "m_recover" has been set/activated
1428 //!< It is used to avoid comparing with the old m_recover value
1429 //!< which was set for handling previous congestion event.
1430 uint32_t m_retxThresh{3}; //!< Fast Retransmit threshold
1431 bool m_limitedTx{true}; //!< perform limited transmit
1432
1433 // Transmission Control Block
1434 Ptr<TcpSocketState> m_tcb; //!< Congestion control information
1436 Ptr<TcpRecoveryOps> m_recoveryOps; //!< Recovery Algorithm
1437 Ptr<TcpRateOps> m_rateOps; //!< Rate operations
1438
1439 // Guesses over the other connection end
1440 bool m_isFirstPartialAck{true}; //!< First partial ACK during RECOVERY
1441
1442 // The following three traces pass a packet with a TCP header
1444 const TcpHeader&,
1446 m_txTrace; //!< Trace of transmitted packets
1447
1449 const TcpHeader&,
1450 const Address&,
1451 const Address&,
1453 m_retransmissionTrace; //!< Trace of retransmitted packets
1454
1456 const TcpHeader&,
1458 m_rxTrace; //!< Trace of received packets
1459
1460 // Pacing related variable
1462
1463 // Parameters related to Explicit Congestion Notification
1465 0}; //!< Sequence number of the last received ECN Echo
1467 0}; //!< Sequence number of the last received Congestion Experienced
1468 TracedValue<SequenceNumber32> m_ecnCWRSeq{0}; //!< Sequence number of the last sent CWR
1469};
1470
1471/**
1472 * @ingroup tcp
1473 * TracedValue Callback signature for TcpCongState_t
1474 *
1475 * @param [in] oldValue original value of the traced variable
1476 * @param [in] newValue new value of the traced variable
1477 */
1479 const TcpSocketState::TcpCongState_t newValue);
1480
1481/**
1482 * @ingroup tcp
1483 * TracedValue Callback signature for ECN state trace
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::EcnState_t newValue);
1490
1491} // namespace ns3
1492
1493#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.
TypeId GetInstanceTypeId() const override
Get the instance TypeId.
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:48
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:1344
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout