-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
@mtomczykmobica, thank you for your changes. |
Please fix styling (see travis astyle failure) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once Travis passing
f176ba7
to
c03f60c
Compare
Done |
received_duplicate_packet = true; | ||
} | ||
} while (received_duplicate_packet); | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
c03f60c
to
11864c7
Compare
There was a problem hiding this 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?
CI started |
Test run: SUCCESSSummary: 5 of 5 test jobs passed |
Description
UDP should ignore duplicate packets, as some networks may produce those.
Pull request type
Reviewers
@SeppoTakalo
@AnttiKauppila
@michalpasztamobica
Release Notes