12#include "ns3/packet.h"
26 .SetGroupName(
"Internet")
28 .AddTraceSource(
"NextRxSequence",
29 "Next sequence number expected (RCV.NXT)",
31 "ns3::SequenceNumber32TracedValueCallback");
154 if (maxSeq < tailSeq)
158 if (tailSeq < headSeq)
165 while (i !=
m_data.end() && i->first <= tailSeq)
168 if (lastByteSeq > headSeq)
170 if (i->first > headSeq && lastByteSeq < tailSeq)
172 m_size -= i->second->GetSize();
176 if (i->first <= headSeq)
178 headSeq = lastByteSeq;
180 if (lastByteSeq >= tailSeq)
188 if (headSeq >= tailSeq)
196 auto length =
static_cast<uint32_t>(tailSeq - headSeq);
197 p = p->CreateFragment(start, length);
210 NS_LOG_LOGIC(
"Buffered packet of seqno=" << headSeq <<
" len=" << p->GetSize());
250 current.first = head;
251 current.second = tail;
283 bool updated =
false;
296 if (begin.first == current.second)
304 else if (begin.second == current.first)
350 if (block.second <= seq)
374 <<
" bytes from TcpRxBuffer of size=" <<
m_size);
375 if (extractSize == 0)
390 outPkt->AddAtEnd(i->second);
398 outPkt->AddAtEnd(i->second->CreateFragment(0, extractSize));
400 i->second->CreateFragment(extractSize,
pktSize - extractSize);
407 if (outPkt->GetSize() == 0)
413 <<
", num pkts in buffer=" <<
m_data.size());
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
std::list< SackBlock > SackList
SACK list definition.
std::pair< SequenceNumber32, SequenceNumber32 > SackBlock
SACK block definition.
Rx reordering buffer for TCP.
uint32_t GetSackListSize() const
Get the size of Sack list.
Ptr< Packet > Extract(uint32_t maxSize)
Extract data from the head of the buffer as indicated by nextRxSeq.
bool Finished()
Check if the buffer did receive all the data (and the connection is closed)
static TypeId GetTypeId()
Get the type ID.
void SetFinSequence(const SequenceNumber32 &s)
Set the FIN Sequence number (i.e., the one closing the connection)
void SetMaxBufferSize(uint32_t s)
Set the Maximum buffer size.
SequenceNumber32 NextRxSequence() const
Get Next Rx Sequence number.
std::map< SequenceNumber32, Ptr< Packet > > m_data
Corresponding data (may be null)
void SetNextRxSequence(const SequenceNumber32 &s)
Set the Next Sequence number.
SequenceNumber32 m_finSeq
Seqnum of the FIN packet.
uint32_t m_availBytes
Number of bytes available to read, i.e.
void IncNextRxSequence()
Increment the Next Sequence number.
uint32_t MaxBufferSize() const
Get the Maximum buffer size.
uint32_t Size() const
Get the actual buffer occupancy.
bool Add(Ptr< Packet > p, const TcpHeader &tcph)
Insert a packet into the buffer and update the availBytes counter to reflect the number of bytes read...
uint32_t m_maxBuffer
Upper bound of the number of data bytes in buffer (RCV.WND)
std::map< SequenceNumber32, Ptr< Packet > >::iterator BufIterator
container for data stored in the buffer
SequenceNumber32 MaxRxSequence() const
Get the lowest sequence number that this TcpRxBuffer cannot accept.
TracedValue< SequenceNumber32 > m_nextRxSeq
Seqnum of the first missing byte in data (RCV.NXT)
TcpRxBuffer(uint32_t n=0)
Constructor.
void UpdateSackList(const SequenceNumber32 &head, const SequenceNumber32 &tail)
Update the sack list, with the block seq starting at the beginning.
uint32_t Available() const
Get the actual number of bytes available to be read.
TcpOptionSack::SackList GetSackList() const
Get the sack list.
uint32_t m_size
Number of total data bytes in the buffer, not necessarily contiguous.
void ClearSackList(const SequenceNumber32 &seq)
Remove old blocks from the sack list.
bool m_gotFin
Did I received FIN packet?
TcpOptionSack::SackList m_sackList
Sack list (updated constantly)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t pktSize
packet size used for the simulation (in bytes)