Merge pull request #1218 from adamdunkels/pr/rpl-massive-test

RPL large-scale test & bugfix
This commit is contained in:
Fredrik Österlind 2015-08-27 12:53:46 +02:00
commit 9738c5c396
14 changed files with 1271 additions and 18 deletions

View File

@ -103,6 +103,7 @@ env:
- BUILD_TYPE='collect'
- BUILD_TYPE='collect-lossy'
- BUILD_TYPE='rpl'
- BUILD_TYPE='large-rpl'
- BUILD_TYPE='rime'
- BUILD_TYPE='ipv6'
- BUILD_TYPE='ip64' MAKE_TARGETS='cooja'

View File

@ -256,7 +256,8 @@ dio_input(void)
PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTF("\n");
return;
goto discard;
}
} else {
PRINTF("RPL: Neighbor already in neighbor cache\n");
@ -306,7 +307,7 @@ dio_input(void)
if(len + i > buffer_length) {
PRINTF("RPL: Invalid DIO packet\n");
RPL_STAT(rpl_stats.malformed_msgs++);
return;
goto discard;
}
PRINTF("RPL: DIO option %u, length: %u\n", subopt_type, len - 2);
@ -316,7 +317,7 @@ dio_input(void)
if(len < 6) {
PRINTF("RPL: Invalid DAG MC, len = %d\n", len);
RPL_STAT(rpl_stats.malformed_msgs++);
return;
goto discard;
}
dio.mc.type = buffer[i + 2];
dio.mc.flags = buffer[i + 3] << 1;
@ -342,14 +343,14 @@ dio_input(void)
dio.mc.obj.energy.energy_est = buffer[i + 7];
} else {
PRINTF("RPL: Unhandled DAG MC type: %u\n", (unsigned)dio.mc.type);
return;
goto discard;
}
break;
case RPL_OPTION_ROUTE_INFO:
if(len < 9) {
PRINTF("RPL: Invalid destination prefix option, len = %d\n", len);
RPL_STAT(rpl_stats.malformed_msgs++);
return;
goto discard;
}
/* The flags field includes the preference value. */
@ -365,7 +366,7 @@ dio_input(void)
} else {
PRINTF("RPL: Invalid route info option, len = %d\n", len);
RPL_STAT(rpl_stats.malformed_msgs++);
return;
goto discard;
}
break;
@ -373,7 +374,7 @@ dio_input(void)
if(len != 16) {
PRINTF("RPL: Invalid DAG configuration option, len = %d\n", len);
RPL_STAT(rpl_stats.malformed_msgs++);
return;
goto discard;
}
/* Path control field not yet implemented - at i + 2 */
@ -395,7 +396,7 @@ dio_input(void)
if(len != 32) {
PRINTF("RPL: Invalid DAG prefix info, len != 32\n");
RPL_STAT(rpl_stats.malformed_msgs++);
return;
goto discard;
}
dio.prefix_info.length = buffer[i + 2];
dio.prefix_info.flags = buffer[i + 3];
@ -418,6 +419,7 @@ dio_input(void)
rpl_process_dio(&from, &dio);
discard:
uip_clear_buf();
}
/*---------------------------------------------------------------------------*/
@ -622,7 +624,7 @@ dao_input(void)
if(instance == NULL) {
PRINTF("RPL: Ignoring a DAO for an unknown RPL instance(%u)\n",
instance_id);
return;
goto discard;
}
lifetime = instance->default_lifetime;
@ -637,7 +639,7 @@ dao_input(void)
if(flags & RPL_DAO_D_FLAG) {
if(memcmp(&dag->dag_id, &buffer[pos], sizeof(dag->dag_id))) {
PRINTF("RPL: Ignoring a DAO for a DAG different from ours\n");
return;
goto discard;
}
pos += 16;
}
@ -658,7 +660,7 @@ dao_input(void)
DAG_RANK(parent->rank, instance), DAG_RANK(dag->rank, instance));
parent->rank = INFINITE_RANK;
parent->flags |= RPL_PARENT_FLAG_UPDATED;
return;
goto discard;
}
/* If we get the DAO from our parent, we also have a loop. */
@ -666,7 +668,7 @@ dao_input(void)
PRINTF("RPL: Loop detected when receiving a unicast DAO from our parent\n");
parent->rank = INFINITE_RANK;
parent->flags |= RPL_PARENT_FLAG_UPDATED;
return;
goto discard;
}
}
@ -743,7 +745,7 @@ dao_input(void)
dao_ack_output(instance, &dao_sender_addr, sequence);
}
}
return;
goto discard;
}
PRINTF("RPL: adding DAO route\n");
@ -765,7 +767,7 @@ dao_input(void)
PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTF("\n");
return;
goto discard;
}
} else {
PRINTF("RPL: Neighbor already in neighbor cache\n");
@ -777,7 +779,7 @@ dao_input(void)
if(rep == NULL) {
RPL_STAT(rpl_stats.mem_overflows++);
PRINTF("RPL: Could not add a route after receiving a DAO\n");
return;
goto discard;
}
rep->state.lifetime = RPL_LIFETIME(instance, lifetime);
@ -801,6 +803,8 @@ fwd_dao:
dao_ack_output(instance, &dao_sender_addr, sequence);
}
}
discard:
uip_clear_buf();
}
/*---------------------------------------------------------------------------*/

View File

@ -89,11 +89,17 @@ rpl_set_mode(enum rpl_mode m)
} else if(m == RPL_MODE_FEATHER) {
PRINTF("RPL: switching to feather mode\n");
mode = m;
if(default_instance != NULL) {
PRINTF("rpl_set_mode: RPL sending DAO with zero lifetime\n");
if(default_instance->current_dag != NULL) {
dao_output(default_instance->current_dag->preferred_parent, RPL_ZERO_LIFETIME);
}
rpl_cancel_dao(default_instance);
} else {
PRINTF("rpl_set_mode: no default instance\n");
}
mode = m;
} else {
mode = m;
}

View File

@ -37,7 +37,7 @@
const struct simInterface rs232_interface;
#define SERIAL_BUF_SIZE 1024
#define SERIAL_BUF_SIZE 2048
// COOJA variables
char simSerialReceivingData[SERIAL_BUF_SIZE];

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
include ../Makefile.simulation-test

View File

@ -0,0 +1,7 @@
CONTIKI=../../../..
MODULES += core/net/http-socket
CFLAGS+=-DPROJECT_CONF_H=\"project-conf.h\"
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,103 @@
#include "contiki-net.h"
#include "http-socket.h"
#include "ip64-addr.h"
#include "dev/leds.h"
#include "rpl.h"
#include <stdio.h>
static struct http_socket s;
static int bytes_received = 0;
static int restarts;
static struct ctimer reconnect_timer;
static void callback(struct http_socket *s, void *ptr,
http_socket_event_t e,
const uint8_t *data, uint16_t datalen);
/*---------------------------------------------------------------------------*/
PROCESS(http_example_process, "HTTP Example");
AUTOSTART_PROCESSES(&http_example_process);
/*---------------------------------------------------------------------------*/
static void
reconnect(void *dummy)
{
rpl_set_mode(RPL_MODE_MESH);
http_socket_get(&s, "http://www.contiki-os.org/", 0, 0,
callback, NULL);
}
/*---------------------------------------------------------------------------*/
static void
restart(void)
{
int scale;
restarts++;
printf("restart %d\n", restarts);
scale = restarts;
if(scale > 5) {
scale = 5;
}
ctimer_set(&reconnect_timer, random_rand() % ((CLOCK_SECOND * 10) << scale),
reconnect, NULL);
}
/*---------------------------------------------------------------------------*/
static void
callback(struct http_socket *s, void *ptr,
http_socket_event_t e,
const uint8_t *data, uint16_t datalen)
{
if(e == HTTP_SOCKET_ERR) {
printf("HTTP socket error\n");
} else if(e == HTTP_SOCKET_TIMEDOUT) {
printf("HTTP socket error: timed out\n");
restart();
} else if(e == HTTP_SOCKET_ABORTED) {
printf("HTTP socket error: aborted\n");
restart();
} else if(e == HTTP_SOCKET_HOSTNAME_NOT_FOUND) {
printf("HTTP socket error: hostname not found\n");
restart();
} else if(e == HTTP_SOCKET_CLOSED) {
if(bytes_received > 0) {
printf("HTTP socket closed, %d bytes received\n", bytes_received);
leds_off(LEDS_RED);
rpl_set_mode(RPL_MODE_FEATHER);
} else {
restart();
}
} else if(e == HTTP_SOCKET_DATA) {
bytes_received += datalen;
printf("HTTP socket received %d bytes of data\n", datalen);
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(http_example_process, ev, data)
{
static struct etimer et;
uip_ip4addr_t ip4addr;
uip_ip6addr_t ip6addr;
PROCESS_BEGIN();
uip_ipaddr(&ip4addr, 8,8,8,8);
ip64_addr_4to6(&ip4addr, &ip6addr);
uip_nameserver_update(&ip6addr, UIP_NAMESERVER_INFINITE_LIFETIME);
etimer_set(&et, CLOCK_SECOND * 20);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
http_socket_init(&s);
http_socket_get(&s, "http://www.contiki-os.org/", 0, 0,
callback, NULL);
leds_on(LEDS_RED);
restarts = 0;
etimer_set(&et, CLOCK_SECOND);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
etimer_reset(&et);
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,6 @@
#define QUEUEBUF_CONF_STATS 1
#define RESOLV_CONF_SUPPORTS_MDNS 0
#define COOJA_MTARCH_STACKSIZE 4096
#define UIP_CONF_MAX_ROUTES 3
#define NBR_TABLE_CONF_MAX_NEIGHBORS 3

View File

@ -0,0 +1,5 @@
CONTIKI=../../../..
CFLAGS+=-DPROJECT_CONF_H=\"project-conf.h\"
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,9 @@
#define QUEUEBUF_CONF_STATS 1
#define RESOLV_CONF_SUPPORTS_MDNS 0
#define COOJA_MTARCH_STACKSIZE 4096
#define UIP_CONF_MAX_ROUTES 8
#define NBR_TABLE_CONF_MAX_NEIGHBORS 8
/*#define RPL_CONF_DEFAULT_LIFETIME_UNIT 10
#define RPL_CONF_DEFAULT_LIFETIME 10*/

View File

@ -0,0 +1,27 @@
#include "contiki.h"
#include "contiki-net.h"
#include "ip64.h"
#include "net/netstack.h"
/*---------------------------------------------------------------------------*/
PROCESS(router_node_process, "Router node");
AUTOSTART_PROCESSES(&router_node_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(router_node_process, ev, data)
{
PROCESS_BEGIN();
/* Set us up as a RPL root node. */
rpl_dag_root_init_dag();
/* Initialize the IP64 module so we'll start translating packets */
ip64_init();
/* ... and do nothing more. */
while(1) {
PROCESS_WAIT_EVENT();
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,78 @@
TIMEOUT(2400000); /* 40 minutes */
var NR_FEATHERS = mote.getSimulation().getMotesCount() - 1;
/* conf */
var travis = java.lang.System.getenv().get("TRAVIS");
if (travis == null) {
/* Instant Contiki */
CMD_TUNNEL = "echo '-vj' > ~/.slirprc && make Connect.class && java Connect 'nc localhost 60001' 'script -t -f -c slirp'";
CMD_PING = "ping -c 5 8.8.8.8";
CMD_DIR = "../../wpcapslip";
} else {
/* Travis */
CMD_TUNNEL = "cd $TRAVIS_BUILD_DIR/tools/wpcapslip && sudo apt-get install slirp && echo '-vj' > ~/.slirprc && make Connect.class && java Connect 'nc localhost 60001' 'script -t -f -c slirp'";
CMD_PING = "ping -c 5 8.8.8.8";
CMD_DIR = ".";
}
/* delay */
GENERATE_MSG(1000, "continue");
YIELD_THEN_WAIT_UNTIL(msg.equals("continue"));
/* realtime speed */
sim.setSpeedLimit(2.0);
/* tunnel interface */
log.log("opening tunnel interface: " + CMD_TUNNEL + "\n");
launcher = new java.lang.ProcessBuilder["(java.lang.String[])"](['sh','-c',CMD_TUNNEL]);
launcher.directory(new java.io.File(CMD_DIR));
launcher.redirectErrorStream(true);
tunProcess = launcher.start();
tunRunnable = new Object();
tunRunnable.run = function() {
var stdIn = new java.io.BufferedReader(new java.io.InputStreamReader(tunProcess.getInputStream()));
while ((line = stdIn.readLine()) != null) {
if (line != null && !line.trim().equals("")) {
//log.log("TUN> " + line + "\n");
}
}
tunProcess.destroy();
}
new java.lang.Thread(new java.lang.Runnable(tunRunnable)).start();
GENERATE_MSG(1000, "continue");
YIELD_THEN_WAIT_UNTIL(msg.equals("continue"));
/* ping */
log.log("pinging: " + CMD_PING + "\n");
launcher = new java.lang.ProcessBuilder["(java.lang.String[])"](['sh','-c',CMD_PING]);
launcher.directory(new java.io.File(CMD_DIR));
launcher.redirectErrorStream(true);
tunProcess = launcher.start();
tunRunnable = new Object();
tunRunnable.run = function() {
var stdIn = new java.io.BufferedReader(new java.io.InputStreamReader(tunProcess.getInputStream()));
while ((line = stdIn.readLine()) != null) {
if (line != null && !line.trim().equals("")) {
log.log("PING> " + line + "\n");
}
}
tunProcess.destroy();
}
new java.lang.Thread(new java.lang.Runnable(tunRunnable)).start();
var completed = {};
while(Object.keys(completed).length < NR_FEATHERS) {
if (!msg.startsWith("#L") && !msg.startsWith("E")) {
//log.log(mote + ": " + msg + "\n");
}
if (id != 1 && msg.startsWith("HTTP socket closed")) {
completed[id] = id;
log.log("Data compelete " + id + ", heard " + Object.keys(completed).length + " in total\n");
}
YIELD();
}
log.testOK();

View File

@ -71,7 +71,7 @@ public class ContikiRS232 extends SerialUI implements ContikiMoteInterface, Poll
private ContikiMote mote = null;
private VarMemory moteMem = null;
static final int SERIAL_BUF_SIZE = 1024; /* rs232.c:40 */
static final int SERIAL_BUF_SIZE = 2048; /* rs232.c:40 */
/**
* Creates an interface to the RS232 at mote.