Added a #define option to send more data than needed to be able to test fragmentation

This commit is contained in:
adamdunkels 2010-02-06 09:58:59 +00:00
parent 9011013fb0
commit 99db24ec2d

View file

@ -30,6 +30,7 @@
#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include "net/uip-netif.h"
#include <string.h>
@ -46,7 +47,6 @@
#endif
#define UDP_NB 5
#define UDP_MAX_DATA_LEN 32
static struct etimer udp_periodic_timer;
@ -60,25 +60,29 @@ AUTOSTART_PROCESSES(&udp_process_sender);
static u8_t
udphandler(process_event_t ev, process_data_t data)
{
if (etimer_expired(&udp_periodic_timer)) {
if(etimer_expired(&udp_periodic_timer)) {
printf("Event timer expired\n");
count=0;
}
if (ev == tcpip_event) {
if(ev == tcpip_event) {
if(uip_newdata()) {
((char *)uip_appdata)[uip_datalen()] = 0;
printf("Sender received: '%s'\n", uip_appdata);
}
}
if(count < UDP_NB){
if(count < UDP_NB) {
count++;
printf("Sender sending to: ");
PRINT6ADDR(&udpconn->ripaddr);
printf("\n");
#if SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION
uip_udp_packet_send(udpconn, "Sender says Hi!", UIP_APPDATA_SIZE);
#else /* SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION */
uip_udp_packet_send(udpconn, "Sender says Hi!", strlen("Sender says Hi!"));
#endif /* SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION */
}
etimer_set(&udp_periodic_timer, 13*CLOCK_SECOND + random_rand()%(4*CLOCK_SECOND));