Skip to content

Commit

Permalink
Updated PR after review
Browse files Browse the repository at this point in the history
  • Loading branch information
mbakholdina committed Apr 12, 2021
1 parent 7da9425 commit 6bf64b3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
16 changes: 8 additions & 8 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7705,8 +7705,8 @@ int CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
if (m_uPeerSrtVersion == SrtVersion(1, 0, 2))
{
data[ACKD_RCVRATE] = rcvRate; // bytes/sec
data[ACKD_XMRATE] = data[ACKD_BANDWIDTH] * m_iMaxSRTPayloadSize; // bytes/sec
ctrlsz = ACKD_FIELD_SIZE * ACKD_TOTAL_SIZE_VER102;
data[ACKD_XMRATE_VER102_ONLY] = data[ACKD_BANDWIDTH] * m_iMaxSRTPayloadSize; // bytes/sec
ctrlsz = ACKD_FIELD_SIZE * ACKD_TOTAL_SIZE_VER102_ONLY;
}
else if (m_uPeerSrtVersion >= SrtVersion(1, 0, 3))
{
Expand Down Expand Up @@ -7995,10 +7995,10 @@ void CUDT::processCtrlAck(const CPacket &ctrlpkt, const steady_clock::time_point
* Additional UDT fields, not always attached:
* ACKD_RCVSPEED
* ACKD_BANDWIDTH
* SRT extension version 1.0.2 (bstats):
* SRT extension since v1.0.1:
* ACKD_RCVRATE
* SRT extension version 1.0.4:
* ACKD_XMRATE
* SRT extension since v1.0.2:
* ACKD_XMRATE_VER102_ONLY
*/

if (acksize > ACKD_TOTAL_SIZE_SMALL)
Expand All @@ -8008,7 +8008,7 @@ void CUDT::processCtrlAck(const CPacket &ctrlpkt, const steady_clock::time_point
int bandwidth = ackdata[ACKD_BANDWIDTH];
int bytesps;

/* SRT v1.0.2 Bytes-based stats: bandwidth (pcData[ACKD_XMRATE]) and delivery rate (pcData[ACKD_RCVRATE]) in
/* SRT v1.0.2 Bytes-based stats: bandwidth (pcData[ACKD_XMRATE_VER102_ONLY]) and delivery rate (pcData[ACKD_RCVRATE]) in
* bytes/sec instead of pkts/sec */
/* SRT v1.0.3 Bytes-based stats: only delivery rate (pcData[ACKD_RCVRATE]) in bytes/sec instead of pkts/sec */
if (acksize > ACKD_TOTAL_SIZE_UDTBASE)
Expand All @@ -8019,8 +8019,8 @@ void CUDT::processCtrlAck(const CPacket &ctrlpkt, const steady_clock::time_point
m_iBandwidth = avg_iir<8>(m_iBandwidth, bandwidth);
m_iDeliveryRate = avg_iir<8>(m_iDeliveryRate, pktps);
m_iByteDeliveryRate = avg_iir<8>(m_iByteDeliveryRate, bytesps);
// XXX not sure if ACKD_XMRATE is of any use. This is simply
// calculated as ACKD_BANDWIDTH * m_iMaxSRTPayloadSize.
// TODO: Not sure if ACKD_XMRATE_VER102_ONLY is of any use. This is
// simply calculated as ACKD_BANDWIDTH * m_iMaxSRTPayloadSize.

// Update Estimated Bandwidth and packet delivery rate
// m_iRcvRate = m_iDeliveryRate;
Expand Down
47 changes: 22 additions & 25 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ modified by
#include <haicrypt.h>


// XXX Utility function - to be moved to utilities.h?
// TODO: Utility function - to be moved to utilities.h?
template <class T>
inline T CountIIR(T base, T newval, double factor)
{
Expand All @@ -88,32 +88,29 @@ inline T CountIIR(T base, T newval, double factor)
}

// TODO: Probably a better rework for that can be done - this can be
// turned into a serializable structure, just like it's for CHandShake.
// turned into a serializable structure, just like it's done for CHandShake.
enum AckDataItem
{
ACKD_RCVLASTACK = 0,
ACKD_RTT = 1,
ACKD_RTTVAR = 2,
ACKD_BUFFERLEFT = 3,
ACKD_TOTAL_SIZE_SMALL = 4,

// Extra fields existing in UDT (not always sent).
ACKD_RCVSPEED = 4, // length = 16
ACKD_BANDWIDTH = 5,
ACKD_TOTAL_SIZE_UDTBASE = 6, // length = 24

// Extra stats for SRT.
ACKD_RCVRATE = 6,
ACKD_TOTAL_SIZE_VER101 = 7, // length = 28
// XXX This is a weird compat stuff. Version 1.1.3 defines it as
// ACKD_BANDWIDTH*m_iMaxSRTPayloadSize when set. Never got.
// XXX NOTE: field number 7 may be used for something in future,
// need to confirm destruction of all !compat 1.0.2 version.
ACKD_XMRATE = 7,

ACKD_TOTAL_SIZE_VER102 = 8, // length = 32
// ACKD_ACKBITMAP = 8, // Feature blocked, probably not to be restored.
ACKD_TOTAL_SIZE = ACKD_TOTAL_SIZE_VER102 // length = 32 (or more)
ACKD_RCVLASTACK = 0,
ACKD_RTT = 1,
ACKD_RTTVAR = 2,
ACKD_BUFFERLEFT = 3,
ACKD_TOTAL_SIZE_SMALL = 4, // Size of the Small ACK, packet length = 16.

// Extra fields for Full ACK.
ACKD_RCVSPEED = 4,
ACKD_BANDWIDTH = 5,
ACKD_TOTAL_SIZE_UDTBASE = 6, // Packet length = 24.

// Extra stats since SRT v1.0.1.
ACKD_RCVRATE = 6,
ACKD_TOTAL_SIZE_VER101 = 7, // Packet length = 28.

// Only in SRT v1.0.2.
ACKD_XMRATE_VER102_ONLY = 7,
ACKD_TOTAL_SIZE_VER102_ONLY = 8, // Packet length = 32.

ACKD_TOTAL_SIZE = ACKD_TOTAL_SIZE_VER102_ONLY // The maximum known ACK length is 32 bytes.
};
const size_t ACKD_FIELD_SIZE = sizeof(int32_t);

Expand Down

0 comments on commit 6bf64b3

Please sign in to comment.