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 TypeId GetInstanceTypeId() const override;
48
49 typedef std::pair<SequenceNumber32, SequenceNumber32> SackBlock; //!< SACK block definition
50 typedef std::list<SackBlock> SackList; //!< SACK list definition
51
53 ~TcpOptionSack() override;
54
55 void Print(std::ostream& os) const override;
56 void Serialize(Buffer::Iterator start) const override;
58
59 uint8_t GetKind() const override;
60 uint32_t GetSerializedSize() const override;
61
62 /**
63 * @brief Add a SACK block
64 * @param s the SACK block to be added
65 */
66 void AddSackBlock(SackBlock s);
67
68 /**
69 * @brief Count the total number of SACK blocks
70 * @return the total number of SACK blocks
71 */
73
74 /**
75 * @brief Clear the SACK list
76 */
77 void ClearSackList();
78
79 /**
80 * @brief Get the SACK list
81 * @return the SACK list
82 */
83 SackList GetSackList() const;
84
85 friend std::ostream& operator<<(std::ostream& os, const TcpOptionSack& sackOption);
86
87 protected:
88 SackList m_sackList; //!< the list of SACK blocks
89};
90
91/**
92 * @brief Output operator.
93 * @param os The output stream.
94 * @param sackOption the option to print.
95 * @returns The output stream.
96 */
97std::ostream& operator<<(std::ostream& os, const TcpOptionSack& sackOption);
98
99/**
100 * @brief Output operator.
101 * @param os The output stream.
102 * @param sackBlock the block to print.
103 * @returns The output stream.
104 */
105std::ostream& operator<<(std::ostream& os, const TcpOptionSack::SackBlock& sackBlock);
106
107} // namespace ns3
108
109#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.
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.
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:48
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