src/internet/model/tcp-header.h
author Tommaso Pecorella <tommaso.pecorella@unifi.it>
Thu, 14 Nov 2013 22:43:53 +0100
changeset 10405 45c8fceae24e
parent 10218 97da49da2d6c
child 10440 1e48ff9185f1
permissions -rw-r--r--
Doxygen fixes to Topology-read, Ipv6, and tcp-socket
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; -*- */
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     2
/*
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     3
 * Copyright (c) 2007 Georgia Tech Research Corporation
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     4
 *
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     8
 *
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    13
 *
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    17
 *
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    18
 * Author: Raj Bhattacharjea <raj.b@gatech.edu>
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    19
 */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    20
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    21
#ifndef TCP_HEADER_H
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    22
#define TCP_HEADER_H
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    23
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    24
#include <stdint.h>
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    25
#include "ns3/header.h"
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    26
#include "ns3/buffer.h"
3132
b0b0abb911cd move Tcp to TcpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2646
diff changeset
    27
#include "ns3/tcp-socket-factory.h"
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    28
#include "ns3/ipv4-address.h"
7717
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7608
diff changeset
    29
#include "ns3/ipv6-address.h"
2321
f1a18a24d318 Make sequence-number.h a public header file (because it is included by another public header, tcp-header.h)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2224
diff changeset
    30
#include "ns3/sequence-number.h"
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    31
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    32
namespace ns3 {
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    33
3266
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    34
/**
3691
372f4475dc47 Doxygen for internet-stack
Tom Henderson <tomh@tomh.org>
parents: 3404
diff changeset
    35
 * \ingroup tcp
3266
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    36
 * \brief Header for the Transmission Control Protocol
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    37
 *
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    38
 * This class has fields corresponding to those in a network TCP header
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    39
 * (port numbers, sequence and acknowledgement numbers, flags, etc) as well
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    40
 * as methods for serialization to and deserialization from a byte buffer.
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    41
 */
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    42
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2321
diff changeset
    43
class TcpHeader : public Header 
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2321
diff changeset
    44
{
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    45
public:
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    46
  TcpHeader ();
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    47
  virtual ~TcpHeader ();
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    48
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    49
  /**
9894
ac4e52a91d5d Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7717
diff changeset
    50
   * \brief Enable checksum calculation for TCP
ac4e52a91d5d Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7717
diff changeset
    51
   *
ac4e52a91d5d Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7717
diff changeset
    52
   * \todo currently has no effect
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    53
   */
3363
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
    54
  void EnableChecksums (void);
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    55
//Setters
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    56
/**
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    57
 * \param port The source port for this TcpHeader
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    58
 */
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    59
  void SetSourcePort (uint16_t port);
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    60
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    61
   * \param port the destination port for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    62
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    63
  void SetDestinationPort (uint16_t port);
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    64
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    65
   * \param sequenceNumber the sequence number for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    66
   */
6434
ac8b4bf77e50 Bug 385 - Add a generic "sequence number" class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3691
diff changeset
    67
  void SetSequenceNumber (SequenceNumber32 sequenceNumber);
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    68
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    69
   * \param ackNumber the ACK number for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    70
   */
6434
ac8b4bf77e50 Bug 385 - Add a generic "sequence number" class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3691
diff changeset
    71
  void SetAckNumber (SequenceNumber32 ackNumber);
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    72
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    73
   * \param length the length of this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    74
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    75
  void SetLength (uint8_t length);
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    76
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    77
   * \param flags the flags for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    78
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    79
  void SetFlags (uint8_t flags);
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    80
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    81
   * \param windowSize the window size for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    82
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    83
  void SetWindowSize (uint16_t windowSize);
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    84
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    85
   * \param urgentPointer the urgent pointer for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    86
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    87
  void SetUrgentPointer (uint16_t urgentPointer);
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    88
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    89
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    90
//Getters
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    91
/**
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    92
 * \return The source port for this TcpHeader
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    93
 */
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    94
  uint16_t GetSourcePort () const;
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    95
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    96
   * \return the destination port for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    97
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    98
  uint16_t GetDestinationPort () const;
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    99
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   100
   * \return the sequence number for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   101
   */
6434
ac8b4bf77e50 Bug 385 - Add a generic "sequence number" class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3691
diff changeset
   102
  SequenceNumber32 GetSequenceNumber () const;
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   103
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   104
   * \return the ACK number for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   105
   */
6434
ac8b4bf77e50 Bug 385 - Add a generic "sequence number" class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3691
diff changeset
   106
  SequenceNumber32 GetAckNumber () const;
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   107
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   108
   * \return the length of this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   109
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   110
  uint8_t  GetLength () const;
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   111
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   112
   * \return the flags for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   113
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   114
  uint8_t  GetFlags () const;
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   115
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   116
   * \return the window size for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   117
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   118
  uint16_t GetWindowSize () const;
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   119
  /**
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   120
   * \return the urgent pointer for this TcpHeader
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   121
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   122
  uint16_t GetUrgentPointer () const;
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   123
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   124
  /**
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   125
   * \brief Initialize the TCP checksum.
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   126
   *
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   127
   * If you want to use tcp checksums, you should call this
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   128
   * method prior to adding the header to a packet.
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   129
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   130
   * \param source the IP source to use in the underlying
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   131
   *        IP packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   132
   * \param destination the IP destination to use in the
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   133
   *        underlying IP packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   134
   * \param protocol the protocol number to use in the underlying
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   135
   *        IP packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   136
   *
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   137
   */
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   138
  void InitializeChecksum (Ipv4Address source, 
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   139
                           Ipv4Address destination,
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   140
                           uint8_t protocol);
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   141
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   142
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   143
   * \brief Initialize the TCP checksum.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   144
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   145
   * If you want to use tcp checksums, you should call this
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   146
   * method prior to adding the header to a packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   147
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   148
   * \param source the IP source to use in the underlying
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   149
   *        IP packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   150
   * \param destination the IP destination to use in the
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   151
   *        underlying IP packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   152
   * \param protocol the protocol number to use in the underlying
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   153
   *        IP packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   154
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   155
   */
7717
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7608
diff changeset
   156
  void InitializeChecksum (Ipv6Address source, 
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7608
diff changeset
   157
                           Ipv6Address destination,
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7608
diff changeset
   158
                           uint8_t protocol);
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   159
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   160
  /**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   161
   * \brief Initialize the TCP checksum.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   162
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   163
   * If you want to use tcp checksums, you should call this
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   164
   * method prior to adding the header to a packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   165
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   166
   * \param source the IP source to use in the underlying
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   167
   *        IP packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   168
   * \param destination the IP destination to use in the
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   169
   *        underlying IP packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   170
   * \param protocol the protocol number to use in the underlying
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   171
   *        IP packet.
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   172
   *
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10218
diff changeset
   173
   */
7717
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7608
diff changeset
   174
  void InitializeChecksum (Address source, 
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7608
diff changeset
   175
                           Address destination,
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7608
diff changeset
   176
                           uint8_t protocol);
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   177
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   178
  typedef enum { NONE = 0, FIN = 1, SYN = 2, RST = 4, PSH = 8, ACK = 16, 
7608
de67936e4017 Mixed bugfixes on TCP, closes bug 1166, 1227, 1242.
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7386
diff changeset
   179
                 URG = 32, ECE = 64, CWR = 128} Flags_t;
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   180
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   181
  static TypeId GetTypeId (void);
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   182
  virtual TypeId GetInstanceTypeId (void) const;
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   183
  virtual void Print (std::ostream &os) const;
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2321
diff changeset
   184
  virtual uint32_t GetSerializedSize (void) const;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2321
diff changeset
   185
  virtual void Serialize (Buffer::Iterator start) const;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2321
diff changeset
   186
  virtual uint32_t Deserialize (Buffer::Iterator start);
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   187
3363
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
   188
  /**
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
   189
   * \brief Is the TCP checksum correct ?
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
   190
   * \returns true if the checksum is correct, false otherwise.
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
   191
   */
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
   192
  bool IsChecksumOk (void) const;
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
   193
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   194
private:
3404
b5d4a04c7b68 bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3363
diff changeset
   195
  uint16_t CalculateHeaderChecksum (uint16_t size) const;
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   196
  uint16_t m_sourcePort;
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   197
  uint16_t m_destinationPort;
6434
ac8b4bf77e50 Bug 385 - Add a generic "sequence number" class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3691
diff changeset
   198
  SequenceNumber32 m_sequenceNumber;
ac8b4bf77e50 Bug 385 - Add a generic "sequence number" class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3691
diff changeset
   199
  SequenceNumber32 m_ackNumber;
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   200
  uint8_t m_length; // really a uint4_t
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   201
  uint8_t m_flags;      // really a uint6_t
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   202
  uint16_t m_windowSize;
3363
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
   203
  uint16_t m_urgentPointer;
3404
b5d4a04c7b68 bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3363
diff changeset
   204
7717
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7608
diff changeset
   205
  Address m_source;
cfa1741013dd Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents: 7608
diff changeset
   206
  Address m_destination;
3404
b5d4a04c7b68 bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3363
diff changeset
   207
  uint8_t m_protocol;
b5d4a04c7b68 bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3363
diff changeset
   208
3363
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
   209
  bool m_calcChecksum;
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3266
diff changeset
   210
  bool m_goodChecksum;
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   211
};
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   212
7386
2310ed220a61 standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents: 7385
diff changeset
   213
} // namespace ns3
2224
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   214
6f97d21a99c2 Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   215
#endif /* TCP_HEADER */