Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fixed group rcv buffering of ignored packet #1804

Merged
merged 4 commits into from
Feb 11, 2021

Conversation

maxsharabayko
Copy link
Collaborator

@maxsharabayko maxsharabayko commented Feb 9, 2021

One of the member links can provide a packet ahead of the current position after another link has provided a valid packet.
This AHEAD packet is saved in group's buffer. However, the payload of the packet was incorrect, as it was read to a buffer different from the one being saved.

Fixes #1799

Ignoring Packet

Already have the one to deliver.

if (output_size)
{
    // We have already the data, so this must fall on the floor
    char lostbuf[SRT_LIVE_MAX_PLSIZE];
    stat = ps->core().receiveMessage((lostbuf), SRT_LIVE_MAX_PLSIZE, (mctrl), CUDTUnited::ERH_RETURN);

Buffering Packet

Here buf is different from lostbuf where the packet was read to.

if (seqdiff > 1)
{
    HLOGC(grlog.Debug,
            log << "@" << id << " %" << mctrl.pktseq << " #" << mctrl.msgno << " AHEAD base=%"
                << m_RcvBaseSeqNo);
    p->packet.assign(buf, buf + stat);
    p->mctrl = mctrl;
    break; // Don't read from that socket anymore.
}

TODO

  • Fix recvDiscard stats (see TODO comment in the code)

@maxsharabayko maxsharabayko added Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core labels Feb 9, 2021
@maxsharabayko maxsharabayko added this to the v1.4.3 milestone Feb 9, 2021
@maxsharabayko maxsharabayko self-assigned this Feb 9, 2021
@ethouris
Copy link
Collaborator

ethouris commented Feb 9, 2021

Not sure what this thing changes. Ignoring the packet is based on a premise - might be that not correctly stated - that the packet with given sequence number is already received. Note that this reception function relies on packets retrieved from single links at their play time, meaning, whatever is not delivered by these links, has been dropped according to overall rules of TLPKTDROP. Here if the output_size has been set, it means that the data for the next packet to deliver have been already read, the user's buffer filled with the payload, and whatever is being done here is to make the link shifted to read the "next position", that is, it should read everything up to the sequence number of the currently delivered packet.

Reading packets that came AHEAD of the current latest read sequence is done in another place, and these are being read to a spare buffer - if I remember correctly.

@maxsharabayko
Copy link
Collaborator Author

The issue is the following.

  1. Group reads the next packet. output_size = non-zero
  2. Iterating to the next read-ready member link, now reading to lostbuf and mctl.
if (output_size)
{
    // We have already the data, so this must fall on the floor
    char lostbuf[SRT_LIVE_MAX_PLSIZE];
    stat = ps->core().receiveMessage((lostbuf), SRT_LIVE_MAX_PLSIZE, (mctrl), CUDTUnited::ERH_RETURN);
  1. Checking the sequence number of the packet. It it happens to be the AHEAD packet, saving buf instead of lostbuf.
if (seqdiff > 1)
{
    p->packet.assign(buf, buf + stat);
    p->mctrl = mctrl;
    break; // Don't read from that socket anymore.
}

Result: group buffered a packet with AHEAD seqno, but a different payload.

@maxsharabayko maxsharabayko marked this pull request as ready for review February 10, 2021 16:59
srtcore/group.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@ethouris ethouris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things to consider.

@maxsharabayko maxsharabayko merged commit bdb3191 into Haivision:master Feb 11, 2021
@maxsharabayko maxsharabayko deleted the hotfix/group-rcvbuf branch February 11, 2021 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Main/backup: The group gives 1 packet out of order when the main link goes down
2 participants