A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-option-sack.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Adrian Sai-wah Tam
3 * Copyright (c) 2015 ResiliNets, ITTC, University of Kansas
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Original Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
19 * Documentation, test cases: Truc Anh N. Nguyen <annguyen@ittc.ku.edu>
20 * ResiliNets Research Group https://resilinets.org/
21 * The University of Kansas
22 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
23 */
24
25#ifndef TCP_OPTION_SACK_H
26#define TCP_OPTION_SACK_H
27
28#include "tcp-option.h"
29
30#include "ns3/sequence-number.h"
31
32namespace ns3
33{
34
35/**
36 * \brief Defines the TCP option of kind 5 (selective acknowledgment option) as
37 * in \RFC{2018}
38 *
39 * TCP SACK Option is used by a receiver to report non-contiguous blocks of data
40 * that have been received and queued in the receiving buffer. Using the
41 * information conveyed in SACK option sender retransmits only the segments that
42 * have actually been lost, allowing the recovery of multiple packet losses per
43 * sending window.
44 *
45 * Each SACK block is defined by two 32-bit unsigned integers specifying the
46 * left and the right edge of the block. It means that with the 40-byte TCP
47 * option limitation in addition to the presence of TCP Timestamp Option, the
48 * maximum number of SACK blocks that can be appended to each segment is 3.
49 */
51{
52 public:
53 /**
54 * \brief Get the type ID.
55 * \return the object TypeId
56 */
57 static TypeId GetTypeId();
58 TypeId GetInstanceTypeId() const override;
59
60 typedef std::pair<SequenceNumber32, SequenceNumber32> SackBlock; //!< SACK block definition
61 typedef std::list<SackBlock> SackList; //!< SACK list definition
62
64 ~TcpOptionSack() override;
65
66 void Print(std::ostream& os) const override;
67 void Serialize(Buffer::Iterator start) const override;
69
70 uint8_t GetKind() const override;
71 uint32_t GetSerializedSize() const override;
72
73 /**
74 * \brief Add a SACK block
75 * \param s the SACK block to be added
76 */
77 void AddSackBlock(SackBlock s);
78
79 /**
80 * \brief Count the total number of SACK blocks
81 * \return the total number of SACK blocks
82 */
84
85 /**
86 * \brief Clear the SACK list
87 */
88 void ClearSackList();
89
90 /**
91 * \brief Get the SACK list
92 * \return the SACK list
93 */
94 SackList GetSackList() const;
95
96 friend std::ostream& operator<<(std::ostream& os, const TcpOptionSack& sackOption);
97
98 protected:
99 SackList m_sackList; //!< the list of SACK blocks
100};
101
102/**
103 * \brief Output operator.
104 * \param os The output stream.
105 * \param sackOption the option to print.
106 * \returns The output stream.
107 */
108std::ostream& operator<<(std::ostream& os, const TcpOptionSack& sackOption);
109
110/**
111 * \brief Output operator.
112 * \param os The output stream.
113 * \param sackBlock the block to print.
114 * \returns The output stream.
115 */
116std::ostream& operator<<(std::ostream& os, const TcpOptionSack::SackBlock& sackBlock);
117
118} // namespace ns3
119
120#endif /* TCP_OPTION_SACK */
iterator in a Buffer instance
Definition: buffer.h:100
Base class for all kinds of TCP options.
Definition: tcp-option.h:38
Defines the TCP option of kind 5 (selective acknowledgment option) as in RFC 2018
friend std::ostream & operator<<(std::ostream &os, const TcpOptionSack &sackOption)
Output operator.
void ClearSackList()
Clear the SACK list.
std::list< SackBlock > SackList
SACK list definition.
uint32_t GetNumSackBlocks() const
Count the total number of SACK blocks.
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793) of this option.
void Print(std::ostream &os) const override
Print the Option contents.
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
std::pair< SequenceNumber32, SequenceNumber32 > SackBlock
SACK block definition.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static TypeId GetTypeId()
Get the type ID.
void AddSackBlock(SackBlock s)
Add a SACK block.
~TcpOptionSack() override
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
SackList m_sackList
the list of SACK blocks
SackList GetSackList() const
Get the SACK list.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159