src/internet/model/tcp-socket.h
author Vedran Miletic <rivanvx@gmail.com>
Thu, 07 Jul 2011 04:31:52 -0400
changeset 7353 09fccf6195ea
parent 7176 9f2663992e99
child 7386 2310ed220a61
permissions -rw-r--r--
bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
/*
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
 * Copyright (c) 2006 Georgia Tech Research Corporation
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
 *               2007 INRIA
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 *
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
 *
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
 * GNU General Public License for more details.
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
 *
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
 *
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
 * Authors: George F. Riley<riley@ece.gatech.edu>
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
 *          Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
 */
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
7353
09fccf6195ea bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents: 7176
diff changeset
    23
#ifndef TCP_SOCKET_H
09fccf6195ea bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents: 7176
diff changeset
    24
#define TCP_SOCKET_H
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
6823
a27f86fb4e55 Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents: 6694
diff changeset
    26
#include "ns3/socket.h"
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
#include "ns3/traced-callback.h"
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
#include "ns3/callback.h"
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
#include "ns3/ptr.h"
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
#include "ns3/object.h"
3136
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    31
#include "ns3/nstime.h"
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
namespace ns3 {
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
class Node;
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
class Packet;
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    38
/* Names of the 11 TCP states */
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    39
typedef enum {
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    40
  CLOSED,       // 0
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    41
  LISTEN,       // 1
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    42
  SYN_SENT,     // 2
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    43
  SYN_RCVD,     // 3
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    44
  ESTABLISHED,  // 4
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    45
  CLOSE_WAIT,   // 5
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    46
  LAST_ACK,     // 6
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    47
  FIN_WAIT_1,   // 7
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    48
  FIN_WAIT_2,   // 8
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    49
  CLOSING,      // 9
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    50
  TIME_WAIT,   // 10
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    51
  LAST_STATE
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    52
} TcpStates_t;
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    53
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    54
/**
3183
fc3b2e03e61e more doxygen
Tom Henderson <tomh@tomh.org>
parents: 3136
diff changeset
    55
 * \ingroup socket
fc3b2e03e61e more doxygen
Tom Henderson <tomh@tomh.org>
parents: 3136
diff changeset
    56
 *
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    57
 * \brief (abstract) base class of all TcpSockets
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    58
 *
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    59
 * This class exists solely for hosting TcpSocket attributes that can
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
 * be reused across different implementations.
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    61
 */
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    62
class TcpSocket : public Socket
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
{
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
public:
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    65
  static TypeId GetTypeId (void);
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
 
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
  TcpSocket (void);
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
  virtual ~TcpSocket (void);
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    70
  // Literal names of TCP states for use in log messages */
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    71
  static const char* const TcpStateName[LAST_STATE];
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    72
3136
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    73
private:
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
  // Indirect the attribute setting and getting through private virtual methods
3136
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    75
  virtual void SetSndBufSize (uint32_t size) = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    76
  virtual uint32_t GetSndBufSize (void) const = 0;
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    77
  virtual void SetRcvBufSize (uint32_t size) = 0;
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    78
  virtual uint32_t GetRcvBufSize (void) const = 0;
3136
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    79
  virtual void SetSegSize (uint32_t size) = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    80
  virtual uint32_t GetSegSize (void) const = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    81
  virtual void SetSSThresh (uint32_t threshold) = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    82
  virtual uint32_t GetSSThresh (void) const = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    83
  virtual void SetInitialCwnd (uint32_t count) = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    84
  virtual uint32_t GetInitialCwnd (void) const = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    85
  virtual void SetConnTimeout (Time timeout) = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    86
  virtual Time GetConnTimeout (void) const = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    87
  virtual void SetConnCount (uint32_t count) = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    88
  virtual uint32_t GetConnCount (void) const = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    89
  virtual void SetDelAckTimeout (Time timeout) = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    90
  virtual Time GetDelAckTimeout (void) const = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    91
  virtual void SetDelAckMaxCount (uint32_t count) = 0;
a59b9ce95b6b Move Tcp attributes from factory to TcpSocket
Tom Henderson <tomh@tomh.org>
parents: 3135
diff changeset
    92
  virtual uint32_t GetDelAckMaxCount (void) const = 0;
6694
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    93
  virtual void SetPersistTimeout (Time timeout) = 0;
a814f37d15bf merge new TCP code
Josh Pelkey <jpelkey@gatech.edu>
parents: 3644
diff changeset
    94
  virtual Time GetPersistTimeout (void) const = 0;
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    95
3135
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
};
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    98
} //namespace ns3
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
#endif /* TCP_SOCKET_H */
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
2ae291cb16ae Add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   102