You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
241 lines
4.5 KiB
241 lines
4.5 KiB
5 years ago
|
= IoT Wireless !
|
||
|
Apostolos rootApostolos@swarmlab.io
|
||
|
// Metadata:
|
||
|
:description: IoT
|
||
|
:keywords: iot, swarm
|
||
|
:data-uri:
|
||
|
:toc: right
|
||
|
:toc-title: Πίνακας περιεχομένων
|
||
|
:toclevels: 4
|
||
|
:source-highlighter: highlight
|
||
|
:icons: font
|
||
|
:sectnums:
|
||
|
|
||
|
include::header.adoc[]
|
||
|
|
||
|
|
||
|
{empty} +
|
||
|
|
||
|
|
||
|
|
||
|
== Contiki
|
||
|
|
||
|
Contiki is a state-of-the-art, open
|
||
|
source operating system for sensor networks and other networked embedded
|
||
|
devices
|
||
|
|
||
|
|
||
|
More Info:
|
||
|
https://en.wikipedia.org/wiki/Contiki[^]
|
||
|
|
||
|
|
||
|
== Start Instant Contiki
|
||
|
|
||
|
|
||
|
.Start VMware and load Instant Contiki.
|
||
|
[source,bash]
|
||
|
----
|
||
|
unzip InstantContiki2.7.zip
|
||
|
vmplayer
|
||
|
----
|
||
|
Start image
|
||
|
|
||
|
== Log In
|
||
|
When the login screen appears, log in to Instant Contiki:
|
||
|
|
||
|
.Log In usermode
|
||
|
[source,bash]
|
||
|
----
|
||
|
Username: user
|
||
|
Password: user
|
||
|
----
|
||
|
|
||
|
.Log In sudo
|
||
|
[source,bash]
|
||
|
----
|
||
|
sudo apt update
|
||
|
Password: user
|
||
|
----
|
||
|
|
||
|
== Open a Terminal
|
||
|
|
||
|
After logging in, click on the terminal icon to start a terminal window.
|
||
|
|
||
|
== System test
|
||
|
|
||
|
|
||
|
.compile hello-world
|
||
|
[source,bash]
|
||
|
----
|
||
|
cd contiki/examples/hello-world/
|
||
|
make TARGET=native
|
||
|
----
|
||
|
|
||
|
.Run the Hello World program in Contiki:
|
||
|
[source,bash]
|
||
|
----
|
||
|
./hello-world.native
|
||
|
----
|
||
|
|
||
|
The program should print the words *“Hello, world”* on the screen and then appear to hang.
|
||
|
|
||
|
In reality, Contiki is still running correctly, but will not produce any output because the Hello World program has finished.
|
||
|
[source,bash]
|
||
|
----
|
||
|
Press Ctrl+C on the keyboard to quit.
|
||
|
----
|
||
|
|
||
|
|
||
|
== Simulating Contiki with COOJA
|
||
|
|
||
|
=== Start COOJA
|
||
|
|
||
|
.start
|
||
|
[source,bash]
|
||
|
----
|
||
|
cd contiki/tools/cooja/
|
||
|
ant run
|
||
|
----
|
||
|
|
||
|
[NOTE]
|
||
|
.INFO
|
||
|
====
|
||
|
COOJA compiles, and after a few seconds the simulator appears.
|
||
|
|
||
|
All COOJA simulations are controlled using plugins: small Java programs that interact with simulations and simulated nodes.
|
||
|
|
||
|
When COOJA is started, no simulation is loaded and no plugins are started.
|
||
|
====
|
||
|
|
||
|
=== Create a simulation
|
||
|
|
||
|
A new simulation is created via the menu.
|
||
|
|
||
|
[source,bash]
|
||
|
----
|
||
|
File > New > Simulation
|
||
|
----
|
||
|
|
||
|
- Enter a Simulation title, and click Create.
|
||
|
|
||
|
We have now created our first simulation in COOJA. However, the simulation does not contain any nodes yet.
|
||
|
|
||
|
To add nodes we need to first create a node type, and then add nodes to the simulation.
|
||
|
|
||
|
=== Create a node type
|
||
|
|
||
|
Any simulated node in COOJA belongs to a node type.
|
||
|
|
||
|
The node type determines, among others, which Contiki applications to simulate.
|
||
|
|
||
|
|
||
|
Click menu item
|
||
|
|
||
|
[source,bash]
|
||
|
----
|
||
|
Motes > Add Motes > Create new mote type > Sky mote.
|
||
|
----
|
||
|
|
||
|
You have selected to emulate Tmote Sky nodes, and now need to select what Contiki program to simulate.
|
||
|
|
||
|
- Enter a Description.
|
||
|
- *Click Browse*, and navigate to *contiki/examples/hello-world/hello-world.c*
|
||
|
- *Click Compile* to start compiling the Contiki program
|
||
|
- *Click Create* when complication finishes.
|
||
|
|
||
|
You will be asked to enter the number of motes of your simulation.
|
||
|
|
||
|
Once you are done, click the Start button in the Simulation control window to start the simulation.
|
||
|
|
||
|
|
||
|
|
||
|
=== Save, Load and Reload in Cooja
|
||
|
|
||
|
Cooja allows for saving and loading simulation configurations.
|
||
|
When a simulation is saved, all active plugins are also stored with the configuration.
|
||
|
|
||
|
.save your current simulation
|
||
|
[source,bash]
|
||
|
----
|
||
|
File > Save simulation
|
||
|
----
|
||
|
|
||
|
.Open simulation
|
||
|
[source,bash]
|
||
|
----
|
||
|
File > Open simulation > Browse...
|
||
|
----
|
||
|
|
||
|
Select a simulation configuration.
|
||
|
|
||
|
When a simulation is loaded, all simulated Contiki applications are recompiled.
|
||
|
|
||
|
|
||
|
.reload your current simulation:
|
||
|
[source,bash]
|
||
|
----
|
||
|
File > Reload simulation
|
||
|
or press
|
||
|
Ctrl+R
|
||
|
----
|
||
|
|
||
|
.Reminder
|
||
|
[NOTE]
|
||
|
====
|
||
|
Reloading can be used to reset the simulation – to restart all nodes.
|
||
|
|
||
|
More importantly, reloading a simulation will recompile all Contiki code, useful while developing Contiki programs.
|
||
|
====
|
||
|
|
||
|
|
||
|
|
||
|
=== Add simulated nodes
|
||
|
|
||
|
[source,bash]
|
||
|
----
|
||
|
Motes > Add motes > [your type description]
|
||
|
----
|
||
|
|
||
|
Enter the number of nodes you want to simulate (e.g., 5), and press Add.
|
||
|
|
||
|
|
||
|
=== Show properties
|
||
|
|
||
|
Go to the *“Network”* window, click the *view* menu, and choose the properties you want to show for the nodes.
|
||
|
|
||
|
|
||
|
==== Radio model in Cooja
|
||
|
|
||
|
From the Network window, click on the
|
||
|
|
||
|
[source,bash]
|
||
|
----
|
||
|
View > Radio Environment (UDGM)
|
||
|
----
|
||
|
|
||
|
|
||
|
If you now left-click on one of the nodes, you will see a green circle around the selected node.
|
||
|
|
||
|
[NOTE]
|
||
|
====
|
||
|
The green circle presents the transmission range of the node, i.e. the selected node can communicate with all other nodes within that circle.
|
||
|
|
||
|
You may also see a grey circle around the green circle.
|
||
|
A node in the grey area cannot receive packets correctly
|
||
|
====
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
:hardbreaks:
|
||
|
|
||
|
{empty} +
|
||
|
{empty} +
|
||
|
{empty}
|
||
|
|
||
|
:!hardbreaks:
|
||
|
|
||
|
'''
|