Department of Information Technology Subject: SL Class/Sem: T.E./VI Roll Number Batch: List of Experiments No. Name No. Date Remark
Department of Information Technology Subject: SL Class/Sem: T.E./VI Roll Number Batch: List of Experiments No. Name No. Date Remark
Subject: SL Class/Sem:
T.E./VI
Roll Number
Batch:
List of Experiments
No. Name Page Date Remark
No.
1 Study different WSN Open Source Simulators like Contiki 1
Cooja, Cupcarbon.
2 Installation of Contiki Cooja. 3
Subject Incharge
EXPERIMENT NO.1
WSN Opensource Simulators
AIM: To study different WSN opensource simulators like Contiki Cooja, Cupcarbon.
OBJECTIVES:
• To study the basic concepts of programming/sensors/ emulator like cooja etc.
• Conduct a survey of several available literatures in the preferred field of study.
• To improve the team building, communication and management skills of the students.
DESCRIPTION:
Contiki Cooja:
Contiki gained popularity because of its built in TCP/IP stack and lightweight preemptive
scheduling over event-driven kernel which is a very motivating feature for IoT.
Contiki provides multitasking and a built-in Internet Protocol Suite (TCP/IP stack), yet needs
only about 10 kilobytes HYPERLINK "https://en.wikipedia.org/wiki/Kilobyte" of random-access
memory HYPERLINK "https://en.wikipedia.org/wiki/Random-access_memory" (RAM) and 30
kilobytes of read-only HYPERLINK "https://en.wikipedia.org/wiki/Read-only_memory"
HYPERLINK "https://en.wikipedia.org/wiki/Read-only_memory"memory HYPERLINK
"https://en.wikipedia.org/wiki/Read-only_memory" (ROM).
Contiki is designed to run on types of hardware devices that are severely constrained in memory,
HYPERLINK "https://en.wikipedia.org/wiki/Electric_power"power, processing power, and
communication bandwidth. A typical Contiki system has memory on the order of kilobytes, a
power budget on the order of milliwatts, processing speed measured in megaHertz, and
communication bandwidth on the order of hundreds of kilobits/second. Such systems include
many types of embedded systems, and old 8-bit HYPERLINK "https://en.wikipedia.org/wiki/8-
bit" computers.
Contiki provides three network mechanisms: the uIP TCP/IP stack, which provides IPv4
networking, the uIPv6 stack, which provides IPv6 networking, and the Rime stack, which is a set
of custom lightweight networking protocols designed for low-power wireless networks.
The Contiki system includes a network simulator called Cooja, which simulates networks of
Contiki nodes. The nodes may belong to either of three classes: emulated nodes, where the entire
hardware of each node is emulated, Cooja nodes, where the Contiki code for the node is
compiled for and executed on the simulation host, or Java nodes, where the behavior of the node
must be reimplemented as a Java class. One Cooja simulation may contain a mix of nodes from
any of the three classes. Emulated nodes can also be used to include non-Contiki nodes in a
simulated network.
Protothreads are cooperatively scheduled. Thus, a Contiki process must always explicitly yield
control back to the kernel at regular intervals. Contiki processes may use a special protothread
construct to block waiting for events while yielding control to the kernel between each event
invocation.
CupCarbon:
CupCarbon is a Smart City and Internet of Things Wireless Sensor Network (SCI-WSN)
simulator. Its objective is to design, visualize, debug and validate distributed algorithms for
monitoring, environmental data collection, etc., and to create environmental scenarios such as
fires, gas, mobiles, and generally within educational and scientific projects. Not only it can help
to visually explain the basic concepts of sensor networks and how they work; it may also support
scientists to test their wireless topologies, protocols, etc.
CupCarbon offers two simulation environments. The first simulation environment enables the
design of mobility scenarios and the generation of natural events such as fires and gas as well as
the simulation of mobiles such as vehicles and flying objects (e.g. UAVs, insects, etc.). The
second simulation environment represents a discrete event simulation of wireless sensor networks
which takes into account the scenario designed on the basis of the first environment.
Networks can be designed and prototyped by an ergonomic and easy to use interface using the
OpenStreetMap (OSM) framework to deploy sensors directly on the map. It includes a script
called SenScript, which allows to program and to configure each sensor node individually. From
this script, it is also possible to generate codes for hardware platforms such as Arduino/XBee.
This part is not fully implemented in CupCarbon, it allows to generate codes for simple networks
and algorithms.
CupCarbon simulation is based on the application layer of the nodes. This makes it a real
complement to existing simulators. It does not simulate all protocol layers due to the complex
nature of urban networks which need to incorporate other complex and resource consuming
information such as buildings, roads, mobility, signals, etc.
CupCarbon offers the possibility to simulate algorithms and scenarios in several steps. For
example, there could be a step for determining the nodes of interest, followed by a step related to
the nature of the communication between these nodes to perform a given task such as the
detection of an event, and finally, a step describing the nature of the routing to the base station in
case that an event is detected. The current version of CupCarbon allows to configure the nodes
dynamically in order to be able to split nodes into separate networks or to join different networks,
a task which is based on the network addresses and the channel. The energy consumption can be
calculated and displayed as a function of the simulated time. This allows to clarify the structure,
feasibility and realistic implementation of a network before its real deployment. The propagation
visibility and the interference models are integrated and includes the ZigBee, LoRa and WiFi
protocols. CupCarbon represents the main kernel of the ANR project PERSEPTEUR that AIMs
to develop algorithms for an accurate simulation of the propagation and interference of signals in
a 3D urban environment.
CONCLUSION:
We conducted a survey of several available simulators in the preferred field of study and
demonstrated an ability to work in teams and manage the conduct of the research study.
EXPERIMENT NO.2
Installation of Contiki
DESCRIPTION:
Steps to install Contiki Cooja:
Step 1: Download Contiki from:
http://downloads.sourceforge.net/project/contiki/Contiki/Contiki HYPERLINK
"http://downloads.sourceforge.net/project/contiki/Contiki/Contiki
%202.7/contiki-2.7.zip" HYPERLINK
"http://downloads.sourceforge.net/project/contiki/Contiki/Contiki%202.7/contiki-
2.7.zip"2.7/contiki-2.7.zip
Step 2: Download and install VMWare Player.
Step 3: Unzip the file
unzip contiki-2.7.zip
Step 4: Rename the file to
Contiki mv contiki-
2.7 contiki
Step 5: Start instant contiki
Boot Ubuntu
Start
Instant Contiki by running InstantContiki2.7.vmx. Wait for the virtual Ubuntu Linux boot up.
Log in
Log into Instant Contiki. The password is user.
Congratulations! Now that we have Instant Contiki up and running, we will start Cooja.
Step 6: Start Cooja
We will now compile and start Cooja, the Contiki network simulator.
Open a terminal window
To start
Cooja, first open a terminal window.
Start Cooja
In the terminal window, go to the Cooja directory:
cd contiki/tools/cooja
Start Cooja with the command:
ant run
Wait for Cooja to start
When Cooja first starts, it will first compile itself, which may take some time.
When Cooja
is compiled, it will start with a blue empty window.
Now that Cooja is up and running, we can try it out with an example simulation.
CONCLUSION:
We successfully installed the Contiki Cooja and studied and enhanced software/ hardware skills.
EXPERIMENT NO.3
in Contiki Cooja.
OBJECTIVE:
• To build and test the program successfully.
• To learn different types of sensors from Motes families.
DESCRIPTION:
Start Cooja
In the terminal window, go to the Cooja directory:
cd contiki/tools/cooja
Start Cooja with the command:
ant run
Wait for Cooja to start
When Cooja first
starts, it will first compile itself, which may take some time.
When Cooja is compiled, it will start with a blue empty window.
Now that Cooja is up and running, we can try it out with an example simulation.
Step 3: Run Contiki in
simulation Create a new
simulation
Create new simulation
Click the File menu
and click New simulation....
Set simulation options
Cooja now opens up the Create new simulation dialog. In this dialog, we may choose to give our
simulation a new name, but for this example, we'll just stick with My simulation. Click the
Create button.
Simulation windows
Cooja brings up the new simulation. The Network window, at the top left of the screen, shows all
the motes in the simulated network - it is empty now, since we have no motes in our
simulation. The
Timeline window, at the bottom of the screen, shows all communication events in the simulation
over time - very handy for understanding what goes on in the network. The Mote output window,
on the right side of the screen, shows all serial port printouts from all the motes. The Notes
window on the top right is where we can put notes for our simulation. And the Simulation control
window is where we start, pause, and reload our simulation.
The header file “contiki.h” which is included at the very first contains all the declarations of the
Contiki operating systems abstractions. stdio.h is included only because I have used printf()
function inside the program. The Macro in third line declares a new Contiki process. First
parameter of it is the variable for the process and the second parameter is a string name for the
process. Fourth line, specify that this process should be started in the startup of the Contiki
operating system. Therefore, when the hardware device which will be the destination of compiled
code switches on, our process also begins running.
Fifth line of the code opens the definition of our process. As the first parameter, we pass the
process’ variable which is my_first_process in this scenario. The second parameter is ‘ev’ which
is the event parameter. It can be used to make the program responding to events that occur in the
system. The third parameter ‘data’ can be used to receive some data which are coming with those
events.
The rest of the instructions of the Contiki process will be included inside two important lines
which are PROCESS_BEGIN() and PROCESS_END(). In our Contiki process we just print a
string. This output goes to the standard output in the platform where our code will be running. If
you compile this code to native platform and run in the terminal, the output will be printed in the
terminal. If you run this in a mote, the output most probably will go to the UART port of the
mote. However, this behavior depends on the design of a particular WSN mote.
Step 1: Open the terminal window.
Step 2: In the terminal window, go to the hello world example folder.
cd /examples/hello-world
Step 3: Compile the code for the native platform (to be used when no mote is connected to the laptop.)
make TARGET=native
If there is any bug during compilation which says "#include<curses.h>: No such file or
directory" you need to do the following on Ubuntu.
If you are currently in the terminal, type "sudo apt-get install libncurses5-dev"(for which you
should have installed the "apt" for 32-bit using "sudo dpkg -i
apt_0.8.16~exp12ubuntu10.10_i386.deb" and for 64-bit using sudo dpkg -i
apt_0.8.16~exp12ubuntu10.10_amd64.deb")
You need to also install a version of javac compiler using the command "sudo apt-get install
openjdk- 7-jdk".
Step 4: Once the compilation is over, run the Hello World program.
./hello-world.native
Step 5: You should be seeing the following on the terminal:
Contiki 3.0 started with IPV6, RPL
Rime started with address
1.2.3.4.5.6.7.8
MAC nullmac RDC nullrdc NETWORK sicslowpan
Tentative link-local IPv6 address
fe80:0000:0000:0000:0302:0304:0506:0708 Hello, world
The code will appear to hang, however, it is still running on Contiki, but not producing any
output as the Hello World program is finished. Press Ctrl-C to quit.
CONCLUSION: We understood the basic programming in Contiki and implemented Hello World
program successfully.
EXPERIMENT NO. 4
Broadcasting, RPL and LED Blinking in Contiki
• Add motes to simulation: Cooja will now ask us if we want to add motes from the
newly created mote type to the simulation. We change the number of motes to add in the
Number of motes field to 8.
• Add the motes: We click the Add motes button to add the motes to the simulation.
• Start the simulation: We can now see the 8 motes we added to the simulation
in the Network window. Click the Start button to start the simulation.
• Pause the simulation: We see printouts from the simulated motes appearing in the Mote
output window. The Network window shows communication going on in the
network. The Timeline window shows communication and radio events over time - the small
gray lines are ContikiMAC periodically waking the radio up. We can click the Pause button to
pause the simulation.
• Watch Output: The motes output and debug messages can be seen in the Motes
Output window. You can filter the output based on the node ID:node_id to watch a
particular node. You can also watch particular debug messages by filtering them. The
other useful functions of the Motes Output are File, Edit and View. The File option helps
in saving the output to a file. The Edit has the option of copying the output - either full or
a particular selected messages. You can also clear the messages using the Clear all
messages option. You can use these messages saved in file to make observations and plot
graphs according to the objective of your experiment.
• Simulating LED using
Cooja: #include<contiki.h>
#include<dev/leds.h>
PROCESS(blink_process,
"Blink");
AUTOSTART_PROCESSES(&blink_process); PROCESS_THREAD(&blink_process, ,ev,data )
{
PROCESS_EXITHANDLER(goto
exit); PROCESS_BEGIN();
While(1){
static struct etimer et;
etimer_set(&et,
CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
leds_on(LEDS_ALL);
etimer_set(&et,
CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNT
IL(c)
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
leds_off(LEDS_ALL);
}
exit:
leds_off(LEDS_
ALL);
PROCESS_END(
);
}
OUT
PUT:
• Broadcasting:
• RPL:
• LED:
EXPERIMENT No. 5
Installation of Cupcarbon and executing Hello World Program
Output:
CupC
arbon Window:
EXPERIMENT No. 6
LED Blinking in Cupcarbon and Running on
Arduino
AIM: Write a program for blinking LED using cupcarbon and run it on Arduino.
REQUIREMENTS: PC/Desktop, Cupcarbon, Arduino Uno, Arduino.
THEORY:
• Open the cupcarbon.jar file
• Create a new project by clicking on Project>New Project. Name the project
• Go to Add> Add Sensor Node to add a sensor to the network. Click on the place
on the whitespace where you wish to position the node.
• Use the SenScript window icon to add a script to the node.
• Type the following program into the
editor: loop
mark 1
delay 1000
mark 0
delay 1000
• Save the file using as .csc extension.
• Right Click on the Sensor and select Assign Script and select the name of the script.
• Click on Run to observe the output.
• Go to Simulation> Generate Arduino Code
• Connect the Arduino Board to the PC and Execute the code using Arduino.
CONCLUSION: Thus we have successfully executed Blinking LED program on Cupcarbon and
Arduino.
Output:
L
ED Blinking using CupCarbon:
LED
Blinking on Arduino:
EXPERIMENT NO. 7
Communication Between 2 Sensors in Cupcarbon and
Arduino
AIM: Write a program for communication between two or more sensors using Cupcarbon and
run it on Arduino.
REQUIREMENTS: PC/Desktop, Cupcarbon, Arduino Uno, Arduini.
THEORY:
• Open the cupcarbon.jar file
• Create a new project by clicking on Project>New Project. Name the project
• Go to Add> Add Sensor Node to add a sensor to the network. Click on the place
on the whitespace where you wish to position the node. Repeat the same for another
node.
• Use the SenScript window icon to add a script to the respective node.
• Type the following Programs into the editor iin 4 separate files:
//Node1 as Receiver //Node 1 as
Transmitter Loop loop
wait send 1
read v delay 1000
mark $v delay 1000
else end
mark 0
Output:
• Before Transmission:
• During Trassmission:
EXPERIMENT NO. 8
Broadcast Data in Cupcarbon
Programs:
Output:
EXPERIMENT NO. 9
Mobility Sensor and Marker in Cupcarbon
AIM: Write a program to simulate an environment using mobility sensor and marker in cupcarbon to
detect the intruder in system
REQUIREMENTS: PC/Desktop, Cupcarbon, Arduino Uno, Arduini.
THEORY:
• Open the cupcarbon.jar file
• Create a new project by clicking on Project>New Project. Name the project
• Go to Add> Add Sensor Node to add a sensor to the network. Click on the place
on the whitespace where you wish to position the node. Repeat the same for another
node.
• Use the SenScript window icon to add a script to the respective node.
• Type the following Programs into the editor in 2 separate files:
//
Rece
iver
loop
wa
it
rea
dv
ma
rk
$v
//
Transmi
tter
loop
send 1 0 12
delay 1000
send 0 0 12
delay 1000
• Save the files using as .csc extension.
• Right Click on the sensors and select Assign Script and select the name of the respective scripts.
• Configure the simulation parameters: To visualize the result of the simulation, in this
example one assign to the simulation speed the value 500 ms (1/2 second) and to the
arrow speed the value 1000 ms (1 second). The arrows correspond to the send messages.
• Click on Run to observe the output.
• Go to Simulation> Generate Arduino Code
• Connect the Arduino Board to the PC and Execute the code using Arduini.
CONCLUSION: Thus we have successfully demonstrated the concept of broadcasting using
Cupcarbon and Arduino.
Programs:
Output
s:
EXPERIMENT NO. 10
DLPCN Algorithm in Cupcarbon
D-LPCN Algorithm:
CONCLUSION: Thus we have successfully understood and demonstrated D-LPCN algorithm using
Cupcarbon.
Program:
Output: