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 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Original Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
8 * Documentation, test cases: Truc Anh N. Nguyen <annguyen@ittc.ku.edu>
9 * ResiliNets Research Group https://resilinets.org/
10 * The University of Kansas
11 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
12 */
13
14#ifndef TCP_OPTION_SACK_H
15#define TCP_OPTION_SACK_H
16
17#include "tcp-option.h"
18
19#include "ns3/sequence-number.h"
20
21namespace ns3
22{
23
24/**
25 * @brief Defines the TCP option of kind 5 (selective acknowledgment option) as
26 * in \RFC{2018}
27 *
28 * TCP SACK Option is used by a receiver to report non-contiguous blocks of data
29 * that have been received and queued in the receiving buffer. Using the
30 * information conveyed in SACK option sender retransmits only the segments that
31 * have actually been lost, allowing the recovery of multiple packet losses per
32 * sending window.
33 *
34 * Each SACK block is defined by two 32-bit unsigned integers specifying the
35 * left and the right edge of the block. It means that with the 40-byte TCP
36 * option limitation in addition to the presence of TCP Timestamp Option, the
37 * maximum number of SACK blocks that can be appended to each segment is 3.
38 */
40{
41 public:
42 /**
43 * @brief Get the type ID.
44 * @return the object TypeId
45 */
46 static TypeId GetTypeId();
47
48 typedef std::pair<SequenceNumber32, SequenceNumber32> SackBlock; //!< SACK block definition
49 typedef std::list<SackBlock> SackList; //!< SACK list definition
50
52 ~TcpOptionSack() override;
53
54 void Print(std::ostream& os) const override;
55 void Serialize(Buffer::Iterator start) const override;
57
58 uint8_t GetKind() const override;
59 uint32_t GetSerializedSize() const override;
60
61 /**
62 * @brief Add a SACK block
63 * @param s the SACK block to be added
64 */
65 void AddSackBlock(SackBlock s);
66
67 /**
68 * @brief Count the total number of SACK blocks
69 * @return the total number of SACK blocks
70 */
72
73 /**
74 * @brief Clear the SACK list
75 */
76 void ClearSackList();
77
78 /**
79 * @brief Get the SACK list
80 * @return the SACK list
81 */
82 SackList GetSackList() const;
83
84 friend std::ostream& operator<<(std::ostream& os, const TcpOptionSack& sackOption);
85
86 protected:
87 SackList m_sackList; //!< the list of SACK blocks
88};
89
90/**
91 * @brief Output operator.
92 * @param os The output stream.
93 * @param sackOption the option to print.
94 * @returns The output stream.
95 */
96std::ostream& operator<<(std::ostream& os, const TcpOptionSack& sackOption);
97
98/**
99 * @brief Output operator.
100 * @param os The output stream.
101 * @param sackBlock the block to print.
102 * @returns The output stream.
103 */
104std::ostream& operator<<(std::ostream& os, const TcpOptionSack::SackBlock& sackBlock);
105
106} // namespace ns3
107
108#endif /* TCP_OPTION_SACK */
iterator in a Buffer instance
Definition buffer.h:89
Base class for all kinds of TCP options.
Definition tcp-option.h:27
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.
static TypeId GetTypeId()
Get the type ID.
void AddSackBlock(SackBlock s)
Add a SACK block.
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:49
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:148