title: How to enable LLSEC in Contiki / Cooja simulator?
body: <p>I'm trying to encrypt my "hello" messages in a simulation in Contiki 3.0</p>
  
  <p>I'm doing the software implementation of LLSEC (link-layer security) layer as advised in <a href="https://stackoverflow.com/questions/37382634/how-to-enable-message-encryption-in-contiki-cooja-simulator">this</a> question's answers.</p>
  
  <p>The example I'm using for my simulation is the IPV6 rpl-udp udp-client.c and udp-server which can be seen <a href="https://github.com/contiki-os/contiki/tree/master/examples/ipv6/rpl-udp" rel="nofollow noreferrer">here</a>.</p>
  
  <p>I have followed the instructions as per documentation <a href="https://github.com/contiki-os/contiki/tree/master/core/net/llsec/noncoresec" rel="nofollow noreferrer">here</a> and created a project-conf.h file and have the Make file referring to it as seen below:</p>
  
  <p>project-conf.h</p>
  
  <pre><code>#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 } 
  </code></pre>
  
  <p>The Makefile</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The period and file sizes of the hello messages are set as:</p>
  
  <pre><code>#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
  </code></pre>
  
  <p>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.</p>
  
  <p>Below you can see 2 examples:</p>
  
  <p>The first run of the log is where the llsec settings are <strong>off</strong> and the second run is with the llsec settings <strong>on</strong> 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.</p>
  
  <p><a href="https://i.stack.imgur.com/xTq38.jpg" rel="nofollow noreferrer">Delay of llsec off and on</a></p>
  
  <p>Very little documentation exists on this and I'm posting here as a last resort. Any suggestions?</p>