net: apps: Resend failed message once in echo-client
If the reply for a sent message is not received, then try to send it once again. If the second resend fails, then mark the packet as failed. Change-Id: Ibe9b9384e2e84f055c6486a5bd4d7293675e5d42 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
4dfb50e514
commit
a63f175d44
1 changed files with 19 additions and 6 deletions
|
@ -310,13 +310,17 @@ static inline bool get_context(struct net_context **unicast,
|
|||
static char __noinit __stack stack_receiving[STACKSIZE];
|
||||
#endif
|
||||
|
||||
void sending(void)
|
||||
void sending(int resend)
|
||||
{
|
||||
static bool send_unicast = true;
|
||||
|
||||
PRINT("%s: Sending packet\n", __func__);
|
||||
|
||||
expecting = sys_rand32_get() % ipsum_len;
|
||||
if (resend) {
|
||||
expecting = resend;
|
||||
} else {
|
||||
expecting = sys_rand32_get() % ipsum_len;
|
||||
}
|
||||
|
||||
if (send_unicast) {
|
||||
if (send_packet(__func__, unicast, ipsum_len,
|
||||
|
@ -335,18 +339,27 @@ void sending(void)
|
|||
|
||||
void receiving(void)
|
||||
{
|
||||
sending();
|
||||
int expecting_len = 0;
|
||||
|
||||
sending(expecting_len);
|
||||
|
||||
while (1) {
|
||||
PRINT("%s: Waiting packet\n", __func__);
|
||||
|
||||
if (wait_reply(__func__, unicast,
|
||||
ipsum_len, expecting)) {
|
||||
PRINT("Waiting %d bytes -> FAIL\n",
|
||||
ipsum_len - expecting);
|
||||
if (expecting_len > 0) {
|
||||
PRINT("Resend %d bytes -> FAIL\n",
|
||||
ipsum_len - expecting);
|
||||
expecting_len = 0;
|
||||
} else {
|
||||
PRINT("Waiting %d bytes -> resending\n",
|
||||
ipsum_len - expecting);
|
||||
expecting_len = expecting;
|
||||
}
|
||||
}
|
||||
|
||||
sending();
|
||||
sending(expecting_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue