net: apps: Modify echo-client to send data only after reception
Modify echo-client to send packet after packet received from server and wait unlimited ticks. Current behaviour flood messages to server irrespective of reception at server end. Modified behavior only for nanokernel at the moment. Change-Id: I6aa20c5b9fc9d6d1cf8f996e90735f5d2b986e5a Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This commit is contained in:
parent
94210770fd
commit
838961af9a
1 changed files with 23 additions and 29 deletions
|
@ -164,8 +164,12 @@ static inline void reverse(unsigned char *buf, int len)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
#define WAIT_TIME 1
|
||||
#define WAIT_TICKS (WAIT_TIME * sys_clock_ticks_per_sec)
|
||||
#else
|
||||
#define WAIT_TICKS TICKS_UNLIMITED
|
||||
#endif
|
||||
|
||||
static inline bool send_packet(const char *name,
|
||||
struct net_context *ctx,
|
||||
|
@ -413,40 +417,31 @@ void taskB(void)
|
|||
|
||||
#define STACKSIZE 2000
|
||||
|
||||
static char fiberStack_sending[STACKSIZE];
|
||||
static char fiberStack_receiving[STACKSIZE];
|
||||
|
||||
/* The other fiber is sending and the other one is receiving. */
|
||||
void fiber_sending(void)
|
||||
{
|
||||
struct nano_timer timer;
|
||||
uint32_t data[2] = {0, 0};
|
||||
bool send_unicast = true;
|
||||
static bool send_unicast = true;
|
||||
|
||||
nano_timer_init(&timer, data);
|
||||
PRINT("%s: Sending packet\n", __func__);
|
||||
|
||||
while (1) {
|
||||
PRINT("%s: Sending packet\n", __func__);
|
||||
expecting = sys_rand32_get() % ipsum_len;
|
||||
|
||||
expecting = sys_rand32_get() % ipsum_len;
|
||||
|
||||
if (send_unicast) {
|
||||
if (send_packet(__func__, unicast, ipsum_len,
|
||||
expecting)) {
|
||||
PRINT("Unicast sending %d bytes FAIL\n",
|
||||
ipsum_len - expecting);
|
||||
}
|
||||
} else {
|
||||
if (send_packet(__func__, multicast, ipsum_len,
|
||||
expecting)) {
|
||||
PRINT("Multicast sending %d bytes FAIL\n",
|
||||
ipsum_len - expecting);
|
||||
}
|
||||
if (send_unicast) {
|
||||
if (send_packet(__func__, unicast, ipsum_len,
|
||||
expecting)) {
|
||||
PRINT("Unicast sending %d bytes FAIL\n",
|
||||
ipsum_len - expecting);
|
||||
}
|
||||
} else {
|
||||
if (send_packet(__func__, multicast, ipsum_len,
|
||||
expecting)) {
|
||||
PRINT("Multicast sending %d bytes FAIL\n",
|
||||
ipsum_len - expecting);
|
||||
}
|
||||
|
||||
send_unicast = !send_unicast;
|
||||
fiber_sleep(10);
|
||||
}
|
||||
|
||||
send_unicast = !send_unicast;
|
||||
}
|
||||
|
||||
void fiber_receiving(void)
|
||||
|
@ -456,6 +451,8 @@ void fiber_receiving(void)
|
|||
|
||||
nano_timer_init(&timer, data);
|
||||
|
||||
fiber_sending();
|
||||
|
||||
while (1) {
|
||||
PRINT("%s: Waiting packet\n", __func__);
|
||||
|
||||
|
@ -465,7 +462,7 @@ void fiber_receiving(void)
|
|||
ipsum_len - expecting);
|
||||
}
|
||||
|
||||
fiber_sleep(10);
|
||||
fiber_sending();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,9 +479,6 @@ void main(void)
|
|||
return;
|
||||
}
|
||||
|
||||
task_fiber_start(&fiberStack_sending[0], STACKSIZE,
|
||||
(nano_fiber_entry_t)fiber_sending, 0, 0, 7, 0);
|
||||
|
||||
task_fiber_start(&fiberStack_receiving[0], STACKSIZE,
|
||||
(nano_fiber_entry_t)fiber_receiving, 0, 0, 7, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue