0

I'm trying to encrypt my "hello" messages in a simulation in Contiki 3.0

I'm doing the software implementation of LLSEC (link-layer security) layer as advised in this question's answers.

The example I'm using for my simulation is the IPV6 rpl-udp udp-client.c and udp-server which can be seen here.

I have followed the instructions as per documentation here and created a project-conf.h file and have the Make file referring to it as seen below:

project-conf.h

#undef LLSEC802154_CONF_ENABLED
#define LLSEC802154_CONF_ENABLED          1
#undef NETSTACK_CONF_FRAMER
#define NETSTACK_CONF_FRAMER              noncoresec_framer
#undef NETSTACK_CONF_LLSEC
#define NETSTACK_CONF_LLSEC               noncoresec_driver
#undef NONCORESEC_CONF_SEC_LVL
#define NONCORESEC_CONF_SEC_LVL           0x07

#define NONCORESEC_CONF_KEY { 0x00 , 0x01 , 0x02 , 0x03 , \
                              0x04 , 0x05 , 0x06 , 0x07 , \ 
                              0x08 , 0x09 , 0x0A , 0x0B , \ 
                              0x0C , 0x0D , 0x0E , 0x0F } 

The Makefile

all: udp-client udp-server
APPS=servreg-hack
CONTIKI=../../..

CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
ifdef WITH_COMPOWER
APPS+=powertrace
CFLAGS+= -DCONTIKIMAC_CONF_COMPOWER=1 -DWITH_COMPOWER=1 -DQUEUEBUF_CONF_NUM=4
endif

#linker optimizations
SMALL=1

ifdef SERVER_REPLY
CFLAGS+=-DSERVER_REPLY=$(SERVER_REPLY)
endif
ifdef PERIOD
CFLAGS+=-DPERIOD=$(PERIOD)
endif

CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include

The period and file sizes of the hello messages are set as:

#ifndef PERIOD
#define PERIOD 20
#endif

#define START_INTERVAL      (10 * CLOCK_SECOND)
#define SEND_INTERVAL       (PERIOD * CLOCK_SECOND)
#define SEND_TIME       (random_rand() % (SEND_INTERVAL))
#define MAX_PAYLOAD_LEN     50

I'm using a python code that processes the log file output to give me the delay between nodes based on the "hello" messages sent from one node to another. I run the simulation for 2 minutes each time.

Below you can see 2 examples:

The first run of the log is where the llsec settings are off and the second run is with the llsec settings on and as you can see there is no delay difference making me believe that the llsec configurations are not working properly or perhaps not enabled at all.

Delay of llsec off and on

Very little documentation exists on this and I'm posting here as a last resort. Any suggestions?

sinap
  • 1
  • What makes you think that the delay should be significantly different? The encryption operations are expected to take microseconds, not milliseconds. – kfx Apr 24 '20 at 11:23
  • A better way to check if its working is to sniff the packets, or to add `printf` of the packet contents at the radio driver's transmit function. – kfx Apr 24 '20 at 11:24
  • @kfx thank you for your reply! I expected encryption to have an additional strain on the network resulting in higher delay/power consumption. Can you kindly let me know how I can use the printf to show the contents of the packet? Would it provide more data about the packet than when looking at it by Radio Messages tab with PCAP analyzer? (seen in a tutorial) I've tried Wireshark too but there does not seem to be any difference unless I cannot see the "encryption" part in the contents by the method mentioned above and Wireshark. Any help would be greatly appriciated. Thank you so much! – sinap Apr 24 '20 at 15:17

0 Answers0