Cooja platform changes to get IPv6/RPL to work better
This commit is contained in:
parent
3768637f03
commit
aaa950ab17
4 changed files with 219 additions and 59 deletions
|
@ -71,7 +71,7 @@ CONTIKI_CPU=$(CONTIKI)/cpu/x86
|
|||
### Compiler arguments
|
||||
#CC = gcc
|
||||
CFLAGSNO = $(EXTRA_CC_ARGS) -Wall -g -I/usr/local/include -DCLASSNAME=$(CLASSNAME)
|
||||
CFLAGS = $(CFLAGSNO)
|
||||
CFLAGS += $(CFLAGSNO)
|
||||
|
||||
ifdef UIP_CONF_IPV6
|
||||
CFLAGS += -DWITH_UIP6=1
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
|
||||
#define COOJA 1
|
||||
|
||||
#define w_memcpy memcpy
|
||||
|
||||
#if WITH_UIP
|
||||
#if WITH_UIP6
|
||||
#error WITH_UIP && WITH_IP6: Bad configuration
|
||||
|
@ -57,13 +59,18 @@
|
|||
/* Default network config */
|
||||
#if WITH_UIP6
|
||||
|
||||
#define NULLRDC_CONF_802154_AUTOACK 0
|
||||
#define NULLRDC_CONF_SEND_802154_ACK 0
|
||||
#define NULLRDC_CONF_ACK_WAIT_TIME RTIMER_SECOND / 500
|
||||
#define NULLRDC_CONF_AFTER_ACK_DETECTED_WAIT_TIME RTIMER_SECOND / 250
|
||||
|
||||
|
||||
/* Network setup for IPv6 */
|
||||
#define NETSTACK_CONF_NETWORK uip_driver
|
||||
#define NETSTACK_CONF_MAC nullmac_driver
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#define NETSTACK_CONF_RADIO cooja_radio_driver
|
||||
#define UIP_CONF_IPV6 1
|
||||
#define UIP_CONF_IP_FORWARD 0
|
||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#define NETSTACK_CONF_RADIO cooja_radio_driver
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
|
||||
#else /* WITH_UIP6 */
|
||||
|
||||
|
@ -80,7 +87,7 @@
|
|||
|
||||
/* Network setup for Rime */
|
||||
#define NETSTACK_CONF_NETWORK rime_driver
|
||||
#define NETSTACK_CONF_MAC nullmac_driver
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#define NETSTACK_CONF_RADIO cooja_radio_driver
|
||||
/*#define NETSTACK_CONF_FRAMER framer_nullmac*/
|
||||
|
@ -90,6 +97,86 @@
|
|||
|
||||
#endif /* NETSTACK_CONF_H */
|
||||
|
||||
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
|
||||
|
||||
/* Default network config */
|
||||
#if WITH_UIP6
|
||||
|
||||
|
||||
|
||||
/* Network setup for IPv6 */
|
||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#define NETSTACK_CONF_RADIO cooja_radio_driver
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
#define UIP_CONF_IPV6 1
|
||||
|
||||
#define RIMEADDR_CONF_SIZE 8
|
||||
|
||||
#define UIP_CONF_LL_802154 1
|
||||
#define UIP_CONF_LLH_LEN 0
|
||||
|
||||
#define UIP_CONF_ROUTER 1
|
||||
#ifndef UIP_CONF_IPV6_RPL
|
||||
#define UIP_CONF_IPV6_RPL 1
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
|
||||
/* configure number of neighbors and routes */
|
||||
#ifndef UIP_CONF_DS6_NBR_NBU
|
||||
#define UIP_CONF_DS6_NBR_NBU 300
|
||||
#endif /* UIP_CONF_DS6_NBR_NBU */
|
||||
#ifndef UIP_CONF_DS6_ROUTE_NBU
|
||||
#define UIP_CONF_DS6_ROUTE_NBU 300
|
||||
#endif /* UIP_CONF_DS6_ROUTE_NBU */
|
||||
|
||||
#define TCPIP_CONF_ANNOTATE_TRANSMISSIONS 1
|
||||
|
||||
#define RPL_CONF_DIO_INTERVAL_MIN 16
|
||||
|
||||
#define RPL_DIS_INTERVAL_CONF (5 * 60)
|
||||
#define RPL_CONF_DAO_LATENCY (CLOCK_SECOND * 60)
|
||||
|
||||
#define UIP_CONF_ND6_SEND_RA 0
|
||||
#define UIP_CONF_ND6_REACHABLE_TIME 600000
|
||||
#define UIP_CONF_ND6_RETRANS_TIMER 10000
|
||||
|
||||
#define RIMEADDR_CONF_SIZE 8
|
||||
#define UIP_CONF_NETIF_MAX_ADDRESSES 3
|
||||
#define UIP_CONF_ND6_MAX_PREFIXES 3
|
||||
#define UIP_CONF_ND6_MAX_NEIGHBORS 4
|
||||
#define UIP_CONF_ND6_MAX_DEFROUTERS 2
|
||||
|
||||
#ifndef UIP_CONF_IPV6_QUEUE_PKT
|
||||
#define UIP_CONF_IPV6_QUEUE_PKT 1
|
||||
#endif /* UIP_CONF_IPV6_QUEUE_PKT */
|
||||
#define UIP_CONF_IPV6_CHECKS 1
|
||||
#define UIP_CONF_IPV6_REASSEMBLY 0
|
||||
#define UIP_CONF_NETIF_MAX_ADDRESSES 3
|
||||
#define UIP_CONF_ND6_MAX_PREFIXES 3
|
||||
#define UIP_CONF_ND6_MAX_NEIGHBORS 4
|
||||
#define UIP_CONF_ND6_MAX_DEFROUTERS 2
|
||||
#define UIP_CONF_IP_FORWARD 0
|
||||
#ifndef UIP_CONF_BUFFER_SIZE
|
||||
#define UIP_CONF_BUFFER_SIZE 240
|
||||
#endif
|
||||
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_IPV6 0
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_HC1 1
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_HC01 2
|
||||
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
||||
#ifndef SICSLOWPAN_CONF_FRAG
|
||||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
#define SICSLOWPAN_CONF_MAXAGE 8
|
||||
#endif /* SICSLOWPAN_CONF_FRAG */
|
||||
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1
|
||||
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
||||
#ifndef SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS
|
||||
#define SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS 8
|
||||
#endif /* SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS */
|
||||
|
||||
#endif /* WITH_UIP6 */
|
||||
|
||||
|
||||
#define PACKETBUF_CONF_ATTRS_INLINE 1
|
||||
|
||||
|
@ -123,28 +210,38 @@ typedef unsigned long rtimer_clock_t;
|
|||
|
||||
#define WITH_ASCII 1
|
||||
|
||||
#define UIP_CONF_MAX_LISTENPORTS 40
|
||||
#define UIP_CONF_MAX_CONNECTIONS 40
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
#define UIP_CONF_TCP_SPLIT 0
|
||||
#define UIP_CONF_LOGGING 0
|
||||
#define UIP_CONF_UDP_CHECKSUMS 0
|
||||
#define UIP_CONF_BROADCAST 1
|
||||
#define UIP_CONF_ICMP_DEST_UNREACH 1
|
||||
|
||||
#define UIP_CONF_UDP 1
|
||||
#define UIP_CONF_TCP 1
|
||||
#define UIP_CONF_DHCP_LIGHT
|
||||
#define UIP_CONF_LLH_LEN 0
|
||||
#ifndef UIP_CONF_RECEIVE_WINDOW
|
||||
#define UIP_CONF_RECEIVE_WINDOW 48
|
||||
#endif
|
||||
#ifndef UIP_CONF_TCP_MSS
|
||||
#define UIP_CONF_TCP_MSS 48
|
||||
#endif
|
||||
#define UIP_CONF_MAX_CONNECTIONS 4
|
||||
#define UIP_CONF_MAX_LISTENPORTS 8
|
||||
#define UIP_CONF_UDP_CONNS 12
|
||||
#define UIP_CONF_FWCACHE_SIZE 30
|
||||
#define UIP_CONF_BROADCAST 1
|
||||
#define UIP_ARCH_IPCHKSUM 1
|
||||
#define UIP_CONF_UDP 1
|
||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||
#define UIP_CONF_PINGADDRCONF 0
|
||||
#define UIP_CONF_LOGGING 0
|
||||
|
||||
#define UIP_CONF_TCP_SPLIT 0
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#define RIMEADDR_CONF_SIZE 8
|
||||
#define UIP_CONF_IPV6_QUEUE_PKT 1
|
||||
#define UIP_CONF_IPV6_CHECKS 1
|
||||
#define UIP_CONF_IPV6_REASSEMBLY 1
|
||||
#define UIP_CONF_NETIF_MAX_ADDRESSES 3
|
||||
#define UIP_CONF_ND6_MAX_PREFIXES 3
|
||||
#define UIP_CONF_ND6_MAX_NEIGHBORS 4
|
||||
#define UIP_CONF_ND6_MAX_DEFROUTERS 2
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
#define CFS_CONF_OFFSET_TYPE long
|
||||
|
||||
/* include the project config */
|
||||
/* PROJECT_CONF_H might be defined in the project Makefile */
|
||||
#ifdef PROJECT_CONF_H
|
||||
#include PROJECT_CONF_H
|
||||
#endif /* PROJECT_CONF_H */
|
||||
|
||||
#endif /* __CONTIKI_CONF_H__ */
|
||||
|
|
|
@ -102,8 +102,6 @@ static uint8_t is_gateway;
|
|||
#define PRINT6ADDR(addr) printf("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
|
||||
#endif /* WITH_UIP6 */
|
||||
|
||||
PROCINIT(&etimer_process,&sensors_process);
|
||||
|
||||
/* Simulation mote interfaces */
|
||||
SIM_INTERFACE_NAME(moteid_interface);
|
||||
SIM_INTERFACE_NAME(vib_interface);
|
||||
|
@ -179,6 +177,30 @@ rtimer_thread_loop(void *data)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
set_rime_addr(void)
|
||||
{
|
||||
rimeaddr_t addr;
|
||||
int i;
|
||||
|
||||
memset(&addr, 0, sizeof(rimeaddr_t));
|
||||
#if WITH_UIP6
|
||||
for(i = 0; i < sizeof(uip_lladdr.addr); i += 2) {
|
||||
addr.u8[i + 1] = node_id & 0xff;
|
||||
addr.u8[i + 0] = node_id >> 8;
|
||||
}
|
||||
#else /* WITH_UIP6 */
|
||||
addr.u8[0] = node_id & 0xff;
|
||||
addr.u8[1] = node_id >> 8;
|
||||
#endif /* WITH_UIP6 */
|
||||
rimeaddr_set_node_addr(&addr);
|
||||
printf("Rime started with address ");
|
||||
for(i = 0; i < sizeof(addr.u8) - 1; i++) {
|
||||
printf("%d.", addr.u8[i]);
|
||||
}
|
||||
printf("%d\n", addr.u8[i]);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
contiki_init()
|
||||
{
|
||||
|
@ -187,8 +209,12 @@ contiki_init()
|
|||
/* Start process handler */
|
||||
process_init();
|
||||
|
||||
|
||||
/* Start Contiki processes */
|
||||
procinit_init();
|
||||
|
||||
process_start(&etimer_process, NULL);
|
||||
process_start(&sensors_process, NULL);
|
||||
ctimer_init();
|
||||
|
||||
/* Print startup information */
|
||||
printf(CONTIKI_VERSION_STRING " started. ");
|
||||
|
@ -198,28 +224,28 @@ contiki_init()
|
|||
printf("Node id is not set.\n");
|
||||
}
|
||||
|
||||
/* RIME CONFIGURATION */
|
||||
set_rime_addr();
|
||||
{
|
||||
int i;
|
||||
rimeaddr_t rimeaddr;
|
||||
uint8_t longaddr[8];
|
||||
uint16_t shortaddr;
|
||||
|
||||
/* Init Rime */
|
||||
ctimer_init();
|
||||
rimeaddr.u8[0] = node_id & 0xff;
|
||||
rimeaddr.u8[1] = node_id >> 8;
|
||||
rimeaddr_set_node_addr(&rimeaddr);
|
||||
printf("Rime address: ");
|
||||
for(i = 0; i < sizeof(rimeaddr_node_addr.u8) - 1; i++) {
|
||||
printf("%d.", rimeaddr_node_addr.u8[i]);
|
||||
}
|
||||
printf("%d\n", rimeaddr_node_addr.u8[i]);
|
||||
shortaddr = (rimeaddr_node_addr.u8[0] << 8) +
|
||||
rimeaddr_node_addr.u8[1];
|
||||
memset(longaddr, 0, sizeof(longaddr));
|
||||
rimeaddr_copy((rimeaddr_t *)&longaddr, &rimeaddr_node_addr);
|
||||
printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
|
||||
longaddr[0], longaddr[1], longaddr[2], longaddr[3],
|
||||
longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
|
||||
}
|
||||
|
||||
queuebuf_init();
|
||||
|
||||
/* Initialize communication stack */
|
||||
netstack_init();
|
||||
printf("MAC %s RDC %s NETWORK %s\n", NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name);
|
||||
printf("%s/%s/%s, channel check rate %lu Hz\n",
|
||||
NETSTACK_NETWORK.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
|
||||
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
|
||||
NETSTACK_RDC.channel_check_interval()));
|
||||
|
||||
#if WITH_UIP
|
||||
/* IPv4 CONFIGURATION */
|
||||
|
@ -255,27 +281,26 @@ contiki_init()
|
|||
{
|
||||
int i;
|
||||
uint8_t addr[sizeof(uip_lladdr.addr)];
|
||||
for (i=0; i < sizeof(uip_lladdr.addr); i++) {
|
||||
addr[i] = node_id & 0xff;
|
||||
for(i = 0; i < sizeof(uip_lladdr.addr); i += 2) {
|
||||
addr[i + 1] = node_id & 0xff;
|
||||
addr[i + 0] = node_id >> 8;
|
||||
}
|
||||
rimeaddr_copy(addr, &rimeaddr_node_addr);
|
||||
memcpy(&uip_lladdr.addr, addr, sizeof(uip_lladdr.addr));
|
||||
|
||||
process_start(&tcpip_process, NULL);
|
||||
|
||||
printf("Tentative link-local IPv6 address ");
|
||||
{
|
||||
int i, a;
|
||||
for(a = 0; a < UIP_DS6_ADDR_NB; a++) {
|
||||
if (uip_ds6_if.addr_list[a].isused) {
|
||||
uip_ds6_addr_t *lladdr;
|
||||
int i;
|
||||
lladdr = uip_ds6_get_link_local(-1);
|
||||
for(i = 0; i < 7; ++i) {
|
||||
printf("%02x%02x:",
|
||||
uip_ds6_if.addr_list[a].ipaddr.u8[i * 2],
|
||||
uip_ds6_if.addr_list[a].ipaddr.u8[i * 2 + 1]);
|
||||
}
|
||||
printf("%02x%02x\n",
|
||||
uip_ds6_if.addr_list[a].ipaddr.u8[14],
|
||||
uip_ds6_if.addr_list[a].ipaddr.u8[15]);
|
||||
}
|
||||
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
|
||||
lladdr->ipaddr.u8[i * 2 + 1]);
|
||||
}
|
||||
printf("%02x%02x\n", lladdr->ipaddr.u8[14],
|
||||
lladdr->ipaddr.u8[15]);
|
||||
}
|
||||
|
||||
if(1) {
|
||||
|
|
|
@ -101,12 +101,45 @@ doInterfaceActionsAfterTick(void)
|
|||
{
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static int log_putchar_with_slip;
|
||||
void
|
||||
log_set_putchar_with_slip(int with)
|
||||
{
|
||||
log_putchar_with_slip = with;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if IMPLEMENT_PRINTF
|
||||
int
|
||||
putchar(int c)
|
||||
{
|
||||
simlog_char(c);
|
||||
return c;
|
||||
#define SLIP_END 0300
|
||||
static char debug_frame = 0;
|
||||
|
||||
if(log_putchar_with_slip) {
|
||||
simlog_char(SLIP_END);
|
||||
|
||||
if(!debug_frame) { /* Start of debug output */
|
||||
simlog_char(SLIP_END);
|
||||
simlog_char('\r'); /* Type debug line == '\r' */
|
||||
debug_frame = 1;
|
||||
}
|
||||
|
||||
simlog_char((char)c);
|
||||
|
||||
/*
|
||||
* Line buffered output, a newline marks the end of debug output and
|
||||
* implicitly flushes debug output.
|
||||
*/
|
||||
if(c == '\n') {
|
||||
simlog_char(SLIP_END);
|
||||
debug_frame = 0;
|
||||
}
|
||||
|
||||
return c;
|
||||
} else {
|
||||
simlog_char(c);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
|
@ -123,11 +156,16 @@ printf(const char *fmt, ...)
|
|||
int res;
|
||||
static char buf[MAX_LOG_LENGTH];
|
||||
va_list ap;
|
||||
int i;
|
||||
|
||||
va_start(ap, fmt);
|
||||
res = vsnprintf(buf, MAX_LOG_LENGTH, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
simlog(buf);
|
||||
// simlog(buf);
|
||||
for(i = 0; i < res; i++) {
|
||||
putchar(buf[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif /* IMPLEMENT_PRINTF */
|
||||
|
|
Loading…
Reference in a new issue