src/internet-stack/tcp-socket-impl.h
author Raj Bhattacharjea <raj.b@gatech.edu>
Wed, 09 Jul 2008 14:10:18 -0400
changeset 3399 5782cdf815e1
parent 3327 ea16c44eb90d
child 3493 53ec8893863d
permissions -rw-r--r--
Add some additional TCP dox about RFC compliance
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
/*
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
 * Copyright (c) 2007 Georgia Tech Research Corporation
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
 *
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
 *
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
 * GNU General Public License for more details.
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
 *
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
 *
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
 * Author: Raj Bhattacharjea <raj.b@gatech.edu>
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
 */
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
#ifndef TCP_SOCKET_IMPL_H
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
#define TCP_SOCKET_IMPL_H
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
#include <stdint.h>
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
#include <queue>
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
#include "ns3/callback.h"
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
#include "ns3/traced-value.h"
3134
1890d6ee27a1 Add abstract base class TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3131
diff changeset
    27
#include "ns3/tcp-socket.h"
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
#include "ns3/ptr.h"
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
#include "ns3/ipv4-address.h"
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
#include "ns3/event-id.h"
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
#include "tcp-typedefs.h"
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
#include "pending-data.h"
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
#include "sequence-number.h"
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
#include "rtt-estimator.h"
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
namespace ns3 {
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
class Ipv4EndPoint;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
class Node;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
class Packet;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
class TcpL4Protocol;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
class TcpHeader;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
3266
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    45
/**
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    46
 * \ingroup socket
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    47
 *
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    48
 * \brief An implementation of a stream socket using TCP.
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    49
 *
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    50
 * This class contains an implementation of TCP Tahoe, as well as a sockets
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    51
 * interface for talking to TCP.  Features include connection orientation,
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    52
 * reliability through cumulative acknowledgements, congestion and flow 
3399
5782cdf815e1 Add some additional TCP dox about RFC compliance
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3327
diff changeset
    53
 * control.  Finite send buffer semantics are modeled, but as of yet, finite
5782cdf815e1 Add some additional TCP dox about RFC compliance
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3327
diff changeset
    54
 * receive buffer modelling is unimplemented.
5782cdf815e1 Add some additional TCP dox about RFC compliance
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3327
diff changeset
    55
 *
5782cdf815e1 Add some additional TCP dox about RFC compliance
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3327
diff changeset
    56
 * The closedown of these sockets is as of yet not compliant with the relevent
5782cdf815e1 Add some additional TCP dox about RFC compliance
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3327
diff changeset
    57
 * RFCs, i.e. the FIN handshaking isn't correct.  While this is visible at the
5782cdf815e1 Add some additional TCP dox about RFC compliance
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3327
diff changeset
    58
 * PCAP tracing level, it has no effect on the statistics users are interested
5782cdf815e1 Add some additional TCP dox about RFC compliance
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3327
diff changeset
    59
 * in, i.e. throughput, delay, etc. of actual payload data.
3266
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    60
 *
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    61
 * Asynchronous callbacks to provide notifications to higher layers that a 
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    62
 * protocol event has occured, such as space freeing up in the send buffer
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    63
 * or new data arriving in the receive buffer.
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    64
 */
3134
1890d6ee27a1 Add abstract base class TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3131
diff changeset
    65
class TcpSocketImpl : public TcpSocket
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
{
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
public:
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
  static TypeId GetTypeId (void);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
  /**
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
   * Create an unbound tcp socket.
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
   */
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
  TcpSocketImpl ();
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
  TcpSocketImpl (const TcpSocketImpl& sock);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
  virtual ~TcpSocketImpl ();
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    76
  void SetNode (Ptr<Node> node);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    77
  void SetTcp (Ptr<TcpL4Protocol> tcp);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    78
  void SetRtt (Ptr<RttEstimator> rtt);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    79
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    80
  virtual enum SocketErrno GetErrno (void) const;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    81
  virtual Ptr<Node> GetNode (void) const;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    82
  virtual int Bind (void);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    83
  virtual int Bind (const Address &address);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    84
  virtual int Close (void);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    85
  virtual int ShutdownSend (void);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    86
  virtual int ShutdownRecv (void);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    87
  virtual int Connect(const Address &address);
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3252
diff changeset
    88
  virtual int Listen(uint32_t queueLimit);
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    89
  virtual uint32_t GetTxAvailable (void) const;
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3252
diff changeset
    90
  virtual int Send (Ptr<Packet> p, uint32_t flags);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3252
diff changeset
    91
  virtual int SendTo(Ptr<Packet> p, uint32_t flags, const Address &toAddress);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3252
diff changeset
    92
  virtual uint32_t GetRxAvailable (void) const;
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    93
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3252
diff changeset
    94
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3252
diff changeset
    95
    Address &fromAddress);
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
private:
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    98
  friend class Tcp;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
  // invoked by Tcp class
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
  int FinishBind (void);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
  void ForwardUp (Ptr<Packet> p, Ipv4Address ipv4, uint16_t port);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   102
  void Destroy (void);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
  int DoSendTo (Ptr<Packet> p, const Address &daddr);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
  int DoSendTo (Ptr<Packet> p, Ipv4Address daddr, uint16_t dport);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   105
  void SendEmptyPacket(uint8_t flags);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   106
  //methods for state
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   107
  bool ProcessAction (Actions_t a);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   108
  bool ProcessAction (Actions_t a, const TcpHeader& tcpHeader,
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   109
                      Ipv4Address saddr, Ipv4Address daddr);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
  bool ProcessPacketAction (Actions_t a, Ptr<Packet> p,
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   111
                                       const TcpHeader& tcpHeader,
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   112
                                       const Address& fromAddress);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   113
  Actions_t ProcessEvent (Events_t e);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   114
  bool SendPendingData(bool withAck = false);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
  void CompleteFork(Ptr<Packet>, const TcpHeader&, const Address& fromAddress);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
  void ConnectionSucceeded();
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   117
  
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   118
  //methods for window management
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
  virtual uint32_t  UnAckDataCount(); // Return count of number of unacked bytes
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
  virtual uint32_t  BytesInFlight();  // Return total bytes in flight
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   121
  virtual uint32_t  Window();         // Return window size (integer)
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   122
  virtual uint32_t  AvailableWindow();// Return unfilled portion of window
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   123
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   124
  // Manage data tx/rx
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   125
  void NewRx (Ptr<Packet>, const TcpHeader&, const Address&);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   126
  // XXX This should be virtual and overridden
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   127
  Ptr<TcpSocketImpl> Copy ();
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   128
  void NewAck (SequenceNumber seq); 
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   129
  // XXX This should be virtual and overridden
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   130
  void DupAck (const TcpHeader& t, uint32_t count); 
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   131
  void ReTxTimeout ();
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   132
  void DelAckTimeout ();
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   133
  void LastAckTimeout ();
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
  void Retransmit ();
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
  void CommonNewAck (SequenceNumber seq, bool skipTimer = false);
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   136
3136
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   137
  // attribute related
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   138
  virtual void SetSndBufSize (uint32_t size);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   139
  virtual uint32_t GetSndBufSize (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   140
  virtual void SetRcvBufSize (uint32_t size);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   141
  virtual uint32_t GetRcvBufSize (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   142
  virtual void SetSegSize (uint32_t size);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   143
  virtual uint32_t GetSegSize (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   144
  virtual void SetAdvWin (uint32_t window);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   145
  virtual uint32_t GetAdvWin (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   146
  virtual void SetSSThresh (uint32_t threshold);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   147
  virtual uint32_t GetSSThresh (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   148
  virtual void SetInitialCwnd (uint32_t cwnd);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   149
  virtual uint32_t GetInitialCwnd (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   150
  virtual void SetConnTimeout (Time timeout);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   151
  virtual Time GetConnTimeout (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   152
  virtual void SetConnCount (uint32_t count);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   153
  virtual uint32_t GetConnCount (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   154
  virtual void SetDelAckTimeout (Time timeout);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   155
  virtual Time GetDelAckTimeout (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   156
  virtual void SetDelAckMaxCount (uint32_t count);
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   157
  virtual uint32_t GetDelAckMaxCount (void) const;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   158
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   159
  bool m_skipRetxResched;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   160
  uint32_t m_dupAckCount;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   161
  EventId m_retxEvent;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   162
  EventId m_lastAckEvent;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   163
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   164
  EventId m_delAckEvent;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   165
  uint32_t m_delAckCount;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   166
  uint32_t m_delAckMaxCount;
3136
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   167
  Time m_delAckTimeout;
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   168
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   169
  Ipv4EndPoint *m_endPoint;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   170
  Ptr<Node> m_node;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   171
  Ptr<TcpL4Protocol> m_tcp;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   172
  Ipv4Address m_remoteAddress;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   173
  uint16_t m_remotePort;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   174
  //these two are so that the socket/endpoint cloning works
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   175
  Ipv4Address m_localAddress;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   176
  uint16_t m_localPort;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   177
  enum SocketErrno m_errno;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   178
  bool m_shutdownSend;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   179
  bool m_shutdownRecv;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   180
  bool m_connected;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   181
  
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   182
  //manage the state infomation
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   183
  States_t m_state;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   184
  bool m_closeNotified;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   185
  bool m_closeRequestNotified;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   186
  bool m_closeOnEmpty;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   187
  bool m_pendingClose;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   188
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   189
  
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   190
  //sequence info, sender side
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   191
  SequenceNumber m_nextTxSequence;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   192
  SequenceNumber m_highTxMark;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   193
  SequenceNumber m_highestRxAck;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   194
  SequenceNumber m_lastRxAck;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   195
  
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   196
  //sequence info, reciever side
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   197
  SequenceNumber m_nextRxSequence;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   198
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   199
  //history data
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   200
  //this is the incoming data buffer which sorts out of sequence data
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   201
  UnAckData_t m_bufferedData;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   202
  //this is kind of the tx buffer
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   203
  PendingData* m_pendingData;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   204
  SequenceNumber m_firstPendingSequence;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   205
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   206
  // Window management
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   207
  uint32_t                       m_segmentSize;          //SegmentSize
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   208
  uint32_t                       m_rxWindowSize;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   209
  uint32_t                       m_advertisedWindowSize; //Window to advertise
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   210
  TracedValue<uint32_t>          m_cWnd;                 //Congestion window
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   211
  uint32_t                       m_ssThresh;             //Slow Start Threshold
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   212
  uint32_t                       m_initialCWnd;          //Initial cWnd value
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   213
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   214
  // Round trip time estimation
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   215
  Ptr<RttEstimator> m_rtt;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   216
  Time m_lastMeasuredRtt;
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   217
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   218
  // Timer-related members
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   219
  Time              m_cnTimeout; 
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   220
  uint32_t          m_cnCount;
3244
dbf56f98a11d Fix tcp rx buffer semantics; fromaddress tagging is broken at the moment
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3136
diff changeset
   221
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   222
  // Temporary queue for delivering data to application
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   223
  uint32_t m_rxAvailable;
3244
dbf56f98a11d Fix tcp rx buffer semantics; fromaddress tagging is broken at the moment
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3136
diff changeset
   224
3136
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   225
  // Attributes
3252
5c53412347ac Fix compile warning
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3244
diff changeset
   226
  uint32_t m_sndBufSize;   // buffer limit for the outgoing queue
3136
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3134
diff changeset
   227
  uint32_t m_rcvBufSize;   // maximum receive socket buffer size
3131
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   228
};
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   229
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   230
}//namespace ns3
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   231
d82336dfd269 change TcpSocket to TcpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   232
#endif /* TCP_SOCKET_IMPL_H */