src/internet/model/tcp-socket-base.h
author Natale Patriciello <natale.patriciello@gmail.com>
Fri, 05 Sep 2014 16:57:11 -0700
changeset 10885 462d70f54ada
parent 10855 7ef081ddfc7f
child 10986 4d7338f5952d
permissions -rw-r--r--
Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7176
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     2
/*
7608
de67936e4017 Mixed bugfixes on TCP, closes bug 1166, 1227, 1242.
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7385
diff changeset
     3
 * Copyright (c) 2007 Georgia Tech Research Corporation
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     4
 * Copyright (c) 2010 Adrian Sai-wah Tam
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     5
 *
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     9
 *
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    13
 * GNU General Public License for more details.
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    14
 *
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    18
 *
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    19
 * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    20
 */
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    21
#ifndef TCP_SOCKET_BASE_H
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    22
#define TCP_SOCKET_BASE_H
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    23
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    24
#include <stdint.h>
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    25
#include <queue>
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    26
#include "ns3/callback.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    27
#include "ns3/traced-value.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    28
#include "ns3/tcp-socket.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    29
#include "ns3/ptr.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    30
#include "ns3/ipv4-address.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    31
#include "ns3/ipv4-header.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    32
#include "ns3/ipv4-interface.h"
9145
5752b425cdf5 Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 9095
diff changeset
    33
#include "ns3/ipv6-header.h"
10528
c1e835b43726 Bug 1796 - Ipv6PacketInfoTag is not filled by UdpSocketImpl::ForwardUp6.
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10440
diff changeset
    34
#include "ns3/ipv6-interface.h"
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    35
#include "ns3/event-id.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    36
#include "tcp-tx-buffer.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    37
#include "tcp-rx-buffer.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    38
#include "rtt-estimator.h"
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    39
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    40
namespace ns3 {
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    41
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    42
class Ipv4EndPoint;
7717
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7619
diff changeset
    43
class Ipv6EndPoint;
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    44
class Node;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    45
class Packet;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    46
class TcpL4Protocol;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    47
class TcpHeader;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    48
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    49
/**
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    50
 * \ingroup socket
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    51
 * \ingroup tcp
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    52
 *
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    53
 * \brief A base class for implementation of a stream socket using TCP.
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    54
 *
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    55
 * This class contains the essential components of TCP, as well as a sockets
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    56
 * interface for upper layers to call. This serves as a base for other TCP
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    57
 * functions where the sliding window mechanism is handled here. This class
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    58
 * provides connection orientation and sliding window flow control. Part of
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    59
 * this class is modified from the original NS-3 TCP socket implementation
7608
de67936e4017 Mixed bugfixes on TCP, closes bug 1166, 1227, 1242.
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7385
diff changeset
    60
 * (TcpSocketImpl) by Raj Bhattacharjea <raj.b@gatech.edu> of Georgia Tech.
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    61
 */
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    62
class TcpSocketBase : public TcpSocket
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    63
{
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    64
public:
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    65
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    66
   * Get the type ID.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    67
   * \brief Get the type ID.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    68
   * \return the object TypeId
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    69
   */
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    70
  static TypeId GetTypeId (void);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    71
  /**
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    72
   * Create an unbound TCP socket
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    73
   */
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    74
  TcpSocketBase (void);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    75
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    76
  /**
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    77
   * Clone a TCP socket, for use upon receiving a connection request in LISTEN state
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    78
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    79
   * \param sock the original Tcp Socket
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    80
   */
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    81
  TcpSocketBase (const TcpSocketBase& sock);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    82
  virtual ~TcpSocketBase (void);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    83
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    84
  // Set associated Node, TcpL4Protocol, RttEstimator to this socket
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    85
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    86
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    87
   * \brief Set the associated node.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    88
   * \param node the node
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    89
   */
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    90
  virtual void SetNode (Ptr<Node> node);
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    91
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    92
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    93
   * \brief Set the associated TCP L4 protocol.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    94
   * \param tcp the TCP L4 protocol
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    95
   */
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    96
  virtual void SetTcp (Ptr<TcpL4Protocol> tcp);
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    97
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    98
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
    99
   * \brief Set the associated RTT estimator.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   100
   * \param rtt the RTT estimator
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   101
   */
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   102
  virtual void SetRtt (Ptr<RttEstimator> rtt);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   103
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   104
  // Necessary implementations of null functions from ns3::Socket
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   105
  virtual enum SocketErrno GetErrno (void) const;    // returns m_errno
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
   106
  virtual enum SocketType GetSocketType (void) const; // returns socket type
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   107
  virtual Ptr<Node> GetNode (void) const;            // returns m_node
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   108
  virtual int Bind (void);    // Bind a socket by setting up endpoint in TcpL4Protocol
7717
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7619
diff changeset
   109
  virtual int Bind6 (void);    // Bind a socket by setting up endpoint in TcpL4Protocol
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   110
  virtual int Bind (const Address &address);         // ... endpoint of specific addr or port
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   111
  virtual int Connect (const Address &address);      // Setup endpoint and call ProcessAction() to connect
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   112
  virtual int Listen (void);  // Verify the socket is in a correct state and call ProcessAction() to listen
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   113
  virtual int Close (void);   // Close by app: Kill socket upon tx buffer emptied
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   114
  virtual int ShutdownSend (void);    // Assert the m_shutdownSend flag to prevent send to network
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   115
  virtual int ShutdownRecv (void);    // Assert the m_shutdownRecv flag to prevent forward to app
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   116
  virtual int Send (Ptr<Packet> p, uint32_t flags);  // Call by app to send data to network
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   117
  virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address &toAddress); // Same as Send(), toAddress is insignificant
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   118
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags); // Return a packet to be forwarded to app
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   119
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress); // ... and write the remote address at fromAddress
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   120
  virtual uint32_t GetTxAvailable (void) const; // Available Tx buffer size
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   121
  virtual uint32_t GetRxAvailable (void) const; // Available-to-read data size, i.e. value of m_rxAvailable
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   122
  virtual int GetSockName (Address &address) const; // Return local addr:port in address
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   123
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice); // NetDevice with my m_endPoint
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   124
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   125
protected:
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   126
  // Implementing ns3::TcpSocket -- Attribute get/set
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   127
  // inherited, no need to doc
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   128
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   129
  virtual void     SetSndBufSize (uint32_t size);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   130
  virtual uint32_t GetSndBufSize (void) const;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   131
  virtual void     SetRcvBufSize (uint32_t size);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   132
  virtual uint32_t GetRcvBufSize (void) const;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   133
  virtual void     SetSegSize (uint32_t size);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   134
  virtual uint32_t GetSegSize (void) const;
10855
7ef081ddfc7f Bug 1831 - TcpSocket SlowStartThreshold is not a TraceSource
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10791
diff changeset
   135
  virtual void     SetInitialSSThresh (uint32_t threshold) = 0;
7ef081ddfc7f Bug 1831 - TcpSocket SlowStartThreshold is not a TraceSource
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10791
diff changeset
   136
  virtual uint32_t GetInitialSSThresh (void) const = 0;
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   137
  virtual void     SetInitialCwnd (uint32_t cwnd) = 0;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   138
  virtual uint32_t GetInitialCwnd (void) const = 0;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   139
  virtual void     SetConnTimeout (Time timeout);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   140
  virtual Time     GetConnTimeout (void) const;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   141
  virtual void     SetConnCount (uint32_t count);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   142
  virtual uint32_t GetConnCount (void) const;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   143
  virtual void     SetDelAckTimeout (Time timeout);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   144
  virtual Time     GetDelAckTimeout (void) const;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   145
  virtual void     SetDelAckMaxCount (uint32_t count);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   146
  virtual uint32_t GetDelAckMaxCount (void) const;
7619
b4dee6307aa7 Nagle's algorithm in TCP (closes bug 1039)
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7608
diff changeset
   147
  virtual void     SetTcpNoDelay (bool noDelay);
b4dee6307aa7 Nagle's algorithm in TCP (closes bug 1039)
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7608
diff changeset
   148
  virtual bool     GetTcpNoDelay (void) const;
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   149
  virtual void     SetPersistTimeout (Time timeout);
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   150
  virtual Time     GetPersistTimeout (void) const;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   151
  virtual bool     SetAllowBroadcast (bool allowBroadcast);
7608
de67936e4017 Mixed bugfixes on TCP, closes bug 1166, 1227, 1242.
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7385
diff changeset
   152
  virtual bool     GetAllowBroadcast (void) const;
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   153
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   154
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   155
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   156
  // Helper functions: Connection set up
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   157
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   158
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   159
   * \brief Common part of the two Bind(), i.e. set callback and remembering local addr:port
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   160
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   161
   * \returns 0 on success, -1 on failure
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   162
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   163
  int SetupCallback (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   164
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   165
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   166
   * \brief Perform the real connection tasks: Send SYN if allowed, RST if invalid
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   167
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   168
   * \returns 0 on success
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   169
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   170
  int DoConnect (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   171
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   172
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   173
   * \brief Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   174
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   175
  void ConnectionSucceeded (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   176
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   177
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   178
   * \brief Configure the endpoint to a local address. Called by Connect() if Bind() didn't specify one.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   179
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   180
   * \returns 0 on success
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   181
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   182
  int SetupEndpoint (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   183
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   184
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   185
   * \brief Configure the endpoint v6 to a local address. Called by Connect() if Bind() didn't specify one.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   186
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   187
   * \returns 0 on success
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   188
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   189
  int SetupEndpoint6 (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   190
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   191
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   192
   * \brief Complete a connection by forking the socket
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   193
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   194
   * This function is called only if a SYN received in LISTEN state. After
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   195
   * TcpSocketBase cloned, allocate a new end point to handle the incoming
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   196
   * connection and send a SYN+ACK to complete the handshake.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   197
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   198
   * \param p the packet triggering the fork
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   199
   * \param tcpHeader the TCP header of the triggering packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   200
   * \param fromAddress the address of the remote host
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   201
   * \param toAddress the address the connection is directed to
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   202
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   203
  void CompleteFork (Ptr<Packet> p, const TcpHeader& tcpHeader, const Address& fromAddress, const Address& toAddress);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   204
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   205
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   206
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   207
  // Helper functions: Transfer operation
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   208
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   209
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   210
   * \brief Called by the L3 protocol when it received a packet to pass on to TCP.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   211
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   212
   * \param packet the incoming packet
10440
1e48ff9185f1 Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10405
diff changeset
   213
   * \param header the packet's IPv4 header
10791
9b29bb9d495b Clarify doxygen for [Tcp,Udp]Socket ForwardUp functions
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10575
diff changeset
   214
   * \param port the remote port
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   215
   * \param incomingInterface the incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   216
   */
7608
de67936e4017 Mixed bugfixes on TCP, closes bug 1166, 1227, 1242.
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7385
diff changeset
   217
  void ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Ptr<Ipv4Interface> incomingInterface);
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   218
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   219
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   220
   * \brief Called by the L3 protocol when it received a packet to pass on to TCP.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   221
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   222
   * \param packet the incoming packet
10440
1e48ff9185f1 Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10405
diff changeset
   223
   * \param header the packet's IPv6 header
10791
9b29bb9d495b Clarify doxygen for [Tcp,Udp]Socket ForwardUp functions
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10575
diff changeset
   224
   * \param port the remote port
10528
c1e835b43726 Bug 1796 - Ipv6PacketInfoTag is not filled by UdpSocketImpl::ForwardUp6.
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10440
diff changeset
   225
   * \param incomingInterface the incoming interface
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   226
   */
10528
c1e835b43726 Bug 1796 - Ipv6PacketInfoTag is not filled by UdpSocketImpl::ForwardUp6.
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10440
diff changeset
   227
  void ForwardUp6 (Ptr<Packet> packet, Ipv6Header header, uint16_t port, Ptr<Ipv6Interface> incomingInterface);
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   228
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   229
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   230
   * \brief Called by TcpSocketBase::ForwardUp().
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   231
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   232
   * \param packet the incoming packet
10440
1e48ff9185f1 Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10405
diff changeset
   233
   * \param header the packet's IPv4 header
10791
9b29bb9d495b Clarify doxygen for [Tcp,Udp]Socket ForwardUp functions
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10575
diff changeset
   234
   * \param port the remote port
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   235
   * \param incomingInterface the incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   236
   */
7608
de67936e4017 Mixed bugfixes on TCP, closes bug 1166, 1227, 1242.
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7385
diff changeset
   237
  virtual void DoForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Ptr<Ipv4Interface> incomingInterface); //Get a pkt from L3
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   238
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   239
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   240
   * \brief Called by TcpSocketBase::ForwardUp6().
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   241
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   242
   * \param packet the incoming packet
10440
1e48ff9185f1 Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10405
diff changeset
   243
   * \param header the packet's IPv6 header
10791
9b29bb9d495b Clarify doxygen for [Tcp,Udp]Socket ForwardUp functions
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10575
diff changeset
   244
   * \param port the remote port
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   245
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   246
  virtual void DoForwardUp (Ptr<Packet> packet, Ipv6Header header, uint16_t port);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   247
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   248
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   249
   * \brief Called by the L3 protocol when it received an ICMP packet to pass on to TCP.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   250
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   251
   * \param icmpSource the ICMP source address
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   252
   * \param icmpTtl the ICMP Time to Live
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   253
   * \param icmpType the ICMP Type
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   254
   * \param icmpCode the ICMP Code
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   255
   * \param icmpInfo the ICMP Info
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   256
   */
9095
8462a1160246 bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7747
diff changeset
   257
  void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo);
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   258
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   259
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   260
   * \brief Called by the L3 protocol when it received an ICMPv6 packet to pass on to TCP.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   261
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   262
   * \param icmpSource the ICMP source address
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   263
   * \param icmpTtl the ICMP Time to Live
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   264
   * \param icmpType the ICMP Type
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   265
   * \param icmpCode the ICMP Code
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   266
   * \param icmpInfo the ICMP Info
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   267
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   268
  void ForwardIcmp6 (Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   269
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   270
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   271
   * \brief Send as much pending data as possible according to the Tx window.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   272
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   273
   * Note that this function did not implement the PSH flag.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   274
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   275
   * \param withAck forces an ACK to be sent
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   276
   * \returns true if some data have been sent
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   277
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   278
  bool SendPendingData (bool withAck = false);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   279
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   280
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   281
   * \brief Extract at most maxSize bytes from the TxBuffer at sequence seq, add the
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   282
   *        TCP header, and send to TcpL4Protocol
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   283
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   284
   * \param seq the sequence number
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   285
   * \param maxSize the maximum data block to be transmitted (in bytes)
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   286
   * \param withAck forces an ACK to be sent
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   287
   * \returns the number of bytes sent
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   288
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   289
  uint32_t SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   290
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   291
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   292
   * \brief Send a empty packet that carries a flag, e.g. ACK
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   293
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   294
   * \param flags the packet's flags
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   295
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   296
  void SendEmptyPacket (uint8_t flags);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   297
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   298
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   299
   * \brief Send reset and tear down this socket
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   300
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   301
  void SendRST (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   302
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   303
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   304
   * \brief Check if a sequence number range is within the rx window
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   305
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   306
   * \param head start of the Sequence window
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   307
   * \param tail end of the Sequence window
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   308
   * \returns true if it is in range
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   309
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   310
  bool OutOfRange (SequenceNumber32 head, SequenceNumber32 tail) const;
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   311
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   312
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   313
  // Helper functions: Connection close
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   314
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   315
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   316
   * \brief Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   317
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   318
   * \returns 0 on success
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   319
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   320
  int DoClose (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   321
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   322
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   323
   * \brief Peacefully close the socket by notifying the upper layer and deallocate end point
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   324
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   325
  void CloseAndNotify (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   326
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   327
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   328
   * \brief Kill this socket by zeroing its attributes (IPv4)
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   329
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   330
   * This is a callback function configured to m_endpoint in
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   331
   * SetupCallback(), invoked when the endpoint is destroyed.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   332
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   333
  void Destroy (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   334
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   335
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   336
   * \brief Kill this socket by zeroing its attributes (IPv6)
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   337
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   338
   * This is a callback function configured to m_endpoint in
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   339
   * SetupCallback(), invoked when the endpoint is destroyed.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   340
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   341
  void Destroy6 (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   342
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   343
  /**
10575
16f8ac386faf Bug 1739 - The endpoint is not deallocated for UDP sockets
Juan C. Granda <jcgranda@uniovi.es>
parents: 10528
diff changeset
   344
   * \brief Deallocate m_endPoint and m_endPoint6
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   345
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   346
  void DeallocateEndPoint (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   347
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   348
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   349
   * \brief Received a FIN from peer, notify rx buffer
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   350
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   351
   * \param p the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   352
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   353
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   354
  void PeerClose (Ptr<Packet> p, const TcpHeader& tcpHeader);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   355
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   356
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   357
   * \brief FIN is in sequence, notify app and respond with a FIN
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   358
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   359
  void DoPeerClose (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   360
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   361
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   362
   * \brief Cancel all timer when endpoint is deleted
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   363
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   364
  void CancelAllTimers (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   365
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   366
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   367
   * \brief Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   368
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   369
  void TimeWait (void);
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   370
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   371
  // State transition functions
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   372
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   373
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   374
   * \brief Received a packet upon ESTABLISHED state.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   375
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   376
   * This function is mimicking the role of tcp_rcv_established() in tcp_input.c in Linux kernel.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   377
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   378
   * \param packet the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   379
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   380
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   381
  void ProcessEstablished (Ptr<Packet> packet, const TcpHeader& tcpHeader); // Received a packet upon ESTABLISHED state
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   382
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   383
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   384
   * \brief Received a packet upon LISTEN state.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   385
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   386
   * \param packet the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   387
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   388
   * \param fromAddress the source address
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   389
   * \param toAddress the destination address
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   390
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   391
  void ProcessListen (Ptr<Packet> packet, const TcpHeader& tcpHeader,
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   392
                      const Address& fromAddress, const Address& toAddress);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   393
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   394
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   395
   * \brief Received a packet upon SYN_SENT
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   396
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   397
   * \param packet the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   398
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   399
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   400
  void ProcessSynSent (Ptr<Packet> packet, const TcpHeader& tcpHeader);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   401
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   402
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   403
   * \brief Received a packet upon SYN_RCVD.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   404
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   405
   * \param packet the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   406
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   407
   * \param fromAddress the source address
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   408
   * \param toAddress the destination address
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   409
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   410
  void ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   411
                       const Address& fromAddress, const Address& toAddress);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   412
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   413
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   414
   * \brief Received a packet upon CLOSE_WAIT, FIN_WAIT_1, FIN_WAIT_2
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   415
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   416
   * \param packet the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   417
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   418
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   419
  void ProcessWait (Ptr<Packet> packet, const TcpHeader& tcpHeader);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   420
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   421
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   422
   * \brief Received a packet upon CLOSING
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   423
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   424
   * \param packet the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   425
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   426
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   427
  void ProcessClosing (Ptr<Packet> packet, const TcpHeader& tcpHeader);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   428
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   429
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   430
   * \brief Received a packet upon LAST_ACK
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   431
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   432
   * \param packet the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   433
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   434
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   435
  void ProcessLastAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   436
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   437
  // Window management
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   438
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   439
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   440
   * \brief Return count of number of unacked bytes
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   441
   * \returns count of number of unacked bytes
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   442
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   443
  virtual uint32_t UnAckDataCount (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   444
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   445
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   446
   * \brief Return total bytes in flight
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   447
   * \returns total bytes in flight
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   448
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   449
  virtual uint32_t BytesInFlight (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   450
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   451
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   452
   * \brief Return the max possible number of unacked bytes
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   453
   * \returns the max possible number of unacked bytes
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   454
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   455
  virtual uint32_t Window (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   456
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   457
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   458
   * \brief Return unfilled portion of window
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   459
   * \return unfilled portion of window
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   460
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   461
  virtual uint32_t AvailableWindow (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   462
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   463
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   464
   * \brief The amount of Rx window announced to the peer
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   465
   * \returns size of Rx window announced to the peer
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   466
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   467
  virtual uint16_t AdvertisedWindowSize (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   468
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   469
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   470
  // Manage data tx/rx
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   471
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   472
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   473
   * \brief Call CopyObject<> to clone me
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   474
   * \returns a copy of the socket
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   475
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   476
  virtual Ptr<TcpSocketBase> Fork (void) = 0;
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   477
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   478
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   479
   * \brief Received an ACK packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   480
   * \param packet the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   481
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   482
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   483
  virtual void ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   484
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   485
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   486
   * \brief Recv of a data, put into buffer, call L7 to get it if necessary
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   487
   * \param packet the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   488
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   489
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   490
  virtual void ReceivedData (Ptr<Packet> packet, const TcpHeader& tcpHeader);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   491
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   492
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   493
   * \brief Take into account the packet for RTT estimation
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   494
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   495
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   496
  virtual void EstimateRtt (const TcpHeader& tcpHeader);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   497
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   498
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   499
   * \brief Update buffers w.r.t. ACK
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   500
   * \param seq the sequence number
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   501
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   502
  virtual void NewAck (SequenceNumber32 const& seq);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   503
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   504
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   505
   * \brief Received dupack (duplicate ACK)
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   506
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   507
   * \param count counter of duplicate ACKs
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   508
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   509
  virtual void DupAck (const TcpHeader& tcpHeader, uint32_t count) = 0;
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   510
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   511
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   512
   * \brief Call Retransmit() upon RTO event
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   513
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   514
  virtual void ReTxTimeout (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   515
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   516
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   517
   * \brief Halving cwnd and call DoRetransmit()
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   518
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   519
  virtual void Retransmit (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   520
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   521
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   522
   * \brief Action upon delay ACK timeout, i.e. send an ACK
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   523
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   524
  virtual void DelAckTimeout (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   525
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   526
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   527
   * \brief Timeout at LAST_ACK, close the connection
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   528
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   529
  virtual void LastAckTimeout (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   530
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   531
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   532
   * \brief Send 1 byte probe to get an updated window size
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   533
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   534
  virtual void PersistTimeout (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   535
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   536
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   537
   * \brief Retransmit the oldest packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   538
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   539
  virtual void DoRetransmit (void);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   540
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   541
  /**
10885
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   542
   * \brief Read TCP options from incoming packets
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   543
   *  
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   544
   * This method sequentially checks each kind of option, and if it
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   545
   * is present in the header, starts its processing.
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   546
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   547
   * To deal with hosts which don't have the option enabled (or
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   548
   * implemented) we disable all options, and then re-enable them
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   549
   * if in the packet there is the option itself.
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   550
   *
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   551
   * \param tcpHeader the packet's TCP header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   552
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   553
  virtual void ReadOptions (const TcpHeader& tcpHeader);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   554
10885
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   555
  /** \brief Add options to TcpHeader
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   556
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   557
   * Test each option, and if it is enabled on our side, add it
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   558
   * to the header
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   559
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   560
   * \param tcpHeader TcpHeader to add options to
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   561
   */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   562
  virtual void AddOptions (TcpHeader& tcpHeader);
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   563
10885
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   564
  /**
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   565
   * \brief Read and parse the Window scale option
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   566
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   567
   * Read the window scale option (encoded logarithmically) and save it.
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   568
   * Per RFC 1323, the value can't exceed 14.
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   569
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   570
   * \param option Window scale option read from the header
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   571
   */
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   572
  void ProcessOptionWScale (const Ptr<const TcpOption> option);
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   573
  /**
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   574
   * \brief Add the window scale option to the header
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   575
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   576
   * Calculate our factor from the rxBuffer max size, and add it
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   577
   * to the header.
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   578
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   579
   * \param header TcpHeader where the method should add the window scale option
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   580
   */
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   581
  void AddOptionWScale (TcpHeader& header);
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   582
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   583
  /**
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   584
   * \brief Calculate window scale value based on receive buffer space
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   585
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   586
   * Calculate our factor from the rxBuffer max size
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   587
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   588
   * \param header TcpHeader where the method should add the window scale option
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   589
   */
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   590
  uint8_t CalculateWScale () const;
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   591
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   592
  /** \brief Process the timestamp option from other side
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   593
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   594
   * Get the timestamp and the echo, then save timestamp (which will
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   595
   * be the echo value in our out-packets) and save the echoed timestamp,
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   596
   * to utilize later to calculate RTT.
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   597
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   598
   * \see EstimateRtt
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   599
   * \param option Option from the packet
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   600
   */
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   601
  void ProcessOptionTimestamp (const Ptr<const TcpOption> option);
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   602
  /**
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   603
   * \brief Add the timestamp option to the header
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   604
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   605
   * Set the timestamp as the lower bits of the Simulator::Now time,
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   606
   * and the echo value as the last seen timestamp from the other part.
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   607
   *
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   608
   * \param header TcpHeader to which add the option to
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   609
   */
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   610
  void AddOptionTimestamp (TcpHeader& header);
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   611
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   612
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   613
protected:
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   614
  // Counters and events
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   615
  EventId           m_retxEvent;       //!< Retransmission event
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   616
  EventId           m_lastAckEvent;    //!< Last ACK timeout event
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   617
  EventId           m_delAckEvent;     //!< Delayed ACK timeout event
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   618
  EventId           m_persistEvent;    //!< Persist event: Send 1 byte to probe for a non-zero Rx window
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   619
  EventId           m_timewaitEvent;   //!< TIME_WAIT expiration event: Move this socket to CLOSED state
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   620
  uint32_t          m_dupAckCount;     //!< Dupack counter
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   621
  uint32_t          m_delAckCount;     //!< Delayed ACK counter
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   622
  uint32_t          m_delAckMaxCount;  //!< Number of packet to fire an ACK before delay timeout
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   623
  bool              m_noDelay;         //!< Set to true to disable Nagle's algorithm
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   624
  uint32_t          m_cnCount;         //!< Count of remaining connection retries
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   625
  uint32_t          m_cnRetries;       //!< Number of connection retries before giving up
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   626
  TracedValue<Time> m_rto;             //!< Retransmit timeout
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   627
  TracedValue<Time> m_lastRtt;         //!< Last RTT sample collected
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   628
  Time              m_delAckTimeout;   //!< Time to delay an ACK
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   629
  Time              m_persistTimeout;  //!< Time between sending 1-byte probes
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   630
  Time              m_cnTimeout;       //!< Timeout for connection retry
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   631
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   632
  // Connections to other layers of TCP/IP
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   633
  Ipv4EndPoint*       m_endPoint;   //!< the IPv4 endpoint
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   634
  Ipv6EndPoint*       m_endPoint6;  //!< the IPv6 endpoint
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   635
  Ptr<Node>           m_node;       //!< the associated node
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   636
  Ptr<TcpL4Protocol>  m_tcp;        //!< the associated TCP L4 protocol
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   637
  Callback<void, Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback;  //!< ICMP callback
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   638
  Callback<void, Ipv6Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback6; //!< ICMPv6 callback
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   639
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   640
  Ptr<RttEstimator> m_rtt; //!< Round trip time estimator
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   641
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   642
  // Rx and Tx buffer management
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   643
  TracedValue<SequenceNumber32> m_nextTxSequence; //!< Next seqnum to be sent (SND.NXT), ReTx pushes it back
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   644
  TracedValue<SequenceNumber32> m_highTxMark;     //!< Highest seqno ever sent, regardless of ReTx
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   645
  TcpRxBuffer                   m_rxBuffer;       //!< Rx buffer (reordering buffer)
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   646
  TcpTxBuffer                   m_txBuffer;       //!< Tx buffer
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   647
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   648
  // State-related attributes
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   649
  TracedValue<TcpStates_t> m_state;         //!< TCP state
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   650
  enum SocketErrno         m_errno;         //!< Socket error code
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   651
  bool                     m_closeNotified; //!< Told app to close socket
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   652
  bool                     m_closeOnEmpty;  //!< Close socket upon tx buffer emptied
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   653
  bool                     m_shutdownSend;  //!< Send no longer allowed
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   654
  bool                     m_shutdownRecv;  //!< Receive no longer allowed
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   655
  bool                     m_connected;     //!< Connection established
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   656
  double                   m_msl;           //!< Max segment lifetime
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   657
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   658
  // Window management
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   659
  uint32_t              m_segmentSize; //!< Segment size
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   660
  uint16_t              m_maxWinSize;  //!< Maximum window size to advertise
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9145
diff changeset
   661
  TracedValue<uint32_t> m_rWnd;        //!< Flow control window at remote side
10885
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   662
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   663
  // Options
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   664
  bool    m_winScalingEnabled;
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   665
  uint8_t m_sndScaleFactor;
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   666
  uint8_t m_rcvScaleFactor;
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   667
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   668
  bool     m_timestampEnabled;
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   669
  uint32_t m_timestampToEcho;
462d70f54ada Support for basic TCP options, window scale, and timestamps, based on original code proposal by Adrian S.-W. Tam
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10855
diff changeset
   670
  uint32_t m_lastEchoedTime;
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   671
};
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   672
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   673
} // namespace ns3
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   674
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   675
#endif /* TCP_SOCKET_BASE_H */