Skip to main content

Contiki Cooja Simulation

Cooja Simulator

Contiki is an open source operating system for sensor networks and other networked embedded devices.  Contiki supports features like uIP stack (IPv6, RPL, 6LoWPAN), HTTP/CoAP, power profiling and others. It also contains a Cooja network simulator specifically designed for Wireless Sensor Networks.
You can set up Contiki with VMware or Virtual-box.
 VMware 
For VMware:-  Install VMware and extract Instant Contiki and start.
For VirtualBox:- use this tutorial for virtual box setup

Cooja Relevant Directories in Contiki







Contiki/tools/Cooja
Type following Command to Run Cooja
ant run
It will open a Cooja blue window


Create New Cooja Simulation
 Select Option File-> New  Simulation







Radio Mediums present in Cooja

Unit Disk Graph Radio Medium UDGM: Distance Loss
Both radio ranges grow with the radio output power indicator. The range parameters are multiplied with [output power]/ [maximum output power]. 
 For example, if the transmission range is 100m, the current power indicator is 50, and the maximum output power indicator is 100, then the resulting transmission range becomes 50m.For radio transmissions within range, two different success ratios are used [0.0-1.0]: one for successful transmissions, and one for successful receptions. 
If the transmission fails, no radio will hear the transmission.   
If one of the receptions fail, only that receiving radio will not receive the transmission, but will be interfered throughout the entire radio connection. 
For UDGM with Distance Loss, the received radio packet signal strength grows inversely with the distance to the transmitter.
TX and RX ratios are just random variables that are added to the sending or reception of a packet to allow the simulation of random errors in TX or RX respectively.
The Unit Disk Graph Radio Medium abstracts radio transmission range as circles. It uses two different range parameters: one for transmissions, and one for interfering with other radios and transmissions.

The TX range is the range in which the transmitted packet can be received correctly by any node within this range. while the interference range is the range in which the transmission can be heard but the transmitted packet cannot be received correctly. outside of these two ranges, the packet cannot be heard.
A collision will be sensed if a node tries to transmit while it lies in the TX or INT range of a node that is sending at the same time. if you are using CSMA, the packet will be retransmitted after a random back-off time. if not, then the packet will be dropped.




No Radio Medium

No data is ever transferred through this medium


Multi-path Ray-tracing radio medium (MRM)
 MRM is an alternative to the simpler radio mediums available in COOJA. It is packet based and uses a 2D ray-tracing approach to approximate signal strength attenuation between simulated radios. Currently the ray-tracing only supports reflections and refractions through homogeneous obstacles.MRM uses a configurable but common transmission power for all radios.MRM provides two plugins: one for visualizing the radio environment, and one for configuring the radio medium parameters.Future work includes adding support for diffraction and scattering. MRM supports both noise source radios and directional antenna radios.












Directed Graph Radio Medium(DGRM)

MRM and DGRM do not consider radio output power in the current version.DGRM simply never checks the output transmission power when creating the radio connections, but fully relies on the configured edges. Add two communication links between each set of nodes so that the communication can be bidirectional. Click on Tools->DGRM Links... This will open a DGRM Configurator Dialog box. Click on Add. Select source and destination nodes and again click on add. This will add a unidirectional link from the source to destination node. For a bidirectional link, you need to add one more link with source and destination nodes switched.You can change other parameters of the link such as RX ratio, RSSI, LQI and Delay according to your application. These parameters affect the individual link quality eg. RX ratio affect the ETX values. So to test your application under various Link Quality conditions these parameters can be changed.


 Contiki motes platforms
A simulated Contiki Mote in COOJA is an actual compiled and executing Contiki system. The system is controlled and analysed by COOJA. This is performed by compiling Contiki for the native platform as a shared library, and loading the library into Java using Java Native Interfaces (JNI). Several different Contiki libraries can be compiled and loaded in the same COOJA simulation, representing different kinds of sensor nodes (heterogeneous networks). COOJA controls and analyses a Contiki system via a few functions. For instance, the simulator informs the Contiki system to handle an event, or fetches the entire Contiki system memory for analysis. This approach gives the simulator full control of simulated systems. Unfortunately, using JNI also has some annoying side-effects. The most significant is the dependency on external tools such as compilers and linkers and their run-time arguments. COOJA was originally developed for Cygwin/Windows and Linux platform, but has later been ported to MacOS.
Create motes:
Motes-> Add Motes-> Create New Mote -> (Select platform)

Below example for Z1 mote (Udp client server application 
RPL Client:- Contiki/examples/rpl-udp/udp-client.
RPL Server:- Contiki/examples/rpl-udp/udp-server.c








Contiki Simulation  















Contiki simulation import windows:
 Network:- Shows the location of each node in the network. Can be used to visualize the status of each node including LEDs, mote types, radio ranges, mote IDs, addresses, print outputs.   
Simulation Control:- This panel is used to Start, Pause, Reload or execute Steps of the simulation. It shows the time of execution and the speed of simulation. It means that we can run the events several times faster than it would take in real-time execution.  
Mote output:- Shows all output of serial interface of the nodes 
Simulation Information:- Shows the simulation information like status of simulation stopped/running, time, number of motes present along with different types of motes present and Radio Medium of simulation. 
Radio Messages:- It shows capured 6lowpan packets like UDP, DIO,DAO, IPV6 packets.
TimeLine:- It shows radio transmitter status, time and transmitted packet.
Notes:- This is a simple notepad for taking notes about the simulation.

Thanks & Regards,
Vaibhav




Comments

Popular posts from this blog

Touch Sensor Module along with Small DC Motor Project for Arduino

Touch Sensor with Arduino With Following tutorial, you will be able to use Arduino digital input and output pins. To replicate exact results of this tutorial you will be required following 1. Arduino Uno 2. Capacitive Touch sensor  Buy Now 3.  Small 3V DC Toy Motor For Arduino Buy Now Procedure:  Connect Arduino Uno to PC for power and programming Connect Touch sensor's VCC pin to Arduino 3.3V output pin. Connect Touch Sensor's GND pin to any of Arduino ground pin. Connect Touch Sensor's SIG input to any digital input of Arduino pin (1-13) I am connecting to digital pin 3  Connect DC motor one leg to Digital Pin 13 and another leg to ground. Program Arduino with the following sketch. #define TOUCH 3 //the touch sensor is connected to D3 int DCMOTOR = 13; // pin for the DC motor.    void setup()  { pinMode(DCMOTOR, OUTPUT); pinMode(TOUCH, INPUT); }    void loop()  { int sensorValue = digitalRead(TOUCH);

Welcome Note

Smart Embedded Creations  Smart Embedded Creations is a new blog for the embedded enthusiast. We find thousands of websites and solutions on the particular embedded idea, but many times it misses the small things which author assumes that everyone knows and he skips it. Also, many facts from an industry point of view are missing. In my blog, I will try to concentrate on such small things which actually very simple but very essential for embedded development. I will be addressing introduction to few embedded open source platforms, few firmware solutions, embedded Linux guide, IOT platform and many more Please let me know by your comments so that together we can build a better-embedded world. Thanks & Regards, Vaibhav Kambli