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

UDPSOCKET_ECHOTEST change to tolerate duplicate packets #11693

Merged
merged 1 commit into from
Nov 4, 2019

Conversation

mtomczykmobica
Copy link
Contributor

Description

UDP should ignore duplicate packets, as some networks may produce those.

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@SeppoTakalo
@AnttiKauppila
@michalpasztamobica

Release Notes

@ciarmcom
Copy link
Member

@mtomczykmobica, thank you for your changes.
@AnttiKauppila @SeppoTakalo @michalpasztamobica @ARMmbed/mbed-os-test @ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers please review.

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 16, 2019

Please fix styling (see travis astyle failure)

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

Once Travis passing

@mtomczykmobica
Copy link
Contributor Author

Please fix styling (see travis astyle failure)

Done

received_duplicate_packet = true;
}
} while (received_duplicate_packet);

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this logic.

You assume that all duplicates will be received in order.

This might be true for ECHOTEST, but might not be true for ECHOTEST_BURST.

So while re-working this, can you change logic so that it tolerates re-ordering as well.

I would assume this kind of logic might work:

// List of packet sizes to send
static const int pkt_sizes[PKTS] = {...);
// List of boolean flags to mark each size as "received"
static bool pkt_received[PKTS] = {false};

// ... in the test case
for (int retry_cnt = 0; retry_cnt <= 2; retry_cnt++) {
    ...
    sent = sock.sendto(udp_addr, tx_buffer, pkt_s);
    if (...) {
        // errors..
    }
    do {
        recvd = sock.recvfrom(...);
        // Check that packet is what we sent
        if (recvd == pkt_sizes[s_idx] && memcmp(rx_last, rx_buffer, recvd) == 0)
            pkt_received[s_idx] = true;
        }
    } while(pkt_received[s_idx] == false);
}

So just accept what we were waiting for, ignore the rest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed logic. Now responses for all sends and duplicates of this responses are accepted. Other packets with incorrect size are interpreted as error.

Copy link
Contributor

@SeppoTakalo SeppoTakalo left a comment

Choose a reason for hiding this comment

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

This looks OK.

One thing I'm wondering, do we set the socket timeout, or does it hang if there is packet losses?

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 4, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Nov 4, 2019

Test run: SUCCESS

Summary: 5 of 5 test jobs passed
Build number : 1
Build artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants