A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tcp-socket-base.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 Georgia Tech Research Corporation
4  * Copyright (c) 2010 Adrian Sai-wah Tam
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
20  */
21 #ifndef TCP_SOCKET_BASE_H
22 #define TCP_SOCKET_BASE_H
23 
24 #include <stdint.h>
25 #include <queue>
26 #include "ns3/callback.h"
27 #include "ns3/traced-value.h"
28 #include "ns3/tcp-socket.h"
29 #include "ns3/ptr.h"
30 #include "ns3/ipv4-address.h"
31 #include "ns3/ipv4-header.h"
32 #include "ns3/ipv4-interface.h"
33 #include "ns3/ipv6-header.h"
34 #include "ns3/ipv6-interface.h"
35 #include "ns3/event-id.h"
36 #include "tcp-tx-buffer.h"
37 #include "tcp-rx-buffer.h"
38 #include "rtt-estimator.h"
39 
40 namespace ns3 {
41 
42 class Ipv4EndPoint;
43 class Ipv6EndPoint;
44 class Node;
45 class Packet;
46 class TcpL4Protocol;
47 class TcpHeader;
48 class TcpCongestionOps;
49 
56 {
57 public:
64  RttHistory (SequenceNumber32 s, uint32_t c, Time t);
69  RttHistory (const RttHistory& h); // Copy constructor
70 public:
72  uint32_t count;
74  bool retx;
75 };
76 
78 typedef std::deque<RttHistory> RttHistory_t;
79 
92 class TcpSocketState : public Object
93 {
94 public:
100  static TypeId GetTypeId (void);
101 
102  TcpSocketState ();
103 
108  TcpSocketState (const TcpSocketState &other);
109 
124  typedef enum
125  {
136  } TcpCongState_t;
137 
145  typedef void (* TcpCongStatesTracedValueCallback)(const TcpCongState_t oldValue,
146  const TcpCongState_t newValue);
147 
152 
153  // Congestion control
156  uint32_t m_initialCWnd;
157  uint32_t m_initialSsThresh;
158 
159  // Segment
160  uint32_t m_segmentSize;
162 
166 
172  uint32_t GetCwndInSegments () const
173  {
174  return m_cWnd / m_segmentSize;
175  }
176 
182  uint32_t GetSsThreshInSegments () const
183  {
184  return m_ssThresh / m_segmentSize;
185  }
186 };
187 
260 class TcpSocketBase : public TcpSocket
261 {
262 public:
268  static TypeId GetTypeId (void);
269 
274  virtual TypeId GetInstanceTypeId () const;
275 
276  friend class TcpGeneralTest;
277 
281  TcpSocketBase (void);
282 
288  TcpSocketBase (const TcpSocketBase& sock);
289  virtual ~TcpSocketBase (void);
290 
291  // Set associated Node, TcpL4Protocol, RttEstimator to this socket
292 
297  virtual void SetNode (Ptr<Node> node);
298 
303  virtual void SetTcp (Ptr<TcpL4Protocol> tcp);
304 
309  virtual void SetRtt (Ptr<RttEstimator> rtt);
310 
315  void SetMinRto (Time minRto);
316 
321  Time GetMinRto (void) const;
322 
327  void SetClockGranularity (Time clockGranularity);
328 
333  Time GetClockGranularity (void) const;
334 
339  Ptr<TcpTxBuffer> GetTxBuffer (void) const;
340 
345  Ptr<TcpRxBuffer> GetRxBuffer (void) const;
346 
351 
356 
361 
366 
371 
377  void UpdateCwnd (uint32_t oldValue, uint32_t newValue);
378 
384  void UpdateSsThresh (uint32_t oldValue, uint32_t newValue);
385 
393 
399  void UpdateHighTxMark (SequenceNumber32 oldValue, SequenceNumber32 newValue);
400 
406  void UpdateNextTxSequence (SequenceNumber32 oldValue, SequenceNumber32 newValue);
407 
414 
415  // Necessary implementations of null functions from ns3::Socket
416  virtual enum SocketErrno GetErrno (void) const; // returns m_errno
417  virtual enum SocketType GetSocketType (void) const; // returns socket type
418  virtual Ptr<Node> GetNode (void) const; // returns m_node
419  virtual int Bind (void); // Bind a socket by setting up endpoint in TcpL4Protocol
420  virtual int Bind6 (void); // Bind a socket by setting up endpoint in TcpL4Protocol
421  virtual int Bind (const Address &address); // ... endpoint of specific addr or port
422  virtual int Connect (const Address &address); // Setup endpoint and call ProcessAction() to connect
423  virtual int Listen (void); // Verify the socket is in a correct state and call ProcessAction() to listen
424  virtual int Close (void); // Close by app: Kill socket upon tx buffer emptied
425  virtual int ShutdownSend (void); // Assert the m_shutdownSend flag to prevent send to network
426  virtual int ShutdownRecv (void); // Assert the m_shutdownRecv flag to prevent forward to app
427  virtual int Send (Ptr<Packet> p, uint32_t flags); // Call by app to send data to network
428  virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address &toAddress); // Same as Send(), toAddress is insignificant
429  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags); // Return a packet to be forwarded to app
430  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress); // ... and write the remote address at fromAddress
431  virtual uint32_t GetTxAvailable (void) const; // Available Tx buffer size
432  virtual uint32_t GetRxAvailable (void) const; // Available-to-read data size, i.e. value of m_rxAvailable
433  virtual int GetSockName (Address &address) const; // Return local addr:port in address
434  virtual int GetPeerName (Address &address) const;
435  virtual void BindToNetDevice (Ptr<NetDevice> netdevice); // NetDevice with my m_endPoint
436 
444  typedef void (* TcpTxRxTracedCallback)(const Ptr<const Packet> packet, const TcpHeader& header,
445  const Ptr<const TcpSocketBase> socket);
446 
447 protected:
448  // Implementing ns3::TcpSocket -- Attribute get/set
449  // inherited, no need to doc
450 
451  virtual void SetSndBufSize (uint32_t size);
452  virtual uint32_t GetSndBufSize (void) const;
453  virtual void SetRcvBufSize (uint32_t size);
454  virtual uint32_t GetRcvBufSize (void) const;
455  virtual void SetSegSize (uint32_t size);
456  virtual uint32_t GetSegSize (void) const;
457  virtual void SetInitialSSThresh (uint32_t threshold);
458  virtual uint32_t GetInitialSSThresh (void) const;
459  virtual void SetInitialCwnd (uint32_t cwnd);
460  virtual uint32_t GetInitialCwnd (void) const;
461  virtual void SetConnTimeout (Time timeout);
462  virtual Time GetConnTimeout (void) const;
463  virtual void SetSynRetries (uint32_t count);
464  virtual uint32_t GetSynRetries (void) const;
465  virtual void SetDataRetries (uint32_t retries);
466  virtual uint32_t GetDataRetries (void) const;
467  virtual void SetDelAckTimeout (Time timeout);
468  virtual Time GetDelAckTimeout (void) const;
469  virtual void SetDelAckMaxCount (uint32_t count);
470  virtual uint32_t GetDelAckMaxCount (void) const;
471  virtual void SetTcpNoDelay (bool noDelay);
472  virtual bool GetTcpNoDelay (void) const;
473  virtual void SetPersistTimeout (Time timeout);
474  virtual Time GetPersistTimeout (void) const;
475  virtual bool SetAllowBroadcast (bool allowBroadcast);
476  virtual bool GetAllowBroadcast (void) const;
477 
478 
479 
480  // Helper functions: Connection set up
481 
487  int SetupCallback (void);
488 
494  int DoConnect (void);
495 
499  void ConnectionSucceeded (void);
500 
506  int SetupEndpoint (void);
507 
513  int SetupEndpoint6 (void);
514 
527  virtual void CompleteFork (Ptr<Packet> p, const TcpHeader& tcpHeader,
528  const Address& fromAddress, const Address& toAddress);
529 
530 
531 
532  // Helper functions: Transfer operation
533 
542  void ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Ptr<Ipv4Interface> incomingInterface);
543 
552  void ForwardUp6 (Ptr<Packet> packet, Ipv6Header header, uint16_t port, Ptr<Ipv6Interface> incomingInterface);
553 
566  virtual void DoForwardUp (Ptr<Packet> packet, const Address &fromAddress,
567  const Address &toAddress);
568 
578  void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo);
579 
589  void ForwardIcmp6 (Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo);
590 
599  bool SendPendingData (bool withAck = false);
600 
610  uint32_t SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck);
611 
617  virtual void SendEmptyPacket (uint8_t flags);
618 
622  void SendRST (void);
623 
631  bool OutOfRange (SequenceNumber32 head, SequenceNumber32 tail) const;
632 
633 
634  // Helper functions: Connection close
635 
641  int DoClose (void);
642 
646  void CloseAndNotify (void);
647 
654  void Destroy (void);
655 
662  void Destroy6 (void);
663 
667  void DeallocateEndPoint (void);
668 
675  void PeerClose (Ptr<Packet> p, const TcpHeader& tcpHeader);
676 
680  void DoPeerClose (void);
681 
685  void CancelAllTimers (void);
686 
690  void TimeWait (void);
691 
692  // State transition functions
693 
702  void ProcessEstablished (Ptr<Packet> packet, const TcpHeader& tcpHeader); // Received a packet upon ESTABLISHED state
703 
712  void ProcessListen (Ptr<Packet> packet, const TcpHeader& tcpHeader,
713  const Address& fromAddress, const Address& toAddress);
714 
721  void ProcessSynSent (Ptr<Packet> packet, const TcpHeader& tcpHeader);
722 
731  void ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
732  const Address& fromAddress, const Address& toAddress);
733 
740  void ProcessWait (Ptr<Packet> packet, const TcpHeader& tcpHeader);
741 
748  void ProcessClosing (Ptr<Packet> packet, const TcpHeader& tcpHeader);
749 
756  void ProcessLastAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
757 
758  // Window management
759 
764  virtual uint32_t UnAckDataCount (void) const;
765 
770  virtual uint32_t BytesInFlight (void);
771 
776  virtual uint32_t Window (void) const;
777 
782  virtual uint32_t AvailableWindow (void) const;
783 
790  virtual uint16_t AdvertisedWindowSize (bool scale = true) const;
791 
804  void UpdateWindowSize (const TcpHeader& header);
805 
806 
807  // Manage data tx/rx
808 
813  virtual Ptr<TcpSocketBase> Fork (void);
814 
820  virtual void ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
821 
827  virtual void ReceivedData (Ptr<Packet> packet, const TcpHeader& tcpHeader);
828 
833  virtual void EstimateRtt (const TcpHeader& tcpHeader);
834 
843  virtual void UpdateRttHistory (const SequenceNumber32 &seq, uint32_t sz,
844  bool isRetransmission);
845 
851  virtual void NewAck (SequenceNumber32 const& seq, bool resetRTO);
852 
856  virtual void ReTxTimeout (void);
857 
861  virtual void Retransmit (void);
862 
866  virtual void DelAckTimeout (void);
867 
871  virtual void LastAckTimeout (void);
872 
876  virtual void PersistTimeout (void);
877 
881  virtual void DoRetransmit (void);
882 
890  virtual void AddOptions (TcpHeader& tcpHeader);
891 
900  void ProcessOptionWScale (const Ptr<const TcpOption> option);
909  void AddOptionWScale (TcpHeader& header);
910 
918  uint8_t CalculateWScale () const;
919 
930  void ProcessOptionTimestamp (const Ptr<const TcpOption> option,
931  const SequenceNumber32 &seq);
940  void AddOptionTimestamp (TcpHeader& header);
941 
951  static uint32_t SafeSubtraction (uint32_t a, uint32_t b);
952 
953 protected:
954  // Counters and events
960  uint32_t m_dupAckCount;
961  uint32_t m_delAckCount;
962  uint32_t m_delAckMaxCount;
963  bool m_noDelay;
964  uint32_t m_synCount;
965  uint32_t m_synRetries;
966  uint32_t m_dataRetrCount;
967  uint32_t m_dataRetries;
976 
977  // Connections to other layers of TCP/IP
984 
986 
987  // Rx and Tx buffer management
990 
991  // State-related attributes
993  mutable enum SocketErrno m_errno;
998  bool m_connected;
999  double m_msl;
1000 
1001  // Window management
1002  uint16_t m_maxWinSize;
1009 
1010  // Options
1012  uint8_t m_rcvWindShift;
1013  uint8_t m_sndWindShift;
1014 
1017 
1019 
1020  // Fast Retransmit and Recovery
1022  uint32_t m_retxThresh;
1024  uint32_t m_retransOut;
1025 
1026  // Transmission Control Block
1029 
1030  // Guesses over the other connection end
1032 
1033  // The following two traces pass a packet with a TCP header
1036 
1039 };
1040 
1049  const TcpSocketState::TcpCongState_t newValue);
1050 
1051 } // namespace ns3
1052 
1053 #endif /* TCP_SOCKET_BASE_H */
TracedCallback< SequenceNumber32, SequenceNumber32 > m_highTxMarkTrace
Callback pointer for high tx mark chaining.
void SetCongestionControlAlgorithm(Ptr< TcpCongestionOps > algo)
Install a congestion control algorithm on this socket.
void PeerClose(Ptr< Packet > p, const TcpHeader &tcpHeader)
Received a FIN from peer, notify rx buffer.
TracedValue< uint32_t > m_bytesInFlight
Bytes in flight.
void(* TcpTxRxTracedCallback)(const Ptr< const Packet > packet, const TcpHeader &header, const Ptr< const TcpSocketBase > socket)
TracedCallback signature for tcp packet transmission or reception events.
bool m_limitedTx
perform limited transmit
void ProcessListen(Ptr< Packet > packet, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Received a packet upon LISTEN state.
virtual void SetInitialCwnd(uint32_t cwnd)
Set the initial Congestion Window.
virtual int Listen(void)
Listen for incoming connections.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Introspection did not find any typical Config paths.
Definition: ipv6-header.h:33
virtual int GetSockName(Address &address) const
Get socket address.
virtual uint32_t Window(void) const
Return the max possible number of unacked bytes.
void ProcessWait(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon CLOSE_WAIT, FIN_WAIT_1, FIN_WAIT_2.
void(* TcpCongStatesTracedValueCallback)(const TcpSocketState::TcpCongState_t oldValue, const TcpSocketState::TcpCongState_t newValue)
TracedValue Callback signature for TcpCongState_t.
Normal state, no dubious events.
uint32_t m_dataRetries
Number of data retransmission attempts.
virtual void SetInitialSSThresh(uint32_t threshold)
Set the initial Slow Start Threshold.
Callback template class.
Definition: callback.h:1176
bool m_noDelay
Set to true to disable Nagle's algorithm.
virtual uint32_t GetSegSize(void) const
Get the segment size.
CWND was reduced, we are fast-retransmitting.
In all the respects it is "Open", but requires a bit more attention.
Time GetClockGranularity(void) const
Get the Clock Granularity (used in RTO calcs).
uint32_t SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, bool withAck)
Extract at most maxSize bytes from the TxBuffer at sequence seq, add the TCP header, and send to TcpL4Protocol.
(abstract) base class of all TcpSockets
Definition: tcp-socket.h:46
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
virtual ~TcpSocketBase(void)
uint32_t m_dataRetrCount
Count of remaining data retransmission attempts.
TracedValue< Time > m_lastRtt
Last RTT sample collected.
uint32_t m_synRetries
Number of connection attempts.
TracedValue< SequenceNumber32 > m_highRxAckMark
Highest ack received.
uint32_t m_initialSsThresh
Initial Slow Start Threshold value.
virtual int ShutdownRecv(void)
TcpSocketBase(void)
Create an unbound TCP socket.
void SetClockGranularity(Time clockGranularity)
Sets the Clock Granularity (used in RTO calcs).
EventId m_retxEvent
Retransmission event.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
Definition: socket.cc:175
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.
virtual void SetPersistTimeout(Time timeout)
Set the timout for persistent connection.
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
virtual bool GetAllowBroadcast(void) const
Query whether broadcast datagram transmissions are allowed.
EventId m_timewaitEvent
TIME_WAIT expiration event: Move this socket to CLOSED state.
static TypeId GetTypeId(void)
Get the type ID.
static const char *const TcpCongStateName[TcpSocketState::CA_LAST_STATE]
Literal names of TCP states for use in log messages.
void ProcessOptionTimestamp(const Ptr< const TcpOption > option, const SequenceNumber32 &seq)
Process the timestamp option from other side.
void UpdateHighTxMark(SequenceNumber32 oldValue, SequenceNumber32 newValue)
Callback function to hook to TcpSocketState high tx mark.
void SendRST(void)
Send reset and tear down this socket.
Ptr< TcpSocketState > m_tcb
Congestion control informations.
bool m_winScalingEnabled
Window Scale option enabled (RFC 7323)
bool m_timestampEnabled
Timestamp option enabled.
uint16_t m_maxWinSize
Maximum window size to advertise.
bool retx
True if this has been retransmitted.
virtual void NewAck(SequenceNumber32 const &seq, bool resetRTO)
Update buffers w.r.t.
uint32_t m_segmentSize
Segment size.
Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback
ICMP callback.
void CancelAllTimers(void)
Cancel all timer when endpoint is deleted.
uint32_t count
Number of bytes sent.
Time m_cnTimeout
Timeout for connection retry.
uint32_t m_initialCWnd
Initial cWnd value.
Data structure that records the congestion state of a connection.
EventId m_lastAckEvent
Last ACK timeout event.
void ConnectionSucceeded(void)
Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received an ACK packet.
ns3::Time timeout
virtual uint32_t GetDataRetries(void) const
Get the number of data transmission retries before giving up.
virtual Time GetPersistTimeout(void) const
Get the timout for persistent connection.
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
void DoPeerClose(void)
FIN is in sequence, notify app and respond with a FIN.
virtual void PersistTimeout(void)
Send 1 byte probe to get an updated window size.
virtual void SetSynRetries(uint32_t count)
Set the number of connection retries before giving up.
Ptr< TcpTxBuffer > GetTxBuffer(void) const
Get a pointer to the Tx buffer.
TracedValue< TcpStates_t > m_state
TCP state.
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.
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:90
void SetMinRto(Time minRto)
Sets the Minimum RTO.
virtual uint32_t GetRcvBufSize(void) const
Get the receive buffer size.
uint32_t m_delAckCount
Delayed ACK counter.
virtual bool GetTcpNoDelay(void) const
Check if Nagle's algorithm is enabled or not.
SequenceNumber32 m_recover
Previous highest Tx seqnum for fast recovery.
void ForwardIcmp6(Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
Called by the L3 protocol when it received an ICMPv6 packet to pass on to TCP.
virtual int Bind(void)
Allocate a local IPv4 endpoint for this socket.
virtual int GetPeerName(Address &address) const
Get the peer address of a connected socket.
virtual void Retransmit(void)
Halving cwnd and call DoRetransmit()
Packet header for IPv4.
Definition: ipv4-header.h:31
virtual void SetDataRetries(uint32_t retries)
Set the number of data transmission retries before giving up.
Ptr< TcpCongestionOps > m_congestionControl
Congestion control.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
void UpdateCwnd(uint32_t oldValue, uint32_t newValue)
Callback function to hook to TcpSocketState congestion window.
virtual void EstimateRtt(const TcpHeader &tcpHeader)
Take into account the packet for RTT estimation.
cWnd was reduced due to some Congestion Notification event.
Time time
Time this one was sent.
virtual void UpdateRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
Update the RTT history, when we send TCP segments.
Ptr< TcpTxBuffer > m_txBuffer
Tx buffer.
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.
virtual uint32_t GetSndBufSize(void) const
Get the send buffer size.
virtual enum SocketType GetSocketType(void) const
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
void UpdateWindowSize(const TcpHeader &header)
Update the receiver window (RWND) based on the value of the window field in the header.
void AddOptionTimestamp(TcpHeader &header)
Add the timestamp option to the header.
SequenceNumber32 m_highTxAck
Highest ack sent.
TracedCallback< uint32_t, uint32_t > m_cWndTrace
Callback pointer for cWnd trace chaining.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void(* TcpCongStatesTracedValueCallback)(const TcpCongState_t oldValue, const TcpCongState_t newValue)
TracedValue Callback signature for TcpCongState_t.
virtual uint32_t GetSynRetries(void) const
Get the number of connection retries before giving up.
bool OutOfRange(SequenceNumber32 head, SequenceNumber32 tail) const
Check if a sequence number range is within the rx window.
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
virtual void SetTcpNoDelay(bool noDelay)
Enable/Disable Nagle's algorithm.
RttHistory(SequenceNumber32 s, uint32_t c, Time t)
Constructor - builds an RttHistory with the given parameters.
void UpdateCongState(TcpSocketState::TcpCongState_t oldValue, TcpSocketState::TcpCongState_t newValue)
Callback function to hook to TcpSocketState congestion state.
std::deque< RttHistory > RttHistory_t
Container for RttHistory objects.
SequenceNumber32 m_lastAckedSeq
Last sequence ACKed.
enum SocketErrno m_errno
Socket error code.
A base class for implementation of a stream socket using TCP.
Ptr< RttEstimator > m_rtt
Round trip time estimator.
bool m_closeNotified
Told app to close socket.
void ProcessSynSent(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon SYN_SENT.
uint32_t GetCwndInSegments() const
Get cwnd in segments rather than bytes.
static uint32_t SafeSubtraction(uint32_t a, uint32_t b)
Performs a safe subtraction between a and b (a-b)
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
int SetupCallback(void)
Common part of the two Bind(), i.e.
virtual void SetTcp(Ptr< TcpL4Protocol > tcp)
Set the associated TCP L4 protocol.
bool m_isFirstPartialAck
First partial ACK during RECOVERY.
Ptr< TcpL4Protocol > m_tcp
the associated TCP L4 protocol
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
void ProcessSynRcvd(Ptr< Packet > packet, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Received a packet upon SYN_RCVD.
virtual int ShutdownSend(void)
uint32_t m_retxThresh
Fast Retransmit threshold.
TcpCongState_t
Definition of the Congestion state machine.
virtual void SetDelAckMaxCount(uint32_t count)
Set the number of packet to fire an ACK before delay timeout.
int DoConnect(void)
Perform the real connection tasks: Send SYN if allowed, RST if invalid.
virtual void CompleteFork(Ptr< Packet > p, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Complete a connection by forking the socket.
virtual void AddOptions(TcpHeader &tcpHeader)
Add options to TcpHeader.
void UpdateNextTxSequence(SequenceNumber32 oldValue, SequenceNumber32 newValue)
Callback function to hook to TcpSocketState next tx sequence.
uint32_t m_dupAckCount
Dupack counter.
Used only in debug messages.
Ptr< Node > m_node
the associated node
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
void TimeWait(void)
Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state.
Header for the Transmission Control Protocol.
Definition: tcp-header.h:44
virtual void SetNode(Ptr< Node > node)
Set the associated node.
virtual uint32_t UnAckDataCount(void) const
Return count of number of unacked bytes.
virtual uint32_t BytesInFlight(void)
Return total bytes in flight.
void Destroy(void)
Kill this socket by zeroing its attributes (IPv4)
static TypeId GetTypeId(void)
Get the type ID.
virtual uint32_t GetInitialSSThresh(void) const
Get the initial Slow Start Threshold.
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
virtual int Close(void)
Close a socket.
virtual void SetRtt(Ptr< RttEstimator > rtt)
Set the associated RTT estimator.
double m_msl
Max segment lifetime.
virtual void ReTxTimeout(void)
Call Retransmit() upon RTO event.
Time m_minRto
minimum value of the Retransmit timeout
virtual void SendEmptyPacket(uint8_t flags)
Send a empty packet that carries a flag, e.g.
Time m_delAckTimeout
Time to delay an ACK.
TracedValue< uint32_t > m_cWnd
Congestion window.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)
Read a single packet from the socket and retrieve the sender address.
virtual void SetSndBufSize(uint32_t size)
Set the send buffer size.
virtual TypeId GetInstanceTypeId() const
Get the instance TypeId.
virtual void SetDelAckTimeout(Time timeout)
Set the time to delay an ACK.
void DeallocateEndPoint(void)
Deallocate m_endPoint and m_endPoint6.
Ptr< TcpRxBuffer > GetRxBuffer(void) const
Get a pointer to the Rx buffer.
Describes an IPv6 address.
Definition: ipv6-address.h:48
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Time GetMinRto(void) const
Get the Minimum RTO.
void ProcessEstablished(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon ESTABLISHED state.
General infrastructure for TCP testing.
void ProcessOptionWScale(const Ptr< const TcpOption > option)
Read and parse the Window scale option.
bool m_connected
Connection established.
uint32_t GetSsThreshInSegments() const
Get slow start thresh in segments rather than bytes.
TracedValue< Time > m_rto
Retransmit timeout.
An identifier for simulation events.
Definition: event-id.h:53
Helper class to store RTT measurements.
uint8_t m_rcvWindShift
Window shift to apply to outgoing segments.
int DoClose(void)
Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state.
SequenceNumber32 seq
First sequence number in packet sent.
CWND was reduced due to RTO timeout or SACK reneging.
RttHistory_t m_history
List of sent packet.
A representation of an internet IPv6 endpoint/connection.
virtual uint32_t GetInitialCwnd(void) const
Get the initial Congestion Window.
uint32_t m_timestampToEcho
Timestamp to echo.
uint32_t m_synCount
Count of remaining connection retries.
TracedValue< SequenceNumber32 > m_highRxMark
Highest seqno received.
virtual enum SocketErrno GetErrno(void) const
Get last error number.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
void ProcessLastAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon LAST_ACK.
void UpdateSsThresh(uint32_t oldValue, uint32_t newValue)
Callback function to hook to TcpSocketState slow start threshold.
virtual void SetSegSize(uint32_t size)
Set the segment size.
void ProcessClosing(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received a packet upon CLOSING.
virtual void ReceivedData(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Recv of a data, put into buffer, call L7 to get it if necessary.
void CloseAndNotify(void)
Peacefully close the socket by notifying the upper layer and deallocate end point.
Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback6
ICMPv6 callback.
A base class which provides memory management and object aggregation.
Definition: object.h:87
tuple address
Definition: first.py:37
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
virtual void SetRcvBufSize(uint32_t size)
Set the receive buffer size.
bool m_shutdownRecv
Receive no longer allowed.
uint32_t m_retransOut
Number of retransmission in this window.
virtual Time GetDelAckTimeout(void) const
Get the time to delay an ACK.
TracedCallback< uint32_t, uint32_t > m_ssThTrace
Callback pointer for ssTh trace chaining.
EventId m_sendPendingDataEvent
micro-delay event to send pending data
virtual void DelAckTimeout(void)
Action upon delay ACK timeout, i.e.
virtual void LastAckTimeout(void)
Timeout at LAST_ACK, close the connection.
uint32_t m_bytesAckedNotProcessed
Bytes acked, but not processed.
virtual int Bind6(void)
Allocate a local IPv6 endpoint for this socket.
TracedCallback< SequenceNumber32, SequenceNumber32 > m_nextTxSequenceTrace
Callback pointer for next tx sequence chaining.
SocketType
Enumeration of the possible socket types.
Definition: socket.h:104
EventId m_delAckEvent
Delayed ACK timeout event.
a unique identifier for an interface.
Definition: type-id.h:58
uint8_t m_sndWindShift
Window shift to apply to incoming segments.
bool m_shutdownSend
Send no longer allowed.
virtual Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
int SetupEndpoint6(void)
Configure the endpoint v6 to a local address.
Time m_clockGranularity
Clock Granularity used in RTO calcs.
bool SendPendingData(bool withAck=false)
Send as much pending data as possible according to the Tx window.
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.
TracedValue< uint32_t > m_rWnd
Receiver window (RCV.WND in RFC793)
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_rxTrace
Trace of received packets.
virtual void DoForwardUp(Ptr< Packet > packet, const Address &fromAddress, const Address &toAddress)
Called by TcpSocketBase::ForwardUp{,6}().
virtual void DoRetransmit(void)
Retransmit the oldest packet.
bool m_closeOnEmpty
Close socket upon tx buffer emptied.
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_txTrace
Trace of transmitted packets.
void AddOptionWScale(TcpHeader &header)
Add the window scale option to the header.
A representation of an internet endpoint/connection.
virtual uint32_t GetDelAckMaxCount(void) const
Get the number of packet to fire an ACK before delay timeout.
virtual void SetConnTimeout(Time timeout)
Set the connection timeout.
EventId m_persistEvent
Persist event: Send 1 byte to probe for a non-zero Rx window.
int SetupEndpoint(void)
Configure the endpoint to a local address.
virtual Time GetConnTimeout(void) const
Get the connection timeout.
TracedCallback< TcpSocketState::TcpCongState_t, TcpSocketState::TcpCongState_t > m_congStateTrace
Callback pointer for congestion state trace chaining.
void Destroy6(void)
Kill this socket by zeroing its attributes (IPv6)
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.
virtual uint32_t AvailableWindow(void) const
Return unfilled portion of window.
Time m_persistTimeout
Time between sending 1-byte probes.
virtual uint32_t GetTxAvailable(void) const
Returns the number of bytes which can be sent in a single call to Send.
virtual uint32_t GetRxAvailable(void) const
Return number of bytes which can be returned from one or multiple calls to Recv.