updated rpl-udp example with scalability test

This commit is contained in:
Joakim Eriksson 2015-08-20 17:13:46 +02:00
parent 3fd8c4db2d
commit f4255fad0f
6 changed files with 1009 additions and 28 deletions

View file

@ -40,12 +40,17 @@
#include <stdio.h>
#include <string.h>
/* Only for TMOTE Sky? */
#include "dev/serial-line.h"
#include "dev/uart1.h"
#include "net/ipv6/uip-ds6-route.h"
#define UDP_CLIENT_PORT 8765
#define UDP_SERVER_PORT 5678
#define UDP_EXAMPLE_ID 190
#define DEBUG DEBUG_PRINT
#define DEBUG DEBUG_FULL
#include "net/ip/uip-debug.h"
#ifndef PERIOD
@ -64,6 +69,9 @@ static uip_ipaddr_t server_ipaddr;
PROCESS(udp_client_process, "UDP client process");
AUTOSTART_PROCESSES(&udp_client_process);
/*---------------------------------------------------------------------------*/
static int seq_id;
static int reply;
static void
tcpip_handler(void)
{
@ -72,16 +80,32 @@ tcpip_handler(void)
if(uip_newdata()) {
str = uip_appdata;
str[uip_datalen()] = '\0';
printf("DATA recv '%s'\n", str);
reply++;
printf("DATA recv '%s' (s:%d, r:%d)\n", str, seq_id, reply);
}
}
/*---------------------------------------------------------------------------*/
static void
send_packet(void *ptr)
{
static int seq_id;
char buf[MAX_PAYLOAD_LEN];
#ifdef SERVER_REPLY
uint8_t num_used = 0;
uip_ds6_nbr_t *nbr;
nbr = nbr_table_head(ds6_neighbors);
while(nbr != NULL) {
nbr = nbr_table_next(ds6_neighbors, nbr);
num_used++;
}
if(seq_id > 0) {
ANNOTATE("#A r=%d/%d,color=%s,n=%d %d\n", reply, seq_id,
reply == seq_id ? "GREEN" : "RED", uip_ds6_route_num_routes(), num_used);
}
#endif /* SERVER_REPLY */
seq_id++;
PRINTF("DATA send to %d 'Hello %d'\n",
server_ipaddr.u8[sizeof(server_ipaddr.u8) - 1], seq_id);
@ -156,8 +180,9 @@ PROCESS_THREAD(udp_client_process, ev, data)
PROCESS_PAUSE();
set_global_address();
PRINTF("UDP client process started\n");
PRINTF("UDP client process started nbr:%d routes:%d\n",
NBR_TABLE_CONF_MAX_NEIGHBORS, UIP_CONF_MAX_ROUTES);
print_local_addresses();
@ -174,6 +199,11 @@ PROCESS_THREAD(udp_client_process, ev, data)
PRINTF(" local/remote port %u/%u\n",
UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));
/* initialize serial line */
uart1_set_input(serial_line_input_byte);
serial_line_init();
#if WITH_COMPOWER
powertrace_sniff(POWERTRACE_ON);
#endif
@ -184,7 +214,41 @@ PROCESS_THREAD(udp_client_process, ev, data)
if(ev == tcpip_event) {
tcpip_handler();
}
if(ev == serial_line_event_message && data != NULL) {
char *str;
str = data;
if(str[0] == 'r') {
uip_ds6_route_t *r;
uip_ipaddr_t *nexthop;
uip_ds6_defrt_t *defrt;
uip_ipaddr_t *ipaddr;
defrt = NULL;
if((ipaddr = uip_ds6_defrt_choose()) != NULL) {
defrt = uip_ds6_defrt_lookup(ipaddr);
}
if(defrt != NULL) {
PRINTF("DefRT: :: -> %02d", defrt->ipaddr.u8[15]);
PRINTF(" lt:%lu inf:%d\n", stimer_remaining(&defrt->lifetime),
defrt->isinfinite);
} else {
PRINTF("DefRT: :: -> NULL\n");
}
for(r = uip_ds6_route_head();
r != NULL;
r = uip_ds6_route_next(r)) {
nexthop = uip_ds6_route_nexthop(r);
PRINTF("Route: %02d -> %02d", r->ipaddr.u8[15], nexthop->u8[15]);
/* PRINT6ADDR(&r->ipaddr); */
/* PRINTF(" -> "); */
/* PRINT6ADDR(nexthop); */
PRINTF(" lt:%lu\n", r->state.lifetime);
}
}
}
if(etimer_expired(&periodic)) {
etimer_reset(&periodic);
ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL);