Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

cooja final

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

CoAP (Constrained Application Protocol) is a lightweight, UDP-based protocol designed for IoT

networks but has inherent vulnerabilities such as plaintext communication, replay attacks, and resource
exhaustion. Using Cooja to simulate an IoT network with CoAP devices, traffic can be captured via its
packet sniffer and analyzed in Wireshark to identify vulnerabilities like unencrypted payloads,
unauthorized access, or flooding patterns. To secure CoAP-based networks, it is essential to enable
DTLS for encryption, implement tokens or nonces to prevent replay attacks, apply rate limiting to
mitigate DoS risks, and secure routing protocols like RPL. These measures enhance security in both
simulated environments and real-world deployments.
In our course of study we decided to use Cooja coniki network IOT simulation to implement our
poject;
Cooja, a network simulator for IoT, is widely used to emulate wireless sensor networks (WSNs). It
allows you to simulate CoAP-based IoT networks using devices running Contiki OS.
Here is a step by step instruction on how to install contiki on Ubuntu 22 or Debian 12

Install development tools for Contiki-NG


Start by installing some necessary packages:
$ sudo apt update
$ sudo apt install build-essential doxygen git git-lfs curl wireshark python3-
serial srecord rlwrap

On recent Ubuntu releases, you may get an error ifconfig: not found and netstat: not
found when trying to run tunslip6. If this is the case, use apt to install net-tools.

While installing Wireshark, select enable the feature that lets non-superuser capture packets (select
“yes”). Now add yourself to the wireshark group:
$ sudo usermod -a -G wireshark <user>

Then you will - if you intend to develop or re-configure examples - also need to install an code/text
editor. There are many alternatives so we leave that up to you!

Install ARM compiler


An ARM compiler is needed to compile for ARM-based platforms such as CC2538DK and Zoul.
You should download it from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
or you can grab an older version from launchpad.net.
$ wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/9-
2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
$ tar -xjf gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
This will create a directory named gcc-arm-none-eabi-9-2020-q2-update in your current
working dir. Add
<working-directory>/gcc-arm-none-eabi-9-2020-q2-update/bin to your path.

Install MSP430 compiler


A compiler for MSP430 is needed to use the MSPSim emulator in Cooja. It is possible to install a GCC
compiler for MSP430 from the Ubuntu package repository (sudo apt install gcc-msp430)
but that version is too old to support the full memory of newer versions of MSP430.
The preferred version of MSP430 gcc is 4.7.2. To install it on /usr/local if you’re using 64-bit
Linux, run:
$ wget -nv http://simonduq.github.io/resources/mspgcc-4.7.2-compiled.tar.bz2 && \
tar xjf mspgcc*.tar.bz2 -C /tmp/ && \
cp -f -r /tmp/msp430/* /usr/local/ && \
rm -rf /tmp/msp430 mspgcc*.tar.bz2

If desired, a script to compile MSP430 GCC 4.7.2 from source can be found here.

Install Java for the Cooja network simulator


$ sudo apt install default-jdk ant
$ update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java):
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Nothing to configure.

Install JTAG software for CC2538 (optional)


Many platforms such as Zolertia Zoul can be programmed via builtin USB but for programming a
device using a JTAG dongle, Segger J-Link has been verified to work well with CC2538. The software
for Segger J-Link can be downloaded from Segger. Download the installation file for Debian Linux.
$ sudo dpkg --install jlink_4.98.5_i386.deb

Install a CoAP client (optional)


Optionally and if you want to use CoAP examples, you can install the CoAP client coap-cli:
$ sudo apt-get install -y npm \
&& sudo apt-get clean \
&& sudo npm install coap-cli -g \
&& sudo ln -s /usr/bin/nodejs /usr/bin/node

Install the Mosquitto MQTT broker and accompanying clients (optional)


Install Mosquitto, if you need MQTT:
$ sudo apt-get install -y mosquitto mosquitto-clients
User access to USB
To be able to access the USB without using sudo, the user should be part of the groups plugdev and
dialout.
$ sudo usermod -a -G plugdev <user>
$ sudo usermod -a -G dialout <user>

Improve stability for CC2538


The modem manager might interfere with the USB for CC2538. Update the configuration with:
echo 'ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16c8",
ENV{ID_MM_DEVICE_IGNORE}="1"' >> /lib/udev/rules.d/77-mm-usb-device-blacklist.rules

After configuration
Reboot the system after all configurations have been made.

Clone Contiki-NG
$ git clone https://github.com/contiki-ng/contiki-ng.git
$ cd contiki-ng
$ git submodule update --init --recursive

Note: we recommend cloning and then initializing the submodules rather than using git clone --
recursive. The latter results in submodules that use absolute paths to the top-level git, rather than
relative paths, which are more flexible for a number of reasons.

Install development tools for Contiki-NG


Start by installing Xcode Command Line Utilities
$ xcode-select --install

This guide makes extensive usage of homebrew. If you don’t already have it, install it:
$ /usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"

Using homebrew, install a bunch of helper tools, such as git, srecord, doxygen (to build the API
documentation), mosquitto (to test Contiki-NG’s MQTT functionality), tuntap (for tunslip and to run
native examples with networking), rlwrap (for shell history), python (python 3 for running scripts and
pip).
$ brew install git git-lfs srecord doxygen uncrustify ant mosquitto wget libmagic
rlwrap python make gawk
$ brew tap caskroom/cask
$ brew cask install tuntap

You may also need to update your PATH environment variable to use GNU Make 4 when running the
“make” command. This can be set in your shell initialization file (e.g., ~/.zshrc) as follows.
$ echo 'PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"' >> ~/.zshrc

Note that if Homebrew is installed in a different path, you have to modify the command accordingly.

Install some python packages


Those are used/needed by some Contiki-NG Python scripts.
$ pip install intelhex pyserial python-magic

Install the ARM GCC toolchain


An ARM compiler is needed to compile for ARM-based platforms.
Using homebrew
You can install the arm-gcc toolchain using homebrew.
# to tap the repository
$ brew tap contiki-ng/contiki-ng-arm
# to install the toolchain
$ brew install contiki-ng-arm-gcc-bin

This will automatically install the same version as the one currently installed in the docker image and
used by the CI tests.
The formula itself is hosted under contiki-ng/homebrew-contiki-ng-arm
Manual Installation
You should download the toolchain from https://developer.arm.com/open-source/gnu-toolchain/gnu-
rm/downloads or you can grab an older version from launchpad.net.
$ wget https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-
arm-none-eabi-5_2-2015q4-20151219-mac.tar.bz2
$ tar jxf gcc-arm-none-eabi-5_2-2015q4-20151219-mac.tar.bz2

This will create a directory named gcc-arm-none-eabi-5_2-2015q4 in your current working


dir. Add <working-directory>/gcc-arm-none-eabi-5_2-2015q4/bin to your path.

You can also try using the latest version, but be prepared to get compilation warnings and/or errors.

Install the MSP430 toolchain


The best way to achieve this on OS X is through homebrew, using a formula provided in a tap. Follow
the instructions here: https://github.com/tgtakaoka/homebrew-mspgcc

Install Java JDK for the Cooja network simulator


Nothing exciting here, just download and install Java for OSX. You will need the JDK 17, not just the
runtime.

Install a CoAP client (libcoap)


Optionally and if you want to use CoAP examples, you can install the CoAP client distributed with
libcoap.
Firstly you will need the following packages:
 automake
 autoconf
 libtool
 pkg-config
They can be installed with homebrew:
$ brew install automake pkg-config libtool autoconf

Then clone libcoap, compile and build it:


$ git clone --recursive https://github.com/obgm/libcoap.git
$ cd libcoap/
$ ./autogen.sh
$ ./configure --disable-doxygen --disable-documentation --disable-shared
$ make
$ make install

This will install coap-client under /usr/local/bin


$ coap-client
coap-client v4.2.0alpha -- a small CoAP implementation
(c) 2010-2015 Olaf Bergmann <bergmann@tzi.org>

usage: coap-client [-A type...] [-t type] [-b [num,]size] [-B seconds] [-e text]
[-m method] [-N] [-o file] [-P addr[:port]] [-p port]
[-s duration] [-O num,text] [-T string] [-v num] [-a addr] [-U]

[-u user] [-k key] [-r] URI


[...]

Clone Contiki-NG
$ git clone https://github.com/contiki-ng/contiki-ng.git
$ cd contiki-ng
$ git submodule update --init --recursive

Note: we recommend cloning and then initializing the submodules rather “git submodule upgate –init
–recursive”. The latter results in submodules that use absolute paths to the top-level git, rather than
relative paths, which are more flexible for a number of reasons.

You might also like