author | Pedro Silva <pmms@inesctec.pt> |
Wed, 29 Oct 2014 10:12:53 -0700 | |
changeset 11040 | cd2eda848730 |
parent 10908 | c3c7427fcb6a |
child 11183 | 52ff59697ec9 |
permissions | -rw-r--r-- |
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:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
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:
diff
changeset
|
2 |
/* |
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:
diff
changeset
|
3 |
* Copyright (c) 2011 Adrian Sai-wah Tam |
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:
diff
changeset
|
4 |
* |
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:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
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:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
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:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
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:
diff
changeset
|
8 |
* |
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:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
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:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
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:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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:
diff
changeset
|
12 |
* GNU General Public License for more details. |
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:
diff
changeset
|
13 |
* |
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:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
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:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
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:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
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:
diff
changeset
|
17 |
* |
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:
diff
changeset
|
18 |
* Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com> |
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:
diff
changeset
|
19 |
* Documentation, test cases: Natale Patriciello <natale.patriciello@gmail.com> |
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:
diff
changeset
|
20 |
*/ |
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:
diff
changeset
|
21 |
|
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:
diff
changeset
|
22 |
#ifndef TCP_OPTION_WINSCALE_H |
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:
diff
changeset
|
23 |
#define TCP_OPTION_WINSCALE_H |
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:
diff
changeset
|
24 |
|
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:
diff
changeset
|
25 |
#include "tcp-option.h" |
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:
diff
changeset
|
26 |
|
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:
diff
changeset
|
27 |
namespace ns3 { |
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:
diff
changeset
|
28 |
|
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:
diff
changeset
|
29 |
/** |
10908
c3c7427fcb6a
TcpOptions Deserialize should return zero if a deserialization error happens
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10885
diff
changeset
|
30 |
* \brief Defines the TCP option of kind 3 (window scale option) as in \RFC{1323} |
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:
diff
changeset
|
31 |
* |
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:
diff
changeset
|
32 |
* For more efficient use of high bandwidth networks, a larger TCP window 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:
diff
changeset
|
33 |
* may be used. The TCP window size field controls the flow of data and its |
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:
diff
changeset
|
34 |
* value is limited to between 2 and 65,535 bytes. |
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:
diff
changeset
|
35 |
* |
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:
diff
changeset
|
36 |
* Since the size field cannot be expanded, a scaling factor is used. |
10908
c3c7427fcb6a
TcpOptions Deserialize should return zero if a deserialization error happens
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10885
diff
changeset
|
37 |
* The TCP window scale option, as defined in \RFC{1323}, is an option used |
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:
diff
changeset
|
38 |
* to increase the maximum window size from 65,535 bytes to 1 gigabyte. |
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:
diff
changeset
|
39 |
* Scaling up to larger window sizes is a part of what is necessary for TCP Tuning. |
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:
diff
changeset
|
40 |
* |
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:
diff
changeset
|
41 |
* The window scale option is used only during the TCP 3-way handshake. |
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:
diff
changeset
|
42 |
* The window scale value represents the number of bits to left-shift the |
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:
diff
changeset
|
43 |
* 16-bit window size field. The window scale value can be set from 0 |
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:
diff
changeset
|
44 |
* (no shift) to 14 for each direction independently. Both sides must |
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:
diff
changeset
|
45 |
* send the option in their SYN segments to enable window scaling in |
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:
diff
changeset
|
46 |
* either direction. |
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:
diff
changeset
|
47 |
*/ |
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:
diff
changeset
|
48 |
class TcpOptionWinScale : public TcpOption |
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:
diff
changeset
|
49 |
{ |
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:
diff
changeset
|
50 |
public: |
10908
c3c7427fcb6a
TcpOptions Deserialize should return zero if a deserialization error happens
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10885
diff
changeset
|
51 |
/** |
c3c7427fcb6a
TcpOptions Deserialize should return zero if a deserialization error happens
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10885
diff
changeset
|
52 |
* \brief Get the type ID. |
c3c7427fcb6a
TcpOptions Deserialize should return zero if a deserialization error happens
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10885
diff
changeset
|
53 |
* \return the object TypeId |
c3c7427fcb6a
TcpOptions Deserialize should return zero if a deserialization error happens
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10885
diff
changeset
|
54 |
*/ |
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:
diff
changeset
|
55 |
static TypeId GetTypeId (void); |
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:
diff
changeset
|
56 |
virtual TypeId GetInstanceTypeId (void) 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:
diff
changeset
|
57 |
|
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:
diff
changeset
|
58 |
TcpOptionWinScale (); |
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:
diff
changeset
|
59 |
virtual ~TcpOptionWinScale (); |
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:
diff
changeset
|
60 |
|
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:
diff
changeset
|
61 |
virtual void Print (std::ostream &os) 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:
diff
changeset
|
62 |
virtual void Serialize (Buffer::Iterator start) 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:
diff
changeset
|
63 |
virtual uint32_t Deserialize (Buffer::Iterator start); |
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:
diff
changeset
|
64 |
|
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:
diff
changeset
|
65 |
virtual uint8_t GetKind (void) 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:
diff
changeset
|
66 |
virtual uint32_t GetSerializedSize (void) 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:
diff
changeset
|
67 |
|
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:
diff
changeset
|
68 |
/** |
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:
diff
changeset
|
69 |
* \brief Get the scale value (uint8_t) |
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:
diff
changeset
|
70 |
* \return The scale value |
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:
diff
changeset
|
71 |
*/ |
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:
diff
changeset
|
72 |
uint8_t GetScale (void) 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:
diff
changeset
|
73 |
|
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:
diff
changeset
|
74 |
/** |
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:
diff
changeset
|
75 |
* \brief Set the 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:
diff
changeset
|
76 |
* |
10908
c3c7427fcb6a
TcpOptions Deserialize should return zero if a deserialization error happens
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10885
diff
changeset
|
77 |
* The scale option SHOULD be <= 14 (as \RFC{1323}). |
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:
diff
changeset
|
78 |
* |
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:
diff
changeset
|
79 |
* \param scale Scale factor |
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:
diff
changeset
|
80 |
*/ |
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:
diff
changeset
|
81 |
void SetScale (uint8_t scale); |
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:
diff
changeset
|
82 |
|
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:
diff
changeset
|
83 |
protected: |
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:
diff
changeset
|
84 |
uint8_t m_scale; //!< Window scaling in number of bit shift |
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:
diff
changeset
|
85 |
}; |
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:
diff
changeset
|
86 |
|
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:
diff
changeset
|
87 |
} // namespace ns3 |
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:
diff
changeset
|
88 |
|
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:
diff
changeset
|
89 |
#endif /* TCP_OPTION_WINSCALE */ |