tcp: Added callbacks for timings in TcpTxBuffer

When a SACK is received or when an item is discarded (the segment was fully
acked) then fire a callback with the modified item. This will help when we will
have some mechanism that will look for the timing of these actions.
This commit is contained in:
Natale Patriciello
2018-06-18 22:38:29 +02:00
committed by Tom Henderson
parent e5ebdb3b11
commit b08ce80459
2 changed files with 27 additions and 5 deletions

View File

@@ -34,6 +34,7 @@ namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("TcpTxBuffer");
NS_OBJECT_ENSURE_REGISTERED (TcpTxBuffer);
Callback<void, TcpTxItem *> TcpTxBuffer::m_nullCb = MakeNullCallback<void, TcpTxItem*> ();
TypeId
TcpTxBuffer::GetTypeId (void)
{
@@ -587,7 +588,7 @@ TcpTxBuffer::MergeItems (TcpTxItem *t1, TcpTxItem *t2) const
// If one is retrans and the other is not, cancel the retransmitted flag.
// We are merging this segment for the retransmit, so the count will
// be updated in GetTransmittedSegment.
// be updated in MarkTransmittedSegment.
if (! AreEquals (t1->m_retrans, t2->m_retrans))
{
if (t1->m_retrans)
@@ -637,7 +638,8 @@ TcpTxBuffer::RemoveFromCounts (TcpTxItem *item, uint32_t size)
}
}
void
TcpTxBuffer::DiscardUpTo (const SequenceNumber32& seq)
TcpTxBuffer::DiscardUpTo (const SequenceNumber32& seq,
const Callback<void, TcpTxItem *> &beforeDelCb)
{
NS_LOG_FUNCTION (this << seq);
@@ -685,6 +687,13 @@ TcpTxBuffer::DiscardUpTo (const SequenceNumber32& seq)
NS_LOG_INFO ("Removed " << *item << " lost: " << m_lostOut <<
" retrans: " << m_retrans << " sacked: " << m_sackedOut <<
". Remaining data " << m_size);
if (!beforeDelCb.IsNull ())
{
// Inform Rate algorithms only when a full packet is ACKed
beforeDelCb (item);
}
delete item;
}
else if (offset > 0)
@@ -747,7 +756,8 @@ TcpTxBuffer::DiscardUpTo (const SequenceNumber32& seq)
}
uint32_t
TcpTxBuffer::Update (const TcpOptionSack::SackList &list)
TcpTxBuffer::Update (const TcpOptionSack::SackList &list,
const Callback<void, TcpTxItem *> &sackedCb)
{
NS_LOG_FUNCTION (this);
NS_LOG_INFO ("Updating scoreboard, got " << list.size () << " blocks to analyze");
@@ -806,6 +816,11 @@ TcpTxBuffer::Update (const TcpOptionSack::SackList &list)
", checking sentList for block " << *(*item_it) <<
", found in the sackboard, sacking, current highSack: " <<
m_highestSack.second);
if (!sackedCb.IsNull ())
{
sackedCb (*item_it);
}
}
}
else if (beginOfCurrentPacket + pktSize > (*option_it).second)

View File

@@ -261,15 +261,21 @@ public:
*
* \param seq The first sequence number to maintain after discarding all the
* previous sequences.
* \param beforeDelCb Callback invoked, if it is not null, before the deletion
* of an Item (because it was, probably, ACKed)
*/
void DiscardUpTo (const SequenceNumber32& seq);
void DiscardUpTo (const SequenceNumber32& seq,
const Callback<void, TcpTxItem *> &beforeDelCb = m_nullCb);
/**
* \brief Update the scoreboard
* \param list list of SACKed blocks
* \param sackedCb Callback invoked, if it is not null, when a segment has been
* SACKed by the receiver.
* \returns the number of bytes newly sacked by the list of blocks
*/
uint32_t Update (const TcpOptionSack::SackList &list);
uint32_t Update (const TcpOptionSack::SackList &list,
const Callback<void, TcpTxItem *> &sackedCb = m_nullCb);
/**
* \brief Check if a segment is lost
@@ -585,6 +591,7 @@ private:
uint32_t m_segmentSize {0}; //!< Segment size from TcpSocketBase
bool m_renoSack {false}; //!< Indicates if AddRenoSack was called
static Callback<void, TcpTxItem *> m_nullCb; //!< Null callback for an item
};
/**