0% found this document useful (0 votes)
175 views19 pages

Department of Information Technology Subject: SL Class/Sem: T.E./VI Roll Number Batch: List of Experiments No. Name No. Date Remark

The document provides details about different wireless sensor network open source simulators like Contiki Cooja and Cupcarbon. It describes Contiki as an operating system for low-power IoT devices with a TCP/IP stack that requires only 10KB RAM. Cooja is Contiki's network simulator that can simulate nodes as emulated, Cooja, or Java nodes. Cupcarbon simulates sensor network algorithms and scenarios using OpenStreetMap to deploy sensors. It allows programming sensors and generating code for platforms like Arduino. The document also provides steps to install Contiki Cooja simulator.

Uploaded by

Avdhut Tarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
175 views19 pages

Department of Information Technology Subject: SL Class/Sem: T.E./VI Roll Number Batch: List of Experiments No. Name No. Date Remark

The document provides details about different wireless sensor network open source simulators like Contiki Cooja and Cupcarbon. It describes Contiki as an operating system for low-power IoT devices with a TCP/IP stack that requires only 10KB RAM. Cooja is Contiki's network simulator that can simulate nodes as emulated, Cooja, or Java nodes. Cupcarbon simulates sensor network algorithms and scenarios using OpenStreetMap to deploy sensors. It allows programming sensors and generating code for platforms like Arduino. The document also provides steps to install Contiki Cooja simulator.

Uploaded by

Avdhut Tarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

DEPARTMENT OF INFORMATION TECHNOLOGY

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

3 Run Basic programs of cooja (Hello_world). 5

4 Simulate Broadcasting, RPL and LED on cooja. 10

5 Installation of cupcarbon and Run basic Hello_World 19


Program using cupcarbon.
6 Write a program for blinking LED using cupcarbon and run 23
it on Arudino.
7 Write a program for communication between two or more 26
sensors using cupcarbon and run it on Arudino.
8 Write a program to broadcast a data using Cupcarbon. 29

9 Simulate a environment with the help of mobility sensor and 33


marker in Cupcarbon to detect the intruder in system.
10 Write a program to implement DLPCN algorithm in 36
Cupcarbon.

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 is an operating HYPERLINK "https://en.wikipedia.org/wiki/Operating_system" HYPERLINK


"https://en.wikipedia.org/wiki/Operating_system"system HYPERLINK
"https://en.wikipedia.org/wiki/Operating_system" for networked, memory-constrained systems
with a focus on low-power wireless Internet of Thingsdevices. Extant uses for Contiki include
systems for street lighting, sound monitoring for smart cities, radiation monitoring, and alarms. It
is open-source HYPERLINK "https://en.wikipedia.org/wiki/Open-source_software" HYPERLINK
"https://en.wikipedia.org/wiki/Open-source_software"software HYPERLINK
"https://en.wikipedia.org/wiki/Open-source_software" released under a BSD HYPERLINK
"https://en.wikipedia.org/wiki/BSD_licenses" HYPERLINK
"https://en.wikipedia.org/wiki/BSD_licenses"license.

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.

To run efficiently on small-memory systems, the Contiki programming model is based on


protothreads. A protothread is a memory-efficient programming abstraction that shares
features of both multithreading and event-driven HYPERLINK
"https://en.wikipedia.org/wiki/Event-driven_programming" HYPERLINK
"https://en.wikipedia.org/wiki/Event-driven_programming"programming to attain a low memory
overhead of each protothread. The kernel invokes the protothread of a process in response to an
internal or external event. Examples of internal events are timers that fire or messages being
posted from other processes. Examples of external events are sensors that trigger or incoming
packets from a radio neighbor.

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

Cooja AIM: To install Contiki Cooja Simulator.


OBJECTIVE:
• To install Contiki Cooja.
• To study the basic concepts of programming/sensors/ emulator like cooja etc

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

Basic programs of cooja

(Hello_world) AIM: To write and execute Hello World program

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.

Add motes to the


simulation Add motes
Before we can simulate our network, we must add one or more motes. We do this via the Motes
menu, where we click on Add motes. Since this is the first mote we add, we must first create a
mote type to
add. Click Create new mote type....and select one of the available mote types. For this example, we
click Sky mote. to create
an emulated Tmote Sky mote type.
Create a new mote type
Cooja opens the Create Mote Type dialog, in which we can choose a name for our mote type as
well as the Contiki application that our mote type will run. For this example, we stick with the
suggested name, and instead click on the Browse button on the right hand side to choose our
Contiki application.

Find example in Contiki application


We go to the directory /home/user/ examples/hello-world/
The below program is the simplest Contiki program you can write which contains most of the necessary
components that should be included in any Contiki program.
1: #include “contiki.h”
2: #include <stdio.h>
3: PROCESS(my_first_process, “Hello World Process”);
4:
AUTOSTART_PROCESSES(&my_first_process
); 5: PROCESS_THREAD(my_first_process, ev,
data) 6: {
7: PROCESS_BEGIN();
8: printf(“Hello World!\n”);
9: PROCESS_END();
10: }
Save this file as hello_world.c

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

AIM: To simulate broadcasting, RPL and Led on


Cooja. REQUIREMENTS: PC/Desktop, VMWare,
Contiki Cooja. THEORY:
• About Cooja simulations: Cooja is a highly useful tool for Contiki development as it
allows developers to test their code and systems long before running it on the target
hardware. Developers regularly set up new simulations both to debug their software and
to verify the behaviour of their systems.
• Create a 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.

• Simulating Broadcast with Cooja:


• Add motes: Before we can simulate our network, we must add one or more motes. We
do this via the Motes menu, where we click on Add motes. Since this is the first mote
we add, we
must first create a mote type to add. Click Create new mote type... and select one of the
available mote types. For this example, we click Sky mote. to create an emulated Tmote
Sky
mote type.
• Create a new mote type: Cooja opens the Create Mote Type dialog, in which we can
choose a name for our mote type as well as the Contiki application that our mote type
will run. For this example, we stick with the suggested name, and instead click on the
Browse button on the
right hand side to choose our Contiki application.
• Find example Contiki application: We go tothe
directory /home/user/contiki HYPERLINK
"https://github.com/contiki-os/contiki/tree/master/examples"/examples HYPERLINK
"https://github.com/contiki-os/contiki/tree/master/examples/rime"/rime/example-
broadcast.c. This directory holds a number of Contiki applications that provide examples
for how to do simple UDP communication over IPv6.
• Specify application C source file: Choose the file broadcast-example.c. This file
contains a simple Contiki application that randomly broadcasts a UDP packet to its
neighbors. Click the Open button to choose the file.
• Compile Contiki and the application: Now Cooja will verify that the selected Contiki
application compiles for the platform that we have selected. Click the Compile button.
This will take some time the first time around, expect it to take a minute at least. The
compilation output will show up in the white panel at the bottom of the window.
• Create the mote type: Click the Create button to create the mote type. The window will close.

• 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.

• Simulating RPL using Cooja:


• Run Cooja: Go to your Contiki folder(contiki-2.7) and then go to /tools/cooja directory.
Run the command sudo ant run to open up a cooja GUI.
• Start a New Simulation: Choose a New Simulation from the File drop down menu (or
alternatively can do Ctrl+N). Give a name to your simulation in the Simulation Name
field. Choose the Directed Graph Radio Medium(DGRM) from the drop down menu for
the Radio Medium under Advanced Settings. Click on the Create
button. The new simulation created will open up multiple windows as shown.
• Add Sink Mote: Add a mote of the type Sink. Here udp-sink code from the rpl-collect
example (/examples/ipv6/rpl-collect/) is being used. However you can upload any code
you want to implement according to your application. Click on Compile button. A Create
button will appear on successful compilation which adds number of motes as desired in
the network. Here only one sink is used.
• Add Sender Motes: Add a mote of the type Sink. Here udp-sender code from the rpl-
collect example (/examples/ipv6/rpl-collect/) is being used. However you can upload any
code you want to implement according to your application. Compile the code and create
many motes of this type according to the topology. Placement of the mote does not
matter here. You can place your motes anywhere in the graph. Since this is different than
the distance model, we make explicit links between the motes for communication, hence
distance between them makes no difference.
• Add Communication Links: 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 add multiple links in this way. After adding the links close the dialog
box.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. Also you can Delete an existing one using
the remove option. The Import option helps in importing any data file which already has
these link connections and parameters specified in it.
• Run Simulation: Run the simulation by using the Start option in the Simulation
Control window. This will initiate the motes and allocate all with a new Rime address
and other initialization processes.

• 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(
);
}

CONCLUSION: We successfully simulated broadcasting, RPL and Led on Cooja.

OUT
PUT:

• Broadcasting:

• RPL:

• LED:

EXPERIMENT No. 5
Installation of Cupcarbon and executing Hello World Program

AIM: Installation of cupcarbon and basic “Hello World” program using


cupcarbon.
REQUIREMENTS: PC/Desktop, Cupcarbon.
THEORY:
Installing Cupcarbon:
• Download the CubCarbon simulator tools from the given
link: http://www.cupcarbon.com/download.html
• Now, open your terminal ctrl+alt+t.
• Update the terminal before install by the command sudo apt-get update
• After update please check your system have latest version of java by the command "java -
version", if not then install from the given command.
• sudo apt-get install default-jdk
• sudo add-apt-repository ppa:webupd8team/java
• sudo apt-get install oracle-java8-installer
• sudo apt-get install oracle-java8-set-default
• Now, after installation java environment in your system, then extract your downloaded
CupCarbon.zip file.
• Extract manually by right click on your downloaded CupCarbon.zip file and extract.
• Else extract by command: chmod +x/cupcarbon/cupcarbon.jar
• Now, open the extracted cupcarbon folder and then double click on cupcarbon.jar file.
Executing Hello World:
• 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
print Hello
World stop
• 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.
CONCLUSION: Thus we have successfully installed cupcarbon and executed Hello World
program on it.

Output:

CupC
arbon Window:

Creating New Project:


Adding the sensor:
Hello World Script:

Assigning Script to the node:

Output on Running the script:

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

// Node 2 Receiver // Node 2 as


Transmitter loop loop
wait send A
read v delay 1000
if($v==A) send B
mark 1 delay 1000

else end

mark 0

• Save the files using as .csc extension.


• Right Click on the sensors and select Assign Script and select the name of the respective scripts.
• 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 communication using Cupcarbon and


Arduino.
Programs:

Output:
• Before Transmission:
• During Trassmission:

EXPERIMENT NO. 8
Broadcast Data in Cupcarbon

AIM: Write a program to broadcast data on cupcarbon.


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:

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

AIM: Write a program to implement DLPCN algorithm in cupcarbon


REQUIREMENTS: PC/Desktop, Cupcarbon.
THEORY:
The D-LPCN algorithm allows to find the boundary sensor nodes of a network. It starts from any
boundary sensor node (for example, the one in the extreme left). Then, each node calculates the
angles formed by the previously found boundary node and each one of its neighbours; and then it
chooses the node that forms the
smallest angle as the next boundary node. To write this algorithm, we will use 3 types of
messages. A message AC to ask the neighbours to send their coordinates, a message CS for
sending the coordinates and a message SN to inform a sensor that it is a boundary node. The
script of the DLPCN algorithm is given as below. First, (lines 1 to 3), each sensor node will
assign to the variable cid its current id and it calculates its current coordinates cx and cy. Since
this script is executed by all the sensor nodes of the network, we will add the variable first (here
it is equal to 49, which represents the extreme left sensor node) to designate the starting node.
Some parts of the script will be executed only by the first node. Then, (lines 5 to 10), only the
first node will execute this part. It will execute it once. That is why in line 6, the variable first is
set to 0. To calculate the angles formed by the previous boundary node and its neighbours. In
lines 5 to 8, we will consider that there is a virtual sensor node, which is situated in the left part
of the starting node, which have the coordinates (px=cx-1 and py=cy). Then, a message SN will
be considered since the starting node is also a boundary node. The line 10 (SN message) will be
followed directly by line 22. The block 23 to 26 represents the stop condition, which represents
visiting twice the starting node. In the first time, the variable first is equal to 0, then the stop
condition is not verified, and the variable first will be set to -1 (line 26). However, if we come
back to this block a second time, the condition (first == –1) is verified, then the stop command
will be called. If the stop condition is not verified, then, as the considered block is executed after
receiving an SN message, which means that the receiver is a boundary sensor node. The line 27
will mark this sensor, and then, from line 28 to 45 the process of asking and receiving the
coordinates of the neighbours will be started. For each received message (coordinates) the angle
will be calculated and compared with the previously calculated angle in order to determine the
smallest one. Line 28 allows to get the value of the coordinates px and py of the previous
boundary node. Line 29 forms a message with an angle equal to 10 radian. Line 30 is used to get
the number of neighbours and their identifiers. Lines 31 to 34 are used to send to each neighbour
node an AC message to ask it to send its coordinates. Lines 35 to 45 are used to wait for the
answer of the neighbours. If a CS message is received, then the coordinates are sent and can be
used to calculate the angle (line 40) in order to select the minimum one (line 42). The function
smin allows to find the minimum value between two values extracted from messages formed by
the id of a sensor node and its corresponding variable. Once the minimum angle is found as well
as its corresponding sensor node (id), then a message SN will be sent (lines 46 and 47) to inform
the obtained sensor node that it is a boundary sensor node. Note that, the lines 17 to 20 are
executed by the sensor nodes that receive the message AC in order to send their coordinates (with
message CS: line 18). For simplicity, we consider as stop condition when the first starting node is
visited twice, which is not the real stop condition.

D-LPCN Algorithm:

CONCLUSION: Thus we have successfully understood and demonstrated D-LPCN algorithm using
Cupcarbon.

Program:
Output:

You might also like