├── .gitignore
├── CHANGES
├── CONTRIBUTORS
├── LICENSE
├── README.md
├── code
├── cli.py
├── content.py
├── cooja.py
├── files.py
├── gui.py
├── iotrain-sim.py
└── storyboard.py
├── content_guide.md
├── database
├── contiki
│ └── examples
│ │ └── ipv6
│ │ └── rpl-collect
│ │ ├── udp-sender-blackhole_attack.sky
│ │ ├── udp-sender-dodag_attack.sky
│ │ ├── udp-sender-flooding_attack.sky
│ │ └── udp-sender-rank_attack.sky
├── fundamental_training
│ ├── networking
│ │ └── broadcast
│ │ │ ├── broadcast_tutorial.pdf
│ │ │ └── simulation
│ │ │ ├── Makefile
│ │ │ ├── broadcast-ex.c
│ │ │ ├── broadcast.csc
│ │ │ └── solution_broadcast1.c
│ └── single_node
│ │ ├── actuation_control
│ │ ├── button
│ │ │ ├── button_tutorial.pdf
│ │ │ └── simulation
│ │ │ │ ├── Makefile
│ │ │ │ ├── button.c
│ │ │ │ ├── button.csc
│ │ │ │ └── solution_button.c
│ │ ├── led
│ │ │ ├── led_tutorial.pdf
│ │ │ └── simulation
│ │ │ │ ├── Makefile
│ │ │ │ ├── led.c
│ │ │ │ ├── led.csc
│ │ │ │ ├── solution_led1.c
│ │ │ │ └── solution_led2.c
│ │ ├── overview
│ │ │ └── actuation_control_overview.pdf
│ │ └── timer
│ │ │ ├── simulation
│ │ │ ├── Makefile
│ │ │ ├── solution_timer.c
│ │ │ ├── timer-ex.c
│ │ │ └── timer.csc
│ │ │ └── timer_tutorial.pdf
│ │ ├── basics_contiki_cooja
│ │ ├── contiki_tutorial.pdf
│ │ ├── cooja_tutorial.pdf
│ │ └── simulation
│ │ │ ├── Makefile
│ │ │ ├── README.md
│ │ │ ├── hello-world.c
│ │ │ └── hello-world.csc
│ │ └── sensing
│ │ ├── sensor_tutorial.pdf
│ │ └── simulation
│ │ ├── Makefile
│ │ ├── sensor.c
│ │ ├── sensor.csc
│ │ └── solution_sensor.c
├── security_training
│ ├── blackhole_attack
│ │ ├── blackhole_attack_tutorial.pdf
│ │ └── simulation
│ │ │ ├── Makefile
│ │ │ ├── blackhole_attack-reference.csc
│ │ │ ├── blackhole_attack-simulation.csc
│ │ │ ├── uip6-attack.c
│ │ │ └── uip6-reference.c
│ ├── decreased_rank_attack
│ │ ├── rank_attack_tutorial.pdf
│ │ └── simulation
│ │ │ ├── Makefile
│ │ │ ├── rank_attack-reference.csc
│ │ │ ├── rank_attack-simulation.csc
│ │ │ ├── rpl-private-attack.h
│ │ │ ├── rpl-private-reference.h
│ │ │ ├── rpl-timers-attack.c
│ │ │ └── rpl-timers-reference.c
│ ├── dodag_version_attack
│ │ ├── dodag_attack_tutorial.pdf
│ │ └── simulation
│ │ │ ├── Makefile
│ │ │ ├── dodag_attack-reference.csc
│ │ │ ├── dodag_attack-simulation.csc
│ │ │ ├── rpl-icmp6-attack.c
│ │ │ └── rpl-icmp6-reference.c
│ ├── flooding_attack
│ │ ├── flooding_attack_tutorial.pdf
│ │ └── simulation
│ │ │ ├── Makefile
│ │ │ ├── flooding_attack-reference.csc
│ │ │ ├── flooding_attack-simulation.csc
│ │ │ ├── rpl-private-attack.h
│ │ │ ├── rpl-private-reference.h
│ │ │ ├── rpl-timers-attack.c
│ │ │ └── rpl-timers-reference.c
│ └── introduction
│ │ ├── routing_protocol_overview.pdf
│ │ └── security_training_tutorial.pdf
└── system_introduction
│ ├── background_iot.pdf
│ └── iotrain-sim_overview.pdf
└── figures
├── collect_view_screenshot.png
├── content_overview.png
├── gui_screenshot.png
├── icon_csc.gif
├── icon_pdf.gif
├── implementation_procedure.png
├── system_architecture.png
├── training_workflow.png
└── tutorial_creation.png
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *~
3 | ._*
4 | .DS_Store
5 |
--------------------------------------------------------------------------------
/CHANGES:
--------------------------------------------------------------------------------
1 |
2 | IoTrain-Sim v1.0
3 | ----------------
4 | * Added C files with solutions for most of the exercises, so that
5 | learners can verify by themselves their answers
6 | * Did a full revision of the training content to improve explanations,
7 | structure and file organization
8 | * Added a graphical user interface (GUI) as the default interface for
9 | interacting with the program
10 | * Added command-line arguments to control which user interface is
11 | used: the new GUI (default) or the legacy CLI
12 | * Various minor bug fixes and improvements
13 |
14 | IoTrain-Sim v0.1
15 | ----------------
16 | * First public release, which includes training content for
17 | fundamental and security training
--------------------------------------------------------------------------------
/CONTRIBUTORS:
--------------------------------------------------------------------------------
1 | This file includes the main contributors to the IoTrain-Sim project.
2 |
3 | Initial implementation:
4 | Jidong Wang
5 | Razvan Beuran
6 |
7 | Various contributions:
8 | Chunqi Du
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2019-2020, Japan Advanced Institute of Science and Technology
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | 3. Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # IoTrain-Sim: IoT Training System Using the Cooja Network Simulator
3 |
4 | IoTrain-Sim is an integrated training system that makes use of the
5 | Cooja network simulator and Contiki OS for IoT education and training
6 | purposes. The system provides training tutorials and ready-to-use
7 | simulations making it possible for learners to easily master the
8 | basics of IoT and IoT security. The included hands-on practice with
9 | simulated IoT devices helps learners get ready to implement real IoT
10 | applications in the future.
11 |
12 | An overview of the architecture of IoTrain-Sim is provided in the
13 | figure below.
14 |
15 |
16 |
17 |
18 | ## Training Process
19 |
20 | Training activities that make use of IoTrain-Sim are typically
21 | conducted as illustrated next.
22 |
23 |
24 |
25 |
26 |
27 | The training content currently provided with IoTrain-Sim is structured
28 | as shown below.
29 |
30 |
31 |
32 |
33 | ## Setup
34 |
35 | The following steps are necessary in order to set up IoTrain-Sim:
36 |
37 | 1. **Download Instant Contiki**: Instant Contiki is a virtual machine
38 | (VM) image provided by Contiki developers that contains all the
39 | necessary tools to run Cooja. The easiest way to get started with
40 | our system is to install it into the Instant Contiki VM. Use the
41 | link below to download the Instant Contiki 3.0 VM image (note that
42 | older VM versions are not compatible with the current IoTrain-Sim
43 | content). After downloading the archive, which has over 3 GB, unzip
44 | it and proceed to the next step.
45 |
46 | >[Instant Contiki 3.0 Repository](https://sourceforge.net/projects/contiki/files/Instant%20Contiki/Instant%20Contiki%203.0/)
47 |
48 | 2. **Install VMware Virtualization Software**: The downloaded Instant
49 | Contiki file is a VMware virtual machine image, hence the VMware
50 | virtualization software is needed to run it. VMware Workstation
51 | Player (formerly VMware Player) is such a solution for Windows and
52 | Linux, and VMware Fusion is the equivalent for macOS. See the links
53 | below for download and license information.
54 |
55 | >[VMware Workstation Player for Windows/Linux](https://www.vmware.com/products/workstation-player.html)
56 | >[VMware Fusion for macOS](https://www.vmware.com/products/fusion.html)
57 |
58 | 3. **Start Instant Contiki**: In order to start Instant Contiki, use
59 | the VMware program to open the main VM image file (the one with
60 | extension `.vmx`) from the extracted Instant Contiki archive and
61 | power it on. Wait for the machine to boot up, then log in; the
62 | default password is "user", but for security reasons you should
63 | change it after the first login. According to the Contiki
64 | developers, it is necessary to prepare the submodules in the OS
65 | source code before being able to run Cooja. To do that, open a
66 | terminal in the Instant Contiki VM and run the following command:
67 |
68 | ```
69 | cd contiki && git submodule update --init && cd ..
70 | ```
71 |
72 | 4. **Install IoTrain-Sim**: To install IoTrain-Sim, from the Instant
73 | Contiki VM download the latest version of the software from the
74 | [releases](https://github.com/crond-jaist/iotrain-sim/releases)
75 | page on GitHub. The IoTrain-Sim code assumes that the archive will
76 | be extracted into the directory `/home/user/iotrain-sim/`. In case
77 | you use a different location, update accordingly the variable
78 | `IOTRAIN_PATH` in the file `code/storyboard.py`. Next, install the
79 | Python Tkinter toolkit used for the IoTrain-Sim GUI by running the
80 | command below:
81 |
82 | ```
83 | sudo apt-get install python-tk
84 | ```
85 |
86 |
87 | ## Quick Start
88 |
89 | In order to run IoTrain-Sim, use a terminal window in the Instant
90 | Contiki VM to execute the following command:
91 |
92 | ```
93 | $ ./iotrain-sim/code/iotrain-sim.py
94 | ```
95 |
96 | Once the training interface is displayed as shown in the screenshot
97 | below, we suggest that you select the menu entry `System Introduction`
98 | > `IoTrain-Sim Overview` for an introduction to IoTrain-Sim. To
99 | learn more about the available training content, and especially about
100 | how to add new training content to the IoTrain-Sim database, see the
101 | [Training Content Guide](content_guide.md) that is also available in
102 | the distribution.
103 |
104 |
105 |
106 | **_NOTE:_** In addition to the graphical user interface (GUI) above,
107 | the legacy command-line interface (CLI) can also be used by
108 | providing the option `--cli` when starting IoTrain-Sim.
109 |
110 |
111 | ## References
112 |
113 | For a research background regarding IoTrain-Sim, please refer to the
114 | following document:
115 |
116 | * J. Wang, "IoT Training System Using the Cooja Network Simulator",
117 | Master's thesis, March 2019. https://hdl.handle.net/10119/15885
118 |
119 | For a list of contributors to this project, check the file
120 | CONTRIBUTORS included with the source code.
121 |
--------------------------------------------------------------------------------
/code/cli.py:
--------------------------------------------------------------------------------
1 |
2 | #############################################################################
3 | # Display the CLI of IoTrain-Sim
4 | #############################################################################
5 |
6 | # Standard library imports
7 | import os
8 | import webbrowser
9 | from collections import OrderedDict
10 |
11 | # Local imports
12 | from content import Content
13 | from cooja import CoojaManager
14 | from storyboard import Storyboard
15 |
16 | # Class that displays CLI training menus
17 | class CLI(object):
18 |
19 | # Enable debug messages
20 | debug = False
21 |
22 | # Find the full path for the file identified by the file name argument
23 | def find_file(self, database_path, file_name):
24 |
25 | if not file_name:
26 | return None
27 |
28 | file_list = []
29 |
30 | # Traverse database_path to find all the files and add them to the list
31 | for home, _, files in os.walk(database_path):
32 | for full_name in files:
33 | file_list.append(os.path.join(home, full_name))
34 |
35 | for file_path in file_list:
36 | if file_name in file_path:
37 | return file_path
38 |
39 | return None
40 |
41 | # Check whether a choice is in the menu range
42 | def is_in_menu_range(self, choice, menu):
43 | if choice > 0 and choice <= len(menu):
44 | return True
45 | else:
46 | return False
47 |
48 | # Clear the screen when displaying CLI menu
49 | def clear_screen(self):
50 | os.system("clear")
51 |
52 | # Display the top training menu
53 | def display_top_menu(self):
54 |
55 | # Clear initialization information
56 | self.clear_screen()
57 |
58 | # Display the top-level menu
59 | try:
60 | self.show_menu(Content().training_content)
61 |
62 | # Catch the quit exception, which indicates that the user wants to quit
63 | except QuitException:
64 | return
65 |
66 | # Show the current training menu; this function works recursively to enable back and forth menu navigation
67 | def show_menu(self, menu):
68 |
69 | # Loop forever
70 | while True:
71 |
72 | # Build list with menu data
73 | current_menu = list(menu)
74 |
75 | # Display the training menu header
76 | print(Storyboard.MENU_HEADER)
77 |
78 | # Print each menu item
79 | for menu_key in current_menu:
80 |
81 | # Prepare suffix to denote sub-menus by checking
82 | # whether the menu value is a dictionary
83 | menu_value = menu[menu_key]
84 | if isinstance(menu_value, dict) or isinstance(menu_value, OrderedDict):
85 | submenu_suffix = Storyboard.SUBMENU_SUFFIX
86 | else:
87 | submenu_suffix = ""
88 |
89 | # Determine maximum menu item length
90 | max_len = len(max(current_menu, key=len))
91 |
92 | # Print item index (starting from 1) and menu text
93 | print((" ({}) {:" + str(max_len+1) + "}{}").format(current_menu.index(menu_key) + 1, menu_key, submenu_suffix))
94 |
95 | # Display the training menu footer
96 | print(Storyboard.MENU_FOOTER)
97 |
98 | # Get the menu selection
99 | choice = raw_input(Storyboard.MENU_PROMPT)
100 |
101 | # Back menu choice (go up one level)
102 | if choice == Storyboard.BACK_CHOICE:
103 | self.clear_screen()
104 |
105 | # Check whether we are at the top level
106 | if current_menu == list(Content().training_content):
107 | print(Storyboard.ERROR_TOP_LEVEL)
108 | else:
109 | # Otherwise just return from the recursive call
110 | return
111 |
112 | # Start Cooja choice
113 | elif choice == Storyboard.COOJA_CHOICE:
114 | self.clear_screen()
115 | print(Storyboard.INFO_START_COOJA)
116 |
117 | # Use helper class to start Cooja
118 | exit_status = CoojaManager().start_cooja()
119 |
120 | # In case of error print a message, otherwise clear the screen
121 | if exit_status != 0:
122 | print(Storyboard.ERROR_COOJA_FAILED)
123 | else:
124 | self.clear_screen()
125 |
126 | # Quit training choice
127 | elif choice == Storyboard.QUIT_CHOICE:
128 | raise QuitException("Quit")
129 |
130 | # Some actual training choice
131 | else:
132 |
133 | # Check whether the input is a number
134 | if choice.isdigit():
135 | choice = int(choice)
136 |
137 | # Check whether the choice is a valid menu item index
138 | if self.is_in_menu_range(choice, current_menu):
139 | self.clear_screen()
140 |
141 | # Get the current menu value
142 | menu_value = menu[current_menu[choice-1]]
143 | if self.debug: print("DEBUG: Value of selected menu: '{}'".format(menu_value))
144 |
145 | # Check whether the menu value is NOT a dictionary
146 | if not isinstance(menu_value, dict) and not isinstance(menu_value, OrderedDict):
147 |
148 | # Check whether the database directory exists
149 | if not os.path.isdir(Storyboard.IOTRAIN_DATABASE_PATH):
150 | print(Storyboard.ERROR_DATABASE_NOT_FOUND.format(Storyboard.IOTRAIN_DATABASE_PATH))
151 | continue
152 |
153 | # Retrieve the full path for the file specified in "menu_value"
154 | if self.debug: print("DEBUG: Find full path for database file: '{}'...".format(menu_value))
155 | file_path = self.find_file(Storyboard.IOTRAIN_DATABASE_PATH, menu_value)
156 |
157 | # Check whether a corresponding file was actually found
158 | if not file_path:
159 | print(Storyboard.ERROR_FILE_NOT_LOCATED.format(menu_value))
160 |
161 | # PDF files are opened via the webbrowser library
162 | elif os.path.splitext(file_path)[1] == ".pdf":
163 | if self.debug: print("DEBUG: Open PDF file: '{}'...".format(file_path))
164 | # Make sure to add the "file://" prefix, or it will not work on macOS
165 | # NOTE: There seems to be no way to catch errors in webbrowser.open()
166 | webbrowser.open("file://" + file_path)
167 |
168 | # CSC files are opened via a helper function
169 | elif os.path.splitext(file_path)[1] == ".csc":
170 | if self.debug: print("DEBUG: Open CSC file: '{}'...".format(file_path))
171 | # Use helper class to open CSC file
172 | exit_status = CoojaManager().open_csc_file(file_path)
173 | # In case of error print a message, otherwise clear the screen
174 | if exit_status != 0:
175 | print(Storyboard.ERROR_CSC_FAILED)
176 | else:
177 | self.clear_screen()
178 |
179 | # Otherwise display an error
180 | else:
181 | print(Storyboard.ERROR_UNKNOWN_FILE_TYPE.format(file_path))
182 |
183 | else:
184 | self.clear_screen()
185 | self.show_menu(menu_value)
186 | else:
187 | self.clear_screen()
188 | print(Storyboard.ERROR_INVALID_CHOICE.format(choice))
189 |
190 | # Otherwise just print an error
191 | else:
192 | self.clear_screen()
193 | print(Storyboard.ERROR_INVALID_INPUT.format(choice))
194 |
195 | # Class that defines a custom quit exception which indicates that the user wants to quit
196 | # This makes possible to exit from the nested recursive calls needed for menu navigation
197 | class QuitException(Exception):
198 | def __init__(self, value):
199 | self.value = value
200 | def __str__(self):
201 | return repr(self.value)
202 |
--------------------------------------------------------------------------------
/code/content.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 |
3 | #############################################################################
4 | # Define training content for IoTrain-Sim
5 | #############################################################################
6 |
7 | # Standard library imports
8 | from collections import OrderedDict
9 |
10 | # NOTE: We use the 'OrderedDict' form of 'dict' collection below in order to
11 | # preserve insertion order, so that menu items are shown in the same order
12 | # in which they are defined in this file. For initialization details, see:
13 | # https://www.georgevreilly.com/blog/2017/02/21/OrderedDictInitialization.html
14 |
15 | # Define training content class
16 | class Content():
17 |
18 | # Initialize training content as an 'OrderedDict' structure
19 | training_content = OrderedDict([
20 | ('System Introduction', OrderedDict([
21 | ('IoTrain-Sim Overview', 'iotrain-sim_overview.pdf'),
22 | ('Background on IoT', 'background_iot.pdf')
23 | ])),
24 | ('Fundamental Training', OrderedDict([
25 | ('Single Node', OrderedDict([
26 | ('Basics of Contiki & Cooja', OrderedDict([
27 | ('Contiki Tutorial', 'contiki_tutorial.pdf'),
28 | ('Hello World Simulation', 'hello-world.csc'),
29 | ('Cooja Tutorial', 'cooja_tutorial.pdf')
30 | ])),
31 | ('Actuation & Control', OrderedDict([
32 | ('Overview', 'actuation_control_overview.pdf'),
33 | ('LED Tutorial', 'led_tutorial.pdf'),
34 | ('LED Simulation', 'led.csc'),
35 | ('Button Tutorial', 'button_tutorial.pdf'),
36 | ('Button Simulation', 'button.csc'),
37 | ('Timer Tutorial', 'timer_tutorial.pdf'),
38 | ('Timer Simulation', 'timer.csc')
39 | ])),
40 | ('Sensing', OrderedDict([
41 | ('Sensor Tutorial', 'sensor_tutorial.pdf'),
42 | ('Sensor Simulation', 'sensor.csc')
43 | ]))
44 | ])),
45 | ('Networking', OrderedDict([
46 | ('Communication', OrderedDict([
47 | ('Broadcast Tutorial', 'broadcast_tutorial.pdf'),
48 | ('Broadcast Simulation', 'broadcast.csc')
49 | ]))
50 | ]))
51 | ])),
52 | ('Security Training', OrderedDict([
53 | ('Introduction', OrderedDict([
54 | ('Security Training Tutorial', 'security_training_tutorial.pdf'),
55 | ('Routing Protocol Overview', 'routing_protocol_overview.pdf')
56 | ])),
57 | ('Resource Attacks', OrderedDict([
58 | ('Direct Attacks', OrderedDict([
59 | ('Flooding Attack Tutorial', 'flooding_attack_tutorial.pdf'),
60 | ('Reference Scenario Simulation', 'flooding_attack-reference.csc'),
61 | ('Flooding Attack Simulation', 'flooding_attack-simulation.csc')
62 | ])),
63 | ('Indirect Attacks', OrderedDict([
64 | ('DODAG Version Attack Tutorial', 'dodag_attack_tutorial.pdf'),
65 | ('Reference Scenario Simulation', 'dodag_attack-reference.csc'),
66 | ('DODAG Version Attack Simulation', 'dodag_attack-simulation.csc')
67 | ])),
68 | ])),
69 | ('Topology Attacks', OrderedDict([
70 | ('Isolation Attacks', OrderedDict([
71 | ('Blackhole Attack Tutorial', 'blackhole_attack_tutorial.pdf'),
72 | ('Reference Scenario Simulation', 'blackhole_attack-reference.csc'),
73 | ('Blackhole Attack Simulation', 'blackhole_attack-simulation.csc')
74 | ]))
75 | ])),
76 | ('Traffic Attacks', OrderedDict([
77 | ('Misappropriation Attacks', OrderedDict([
78 | ('Decreased Rank Attack Tutorial', 'rank_attack_tutorial.pdf'),
79 | ('Reference Scenario Simulation', 'rank_attack-reference.csc'),
80 | ('Decreased Rank Attack Simulation', 'rank_attack-simulation.csc')
81 | ]))
82 | ]))
83 | ]))
84 | ])
85 |
--------------------------------------------------------------------------------
/code/cooja.py:
--------------------------------------------------------------------------------
1 |
2 | #############################################################################
3 | # Helper class for managing Cooja
4 | #############################################################################
5 |
6 | # Standard library imports
7 | import os
8 | import subprocess
9 | import time
10 |
11 | # Local imports
12 | from storyboard import Storyboard
13 |
14 | # Cooja manager class
15 | class CoojaManager():
16 |
17 | # Run a process and detect error status immediately after launch
18 | def run_process(self, command_list, working_dir):
19 | try:
20 | process = subprocess.Popen(command_list, cwd=working_dir)
21 | # Wait to capture (some) execution errors, but without guarantees
22 | for _ in range(5):
23 | time.sleep(1)
24 | poll_result = process.poll()
25 | if poll_result: # Process ended => return exit code
26 | return poll_result
27 | # Process is still running => assume no error
28 | return 0
29 | except OSError as error:
30 | print("ERROR: " + str(error))
31 | return 255
32 |
33 | # Use the command 'ant run' to start Cooja
34 | def start_cooja(self):
35 | # Run command "ant run" after changing to CONTIKI_COOJA_PATH directory
36 | return self.run_process(["ant", "run"], Storyboard.CONTIKI_COOJA_PATH)
37 |
38 | # Open CSC files via Cooja
39 | def open_csc_file(self, file_path):
40 |
41 | # Get the directory where the file is located
42 | dir_path = os.path.dirname(file_path)
43 |
44 | # Get the actual file name
45 | file_name=os.path.basename(file_path)
46 |
47 | # Run command "make TARGET=cooja FILE_NAME" after changing to DIR_PATH directory
48 | return self.run_process(["make", "TARGET=cooja", file_name], dir_path)
49 |
--------------------------------------------------------------------------------
/code/files.py:
--------------------------------------------------------------------------------
1 |
2 | #############################################################################
3 | # Helper class for managing files
4 | #############################################################################
5 |
6 | # Standard library imports
7 | import os
8 | import distutils.dir_util
9 | from distutils.errors import DistutilsFileError
10 |
11 | # Local imports
12 | from storyboard import Storyboard
13 |
14 | # File manager class
15 | class FileManager():
16 |
17 | debug = False
18 |
19 | # Copy the file and subdirectory structure in the directory 'src_dir'
20 | # to 'dst_dir' (new subdirectories are created if needed)
21 | def copy_hierarchy(self, src_dir, dst_dir):
22 |
23 | if self.debug: print("DEBUG: Copying all files in '{}' to '{}'...".format(src_dir, dst_dir))
24 | try:
25 | distutils.dir_util.copy_tree(src_dir, dst_dir)
26 | return True
27 | except DistutilsFileError as error:
28 | print("ERROR: " + str(error))
29 | return False
30 |
31 | # Delete the files structure present in the directory 'src_dir' from
32 | # 'dst_dir' (other files in 'dst_dir' and any directories that became
33 | # empty are not deleted)
34 | def delete_hierarchy(self, src_dir, dst_dir):
35 |
36 | if self.debug: print("DEBUG: Deleting all files in '{}' from '{}'...".format(src_dir, dst_dir))
37 |
38 | # Build a list of files in the source directory
39 | file_list = []
40 | for home, _, files in os.walk(src_dir):
41 | for full_name in files:
42 | file_list.append(os.path.join(home, full_name))
43 | if self.debug: print("DEBUG: Files in source directory: {}".format(file_list))
44 |
45 | no_error_encountered = True
46 | # Iterate over the files in the source directory
47 | for file_name in file_list:
48 |
49 | # Build the name of the corresponding file in the destination
50 | # directory
51 | dst_file_name = file_name.replace(src_dir, dst_dir)
52 |
53 | # Actually delete the file
54 | if self.debug: print("DEBUG: File to be deleted: {}".format(dst_file_name))
55 | try:
56 | os.remove(dst_file_name)
57 | except OSError as error:
58 | print("ERROR: " + str(error))
59 | no_error_encountered = False
60 |
61 | return no_error_encountered
62 |
--------------------------------------------------------------------------------
/code/gui.py:
--------------------------------------------------------------------------------
1 |
2 | #############################################################################
3 | # Display the GUI of IoTrain-Sim
4 | #############################################################################
5 |
6 | # Standard library imports
7 | import os
8 | import webbrowser
9 | from collections import OrderedDict
10 | import re
11 | import Tkinter as tk
12 | import ttk
13 | import tkMessageBox
14 |
15 | # Local imports
16 | from content import Content
17 | from cooja import CoojaManager
18 | from storyboard import Storyboard
19 |
20 | # Tree structure constants
21 | TREE_ROOT = ""
22 | ITEM_OPEN = True
23 | KEY_PREFIX = " "
24 |
25 | # Visual aspect constants (adjusted for the Instant Contiki VM)
26 | FONT_SIZE = 11 # 15
27 | WINDOW_SIZE = "420x500"
28 |
29 | # Class that displays GUI training menus
30 | class GUI(object):
31 |
32 | # Insert the dictionary content into the menu tree structure
33 | def process_dict(self, dict, tree, parent, is_open):
34 | for key, value in dict.items():
35 | if type(value) is str:
36 | if ".pdf" in value:
37 | tree.insert(parent, "end", text=KEY_PREFIX+key, values=value, image=self.icon_pdf)
38 | elif ".csc" in value:
39 | tree.insert(parent, "end", text=KEY_PREFIX+key, values=value, image=self.icon_csc)
40 | else:
41 | # We insert unknown files without icon and print an error message
42 | tree.insert(parent, "end", text=KEY_PREFIX+key, values=value)
43 | print(Storyboard.ERROR_UNKNOWN_FILE_TYPE.format(value))
44 | else:
45 | child = tree.insert(parent, "end", text=key, open=is_open, tag=Storyboard.TAG_CATEGORY)
46 | self.process_dict(value, tree, child, is_open)
47 |
48 | # Do the appropriate action on the file identified by the file name argument
49 | def do_file_action(self, database_path, file_name):
50 |
51 | if not file_name:
52 | return
53 |
54 | file_list = []
55 |
56 | # Traverse database_path to find all the files and add them to the list
57 | for home, _, files in os.walk(database_path):
58 | for full_name in files:
59 | file_list.append(os.path.join(home, full_name))
60 |
61 | # Try to find the file name and apply the appropriate action
62 | file_found = False
63 | for file_path in file_list:
64 | if file_name in file_path:
65 | file_found = True
66 |
67 | # PDF files are opened via the webbrowser library
68 | if os.path.splitext(file_name)[1] == ".pdf":
69 | # Make sure to add the "file://" prefix, or it will not work on macOS
70 | # NOTE: There seems to be no way to catch errors in webbrowser.open()
71 | webbrowser.open("file://" + os.path.abspath(file_path))
72 |
73 | # CSC files are opened via a helper function
74 | elif os.path.splitext(file_name)[1] == ".csc":
75 | # Use helper class to open CSC file
76 | exit_status = CoojaManager().open_csc_file(file_path)
77 | if exit_status != 0:
78 | tkMessageBox.showerror(title=Storyboard.ERROR_COOJA_DIALOG_TITLE_GUI,
79 | message=Storyboard.ERROR_CSC_FAILED_GUI)
80 |
81 | # Handle unknown file types
82 | else:
83 | tkMessageBox.showerror(title=Storyboard.ERROR_MAIN_DIALOG_TITLE_GUI,
84 | message=Storyboard.ERROR_UNKNOWN_FILE_TYPE_GUI.format(file_name))
85 |
86 | # Deal with the case that the target file was not found
87 | if not file_found:
88 | tkMessageBox.showerror(title=Storyboard.ERROR_MAIN_DIALOG_TITLE_GUI,
89 | message=Storyboard.ERROR_FILE_NOT_LOCATED_GUI.format(file_name))
90 |
91 | # Start GUI menu
92 | def start(self):
93 |
94 | # Setup window
95 | window = tk.Tk()
96 |
97 | # Prepare resources
98 | self.icon_csc = tk.PhotoImage(file=Storyboard.IOTRAIN_FIGURES_PATH + "icon_csc.gif")
99 | self.icon_pdf = tk.PhotoImage(file=Storyboard.IOTRAIN_FIGURES_PATH + "icon_pdf.gif")
100 |
101 | ############################################
102 | # Create a tree view panel
103 | tree = ttk.Treeview(window, height=10, show="tree headings", selectmode="browse")
104 | style = ttk.Style()
105 | style.configure("Treeview", font=("", FONT_SIZE), rowheight=21)
106 | tree.tag_configure(Storyboard.TAG_CATEGORY, font=("", FONT_SIZE, "bold"))
107 | # Color reference: https://www.rapidtables.com/web/color/gray-color.html
108 | style.configure("Treeview.Heading", foreground="#696969", font=("", FONT_SIZE, "bold"))
109 | #style.configure('Treeview', relief = 'flat', borderwidth = 0)
110 | #style.layout("Treeview", [('Treeview.treearea', {'sticky': 'nswe'})]) # Remove borders
111 | tree.heading("#0", text=Storyboard.HEADING_NAME)
112 |
113 | # Setup vertical and horizontal scrollbars for tree
114 | y_scrollbar = tk.Scrollbar(tree, orient=tk.VERTICAL, command=tree.yview)
115 | y_scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
116 | x_scrollbar = tk.Scrollbar(tree, orient=tk.HORIZONTAL, command=tree.xview)
117 | x_scrollbar.pack(side=tk.BOTTOM, fill=tk.X)
118 | tree.configure(yscrollcommand=y_scrollbar.set, xscrollcommand=x_scrollbar.set)
119 |
120 | # Default scrollbar width is supposed to be 16, but padding looks better with 13
121 | # Reference: https://effbot.org/tkinterbook/scrollbar.htm
122 | PADDING_X=13
123 | PADDING_Y=PADDING_X
124 | tree.pack(side=tk.TOP, expand=True, fill=tk.BOTH, padx=(PADDING_X,0))
125 |
126 | # Import training content into tree
127 | content = Content().training_content
128 | self.process_dict(content, tree, TREE_ROOT, not ITEM_OPEN)
129 |
130 | ############################################
131 | # Set up buttons
132 |
133 | ## Callback functions
134 | def delete_tree(tree):
135 | items = tree.get_children()
136 | for item in items:
137 | tree.delete(item)
138 | def expand_callback():
139 | delete_tree(tree)
140 | self.process_dict(content, tree, TREE_ROOT, ITEM_OPEN)
141 | def collapse_callback():
142 | delete_tree(tree)
143 | self.process_dict(content, tree, TREE_ROOT, not ITEM_OPEN)
144 | def cooja_callback():
145 | print(Storyboard.INFO_START_COOJA)
146 | # Use helper class to start Cooja
147 | # (set cursor before, and reset cursor after the operation)
148 | # NOTE: The "wait" cursor maps to native cursors on macOS & Windows,
149 | # but it is not portable, so we use "watch" instead
150 | # Reference: https://www.tcl.tk/man/tcl8.6/TkCmd/cursors.htm
151 | window.config(cursor="watch")
152 | cooja_button.config(cursor="watch")
153 | exit_status = CoojaManager().start_cooja()
154 | window.config(cursor="")
155 | cooja_button.config(cursor="")
156 | if exit_status != 0:
157 | tkMessageBox.showerror(title=Storyboard.ERROR_COOJA_DIALOG_TITLE_GUI,
158 | message=Storyboard.ERROR_COOJA_FAILED_GUI)
159 |
160 | ## Actual button setup
161 | expand_button = ttk.Button(window, text=Storyboard.BUTTON_EXPAND_ALL,
162 | command=expand_callback)
163 | collapse_button = ttk.Button(window, text=Storyboard.BUTTON_COLLAPSE_ALL,
164 | command=collapse_callback)
165 | cooja_button = ttk.Button(window, text=Storyboard.BUTTON_START_COOJA,
166 | command=cooja_callback)
167 | quit_button = ttk.Button(window, text=Storyboard.BUTTON_QUIT,
168 | command=window.destroy)
169 | expand_button.pack(side=tk.LEFT, expand=True, fill=tk.X, padx=(PADDING_X,0), pady=(0,PADDING_Y))
170 | collapse_button.pack(side=tk.LEFT, expand=True, fill=tk.X, pady=(0,PADDING_Y))
171 | cooja_button.pack(side=tk.LEFT, expand=True, fill=tk.X, pady=(0,PADDING_Y))
172 | quit_button.pack(side=tk.LEFT, expand=True, fill=tk.X, padx=(0,PADDING_X), pady=(0,PADDING_Y))
173 |
174 | # Set up an action for when a file is clicked
175 | def on_click(event):
176 | if tree.selection():
177 | file_name_list = tree.item(tree.selection()[0], "values")
178 | if file_name_list:
179 | if not os.path.isdir(Storyboard.IOTRAIN_DATABASE_PATH):
180 | tkMessageBox.showerror(title=Storyboard.ERROR_MAIN_DIALOG_TITLE_GUI,
181 | message=Storyboard.ERROR_DATABASE_NOT_FOUND_GUI.format(Storyboard.IOTRAIN_DATABASE_PATH))
182 | else:
183 | # Perform action on file
184 | # (set cursor before, and reset cursor after the operation)
185 | window.config(cursor="watch")
186 | tree.config(cursor="watch")
187 | self.do_file_action(Storyboard.IOTRAIN_DATABASE_PATH, file_name_list[0])
188 | window.config(cursor="")
189 | tree.config(cursor="")
190 | #tree.bind("", on_click) # Single click
191 | tree.bind("", on_click) # Double click
192 |
193 | ############################################
194 | # Set up window for GUI
195 | window.geometry(WINDOW_SIZE)
196 | window.title("IoTrain-Sim")
197 | menubar = tk.Menu(window)
198 | actions_menu = tk.Menu(menubar, tearoff=0) # Disable tearoff (detachable menu) feature
199 | actions_menu.add_command(label=Storyboard.BUTTON_START_COOJA, command=cooja_callback)
200 | actions_menu.add_separator()
201 | actions_menu.add_command(label=Storyboard.BUTTON_QUIT, command=window.quit)
202 | menubar.add_cascade(label="Actions", menu=actions_menu)
203 | window.config(menu=menubar)
204 |
205 | # Start the window loop
206 | window.mainloop()
207 |
--------------------------------------------------------------------------------
/code/iotrain-sim.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env python
2 |
3 | #############################################################################
4 | # Main program file for the IoTrain-Sim training system
5 | #############################################################################
6 |
7 | # Standard library imports
8 | import os
9 | import time
10 | import sys
11 | import getopt
12 |
13 | # Local imports
14 | from cli import CLI
15 | from gui import GUI
16 | from files import FileManager
17 | from storyboard import Storyboard
18 |
19 | #############################################################################
20 | # Functions
21 | #############################################################################
22 |
23 | # Print usage information
24 | def usage():
25 | print "\nUSAGE: iotrain-sim.py [options]\n"
26 | print "OPTIONS:"
27 | print "-h, --help Display this help message and exit"
28 | print "-c, --cli Use command-line user interface"
29 | print "-g, --gui Use graphical user interface (default)\n"
30 |
31 | #############################################################################
32 | # Main program
33 | #############################################################################
34 | def main(args):
35 |
36 | # Program parameters and their default values
37 | use_cli = False
38 |
39 | # Print banner
40 | print(Storyboard.SEPARATOR3)
41 | print(Storyboard.STARTUP_BANNER.format(Storyboard.IOTRAIN_SIM_VERSION))
42 | print(Storyboard.SEPARATOR3)
43 |
44 | # Parse command line arguments
45 | try:
46 | # Make sure to add ':' for short-form and '=' for long-form options that require an argument
47 | opts, trailing_args = getopt.getopt(args, "hcg", ["help", "cli", "gui"])
48 | except getopt.GetoptError as err:
49 | print(Storyboard.ERROR_CMD_LINE_ARGS.format(str(err)))
50 | usage()
51 | sys.exit(1)
52 |
53 | for opt, _ in opts:
54 | if opt in ("-h", "--help"):
55 | usage()
56 | sys.exit(0)
57 | elif opt in ("-c", "--cli"):
58 | use_cli = True
59 | elif opt in ("-g", "--gui"):
60 | use_cli = False
61 | else:
62 | # Nothing to be done on else, since unrecognized options are caught by
63 | # the getopt.GetoptError exception above
64 | pass
65 |
66 | if trailing_args:
67 | print(Storyboard.ERROR_TRAILING_ARGS.format(trailing_args))
68 | usage()
69 | sys.exit(2)
70 |
71 | # Make sure the database directory exists
72 | if not os.path.isdir(Storyboard.IOTRAIN_DATABASE_PATH):
73 | print(Storyboard.ERROR_DATABASE_NOT_FOUND.format(Storyboard.IOTRAIN_DATABASE_PATH))
74 | sys.exit(3)
75 |
76 | # Prepare the Contiki environment
77 | print(Storyboard.INFO_COPY_BIN)
78 | if not FileManager().copy_hierarchy(Storyboard.IOTRAIN_CONTIKI_PATH, Storyboard.CONTIKI_PATH):
79 | print(Storyboard.ERROR_FAILED_COPY_BIN)
80 | sys.exit(4)
81 |
82 | # Display the appropriate interface
83 | if use_cli:
84 | # Display the top CLI training menu
85 | print(Storyboard.INFO_START_CLI)
86 | time.sleep(1) # Used for debugging purposes, to make sure messages are displayed
87 | CLI().display_top_menu()
88 | else:
89 | # Display the top GUI training
90 | print(Storyboard.INFO_START_GUI)
91 | GUI().start()
92 |
93 | # Cleanup the Contiki environment
94 | print(Storyboard.INFO_REMOVE_BIN)
95 | if not FileManager().delete_hierarchy(Storyboard.IOTRAIN_CONTIKI_PATH, Storyboard.CONTIKI_PATH):
96 | sys.exit(5)
97 |
98 | #############################################################################
99 | # Run program
100 | if __name__ == "__main__":
101 | main(sys.argv[1:])
102 |
--------------------------------------------------------------------------------
/code/storyboard.py:
--------------------------------------------------------------------------------
1 |
2 | #############################################################################
3 | # Helper class for the IoTrain-Sim storyboard
4 | #############################################################################
5 |
6 | class Storyboard:
7 |
8 | #############################################################################
9 | # Generic constants
10 |
11 | # Program version
12 | IOTRAIN_SIM_VERSION = "1.0"
13 |
14 | # Separator constants
15 | SEPARATOR1 = "-------------------------------------------------------------------------"
16 | SEPARATOR2 = "========================================================================="
17 | SEPARATOR3 = "#########################################################################"
18 |
19 | #############################################################################
20 | # Path constants for IoTrain-Sim folders
21 |
22 | # Global paths
23 | IOTRAIN_PATH = "/home/user/iotrain-sim/"
24 | CONTIKI_PATH = "/home/user/contiki/"
25 |
26 | # Relative paths
27 | IOTRAIN_DATABASE_PATH = IOTRAIN_PATH + "database/"
28 | IOTRAIN_FIGURES_PATH = IOTRAIN_PATH + "figures/"
29 | IOTRAIN_CONTIKI_PATH = IOTRAIN_DATABASE_PATH + "contiki/"
30 | CONTIKI_COOJA_PATH = CONTIKI_PATH + "tools/cooja/"
31 |
32 | #############################################################################
33 | # CLI constants
34 |
35 | # Menu choices
36 | BACK_CHOICE = "b"
37 | COOJA_CHOICE = "c"
38 | QUIT_CHOICE = "q"
39 |
40 | # Menu details
41 | MENU_HEADER = SEPARATOR2 + "\nTRAINING MENU\n" + SEPARATOR1
42 | MENU_FOOTER = SEPARATOR1
43 | MENU_PROMPT = "Enter your choice (or '{}' to go back, '{}' to start Cooja, '{}' to quit): ".format(BACK_CHOICE, COOJA_CHOICE, QUIT_CHOICE)
44 | SUBMENU_SUFFIX = "[>]"
45 |
46 | #############################################################################
47 | # GUI constants
48 |
49 | # Button labels
50 | BUTTON_EXPAND_ALL = "Expand All"
51 | BUTTON_COLLAPSE_ALL = "Colapse All"
52 | BUTTON_START_COOJA = "Start Cooja"
53 | BUTTON_QUIT = "Quit"
54 |
55 | # Treeview items
56 | TAG_CATEGORY = "category"
57 | HEADING_NAME = "Training Content"
58 |
59 | #############################################################################
60 | # Mesage constants
61 |
62 | # General messages
63 | STARTUP_BANNER = "IoTrain-Sim v{}: IoT Training System Using the Cooja Network Simulator"
64 | INFO_COPY_BIN = "INFO: Copy precompiled IoTrain-Sim training binaries to Contiki..."
65 | INFO_START_CLI = "INFO: Start CLI interface..."
66 | INFO_START_GUI = "INFO: Start GUI interface..."
67 | INFO_REMOVE_BIN = "INFO: Remove precompiled IoTrain-Sim training binaries from Contiki..."
68 | INFO_START_COOJA = "INFO: Start Cooja..."
69 |
70 | # Error messages
71 | # (a GUI suffix means the message is intended for use in GUI)
72 | ERROR_CMD_LINE_ARGS = "ERROR: Command-line argument error: '{}' => abort execution\n"
73 | ERROR_TRAILING_ARGS = "ERROR: Unrecognized trailing arguments: '{}' => abort execution\n"
74 | ERROR_FAILED_COPY_BIN = "ERROR: Failed to copy precompiled training binaries => abort execution\n "
75 | ERROR_COOJA_FAILED = "ERROR: Cooja execution failed\n"
76 | ERROR_COOJA_FAILED_GUI = "Cooja execution failed"
77 | ERROR_CSC_FAILED = "ERROR: CSC file execution failed\n"
78 | ERROR_CSC_FAILED_GUI = "CSC file execution failed"
79 | ERROR_COOJA_DIALOG_TITLE_GUI = "Cooja Error"
80 |
81 | ERROR_TOP_LEVEL = "ERROR: Already at top level\n"
82 | ERROR_INVALID_CHOICE = "ERROR: Invalid choice: '{}'\n"
83 | ERROR_INVALID_INPUT = "ERROR: Invalid input: '{}'\n"
84 |
85 | ERROR_DATABASE_NOT_FOUND = ("ERROR: Database directory does not exist: '{}'\n" +
86 | " Check 'code/storyboard.py' for errors: is IOTRAIN_PATH correct?\n")
87 | ERROR_DATABASE_NOT_FOUND_GUI = ("Database directory does not exist:\n\t{}\n" +
88 | "Check 'code/storyboard.py' for errors: is IOTRAIN_PATH correct?\n")
89 | ERROR_FILE_NOT_LOCATED = ("ERROR: File could not be located in database: '{}'\n" +
90 | " Check 'code/contents.py' for errors\n")
91 | ERROR_FILE_NOT_LOCATED_GUI = ("File could not be located in database:\n\t{}\n" +
92 | "Check 'code/contents.py' for errors.")
93 | ERROR_UNKNOWN_FILE_TYPE = ("ERROR: Unknown type for file: '{}'\n"+
94 | " Check 'code/contents.py' for errors\n")
95 | ERROR_UNKNOWN_FILE_TYPE_GUI = ("Unknown type for file:\n\t{}\n" +
96 | "Check 'code/contents.py' for errors.")
97 | ERROR_MAIN_DIALOG_TITLE_GUI = "IoTrain-Sim Error"
98 |
--------------------------------------------------------------------------------
/content_guide.md:
--------------------------------------------------------------------------------
1 |
2 | # Training Content Guide
3 |
4 | This file includes information about the training content included
5 | with IoTrain-Sim, as well as details about the procedure of adding new
6 | training content to the system.
7 |
8 |
9 | ## Content Structure
10 |
11 | For someone who wants to learn about IoT, the first thing to do is to
12 | acquire basic knowledge regarding IoT devices, then to understand more
13 | advanced concepts, such as networking or security. Thus, when
14 | designing the training content structure, we divided it into three
15 | categories, namely `System Introduction`, `Fundamental Training`, and
16 | `Security Training`, as shown in the following figure.
17 |
18 |
19 |
20 | ### System Introduction
21 |
22 | The system introduction is aimed at all users who are using
23 | IoTrain-Sim for the first time. It begins with an overview of the
24 | system itself, then covers the background of IoT technologies and IoT
25 | security.
26 |
27 | ### Fundamental Training
28 |
29 | The fundamental training category is further divided into two areas:
30 | `Single Node` and `Networking`. The first content area starts by
31 | presenting the basics of Contiki OS and Cooja, including a `Hello
32 | World Simulation` tutorial. Several Contiki-based IoT devices are
33 | introduced next, such as actuators, controllers, and sensors. The
34 | second content area focuses on network communication techniques
35 | employed by IoT devices, with examples of broadcast communication,
36 | which is often used by sensor devices.
37 |
38 | ### Security Training
39 |
40 | The security training category includes examples of several attack
41 | simulations relevant to IoT technologies as used in Wireless Sensor
42 | Networks (WSN). Depending on the attack mechanism, we distinguish
43 | three types of attacks: `Resource Attacks`, `Topology Attacks`, and
44 | `Traffic Attacks`. Following a tutorial on security training and an
45 | introduction to routing protocols, we present various hands-on
46 | exercises, such as `Flooding Attack`, `Blackhole Attack`, and so on.
47 |
48 |
49 | ## Content Creation
50 |
51 | Two steps are required in order to add new content to IoTrain-Sim, as
52 | explained below:
53 |
54 | 1. Add specific files to the training database that is located in the
55 | directory `database/`
56 |
57 | 2. Register the new files with IoTrain-Sim (see the bottom of this
58 | page for instructions)
59 |
60 |
61 | ### 1. File Creation
62 |
63 | There are three types of content files in IoTrain-Sim. The first type
64 | is **PDF** (Portable Document Format), which is used for training
65 | tutorials. The second type is **CSC** (Cooja Simulation
66 | Configuration), which is a file type that can be opened into the Cooja
67 | network simulator. The third type is **C** language source code, for
68 | original and modified Contiki files that we provide as attack
69 | implementations, which can also be created by advanced users under the
70 | guidance of tutorials.
71 |
72 | #### Training Tutorials
73 |
74 | To create tutorials, developers first need to study a variety of
75 | materials, then create slides in PDF format (for instance, by
76 | exporting them from Microsoft PowerPoint), and finally store these PDF
77 | files in the training database. This tutorial creation procedure is
78 | illustrated below.
79 |
80 |
81 |
82 | #### Simulation Files
83 |
84 | Below we provide simulation implementation suggestions for the two
85 | categories of training content included in IoTrain-Sim, fundamental
86 | training and security training.
87 |
88 | a. Fundamental Training Simulations
89 |
90 | To implement a fundamental training simulation, first write a Contiki
91 | OS application using C language according to the programming rules of
92 | Contiki, and save it as a C file. Then, import the application into
93 | the Cooja network simulator, and select an appropriate hardware
94 | platform for compiling and generating the simulation. Finally, save
95 | the simulation in the training database as a CSC file, so that
96 | trainees can simply open it via Cooja to do the training. The
97 | implementation procedure is illustrated below.
98 |
99 |
100 |
101 | b. Security Training Simulations
102 |
103 | Our approach to security training is two have two simulations per
104 | training topic: a *reference simulation* that contains the normal
105 | conditions for a scenario, and an *attack simulation* that includes
106 | malicious nodes for that scenario. Trainees are advised to run both
107 | these simulations, then use Cooja tools, such as the `collect-view`
108 | application pictured below, to visualize simulation conditions and
109 | investigate issues related to the attack scenario, such as identifying
110 | the malicious nodes, determining the effects of the attack, and so on.
111 |
112 |
113 |
114 |
115 |
116 | Developers should first implement the reference simulation based on
117 | the sample C files included in Contiki OS. For example, for a scenario
118 | with a sink mote and multiple sources, the sink mote can be based on
119 | `sink.c`, and the source mote can be based on `udp-sender.c`, both
120 | located in `contiki/examples/ipv6/rpl-collect/`. Essentially, the
121 | steps to create a reference simulation are the same as the steps for
122 | creating a fundamental training simulation explained above, and the
123 | appropriate files must be compiled in Cooja and used to create
124 | simulated motes.
125 |
126 | For creating an attack simulation, we recommend to start with a
127 | reference simulation scenario, then replace a source mote in the
128 | reference simulation with a malicious mote that will perform some kind
129 | of attack. The steps to achieve this are detailed below:
130 |
131 | 1. Duplicate the Contiki OS folder `contiki/` to create a new OS
132 | instance.
133 |
134 | 2. Modify files as necessary according to the desired attack. For
135 | example, to implement a flooding attack the files `rpl_private.h`
136 | and `rpl_timers.c` should be modified.
137 |
138 | 3. Create a new malicious mote in Cooja, for instance by compiling the
139 | `udp-sender.c` file within the duplicated Contiki OS directory.
140 |
141 | 4. Use the malicious mote to replace one of the motes in the reference
142 | simulation scenario in order to transform it into an attack
143 | scenario.
144 |
145 | Both for reference and attack simulations, the resulting CSC files
146 | should be saved into the training database. Intermediate users can
147 | view these simulations in order to gain insight into an attack, while
148 | advanced trainees could be tasked with modifying Contiki source code
149 | in order to implement by themselves attacks and even defense
150 | mechanisms under the guidance of tutorials.
151 |
152 | #### Additional Training Files
153 |
154 | IoTrain-Sim provides support for including additional training files,
155 | such as precompiled binaries, that can be used in simulations without
156 | the need to perform any compilation. For this purpose, all the files
157 | located in the directory `database/contiki/` of IoTrain-Sim are
158 | automatically copied in the Contiki source code directory when the
159 | program starts, preserving the directory structure and even creating
160 | new subdirectories if necessary. When IoTrain-Sim execution ends,
161 | these files are removed automatically from the Contiki source code
162 | directory, leaving it in a "clean" state. Several such firmware
163 | binaries are already included in the IoTrain-Sim distribution, and are
164 | used to run example attack simulations with malicious motes without
165 | the need to compile the firmware.
166 |
167 |
168 | ### 2. File Registration
169 |
170 | Once the new training content files are created and added into the
171 | training database directory, they need to be registered with
172 | IoTrain-Sim, so that they are displayed in its user interface. To do
173 | this, update the file `code/content.py` by adding entries to it as
174 | needed using the Python initialization syntax for the 'OrderedDict'
175 | type of dictionary objects, as illustrated in the file.
176 |
--------------------------------------------------------------------------------
/database/contiki/examples/ipv6/rpl-collect/udp-sender-blackhole_attack.sky:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/contiki/examples/ipv6/rpl-collect/udp-sender-blackhole_attack.sky
--------------------------------------------------------------------------------
/database/contiki/examples/ipv6/rpl-collect/udp-sender-dodag_attack.sky:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/contiki/examples/ipv6/rpl-collect/udp-sender-dodag_attack.sky
--------------------------------------------------------------------------------
/database/contiki/examples/ipv6/rpl-collect/udp-sender-flooding_attack.sky:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/contiki/examples/ipv6/rpl-collect/udp-sender-flooding_attack.sky
--------------------------------------------------------------------------------
/database/contiki/examples/ipv6/rpl-collect/udp-sender-rank_attack.sky:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/contiki/examples/ipv6/rpl-collect/udp-sender-rank_attack.sky
--------------------------------------------------------------------------------
/database/fundamental_training/networking/broadcast/broadcast_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/fundamental_training/networking/broadcast/broadcast_tutorial.pdf
--------------------------------------------------------------------------------
/database/fundamental_training/networking/broadcast/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI_PROJECT = broadcast-ex
2 | all: $(CONTIKI_PROJECT)
3 |
4 | CONTIKI = /home/user/contiki
5 | CONTIKI_WITH_RIME = 1
6 | include $(CONTIKI)/Makefile.include
7 |
--------------------------------------------------------------------------------
/database/fundamental_training/networking/broadcast/simulation/broadcast-ex.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2007, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the Contiki operating system.
30 | *
31 | */
32 |
33 | /**
34 | * \file
35 | * Testing the broadcast layer in Rime
36 | * \author
37 | * Adam Dunkels
38 | */
39 |
40 | #include "contiki.h"
41 | #include "net/rime/rime.h"
42 | #include "random.h"
43 |
44 | #include "dev/button-sensor.h"
45 |
46 | #include "dev/leds.h"
47 |
48 | #include
49 | /*---------------------------------------------------------------------------*/
50 | PROCESS(example_broadcast_process, "Broadcast example");
51 | AUTOSTART_PROCESSES(&example_broadcast_process);
52 | /*---------------------------------------------------------------------------*/
53 | static void
54 | broadcast_recv(struct broadcast_conn *c, const linkaddr_t *from)
55 | {
56 | printf("broadcast message received from %d.%d: '%s'\n",
57 | from->u8[0], from->u8[1], (char *)packetbuf_dataptr());
58 | }
59 | static const struct broadcast_callbacks broadcast_call = {broadcast_recv};
60 | static struct broadcast_conn broadcast;
61 | /*---------------------------------------------------------------------------*/
62 | PROCESS_THREAD(example_broadcast_process, ev, data)
63 | {
64 | static struct etimer et;
65 |
66 | PROCESS_EXITHANDLER(broadcast_close(&broadcast);)
67 |
68 | PROCESS_BEGIN();
69 |
70 | broadcast_open(&broadcast, 129, &broadcast_call);
71 |
72 | while(1) {
73 |
74 | /* Delay 4-8 seconds */
75 | etimer_set(&et, CLOCK_SECOND * 4 + random_rand() % (CLOCK_SECOND * 4));
76 |
77 | PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
78 |
79 | packetbuf_copyfrom("Hello", 6);
80 | broadcast_send(&broadcast);
81 | printf("broadcast message sent\n");
82 | }
83 |
84 | PROCESS_END();
85 | }
86 | /*---------------------------------------------------------------------------*/
87 |
--------------------------------------------------------------------------------
/database/fundamental_training/networking/broadcast/simulation/broadcast.csc:
--------------------------------------------------------------------------------
1 |
2 |
3 | [APPS_DIR]/mrm
4 | [APPS_DIR]/mspsim
5 | [APPS_DIR]/avrora
6 | [APPS_DIR]/serial_socket
7 | [APPS_DIR]/collect-view
8 | [APPS_DIR]/powertracker
9 |
10 | Broadcast example
11 | 123456
12 | 1000000
13 |
14 | org.contikios.cooja.radiomediums.UDGM
15 | 50.0
16 | 100.0
17 | 1.0
18 | 1.0
19 |
20 |
21 | 40000
22 |
23 |
24 | org.contikios.cooja.mspmote.SkyMoteType
25 | sky1
26 | Broadcast example
27 | [CONFIG_DIR]/broadcast-ex.c
28 | make broadcast-ex.sky TARGET=sky
29 | [CONFIG_DIR]/broadcast-ex.sky
30 | org.contikios.cooja.interfaces.Position
31 | org.contikios.cooja.interfaces.RimeAddress
32 | org.contikios.cooja.interfaces.IPAddress
33 | org.contikios.cooja.interfaces.Mote2MoteRelations
34 | org.contikios.cooja.interfaces.MoteAttributes
35 | org.contikios.cooja.mspmote.interfaces.MspClock
36 | org.contikios.cooja.mspmote.interfaces.MspMoteID
37 | org.contikios.cooja.mspmote.interfaces.SkyButton
38 | org.contikios.cooja.mspmote.interfaces.SkyFlash
39 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
40 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
41 | org.contikios.cooja.mspmote.interfaces.MspSerial
42 | org.contikios.cooja.mspmote.interfaces.SkyLED
43 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
44 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
45 |
46 |
47 |
48 |
49 | org.contikios.cooja.interfaces.Position
50 | 37.5366545201821
51 | 20.133438936240488
52 | 0.0
53 |
54 |
55 | org.contikios.cooja.mspmote.interfaces.MspClock
56 | 1.0
57 |
58 |
59 | org.contikios.cooja.mspmote.interfaces.MspMoteID
60 | 1
61 |
62 | sky1
63 |
64 |
65 |
66 |
67 | org.contikios.cooja.interfaces.Position
68 | 50.05393308569106
69 | 3.886106972235548
70 | 0.0
71 |
72 |
73 | org.contikios.cooja.mspmote.interfaces.MspClock
74 | 1.0
75 |
76 |
77 | org.contikios.cooja.mspmote.interfaces.MspMoteID
78 | 2
79 |
80 | sky1
81 |
82 |
83 |
84 |
85 | org.contikios.cooja.interfaces.Position
86 | 53.50011157471555
87 | 48.16869587128244
88 | 0.0
89 |
90 |
91 | org.contikios.cooja.mspmote.interfaces.MspClock
92 | 1.0
93 |
94 |
95 | org.contikios.cooja.mspmote.interfaces.MspMoteID
96 | 3
97 |
98 | sky1
99 |
100 |
101 |
102 |
103 | org.contikios.cooja.interfaces.Position
104 | 12.542870357677295
105 | 50.15965479801062
106 | 0.0
107 |
108 |
109 | org.contikios.cooja.mspmote.interfaces.MspClock
110 | 1.0
111 |
112 |
113 | org.contikios.cooja.mspmote.interfaces.MspMoteID
114 | 4
115 |
116 | sky1
117 |
118 |
119 |
120 |
121 | org.contikios.cooja.interfaces.Position
122 | 45.30496839108535
123 | 49.347800977978565
124 | 0.0
125 |
126 |
127 | org.contikios.cooja.mspmote.interfaces.MspClock
128 | 1.0
129 |
130 |
131 | org.contikios.cooja.mspmote.interfaces.MspMoteID
132 | 5
133 |
134 | sky1
135 |
136 |
137 |
138 |
139 | org.contikios.cooja.interfaces.Position
140 | 74.7539300728242
141 | 28.371269772953212
142 | 0.0
143 |
144 |
145 | org.contikios.cooja.mspmote.interfaces.MspClock
146 | 1.0
147 |
148 |
149 | org.contikios.cooja.mspmote.interfaces.MspMoteID
150 | 6
151 |
152 | sky1
153 |
154 |
155 |
156 |
157 | org.contikios.cooja.interfaces.Position
158 | 51.968753134087585
159 | 77.76059892362437
160 | 0.0
161 |
162 |
163 | org.contikios.cooja.mspmote.interfaces.MspClock
164 | 1.0
165 |
166 |
167 | org.contikios.cooja.mspmote.interfaces.MspMoteID
168 | 7
169 |
170 | sky1
171 |
172 |
173 |
174 |
175 | org.contikios.cooja.interfaces.Position
176 | 63.365939830655286
177 | 24.573727672975103
178 | 0.0
179 |
180 |
181 | org.contikios.cooja.mspmote.interfaces.MspClock
182 | 1.0
183 |
184 |
185 | org.contikios.cooja.mspmote.interfaces.MspMoteID
186 | 8
187 |
188 | sky1
189 |
190 |
191 |
192 |
193 | org.contikios.cooja.interfaces.Position
194 | 21.82676295937117
195 | 84.86468902217199
196 | 0.0
197 |
198 |
199 | org.contikios.cooja.mspmote.interfaces.MspClock
200 | 1.0
201 |
202 |
203 | org.contikios.cooja.mspmote.interfaces.MspMoteID
204 | 9
205 |
206 | sky1
207 |
208 |
209 |
210 |
211 | org.contikios.cooja.interfaces.Position
212 | 8.668640141529082
213 | 21.113338033999675
214 | 0.0
215 |
216 |
217 | org.contikios.cooja.mspmote.interfaces.MspClock
218 | 1.0
219 |
220 |
221 | org.contikios.cooja.mspmote.interfaces.MspMoteID
222 | 10
223 |
224 | sky1
225 |
226 |
227 |
228 | org.contikios.cooja.plugins.SimControl
229 | 318
230 | 2
231 | 192
232 | 657
233 | 22
234 |
235 |
236 | org.contikios.cooja.plugins.Visualizer
237 |
238 | org.contikios.cooja.plugins.skins.IDVisualizerSkin
239 | org.contikios.cooja.plugins.skins.AddressVisualizerSkin
240 | org.contikios.cooja.plugins.skins.UDGMVisualizerSkin
241 | org.contikios.cooja.plugins.skins.TrafficVisualizerSkin
242 | org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin
243 | 2.6322285313650773 0.0 0.0 2.6322285313650773 153.2063652609864 74.31633289719939
244 |
245 | 495
246 | 1
247 | 392
248 | 12
249 | 2
250 |
251 |
252 | org.contikios.cooja.plugins.LogListener
253 |
254 |
255 |
256 |
257 |
258 | 1101
259 | 0
260 | 370
261 | 290
262 | 395
263 |
264 |
265 | org.contikios.cooja.plugins.TimeLine
266 |
267 | 0
268 | 1
269 | 2
270 | 3
271 | 4
272 | 5
273 | 6
274 | 7
275 | 8
276 | 9
277 |
278 |
279 | 500.0
280 |
281 | 828
282 | -1
283 | 138
284 | 293
285 | 561
286 | true
287 |
288 |
289 |
290 |
--------------------------------------------------------------------------------
/database/fundamental_training/networking/broadcast/simulation/solution_broadcast1.c:
--------------------------------------------------------------------------------
1 | #include "contiki.h"
2 | #include "net/rime/rime.h"
3 | #include "random.h"
4 |
5 | #include "dev/button-sensor.h"
6 |
7 | #include "dev/leds.h"
8 |
9 | #include
10 | /*---------------------------------------------------------------------------*/
11 | PROCESS(example_broadcast_process, "Broadcast example");
12 | AUTOSTART_PROCESSES(&example_broadcast_process);
13 | /*---------------------------------------------------------------------------*/
14 | static void
15 | broadcast_recv(struct broadcast_conn *c, const linkaddr_t *from)
16 | {
17 | printf("broadcast message received from %d.%d: '%s'\n",
18 | from->u8[0], from->u8[1], (char *)packetbuf_dataptr());
19 | }
20 | static const struct broadcast_callbacks broadcast_call = {broadcast_recv};
21 | static struct broadcast_conn broadcast;
22 | /*---------------------------------------------------------------------------*/
23 | PROCESS_THREAD(example_broadcast_process, ev, data)
24 | {
25 | static struct etimer et;
26 |
27 | PROCESS_EXITHANDLER(broadcast_close(&broadcast);)
28 |
29 | PROCESS_BEGIN();
30 |
31 | broadcast_open(&broadcast, 129, &broadcast_call);
32 |
33 | while(1) {
34 |
35 | /* Delay 4-8 seconds */
36 | etimer_set(&et, CLOCK_SECOND * 4 + random_rand() % (CLOCK_SECOND * 4));
37 |
38 | PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
39 |
40 | packetbuf_copyfrom("Goodbye", 8);
41 | broadcast_send(&broadcast);
42 | printf("broadcast message sent\n");
43 | }
44 |
45 | PROCESS_END();
46 | }
47 | /*---------------------------------------------------------------------------*/
48 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/button/button_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/fundamental_training/single_node/actuation_control/button/button_tutorial.pdf
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/button/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI_PROJECT = button
2 | all: $(CONTIKI_PROJECT)
3 |
4 | CONTIKI = /home/user/contiki
5 | include $(CONTIKI)/Makefile.include
6 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/button/simulation/button.c:
--------------------------------------------------------------------------------
1 | #include "contiki.h"
2 | #include "dev/leds.h"
3 | #include "dev/button-sensor.h"
4 | #include
5 | /*---------------------------------------------------------------------------*/
6 | PROCESS(button_process, "button process");
7 | AUTOSTART_PROCESSES(&button_process);
8 | /*---------------------------------------------------------------------------*/
9 | PROCESS_THREAD(button_process, ev, data)
10 | {
11 | PROCESS_BEGIN();
12 | SENSORS_ACTIVATE(button_sensor);
13 | /*------------------------------------------------------------------------*/
14 | while(1)
15 | {
16 | PROCESS_WAIT_EVENT_UNTIL((ev==sensors_event) && (data == &button_sensor));
17 | printf("Hello world!\n");
18 | }
19 | /*------------------------------------------------------------------------*/
20 | PROCESS_END();
21 | }
22 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/button/simulation/button.csc:
--------------------------------------------------------------------------------
1 |
2 |
3 | [APPS_DIR]/mrm
4 | [APPS_DIR]/mspsim
5 | [APPS_DIR]/avrora
6 | [APPS_DIR]/serial_socket
7 | [APPS_DIR]/collect-view
8 | [APPS_DIR]/powertracker
9 |
10 | My simulation
11 | 123456
12 | 1000000
13 |
14 | org.contikios.cooja.radiomediums.UDGM
15 | 50.0
16 | 100.0
17 | 1.0
18 | 1.0
19 |
20 |
21 | 40000
22 |
23 |
24 | org.contikios.cooja.mspmote.SkyMoteType
25 | sky1
26 | Sky Mote Type #sky1
27 | [CONFIG_DIR]/button.c
28 | make button.sky TARGET=sky
29 | [CONFIG_DIR]/button.sky
30 | org.contikios.cooja.interfaces.Position
31 | org.contikios.cooja.interfaces.RimeAddress
32 | org.contikios.cooja.interfaces.IPAddress
33 | org.contikios.cooja.interfaces.Mote2MoteRelations
34 | org.contikios.cooja.interfaces.MoteAttributes
35 | org.contikios.cooja.mspmote.interfaces.MspClock
36 | org.contikios.cooja.mspmote.interfaces.MspMoteID
37 | org.contikios.cooja.mspmote.interfaces.SkyButton
38 | org.contikios.cooja.mspmote.interfaces.SkyFlash
39 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
40 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
41 | org.contikios.cooja.mspmote.interfaces.MspSerial
42 | org.contikios.cooja.mspmote.interfaces.SkyLED
43 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
44 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
45 |
46 |
47 |
48 |
49 | org.contikios.cooja.interfaces.Position
50 | 42.546357955037195
51 | 21.326272928653957
52 | 0.0
53 |
54 |
55 | org.contikios.cooja.mspmote.interfaces.MspClock
56 | 1.0
57 |
58 |
59 | org.contikios.cooja.mspmote.interfaces.MspMoteID
60 | 1
61 |
62 | sky1
63 |
64 |
65 |
66 | org.contikios.cooja.plugins.SimControl
67 | 280
68 | 0
69 | 160
70 | 400
71 | 0
72 |
73 |
74 | org.contikios.cooja.plugins.Visualizer
75 |
76 | true
77 | org.contikios.cooja.plugins.skins.IDVisualizerSkin
78 | org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin
79 | 0.9090909090909091 0.0 0.0 0.9090909090909091 155.321492768148 153.61247915576914
80 |
81 | 400
82 | 2
83 | 400
84 | 1
85 | 1
86 |
87 |
88 | org.contikios.cooja.plugins.LogListener
89 |
90 |
91 |
92 |
93 |
94 | 829
95 | 5
96 | 240
97 | 400
98 | 160
99 |
100 |
101 | org.contikios.cooja.plugins.TimeLine
102 |
103 | 0
104 |
105 |
106 |
107 | 500.0
108 |
109 | 1229
110 | 4
111 | 166
112 | 0
113 | 481
114 |
115 |
116 | org.contikios.cooja.plugins.Notes
117 |
118 | Click on the "Start" button to start the simulation.
119 | Then use "Click button" in the right panel to print messages.
120 | true
121 |
122 | 549
123 | 3
124 | 160
125 | 680
126 | 0
127 |
128 |
129 | org.contikios.cooja.plugins.MoteInterfaceViewer
130 | 0
131 |
132 | Button
133 | 0,0
134 |
135 | 350
136 | 1
137 | 300
138 | 1265
139 | 90
140 |
141 |
142 | org.contikios.cooja.plugins.ScriptRunner
143 |
144 |
157 | true
158 |
159 | 600
160 | -1
161 | 700
162 | 1285
163 | 469
164 | true
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/button/simulation/solution_button.c:
--------------------------------------------------------------------------------
1 | #include "contiki.h"
2 | #include "dev/leds.h"
3 | #include "dev/button-sensor.h"
4 | #include
5 | /*---------------------------------------------------------------------------*/
6 | PROCESS(button_process, "button process");
7 | AUTOSTART_PROCESSES(&button_process);
8 | /*---------------------------------------------------------------------------*/
9 | PROCESS_THREAD(button_process, ev, data)
10 | {
11 | PROCESS_BEGIN();
12 | SENSORS_ACTIVATE(button_sensor);
13 | /*------------------------------------------------------------------------*/
14 | while(1)
15 | {
16 | PROCESS_WAIT_EVENT_UNTIL((ev == sensors_event) && (data == &button_sensor));
17 | leds_on(LEDS_GREEN);
18 | PROCESS_WAIT_EVENT_UNTIL((ev == sensors_event) && (data == &button_sensor));
19 | leds_off(LEDS_GREEN);
20 | }
21 | /*------------------------------------------------------------------------*/
22 | PROCESS_END();
23 | }
24 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/led/led_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/fundamental_training/single_node/actuation_control/led/led_tutorial.pdf
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/led/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI_PROJECT = led
2 | all: $(CONTIKI_PROJECT)
3 |
4 | CONTIKI = /home/user/contiki
5 | include $(CONTIKI)/Makefile.include
6 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/led/simulation/led.c:
--------------------------------------------------------------------------------
1 | #include "contiki.h"
2 | #include "dev/leds.h"
3 | #include
4 | /*---------------------------------------------------------------------------*/
5 | PROCESS(led_process, "LED process");
6 | AUTOSTART_PROCESSES(&led_process);
7 | /*---------------------------------------------------------------------------*/
8 | PROCESS_THREAD(led_process, ev, data)
9 | {
10 | PROCESS_BEGIN();
11 | printf("Turn ON the red LED\n");
12 | leds_on(LEDS_RED);
13 | PROCESS_END();
14 | }
15 | /*---------------------------------------------------------------------------*/
16 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/led/simulation/led.csc:
--------------------------------------------------------------------------------
1 |
2 |
3 | [APPS_DIR]/mrm
4 | [APPS_DIR]/mspsim
5 | [APPS_DIR]/avrora
6 | [APPS_DIR]/serial_socket
7 | [APPS_DIR]/collect-view
8 | [APPS_DIR]/powertracker
9 |
10 | My simulation
11 | 123456
12 | 1000000
13 |
14 | org.contikios.cooja.radiomediums.UDGM
15 | 50.0
16 | 100.0
17 | 1.0
18 | 1.0
19 |
20 |
21 | 40000
22 |
23 |
24 | org.contikios.cooja.mspmote.SkyMoteType
25 | sky1
26 | Sky Mote Type #sky1
27 | [CONFIG_DIR]/led.c
28 | make led.sky TARGET=sky
29 | [CONFIG_DIR]/led.sky
30 | org.contikios.cooja.interfaces.Position
31 | org.contikios.cooja.interfaces.RimeAddress
32 | org.contikios.cooja.interfaces.IPAddress
33 | org.contikios.cooja.interfaces.Mote2MoteRelations
34 | org.contikios.cooja.interfaces.MoteAttributes
35 | org.contikios.cooja.mspmote.interfaces.MspClock
36 | org.contikios.cooja.mspmote.interfaces.MspMoteID
37 | org.contikios.cooja.mspmote.interfaces.SkyButton
38 | org.contikios.cooja.mspmote.interfaces.SkyFlash
39 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
40 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
41 | org.contikios.cooja.mspmote.interfaces.MspSerial
42 | org.contikios.cooja.mspmote.interfaces.SkyLED
43 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
44 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
45 |
46 |
47 |
48 |
49 | org.contikios.cooja.interfaces.Position
50 | 28.967181572989652
51 | 40.82182119630641
52 | 0.0
53 |
54 |
55 | org.contikios.cooja.mspmote.interfaces.MspClock
56 | 1.0
57 |
58 |
59 | org.contikios.cooja.mspmote.interfaces.MspMoteID
60 | 1
61 |
62 | sky1
63 |
64 |
65 |
66 | org.contikios.cooja.plugins.SimControl
67 | 280
68 | 1
69 | 160
70 | 400
71 | 0
72 |
73 |
74 | org.contikios.cooja.plugins.Visualizer
75 |
76 | true
77 | org.contikios.cooja.plugins.skins.IDVisualizerSkin
78 | org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin
79 | 0.9090909090909091 0.0 0.0 0.9090909090909091 167.6661985700094 135.88925345790327
80 |
81 | 400
82 | 3
83 | 400
84 | 1
85 | 1
86 |
87 |
88 | org.contikios.cooja.plugins.LogListener
89 |
90 |
91 |
92 |
93 |
94 | 2160
95 | 5
96 | 240
97 | 400
98 | 160
99 |
100 |
101 | org.contikios.cooja.plugins.TimeLine
102 |
103 | 0
104 |
105 |
106 |
107 | 500.0
108 |
109 | 2560
110 | 4
111 | 166
112 | 0
113 | 1174
114 |
115 |
116 | org.contikios.cooja.plugins.Notes
117 |
118 | Press the "Start" button to begin the simulation,
119 | which will stop automatically after 10 seconds.
120 | Once the simulation stops, you can press again "Start"
121 | to continue, or "Reload" to reload it.
122 | true
123 |
124 | 1880
125 | 0
126 | 160
127 | 680
128 | 0
129 |
130 |
131 | org.contikios.cooja.plugins.MoteInterfaceViewer
132 | 0
133 |
134 | Sky LED
135 | 0,0
136 |
137 | 350
138 | 2
139 | 300
140 | 35
141 | 426
142 |
143 |
144 | org.contikios.cooja.plugins.ScriptRunner
145 |
146 |
159 | true
160 |
161 | 600
162 | -1
163 | 700
164 | 1245
165 | 418
166 | true
167 |
168 |
169 |
170 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/led/simulation/solution_led1.c:
--------------------------------------------------------------------------------
1 | #include "contiki.h"
2 | #include "dev/leds.h"
3 | #include
4 | /*---------------------------------------------------------------------------*/
5 | PROCESS(led_process, "LED process");
6 | AUTOSTART_PROCESSES(&led_process);
7 | /*---------------------------------------------------------------------------*/
8 | PROCESS_THREAD(led_process, ev, data)
9 | {
10 | PROCESS_BEGIN();
11 | printf("Turn ON all the LEDs\n");
12 | leds_on(LEDS_ALL);
13 | PROCESS_END();
14 | }
15 | /*---------------------------------------------------------------------------*/
16 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/led/simulation/solution_led2.c:
--------------------------------------------------------------------------------
1 | #include "contiki.h"
2 | #include "dev/leds.h"
3 | #include
4 | /*---------------------------------------------------------------------------*/
5 | PROCESS(led_process, "LED process");
6 | AUTOSTART_PROCESSES(&led_process);
7 | /*---------------------------------------------------------------------------*/
8 | PROCESS_THREAD(led_process, ev, data)
9 | {
10 | PROCESS_BEGIN();
11 | leds_on(LEDS_ALL);
12 | printf("LED %u status is %u\n", LEDS_ALL, leds_get());
13 | PROCESS_END();
14 | }
15 | /*---------------------------------------------------------------------------*/
16 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/overview/actuation_control_overview.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/fundamental_training/single_node/actuation_control/overview/actuation_control_overview.pdf
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/timer/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI_PROJECT = timer-ex
2 | all: $(CONTIKI_PROJECT)
3 |
4 | CONTIKI = /home/user/contiki
5 | include $(CONTIKI)/Makefile.include
6 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/timer/simulation/solution_timer.c:
--------------------------------------------------------------------------------
1 | #include "contiki.h"
2 | #include "sys/etimer.h"
3 | #include "dev/leds.h"
4 | #include
5 |
6 | #define SECONDS 1
7 | /*-------------------------------------------------*/
8 | PROCESS(blink_process, "blink process");
9 | AUTOSTART_PROCESSES(&blink_process);
10 | /*-------------------------------------------------*/
11 | PROCESS_THREAD(blink_process, ev, data)
12 | {
13 | PROCESS_BEGIN();
14 | static struct etimer et;
15 | while (1)
16 | {
17 | etimer_set(&et, CLOCK_SECOND * SECONDS);
18 | PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
19 | leds_on(LEDS_BLUE);
20 | printf("Blue LED is ON\n");
21 |
22 | etimer_set(&et, CLOCK_SECOND * SECONDS);
23 | PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
24 | leds_off(LEDS_BLUE);
25 | printf("Blue LED is OFF\n");
26 | }
27 | PROCESS_END();
28 | }
29 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/timer/simulation/timer-ex.c:
--------------------------------------------------------------------------------
1 | #include "contiki.h"
2 | #include "sys/etimer.h"
3 | #include
4 |
5 | #define SECONDS 3
6 | /*-------------------------------------------------*/
7 | PROCESS(timer_process, "timer process");
8 | AUTOSTART_PROCESSES(&timer_process);
9 | /*-------------------------------------------------*/
10 | PROCESS_THREAD(timer_process, ev, data)
11 | {
12 | PROCESS_BEGIN();
13 | static struct etimer et;
14 | while (1)
15 | {
16 | etimer_set(&et, CLOCK_SECOND * SECONDS);
17 | PROCESS_WAIT_EVENT();
18 | if (etimer_expired(&et))
19 | {
20 | printf("Timer expired\n");
21 | etimer_reset(&et);
22 | }
23 | }
24 | PROCESS_END();
25 | }
26 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/timer/simulation/timer.csc:
--------------------------------------------------------------------------------
1 |
2 |
3 | [APPS_DIR]/mrm
4 | [APPS_DIR]/mspsim
5 | [APPS_DIR]/avrora
6 | [APPS_DIR]/serial_socket
7 | [APPS_DIR]/collect-view
8 | [APPS_DIR]/powertracker
9 |
10 | My simulation
11 | 1.0
12 | 123456
13 | 1000000
14 |
15 | org.contikios.cooja.radiomediums.UDGM
16 | 50.0
17 | 100.0
18 | 1.0
19 | 1.0
20 |
21 |
22 | 40000
23 |
24 |
25 | org.contikios.cooja.mspmote.SkyMoteType
26 | sky1
27 | Sky Mote Type #sky1
28 | [CONFIG_DIR]/timer-ex.c
29 | make timer-ex.sky TARGET=sky
30 | [CONFIG_DIR]/timer-ex.sky
31 | org.contikios.cooja.interfaces.Position
32 | org.contikios.cooja.interfaces.RimeAddress
33 | org.contikios.cooja.interfaces.IPAddress
34 | org.contikios.cooja.interfaces.Mote2MoteRelations
35 | org.contikios.cooja.interfaces.MoteAttributes
36 | org.contikios.cooja.mspmote.interfaces.MspClock
37 | org.contikios.cooja.mspmote.interfaces.MspMoteID
38 | org.contikios.cooja.mspmote.interfaces.SkyButton
39 | org.contikios.cooja.mspmote.interfaces.SkyFlash
40 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
41 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
42 | org.contikios.cooja.mspmote.interfaces.MspSerial
43 | org.contikios.cooja.mspmote.interfaces.SkyLED
44 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
45 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
46 |
47 |
48 |
49 |
50 | org.contikios.cooja.interfaces.Position
51 | 58.90750863621111
52 | 58.48030308535777
53 | 0.0
54 |
55 |
56 | org.contikios.cooja.mspmote.interfaces.MspClock
57 | 1.0
58 |
59 |
60 | org.contikios.cooja.mspmote.interfaces.MspMoteID
61 | 1
62 |
63 | sky1
64 |
65 |
66 |
67 | org.contikios.cooja.plugins.SimControl
68 | 280
69 | 0
70 | 160
71 | 400
72 | 0
73 |
74 |
75 | org.contikios.cooja.plugins.Visualizer
76 |
77 | true
78 | org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin
79 | org.contikios.cooja.plugins.skins.IDVisualizerSkin
80 | 0.9090909090909091 0.0 0.0 0.9090909090909091 140.44771942162626 119.83608810422021
81 |
82 | 400
83 | 1
84 | 400
85 | 1
86 | 1
87 |
88 |
89 | org.contikios.cooja.plugins.LogListener
90 |
91 |
92 |
93 |
94 |
95 | 2160
96 | 4
97 | 240
98 | 400
99 | 160
100 |
101 |
102 | org.contikios.cooja.plugins.TimeLine
103 |
104 | 0
105 |
106 |
107 |
108 | 500.0
109 |
110 | 2560
111 | 3
112 | 166
113 | 0
114 | 1174
115 |
116 |
117 | org.contikios.cooja.plugins.Notes
118 |
119 | Click on the "Start" button to begin the simulation.
120 | true
121 |
122 | 1880
123 | 2
124 | 160
125 | 680
126 | 0
127 |
128 |
129 | org.contikios.cooja.plugins.ScriptRunner
130 |
131 |
144 | true
145 |
146 | 600
147 | -1
148 | 700
149 | 710
150 | 30
151 | true
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/actuation_control/timer/timer_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/fundamental_training/single_node/actuation_control/timer/timer_tutorial.pdf
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/basics_contiki_cooja/contiki_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/fundamental_training/single_node/basics_contiki_cooja/contiki_tutorial.pdf
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/basics_contiki_cooja/cooja_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/fundamental_training/single_node/basics_contiki_cooja/cooja_tutorial.pdf
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/basics_contiki_cooja/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI_PROJECT = hello-world
2 | all: $(CONTIKI_PROJECT)
3 |
4 | CONTIKI = /home/user/contiki
5 | include $(CONTIKI)/Makefile.include
6 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/basics_contiki_cooja/simulation/README.md:
--------------------------------------------------------------------------------
1 | Hello-world
2 | ===========
3 |
4 | This adds the hello-world process in hello-world.c to the platform build, which
5 | prints "Hello-world" to stdout on startup.
6 |
7 | The entire platform is built, with uip stack, radio drivers, routing, etc.
8 | So it is not usually a simple build! The native platform is the default:
9 |
10 | make
11 | ./hello-world.native
12 | Starting Contiki
13 | Hello, world
14 |
15 | When switching between ipv4 and ipv6 builds on a platform,
16 |
17 | make TARGET= clean
18 |
19 | else the library for that platform will contain duplicate or unresolved
20 | modules.
21 |
22 | For example, using a loopback interface with the minimal-net platform:
23 |
24 | cd /examples/hello-world
25 | make TARGET=minimal-net
26 | ./hello-world.minimal-net
27 | Hello, world
28 | IP Address: 10.1.1.1
29 | Subnet Mask: 255.0.0.0
30 | Def. Router: 10.1.1.100
31 | ^C
32 |
33 | make TARGET=minimal-net clean
34 | make UIP_CONF_IPV6=1 TARGET=minimal-net
35 | ./hello-world.minimal-net
36 | Hello, world
37 | IPV6 Address: [aaaa::206:98ff:fe00:232]
38 | IPV6 Address: [fe80::206:98ff:fe00:232]
39 | ^C
40 |
41 | Note to AVR Raven users: Output goes to UART1, not the LCD. To see it,
42 |
43 | make TARGET=avr-raven hello-world.elf
44 |
45 | Load the .elf in AVR Studio and connect a hapsim terminal to the 1284p simulation.
46 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/basics_contiki_cooja/simulation/hello-world.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the Contiki operating system.
30 | *
31 | */
32 |
33 | /**
34 | * \file
35 | * A very simple Contiki application showing how Contiki programs look
36 | * \author
37 | * Adam Dunkels
38 | */
39 |
40 | #include "contiki.h"
41 |
42 | #include /* For printf() */
43 | /*---------------------------------------------------------------------------*/
44 | PROCESS(hello_world_process, "Hello world process");
45 | AUTOSTART_PROCESSES(&hello_world_process);
46 | /*---------------------------------------------------------------------------*/
47 | PROCESS_THREAD(hello_world_process, ev, data)
48 | {
49 | PROCESS_BEGIN();
50 |
51 | printf("Hello, world\n");
52 |
53 | PROCESS_END();
54 | }
55 | /*---------------------------------------------------------------------------*/
56 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/basics_contiki_cooja/simulation/hello-world.csc:
--------------------------------------------------------------------------------
1 |
2 |
3 | [APPS_DIR]/mrm
4 | [APPS_DIR]/mspsim
5 | [APPS_DIR]/avrora
6 | [APPS_DIR]/serial_socket
7 | [APPS_DIR]/collect-view
8 | [APPS_DIR]/powertracker
9 |
10 | My simulation
11 | 123456
12 | 1000000
13 |
14 | org.contikios.cooja.radiomediums.UDGM
15 | 50.0
16 | 100.0
17 | 1.0
18 | 1.0
19 |
20 |
21 | 40000
22 |
23 |
24 | org.contikios.cooja.mspmote.SkyMoteType
25 | sky1
26 | Sky Mote Type #sky1
27 | [CONFIG_DIR]/hello-world.c
28 | make hello-world.sky TARGET=sky
29 | [CONFIG_DIR]/hello-world.sky
30 | org.contikios.cooja.interfaces.Position
31 | org.contikios.cooja.interfaces.RimeAddress
32 | org.contikios.cooja.interfaces.IPAddress
33 | org.contikios.cooja.interfaces.Mote2MoteRelations
34 | org.contikios.cooja.interfaces.MoteAttributes
35 | org.contikios.cooja.mspmote.interfaces.MspClock
36 | org.contikios.cooja.mspmote.interfaces.MspMoteID
37 | org.contikios.cooja.mspmote.interfaces.SkyButton
38 | org.contikios.cooja.mspmote.interfaces.SkyFlash
39 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
40 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
41 | org.contikios.cooja.mspmote.interfaces.MspSerial
42 | org.contikios.cooja.mspmote.interfaces.SkyLED
43 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
44 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
45 |
46 |
47 |
48 |
49 | org.contikios.cooja.interfaces.Position
50 | 68.13532946926813
51 | 36.796296205351574
52 | 0.0
53 |
54 |
55 | org.contikios.cooja.mspmote.interfaces.MspClock
56 | 1.0
57 |
58 |
59 | org.contikios.cooja.mspmote.interfaces.MspMoteID
60 | 1
61 |
62 | sky1
63 |
64 |
65 |
66 | org.contikios.cooja.plugins.SimControl
67 | 280
68 | 0
69 | 160
70 | 400
71 | 0
72 |
73 |
74 | org.contikios.cooja.plugins.Visualizer
75 |
76 | true
77 | org.contikios.cooja.plugins.skins.IDVisualizerSkin
78 | org.contikios.cooja.plugins.skins.TrafficVisualizerSkin
79 | org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin
80 | org.contikios.cooja.plugins.skins.UDGMVisualizerSkin
81 | 0.9090909090909091 0.0 0.0 0.9090909090909091 132.05879139157443 139.54882163149856
82 |
83 | 400
84 | 1
85 | 400
86 | 1
87 | 1
88 |
89 |
90 | org.contikios.cooja.plugins.LogListener
91 |
92 |
93 |
94 |
95 |
96 | 2160
97 | 4
98 | 240
99 | 400
100 | 160
101 |
102 |
103 | org.contikios.cooja.plugins.TimeLine
104 |
105 | 0
106 |
107 |
108 |
109 | 500.0
110 |
111 | 2560
112 | 3
113 | 166
114 | 0
115 | 1174
116 |
117 |
118 | org.contikios.cooja.plugins.Notes
119 |
120 | Click on the "Start" button to start the simulation.
121 | true
122 |
123 | 1880
124 | 2
125 | 160
126 | 680
127 | 0
128 |
129 |
130 | org.contikios.cooja.plugins.ScriptRunner
131 |
132 |
145 | true
146 |
147 | 600
148 | -1
149 | 700
150 | 1274
151 | 435
152 | true
153 |
154 |
155 |
156 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/sensing/sensor_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/fundamental_training/single_node/sensing/sensor_tutorial.pdf
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/sensing/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI_PROJECT = sensor
2 | all: $(CONTIKI_PROJECT)
3 |
4 | CONTIKI = /home/user/contiki
5 | include $(CONTIKI)/Makefile.include
6 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/sensing/simulation/sensor.c:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Copyright (c) 2007, Swedish Institute of Computer Science.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the Institute nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | *
30 | * This file is part of the Contiki operating system.
31 | *
32 | */
33 |
34 | /**
35 | * \file
36 | * Sensing temperature, humidity and light intensity in the vicinity of Tmote-sky
37 | * \author
38 | * Adam Dunkels
39 | */
40 |
41 | #include "contiki.h"
42 |
43 | #include "dev/light-sensor.h"
44 | #include "dev/sht11/sht11-sensor.h"
45 |
46 | #include
47 | #include
48 |
49 | /*---------------------------------------------------------------------------*/
50 | PROCESS(sensor_acq_process,"Sensor Acquisition");
51 | AUTOSTART_PROCESSES(&sensor_acq_process);
52 |
53 | PROCESS_THREAD(sensor_acq_process,ev,data)
54 | {
55 | static struct etimer et;
56 | static int val;
57 | static float s = 0;
58 | static int dec;
59 | static float frac;
60 |
61 | PROCESS_BEGIN();
62 |
63 | printf("Starting Sensor Example.\n");
64 |
65 | while(1)
66 | {
67 | etimer_set(&et, CLOCK_SECOND * 2);
68 | SENSORS_ACTIVATE(light_sensor);
69 | SENSORS_ACTIVATE(sht11_sensor);
70 |
71 | PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
72 |
73 |
74 | val = sht11_sensor.value(SHT11_SENSOR_TEMP);
75 | if(val != -1)
76 | {
77 | s= ((0.01*val) - 39.60);
78 | dec = s;
79 | frac = s - dec;
80 | printf("\nTemperature=%d.%02u C (%d)\n", dec, (unsigned int)(frac * 100),val);
81 | }
82 |
83 | val=sht11_sensor.value(SHT11_SENSOR_HUMIDITY);
84 | if(val != -1)
85 | {
86 | s= (((0.0405*val) - 4) + ((-2.8 * 0.000001)*(pow(val,2))));
87 | dec = s;
88 | frac = s - dec;
89 | printf("Humidity=%d.%02u %% (%d)\n", dec, (unsigned int)(frac * 100),val);
90 | }
91 |
92 | val = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR);
93 | if(val != -1)
94 | {
95 | s = (float)(val * 0.4071);
96 | dec = s;
97 | frac = s - dec;
98 | printf("Light=%d.%02u lux (%d)\n", dec, (unsigned int)(frac * 100),val);
99 | }
100 |
101 | etimer_reset(&et);
102 | SENSORS_DEACTIVATE(light_sensor);
103 | SENSORS_DEACTIVATE(sht11_sensor);
104 |
105 | } //end of while
106 |
107 | PROCESS_END();
108 | }
109 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/sensing/simulation/sensor.csc:
--------------------------------------------------------------------------------
1 |
2 |
3 | [APPS_DIR]/mrm
4 | [APPS_DIR]/mspsim
5 | [APPS_DIR]/avrora
6 | [APPS_DIR]/serial_socket
7 | [APPS_DIR]/collect-view
8 | [APPS_DIR]/powertracker
9 |
10 | My simulation
11 | 123456
12 | 1000000
13 |
14 | org.contikios.cooja.radiomediums.UDGM
15 | 50.0
16 | 100.0
17 | 1.0
18 | 1.0
19 |
20 |
21 | 40000
22 |
23 |
24 | org.contikios.cooja.mspmote.SkyMoteType
25 | sky1
26 | Sky Mote Type #sky1
27 | [CONFIG_DIR]/sensor.c
28 | make sensor.sky TARGET=sky
29 | [CONFIG_DIR]/sensor.sky
30 | org.contikios.cooja.interfaces.Position
31 | org.contikios.cooja.interfaces.RimeAddress
32 | org.contikios.cooja.interfaces.IPAddress
33 | org.contikios.cooja.interfaces.Mote2MoteRelations
34 | org.contikios.cooja.interfaces.MoteAttributes
35 | org.contikios.cooja.mspmote.interfaces.MspClock
36 | org.contikios.cooja.mspmote.interfaces.MspMoteID
37 | org.contikios.cooja.mspmote.interfaces.SkyButton
38 | org.contikios.cooja.mspmote.interfaces.SkyFlash
39 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
40 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
41 | org.contikios.cooja.mspmote.interfaces.MspSerial
42 | org.contikios.cooja.mspmote.interfaces.SkyLED
43 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
44 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
45 |
46 |
47 |
48 |
49 | org.contikios.cooja.interfaces.Position
50 | 13.705706674679941
51 | 11.166540870419507
52 | 0.0
53 |
54 |
55 | org.contikios.cooja.mspmote.interfaces.MspClock
56 | 1.0
57 |
58 |
59 | org.contikios.cooja.mspmote.interfaces.MspMoteID
60 | 1
61 |
62 | sky1
63 |
64 |
65 |
66 | org.contikios.cooja.plugins.SimControl
67 | 280
68 | 0
69 | 160
70 | 400
71 | 0
72 |
73 |
74 | org.contikios.cooja.plugins.Visualizer
75 |
76 | true
77 | org.contikios.cooja.plugins.skins.IDVisualizerSkin
78 | org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin
79 | 0.9090909090909091 0.0 0.0 0.9090909090909091 181.54026665938187 162.84859920870954
80 |
81 | 400
82 | 1
83 | 400
84 | 1
85 | 1
86 |
87 |
88 | org.contikios.cooja.plugins.LogListener
89 |
90 |
91 |
92 |
93 |
94 | 2160
95 | 4
96 | 240
97 | 400
98 | 160
99 |
100 |
101 | org.contikios.cooja.plugins.TimeLine
102 |
103 | 0
104 |
105 |
106 |
107 | 500.0
108 |
109 | 2560
110 | 3
111 | 166
112 | 0
113 | 1174
114 |
115 |
116 | org.contikios.cooja.plugins.Notes
117 |
118 | Click on the "Start" button to start the simulation.
119 | true
120 |
121 | 1880
122 | 2
123 | 160
124 | 680
125 | 0
126 |
127 |
128 | org.contikios.cooja.plugins.ScriptRunner
129 |
130 |
143 | true
144 |
145 | 600
146 | -1
147 | 700
148 | 31
149 | 31
150 | true
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/database/fundamental_training/single_node/sensing/simulation/solution_sensor.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "contiki.h"
3 | #include "dev/button-sensor.h"
4 | #include "dev/light-sensor.h"
5 | #include "dev/leds.h"
6 |
7 | /*---------------------------------------------------------------------------*/
8 | PROCESS(light_button_process, "light button");
9 | AUTOSTART_PROCESSES(&light_button_process);
10 | /*---------------------------------------------------------------------------*/
11 | static uint8_t active;
12 | PROCESS_THREAD(light_button_process, ev, data)
13 | {
14 | PROCESS_BEGIN();
15 | active = 0;
16 | SENSORS_ACTIVATE(button_sensor);
17 |
18 | while(1) {
19 | PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event &&
20 | data == &button_sensor);
21 | leds_toggle(LEDS_ALL);
22 | if(!active) {
23 | /* activate light sensor */
24 | SENSORS_ACTIVATE(light_sensor);
25 | printf("Light: %d\n", light_sensor.value(0));
26 | } else {
27 | /* deactivate light sensor */
28 | printf("Light: %d\n", light_sensor.value(0));
29 | SENSORS_DEACTIVATE(light_sensor);
30 | }
31 | active ^= 1;
32 | leds_toggle(LEDS_ALL);
33 | }
34 | PROCESS_END();
35 | }
36 | /*---------------------------------------------------------------------------*/
37 |
--------------------------------------------------------------------------------
/database/security_training/blackhole_attack/blackhole_attack_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/security_training/blackhole_attack/blackhole_attack_tutorial.pdf
--------------------------------------------------------------------------------
/database/security_training/blackhole_attack/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI = /home/user/contiki
2 | include $(CONTIKI)/Makefile.include
3 |
--------------------------------------------------------------------------------
/database/security_training/decreased_rank_attack/rank_attack_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/security_training/decreased_rank_attack/rank_attack_tutorial.pdf
--------------------------------------------------------------------------------
/database/security_training/decreased_rank_attack/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI = /home/user/contiki
2 | include $(CONTIKI)/Makefile.include
3 |
--------------------------------------------------------------------------------
/database/security_training/decreased_rank_attack/simulation/rank_attack-reference.csc:
--------------------------------------------------------------------------------
1 |
2 |
3 | [APPS_DIR]/mrm
4 | [APPS_DIR]/mspsim
5 | [APPS_DIR]/avrora
6 | [APPS_DIR]/serial_socket
7 | [APPS_DIR]/collect-view
8 | [APPS_DIR]/powertracker
9 |
10 | My simulation
11 | 123456
12 | 1000000
13 |
14 | org.contikios.cooja.radiomediums.UDGM
15 | 50.0
16 | 100.0
17 | 1.0
18 | 1.0
19 |
20 |
21 | 40000
22 |
23 |
24 | org.contikios.cooja.mspmote.SkyMoteType
25 | sky1
26 | Sky Mote Type #sky1
27 | [CONTIKI_DIR]/examples/ipv6/rpl-collect/udp-sink.c
28 | make udp-sink.sky TARGET=sky
29 | [CONTIKI_DIR]/examples/ipv6/rpl-collect/udp-sink.sky
30 | org.contikios.cooja.interfaces.Position
31 | org.contikios.cooja.interfaces.RimeAddress
32 | org.contikios.cooja.interfaces.IPAddress
33 | org.contikios.cooja.interfaces.Mote2MoteRelations
34 | org.contikios.cooja.interfaces.MoteAttributes
35 | org.contikios.cooja.mspmote.interfaces.MspClock
36 | org.contikios.cooja.mspmote.interfaces.MspMoteID
37 | org.contikios.cooja.mspmote.interfaces.SkyButton
38 | org.contikios.cooja.mspmote.interfaces.SkyFlash
39 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
40 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
41 | org.contikios.cooja.mspmote.interfaces.MspSerial
42 | org.contikios.cooja.mspmote.interfaces.SkyLED
43 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
44 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
45 |
46 |
47 | org.contikios.cooja.mspmote.SkyMoteType
48 | sky2
49 | Sky Mote Type #sky2
50 | [CONTIKI_DIR]/examples/ipv6/rpl-collect/udp-sender.c
51 | make udp-sender.sky TARGET=sky
52 | [CONTIKI_DIR]/examples/ipv6/rpl-collect/udp-sender.sky
53 | org.contikios.cooja.interfaces.Position
54 | org.contikios.cooja.interfaces.RimeAddress
55 | org.contikios.cooja.interfaces.IPAddress
56 | org.contikios.cooja.interfaces.Mote2MoteRelations
57 | org.contikios.cooja.interfaces.MoteAttributes
58 | org.contikios.cooja.mspmote.interfaces.MspClock
59 | org.contikios.cooja.mspmote.interfaces.MspMoteID
60 | org.contikios.cooja.mspmote.interfaces.SkyButton
61 | org.contikios.cooja.mspmote.interfaces.SkyFlash
62 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
63 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
64 | org.contikios.cooja.mspmote.interfaces.MspSerial
65 | org.contikios.cooja.mspmote.interfaces.SkyLED
66 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
67 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
68 |
69 |
70 |
71 |
72 | org.contikios.cooja.interfaces.Position
73 | 60.15394056784298
74 | -26.204367304268644
75 | 0.0
76 |
77 |
78 | org.contikios.cooja.mspmote.interfaces.MspClock
79 | 1.0
80 |
81 |
82 | org.contikios.cooja.mspmote.interfaces.MspMoteID
83 | 1
84 |
85 | sky1
86 |
87 |
88 |
89 |
90 | org.contikios.cooja.interfaces.Position
91 | 43.979250984698325
92 | -2.506091037119106
93 | 0.0
94 |
95 |
96 | org.contikios.cooja.mspmote.interfaces.MspClock
97 | 1.0
98 |
99 |
100 | org.contikios.cooja.mspmote.interfaces.MspMoteID
101 | 2
102 |
103 | sky2
104 |
105 |
106 |
107 |
108 | org.contikios.cooja.interfaces.Position
109 | 52.46680694019093
110 | 16.089424035596007
111 | 0.0
112 |
113 |
114 | org.contikios.cooja.mspmote.interfaces.MspClock
115 | 1.0
116 |
117 |
118 | org.contikios.cooja.mspmote.interfaces.MspMoteID
119 | 3
120 |
121 | sky2
122 |
123 |
124 |
125 |
126 | org.contikios.cooja.interfaces.Position
127 | 20.753479300433114
128 | 27.98875720473701
129 | 0.0
130 |
131 |
132 | org.contikios.cooja.mspmote.interfaces.MspClock
133 | 1.0
134 |
135 |
136 | org.contikios.cooja.mspmote.interfaces.MspMoteID
137 | 4
138 |
139 | sky2
140 |
141 |
142 |
143 |
144 | org.contikios.cooja.interfaces.Position
145 | 38.221528276175874
146 | 15.234092247837836
147 | 0.0
148 |
149 |
150 | org.contikios.cooja.mspmote.interfaces.MspClock
151 | 1.0
152 |
153 |
154 | org.contikios.cooja.mspmote.interfaces.MspMoteID
155 | 5
156 |
157 | sky2
158 |
159 |
160 |
161 |
162 | org.contikios.cooja.interfaces.Position
163 | 58.257985348361274
164 | 37.1378970370735
165 | 0.0
166 |
167 |
168 | org.contikios.cooja.mspmote.interfaces.MspClock
169 | 1.0
170 |
171 |
172 | org.contikios.cooja.mspmote.interfaces.MspMoteID
173 | 6
174 |
175 | sky2
176 |
177 |
178 |
179 |
180 | org.contikios.cooja.interfaces.Position
181 | 71.45879070267844
182 | 45.313598647109295
183 | 0.0
184 |
185 |
186 | org.contikios.cooja.mspmote.interfaces.MspClock
187 | 1.0
188 |
189 |
190 | org.contikios.cooja.mspmote.interfaces.MspMoteID
191 | 7
192 |
193 | sky2
194 |
195 |
196 |
197 |
198 | org.contikios.cooja.interfaces.Position
199 | 48.491049594040064
200 | 52.20922673605821
201 | 0.0
202 |
203 |
204 | org.contikios.cooja.mspmote.interfaces.MspClock
205 | 1.0
206 |
207 |
208 | org.contikios.cooja.mspmote.interfaces.MspMoteID
209 | 8
210 |
211 | sky2
212 |
213 |
214 |
215 |
216 | org.contikios.cooja.interfaces.Position
217 | 33.00673836394147
218 | 40.27695816963818
219 | 0.0
220 |
221 |
222 | org.contikios.cooja.mspmote.interfaces.MspClock
223 | 1.0
224 |
225 |
226 | org.contikios.cooja.mspmote.interfaces.MspMoteID
227 | 9
228 |
229 | sky2
230 |
231 |
232 |
233 |
234 | org.contikios.cooja.interfaces.Position
235 | 72.76664013127424
236 | -0.9606322782931693
237 | 0.0
238 |
239 |
240 | org.contikios.cooja.mspmote.interfaces.MspClock
241 | 1.0
242 |
243 |
244 | org.contikios.cooja.mspmote.interfaces.MspMoteID
245 | 10
246 |
247 | sky2
248 |
249 |
250 |
251 |
252 | org.contikios.cooja.interfaces.Position
253 | 75.51699289426521
254 | 17.601314184407002
255 | 0.0
256 |
257 |
258 | org.contikios.cooja.mspmote.interfaces.MspClock
259 | 1.0
260 |
261 |
262 | org.contikios.cooja.mspmote.interfaces.MspMoteID
263 | 11
264 |
265 | sky2
266 |
267 |
268 |
269 |
270 | org.contikios.cooja.interfaces.Position
271 | 63.39456016152474
272 | 16.568686144274338
273 | 0.0
274 |
275 |
276 | org.contikios.cooja.mspmote.interfaces.MspClock
277 | 1.0
278 |
279 |
280 | org.contikios.cooja.mspmote.interfaces.MspMoteID
281 | 12
282 |
283 | sky2
284 |
285 |
286 |
287 | org.contikios.cooja.plugins.SimControl
288 | 280
289 | 0
290 | 160
291 | 3
292 | 401
293 |
294 |
295 | org.contikios.cooja.plugins.Visualizer
296 |
297 | true
298 | org.contikios.cooja.plugins.skins.IDVisualizerSkin
299 | org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin
300 | org.contikios.cooja.plugins.skins.UDGMVisualizerSkin
301 | org.contikios.cooja.plugins.skins.GridVisualizerSkin
302 | org.contikios.cooja.plugins.skins.TrafficVisualizerSkin
303 | 2.4979093180280176 0.0 0.0 2.4979093180280176 65.57430062313566 103.04011895259688
304 |
305 | 400
306 | 1
307 | 400
308 | 1
309 | 1
310 |
311 |
312 | org.contikios.cooja.plugins.LogListener
313 |
314 |
315 |
316 |
317 |
318 | 1040
319 | -1
320 | 240
321 | 400
322 | 160
323 | true
324 |
325 |
326 | org.contikios.cooja.plugins.TimeLine
327 |
328 | 0
329 | 1
330 | 2
331 | 3
332 | 4
333 | 5
334 | 6
335 | 7
336 | 8
337 | 9
338 | 10
339 | 11
340 |
341 |
342 |
343 | 500.0
344 |
345 | 1440
346 | 2
347 | 166
348 | 0
349 | 634
350 |
351 |
352 | org.contikios.cooja.plugins.Notes
353 |
354 | Enter notes here
355 | true
356 |
357 | 760
358 | -1
359 | 160
360 | 680
361 | 0
362 | true
363 |
364 |
365 | org.contikios.cooja.plugins.collectview.CollectView
366 | 0
367 | 233
368 | -1
369 | 72
370 | 57
371 | 423
372 | true
373 |
374 |
375 |
376 |
--------------------------------------------------------------------------------
/database/security_training/decreased_rank_attack/simulation/rpl-private-attack.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the Contiki operating system.
30 | *
31 | * \file
32 | * Private declarations for ContikiRPL.
33 | * \author
34 | * Joakim Eriksson , Nicolas Tsiftes
35 | */
36 |
37 | #ifndef RPL_PRIVATE_H
38 | #define RPL_PRIVATE_H
39 |
40 | #include "net/rpl/rpl.h"
41 |
42 | #include "lib/list.h"
43 | #include "net/ip/uip.h"
44 | #include "sys/clock.h"
45 | #include "sys/ctimer.h"
46 | #include "net/ipv6/uip-ds6.h"
47 | #include "net/ipv6/multicast/uip-mcast6.h"
48 |
49 | /*---------------------------------------------------------------------------*/
50 | /** \brief Is IPv6 address addr the link-local, all-RPL-nodes
51 | multicast address? */
52 | #define uip_is_addr_linklocal_rplnodes_mcast(addr) \
53 | ((addr)->u8[0] == 0xff) && \
54 | ((addr)->u8[1] == 0x02) && \
55 | ((addr)->u16[1] == 0) && \
56 | ((addr)->u16[2] == 0) && \
57 | ((addr)->u16[3] == 0) && \
58 | ((addr)->u16[4] == 0) && \
59 | ((addr)->u16[5] == 0) && \
60 | ((addr)->u16[6] == 0) && \
61 | ((addr)->u8[14] == 0) && \
62 | ((addr)->u8[15] == 0x1a))
63 |
64 | /** \brief Set IP address addr to the link-local, all-rpl-nodes
65 | multicast address. */
66 | #define uip_create_linklocal_rplnodes_mcast(addr) \
67 | uip_ip6addr((addr), 0xff02, 0, 0, 0, 0, 0, 0, 0x001a)
68 | /*---------------------------------------------------------------------------*/
69 | /* RPL message types */
70 | #define RPL_CODE_DIS 0x00 /* DAG Information Solicitation */
71 | #define RPL_CODE_DIO 0x01 /* DAG Information Option */
72 | #define RPL_CODE_DAO 0x02 /* Destination Advertisement Option */
73 | #define RPL_CODE_DAO_ACK 0x03 /* DAO acknowledgment */
74 | #define RPL_CODE_SEC_DIS 0x80 /* Secure DIS */
75 | #define RPL_CODE_SEC_DIO 0x81 /* Secure DIO */
76 | #define RPL_CODE_SEC_DAO 0x82 /* Secure DAO */
77 | #define RPL_CODE_SEC_DAO_ACK 0x83 /* Secure DAO ACK */
78 |
79 | /* RPL control message options. */
80 | #define RPL_OPTION_PAD1 0
81 | #define RPL_OPTION_PADN 1
82 | #define RPL_OPTION_DAG_METRIC_CONTAINER 2
83 | #define RPL_OPTION_ROUTE_INFO 3
84 | #define RPL_OPTION_DAG_CONF 4
85 | #define RPL_OPTION_TARGET 5
86 | #define RPL_OPTION_TRANSIT 6
87 | #define RPL_OPTION_SOLICITED_INFO 7
88 | #define RPL_OPTION_PREFIX_INFO 8
89 | #define RPL_OPTION_TARGET_DESC 9
90 |
91 | #define RPL_DAO_K_FLAG 0x80 /* DAO ACK requested */
92 | #define RPL_DAO_D_FLAG 0x40 /* DODAG ID present */
93 | /*---------------------------------------------------------------------------*/
94 | /* RPL IPv6 extension header option. */
95 | #define RPL_HDR_OPT_LEN 4
96 | #define RPL_HOP_BY_HOP_LEN (RPL_HDR_OPT_LEN + 2 + 2)
97 | #define RPL_HDR_OPT_DOWN 0x80
98 | #define RPL_HDR_OPT_DOWN_SHIFT 7
99 | #define RPL_HDR_OPT_RANK_ERR 0x40
100 | #define RPL_HDR_OPT_RANK_ERR_SHIFT 6
101 | #define RPL_HDR_OPT_FWD_ERR 0x20
102 | #define RPL_HDR_OPT_FWD_ERR_SHIFT 5
103 | /*---------------------------------------------------------------------------*/
104 | /* Default values for RPL constants and variables. */
105 |
106 | /* The default value for the DAO timer. */
107 | #ifdef RPL_CONF_DAO_LATENCY
108 | #define RPL_DAO_LATENCY RPL_CONF_DAO_LATENCY
109 | #else /* RPL_CONF_DAO_LATENCY */
110 | #define RPL_DAO_LATENCY (CLOCK_SECOND * 4)
111 | #endif /* RPL_DAO_LATENCY */
112 |
113 | /* Special value indicating immediate removal. */
114 | #define RPL_ZERO_LIFETIME 0
115 |
116 | #define RPL_LIFETIME(instance, lifetime) \
117 | ((unsigned long)(instance)->lifetime_unit * (lifetime))
118 |
119 | #ifndef RPL_CONF_MIN_HOPRANKINC
120 | #define RPL_CONF_MIN_HOPRANKINC 0 //added set RPL_CONF_MIN_HOPRANKINC to 0
121 | #define RPL_MIN_HOPRANKINC 256
122 | #else
123 | #define RPL_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC
124 | #endif
125 | #define RPL_MAX_RANKINC 0 //change (7 * RPL_MIN_HOPRANKINC) to 0
126 |
127 | #define DAG_RANK(fixpt_rank, instance) \
128 | ((fixpt_rank) / (instance)->min_hoprankinc)
129 |
130 | /* Rank of a virtual root node that coordinates DAG root nodes. */
131 | #define BASE_RANK 0
132 |
133 | /* Rank of a root node. */
134 | #define ROOT_RANK(instance) (instance)->min_hoprankinc
135 |
136 | #define INFINITE_RANK 256 //change 0xffff to 256
137 |
138 |
139 | /* Expire DAOs from neighbors that do not respond in this time. (seconds) */
140 | #define DAO_EXPIRATION_TIMEOUT 60
141 | /*---------------------------------------------------------------------------*/
142 | #define RPL_INSTANCE_LOCAL_FLAG 0x80
143 | #define RPL_INSTANCE_D_FLAG 0x40
144 |
145 | /* Values that tell where a route came from. */
146 | #define RPL_ROUTE_FROM_INTERNAL 0
147 | #define RPL_ROUTE_FROM_UNICAST_DAO 1
148 | #define RPL_ROUTE_FROM_MULTICAST_DAO 2
149 | #define RPL_ROUTE_FROM_DIO 3
150 |
151 | /* DAG Mode of Operation */
152 | #define RPL_MOP_NO_DOWNWARD_ROUTES 0
153 | #define RPL_MOP_NON_STORING 1
154 | #define RPL_MOP_STORING_NO_MULTICAST 2
155 | #define RPL_MOP_STORING_MULTICAST 3
156 |
157 | #ifdef RPL_CONF_MOP
158 | #define RPL_MOP_DEFAULT RPL_CONF_MOP
159 | #else /* RPL_CONF_MOP */
160 | #if RPL_CONF_MULTICAST
161 | #define RPL_MOP_DEFAULT RPL_MOP_STORING_MULTICAST
162 | #else
163 | #define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST
164 | #endif /* UIP_IPV6_MULTICAST_RPL */
165 | #endif /* RPL_CONF_MOP */
166 |
167 | /* Emit a pre-processor error if the user configured multicast with bad MOP */
168 | #if RPL_CONF_MULTICAST && (RPL_MOP_DEFAULT != RPL_MOP_STORING_MULTICAST)
169 | #error "RPL Multicast requires RPL_MOP_DEFAULT==3. Check contiki-conf.h"
170 | #endif
171 |
172 | /* Multicast Route Lifetime as a multiple of the lifetime unit */
173 | #ifdef RPL_CONF_MCAST_LIFETIME
174 | #define RPL_MCAST_LIFETIME RPL_CONF_MCAST_LIFETIME
175 | #else
176 | #define RPL_MCAST_LIFETIME 3
177 | #endif
178 |
179 | /*
180 | * The ETX in the metric container is expressed as a fixed-point value
181 | * whose integer part can be obtained by dividing the value by
182 | * RPL_DAG_MC_ETX_DIVISOR.
183 | */
184 | #define RPL_DAG_MC_ETX_DIVISOR 256
185 |
186 | /* DIS related */
187 | #define RPL_DIS_SEND 1
188 | #ifdef RPL_DIS_INTERVAL_CONF
189 | #define RPL_DIS_INTERVAL RPL_DIS_INTERVAL_CONF
190 | #else
191 | #define RPL_DIS_INTERVAL 60
192 | #endif
193 | #define RPL_DIS_START_DELAY 5
194 | /*---------------------------------------------------------------------------*/
195 | /* Lollipop counters */
196 |
197 | #define RPL_LOLLIPOP_MAX_VALUE 255
198 | #define RPL_LOLLIPOP_CIRCULAR_REGION 127
199 | #define RPL_LOLLIPOP_SEQUENCE_WINDOWS 16
200 | #define RPL_LOLLIPOP_INIT (RPL_LOLLIPOP_MAX_VALUE - RPL_LOLLIPOP_SEQUENCE_WINDOWS + 1)
201 | #define RPL_LOLLIPOP_INCREMENT(counter) \
202 | do { \
203 | if((counter) > RPL_LOLLIPOP_CIRCULAR_REGION) { \
204 | (counter) = ((counter) + 1) & RPL_LOLLIPOP_MAX_VALUE; \
205 | } else { \
206 | (counter) = ((counter) + 1) & RPL_LOLLIPOP_CIRCULAR_REGION; \
207 | } \
208 | } while(0)
209 |
210 | #define RPL_LOLLIPOP_IS_INIT(counter) \
211 | ((counter) > RPL_LOLLIPOP_CIRCULAR_REGION)
212 | /*---------------------------------------------------------------------------*/
213 | /* Logical representation of a DAG Information Object (DIO.) */
214 | struct rpl_dio {
215 | uip_ipaddr_t dag_id;
216 | rpl_ocp_t ocp;
217 | rpl_rank_t rank;
218 | uint8_t grounded;
219 | uint8_t mop;
220 | uint8_t preference;
221 | uint8_t version;
222 | uint8_t instance_id;
223 | uint8_t dtsn;
224 | uint8_t dag_intdoubl;
225 | uint8_t dag_intmin;
226 | uint8_t dag_redund;
227 | uint8_t default_lifetime;
228 | uint16_t lifetime_unit;
229 | rpl_rank_t dag_max_rankinc;
230 | rpl_rank_t dag_min_hoprankinc;
231 | rpl_prefix_t destination_prefix;
232 | rpl_prefix_t prefix_info;
233 | struct rpl_metric_container mc;
234 | };
235 | typedef struct rpl_dio rpl_dio_t;
236 |
237 | #if RPL_CONF_STATS
238 | /* Statistics for fault management. */
239 | struct rpl_stats {
240 | uint16_t mem_overflows;
241 | uint16_t local_repairs;
242 | uint16_t global_repairs;
243 | uint16_t malformed_msgs;
244 | uint16_t resets;
245 | uint16_t parent_switch;
246 | uint16_t forward_errors;
247 | uint16_t loop_errors;
248 | uint16_t loop_warnings;
249 | uint16_t root_repairs;
250 | };
251 | typedef struct rpl_stats rpl_stats_t;
252 |
253 | extern rpl_stats_t rpl_stats;
254 | #endif
255 | /*---------------------------------------------------------------------------*/
256 | /* RPL macros. */
257 |
258 | #if RPL_CONF_STATS
259 | #define RPL_STAT(code) (code)
260 | #else
261 | #define RPL_STAT(code)
262 | #endif /* RPL_CONF_STATS */
263 | /*---------------------------------------------------------------------------*/
264 | /* Instances */
265 | extern rpl_instance_t instance_table[];
266 | extern rpl_instance_t *default_instance;
267 |
268 | /* ICMPv6 functions for RPL. */
269 | void dis_output(uip_ipaddr_t *addr);
270 | void dio_output(rpl_instance_t *, uip_ipaddr_t *uc_addr);
271 | void dao_output(rpl_parent_t *, uint8_t lifetime);
272 | void dao_output_target(rpl_parent_t *, uip_ipaddr_t *, uint8_t lifetime);
273 | void dao_ack_output(rpl_instance_t *, uip_ipaddr_t *, uint8_t);
274 | void rpl_icmp6_register_handlers(void);
275 |
276 | /* RPL logic functions. */
277 | void rpl_join_dag(uip_ipaddr_t *from, rpl_dio_t *dio);
278 | void rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio);
279 | void rpl_local_repair(rpl_instance_t *instance);
280 | void rpl_process_dio(uip_ipaddr_t *, rpl_dio_t *);
281 | int rpl_process_parent_event(rpl_instance_t *, rpl_parent_t *);
282 |
283 | /* DAG object management. */
284 | rpl_dag_t *rpl_alloc_dag(uint8_t, uip_ipaddr_t *);
285 | rpl_instance_t *rpl_alloc_instance(uint8_t);
286 | void rpl_free_dag(rpl_dag_t *);
287 | void rpl_free_instance(rpl_instance_t *);
288 |
289 | /* DAG parent management function. */
290 | rpl_parent_t *rpl_add_parent(rpl_dag_t *, rpl_dio_t *dio, uip_ipaddr_t *);
291 | rpl_parent_t *rpl_find_parent(rpl_dag_t *, uip_ipaddr_t *);
292 | rpl_parent_t *rpl_find_parent_any_dag(rpl_instance_t *instance, uip_ipaddr_t *addr);
293 | void rpl_nullify_parent(rpl_parent_t *);
294 | void rpl_remove_parent(rpl_parent_t *);
295 | void rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent);
296 | rpl_parent_t *rpl_select_parent(rpl_dag_t *dag);
297 | rpl_dag_t *rpl_select_dag(rpl_instance_t *instance,rpl_parent_t *parent);
298 | void rpl_recalculate_ranks(void);
299 |
300 | /* RPL routing table functions. */
301 | void rpl_remove_routes(rpl_dag_t *dag);
302 | void rpl_remove_routes_by_nexthop(uip_ipaddr_t *nexthop, rpl_dag_t *dag);
303 | uip_ds6_route_t *rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix,
304 | int prefix_len, uip_ipaddr_t *next_hop);
305 | void rpl_purge_routes(void);
306 |
307 | /* Lock a parent in the neighbor cache. */
308 | void rpl_lock_parent(rpl_parent_t *p);
309 |
310 | /* Objective function. */
311 | rpl_of_t *rpl_find_of(rpl_ocp_t);
312 |
313 | /* Timer functions. */
314 | void rpl_schedule_dao(rpl_instance_t *);
315 | void rpl_schedule_dao_immediately(rpl_instance_t *);
316 | void rpl_cancel_dao(rpl_instance_t *instance);
317 | void rpl_schedule_probing(rpl_instance_t *instance);
318 |
319 | void rpl_reset_dio_timer(rpl_instance_t *);
320 | void rpl_reset_periodic_timer(void);
321 |
322 | /* Route poisoning. */
323 | void rpl_poison_routes(rpl_dag_t *, rpl_parent_t *);
324 |
325 |
326 | rpl_instance_t *rpl_get_default_instance(void);
327 |
328 | #endif /* RPL_PRIVATE_H */
329 |
--------------------------------------------------------------------------------
/database/security_training/decreased_rank_attack/simulation/rpl-private-reference.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the Contiki operating system.
30 | *
31 | * \file
32 | * Private declarations for ContikiRPL.
33 | * \author
34 | * Joakim Eriksson , Nicolas Tsiftes
35 | */
36 |
37 | #ifndef RPL_PRIVATE_H
38 | #define RPL_PRIVATE_H
39 |
40 | #include "net/rpl/rpl.h"
41 |
42 | #include "lib/list.h"
43 | #include "net/ip/uip.h"
44 | #include "sys/clock.h"
45 | #include "sys/ctimer.h"
46 | #include "net/ipv6/uip-ds6.h"
47 | #include "net/ipv6/multicast/uip-mcast6.h"
48 |
49 | /*---------------------------------------------------------------------------*/
50 | /** \brief Is IPv6 address addr the link-local, all-RPL-nodes
51 | multicast address? */
52 | #define uip_is_addr_linklocal_rplnodes_mcast(addr) \
53 | ((addr)->u8[0] == 0xff) && \
54 | ((addr)->u8[1] == 0x02) && \
55 | ((addr)->u16[1] == 0) && \
56 | ((addr)->u16[2] == 0) && \
57 | ((addr)->u16[3] == 0) && \
58 | ((addr)->u16[4] == 0) && \
59 | ((addr)->u16[5] == 0) && \
60 | ((addr)->u16[6] == 0) && \
61 | ((addr)->u8[14] == 0) && \
62 | ((addr)->u8[15] == 0x1a))
63 |
64 | /** \brief Set IP address addr to the link-local, all-rpl-nodes
65 | multicast address. */
66 | #define uip_create_linklocal_rplnodes_mcast(addr) \
67 | uip_ip6addr((addr), 0xff02, 0, 0, 0, 0, 0, 0, 0x001a)
68 | /*---------------------------------------------------------------------------*/
69 | /* RPL message types */
70 | #define RPL_CODE_DIS 0x00 /* DAG Information Solicitation */
71 | #define RPL_CODE_DIO 0x01 /* DAG Information Option */
72 | #define RPL_CODE_DAO 0x02 /* Destination Advertisement Option */
73 | #define RPL_CODE_DAO_ACK 0x03 /* DAO acknowledgment */
74 | #define RPL_CODE_SEC_DIS 0x80 /* Secure DIS */
75 | #define RPL_CODE_SEC_DIO 0x81 /* Secure DIO */
76 | #define RPL_CODE_SEC_DAO 0x82 /* Secure DAO */
77 | #define RPL_CODE_SEC_DAO_ACK 0x83 /* Secure DAO ACK */
78 |
79 | /* RPL control message options. */
80 | #define RPL_OPTION_PAD1 0
81 | #define RPL_OPTION_PADN 1
82 | #define RPL_OPTION_DAG_METRIC_CONTAINER 2
83 | #define RPL_OPTION_ROUTE_INFO 3
84 | #define RPL_OPTION_DAG_CONF 4
85 | #define RPL_OPTION_TARGET 5
86 | #define RPL_OPTION_TRANSIT 6
87 | #define RPL_OPTION_SOLICITED_INFO 7
88 | #define RPL_OPTION_PREFIX_INFO 8
89 | #define RPL_OPTION_TARGET_DESC 9
90 |
91 | #define RPL_DAO_K_FLAG 0x80 /* DAO ACK requested */
92 | #define RPL_DAO_D_FLAG 0x40 /* DODAG ID present */
93 | /*---------------------------------------------------------------------------*/
94 | /* RPL IPv6 extension header option. */
95 | #define RPL_HDR_OPT_LEN 4
96 | #define RPL_HOP_BY_HOP_LEN (RPL_HDR_OPT_LEN + 2 + 2)
97 | #define RPL_HDR_OPT_DOWN 0x80
98 | #define RPL_HDR_OPT_DOWN_SHIFT 7
99 | #define RPL_HDR_OPT_RANK_ERR 0x40
100 | #define RPL_HDR_OPT_RANK_ERR_SHIFT 6
101 | #define RPL_HDR_OPT_FWD_ERR 0x20
102 | #define RPL_HDR_OPT_FWD_ERR_SHIFT 5
103 | /*---------------------------------------------------------------------------*/
104 | /* Default values for RPL constants and variables. */
105 |
106 | /* The default value for the DAO timer. */
107 | #ifdef RPL_CONF_DAO_LATENCY
108 | #define RPL_DAO_LATENCY RPL_CONF_DAO_LATENCY
109 | #else /* RPL_CONF_DAO_LATENCY */
110 | #define RPL_DAO_LATENCY (CLOCK_SECOND * 4)
111 | #endif /* RPL_DAO_LATENCY */
112 |
113 | /* Special value indicating immediate removal. */
114 | #define RPL_ZERO_LIFETIME 0
115 |
116 | #define RPL_LIFETIME(instance, lifetime) \
117 | ((unsigned long)(instance)->lifetime_unit * (lifetime))
118 |
119 | #ifndef RPL_CONF_MIN_HOPRANKINC
120 | #define RPL_MIN_HOPRANKINC 256
121 | #else
122 | #define RPL_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC
123 | #endif
124 | #define RPL_MAX_RANKINC (7 * RPL_MIN_HOPRANKINC)
125 |
126 | #define DAG_RANK(fixpt_rank, instance) \
127 | ((fixpt_rank) / (instance)->min_hoprankinc)
128 |
129 | /* Rank of a virtual root node that coordinates DAG root nodes. */
130 | #define BASE_RANK 0
131 |
132 | /* Rank of a root node. */
133 | #define ROOT_RANK(instance) (instance)->min_hoprankinc
134 |
135 | #define INFINITE_RANK 0xffff
136 |
137 |
138 | /* Expire DAOs from neighbors that do not respond in this time. (seconds) */
139 | #define DAO_EXPIRATION_TIMEOUT 60
140 | /*---------------------------------------------------------------------------*/
141 | #define RPL_INSTANCE_LOCAL_FLAG 0x80
142 | #define RPL_INSTANCE_D_FLAG 0x40
143 |
144 | /* Values that tell where a route came from. */
145 | #define RPL_ROUTE_FROM_INTERNAL 0
146 | #define RPL_ROUTE_FROM_UNICAST_DAO 1
147 | #define RPL_ROUTE_FROM_MULTICAST_DAO 2
148 | #define RPL_ROUTE_FROM_DIO 3
149 |
150 | /* DAG Mode of Operation */
151 | #define RPL_MOP_NO_DOWNWARD_ROUTES 0
152 | #define RPL_MOP_NON_STORING 1
153 | #define RPL_MOP_STORING_NO_MULTICAST 2
154 | #define RPL_MOP_STORING_MULTICAST 3
155 |
156 | #ifdef RPL_CONF_MOP
157 | #define RPL_MOP_DEFAULT RPL_CONF_MOP
158 | #else /* RPL_CONF_MOP */
159 | #if RPL_CONF_MULTICAST
160 | #define RPL_MOP_DEFAULT RPL_MOP_STORING_MULTICAST
161 | #else
162 | #define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST
163 | #endif /* UIP_IPV6_MULTICAST_RPL */
164 | #endif /* RPL_CONF_MOP */
165 |
166 | /* Emit a pre-processor error if the user configured multicast with bad MOP */
167 | #if RPL_CONF_MULTICAST && (RPL_MOP_DEFAULT != RPL_MOP_STORING_MULTICAST)
168 | #error "RPL Multicast requires RPL_MOP_DEFAULT==3. Check contiki-conf.h"
169 | #endif
170 |
171 | /* Multicast Route Lifetime as a multiple of the lifetime unit */
172 | #ifdef RPL_CONF_MCAST_LIFETIME
173 | #define RPL_MCAST_LIFETIME RPL_CONF_MCAST_LIFETIME
174 | #else
175 | #define RPL_MCAST_LIFETIME 3
176 | #endif
177 |
178 | /*
179 | * The ETX in the metric container is expressed as a fixed-point value
180 | * whose integer part can be obtained by dividing the value by
181 | * RPL_DAG_MC_ETX_DIVISOR.
182 | */
183 | #define RPL_DAG_MC_ETX_DIVISOR 256
184 |
185 | /* DIS related */
186 | #define RPL_DIS_SEND 1
187 | #ifdef RPL_DIS_INTERVAL_CONF
188 | #define RPL_DIS_INTERVAL RPL_DIS_INTERVAL_CONF
189 | #else
190 | #define RPL_DIS_INTERVAL 60
191 | #endif
192 | #define RPL_DIS_START_DELAY 5
193 | /*---------------------------------------------------------------------------*/
194 | /* Lollipop counters */
195 |
196 | #define RPL_LOLLIPOP_MAX_VALUE 255
197 | #define RPL_LOLLIPOP_CIRCULAR_REGION 127
198 | #define RPL_LOLLIPOP_SEQUENCE_WINDOWS 16
199 | #define RPL_LOLLIPOP_INIT (RPL_LOLLIPOP_MAX_VALUE - RPL_LOLLIPOP_SEQUENCE_WINDOWS + 1)
200 | #define RPL_LOLLIPOP_INCREMENT(counter) \
201 | do { \
202 | if((counter) > RPL_LOLLIPOP_CIRCULAR_REGION) { \
203 | (counter) = ((counter) + 1) & RPL_LOLLIPOP_MAX_VALUE; \
204 | } else { \
205 | (counter) = ((counter) + 1) & RPL_LOLLIPOP_CIRCULAR_REGION; \
206 | } \
207 | } while(0)
208 |
209 | #define RPL_LOLLIPOP_IS_INIT(counter) \
210 | ((counter) > RPL_LOLLIPOP_CIRCULAR_REGION)
211 | /*---------------------------------------------------------------------------*/
212 | /* Logical representation of a DAG Information Object (DIO.) */
213 | struct rpl_dio {
214 | uip_ipaddr_t dag_id;
215 | rpl_ocp_t ocp;
216 | rpl_rank_t rank;
217 | uint8_t grounded;
218 | uint8_t mop;
219 | uint8_t preference;
220 | uint8_t version;
221 | uint8_t instance_id;
222 | uint8_t dtsn;
223 | uint8_t dag_intdoubl;
224 | uint8_t dag_intmin;
225 | uint8_t dag_redund;
226 | uint8_t default_lifetime;
227 | uint16_t lifetime_unit;
228 | rpl_rank_t dag_max_rankinc;
229 | rpl_rank_t dag_min_hoprankinc;
230 | rpl_prefix_t destination_prefix;
231 | rpl_prefix_t prefix_info;
232 | struct rpl_metric_container mc;
233 | };
234 | typedef struct rpl_dio rpl_dio_t;
235 |
236 | #if RPL_CONF_STATS
237 | /* Statistics for fault management. */
238 | struct rpl_stats {
239 | uint16_t mem_overflows;
240 | uint16_t local_repairs;
241 | uint16_t global_repairs;
242 | uint16_t malformed_msgs;
243 | uint16_t resets;
244 | uint16_t parent_switch;
245 | uint16_t forward_errors;
246 | uint16_t loop_errors;
247 | uint16_t loop_warnings;
248 | uint16_t root_repairs;
249 | };
250 | typedef struct rpl_stats rpl_stats_t;
251 |
252 | extern rpl_stats_t rpl_stats;
253 | #endif
254 | /*---------------------------------------------------------------------------*/
255 | /* RPL macros. */
256 |
257 | #if RPL_CONF_STATS
258 | #define RPL_STAT(code) (code)
259 | #else
260 | #define RPL_STAT(code)
261 | #endif /* RPL_CONF_STATS */
262 | /*---------------------------------------------------------------------------*/
263 | /* Instances */
264 | extern rpl_instance_t instance_table[];
265 | extern rpl_instance_t *default_instance;
266 |
267 | /* ICMPv6 functions for RPL. */
268 | void dis_output(uip_ipaddr_t *addr);
269 | void dio_output(rpl_instance_t *, uip_ipaddr_t *uc_addr);
270 | void dao_output(rpl_parent_t *, uint8_t lifetime);
271 | void dao_output_target(rpl_parent_t *, uip_ipaddr_t *, uint8_t lifetime);
272 | void dao_ack_output(rpl_instance_t *, uip_ipaddr_t *, uint8_t);
273 | void rpl_icmp6_register_handlers(void);
274 |
275 | /* RPL logic functions. */
276 | void rpl_join_dag(uip_ipaddr_t *from, rpl_dio_t *dio);
277 | void rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio);
278 | void rpl_local_repair(rpl_instance_t *instance);
279 | void rpl_process_dio(uip_ipaddr_t *, rpl_dio_t *);
280 | int rpl_process_parent_event(rpl_instance_t *, rpl_parent_t *);
281 |
282 | /* DAG object management. */
283 | rpl_dag_t *rpl_alloc_dag(uint8_t, uip_ipaddr_t *);
284 | rpl_instance_t *rpl_alloc_instance(uint8_t);
285 | void rpl_free_dag(rpl_dag_t *);
286 | void rpl_free_instance(rpl_instance_t *);
287 |
288 | /* DAG parent management function. */
289 | rpl_parent_t *rpl_add_parent(rpl_dag_t *, rpl_dio_t *dio, uip_ipaddr_t *);
290 | rpl_parent_t *rpl_find_parent(rpl_dag_t *, uip_ipaddr_t *);
291 | rpl_parent_t *rpl_find_parent_any_dag(rpl_instance_t *instance, uip_ipaddr_t *addr);
292 | void rpl_nullify_parent(rpl_parent_t *);
293 | void rpl_remove_parent(rpl_parent_t *);
294 | void rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent);
295 | rpl_parent_t *rpl_select_parent(rpl_dag_t *dag);
296 | rpl_dag_t *rpl_select_dag(rpl_instance_t *instance,rpl_parent_t *parent);
297 | void rpl_recalculate_ranks(void);
298 |
299 | /* RPL routing table functions. */
300 | void rpl_remove_routes(rpl_dag_t *dag);
301 | void rpl_remove_routes_by_nexthop(uip_ipaddr_t *nexthop, rpl_dag_t *dag);
302 | uip_ds6_route_t *rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix,
303 | int prefix_len, uip_ipaddr_t *next_hop);
304 | void rpl_purge_routes(void);
305 |
306 | /* Lock a parent in the neighbor cache. */
307 | void rpl_lock_parent(rpl_parent_t *p);
308 |
309 | /* Objective function. */
310 | rpl_of_t *rpl_find_of(rpl_ocp_t);
311 |
312 | /* Timer functions. */
313 | void rpl_schedule_dao(rpl_instance_t *);
314 | void rpl_schedule_dao_immediately(rpl_instance_t *);
315 | void rpl_cancel_dao(rpl_instance_t *instance);
316 | void rpl_schedule_probing(rpl_instance_t *instance);
317 |
318 | void rpl_reset_dio_timer(rpl_instance_t *);
319 | void rpl_reset_periodic_timer(void);
320 |
321 | /* Route poisoning. */
322 | void rpl_poison_routes(rpl_dag_t *, rpl_parent_t *);
323 |
324 |
325 | rpl_instance_t *rpl_get_default_instance(void);
326 |
327 | #endif /* RPL_PRIVATE_H */
328 |
--------------------------------------------------------------------------------
/database/security_training/dodag_version_attack/dodag_attack_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/security_training/dodag_version_attack/dodag_attack_tutorial.pdf
--------------------------------------------------------------------------------
/database/security_training/dodag_version_attack/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI = /home/user/contiki
2 | include $(CONTIKI)/Makefile.include
3 |
--------------------------------------------------------------------------------
/database/security_training/flooding_attack/flooding_attack_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/security_training/flooding_attack/flooding_attack_tutorial.pdf
--------------------------------------------------------------------------------
/database/security_training/flooding_attack/simulation/Makefile:
--------------------------------------------------------------------------------
1 | CONTIKI = /home/user/contiki
2 | include $(CONTIKI)/Makefile.include
3 |
--------------------------------------------------------------------------------
/database/security_training/flooding_attack/simulation/flooding_attack-reference.csc:
--------------------------------------------------------------------------------
1 |
2 |
3 | [APPS_DIR]/mrm
4 | [APPS_DIR]/mspsim
5 | [APPS_DIR]/avrora
6 | [APPS_DIR]/serial_socket
7 | [APPS_DIR]/collect-view
8 | [APPS_DIR]/powertracker
9 |
10 | My simulation
11 | 123456
12 | 1000000
13 |
14 | org.contikios.cooja.radiomediums.UDGM
15 | 50.0
16 | 100.0
17 | 1.0
18 | 1.0
19 |
20 |
21 | 40000
22 |
23 |
24 | org.contikios.cooja.mspmote.SkyMoteType
25 | sky1
26 | Sky Mote Type #sky1
27 | [CONTIKI_DIR]/examples/ipv6/rpl-collect/udp-sink.c
28 | make udp-sink.sky TARGET=sky
29 | [CONTIKI_DIR]/examples/ipv6/rpl-collect/udp-sink.sky
30 | org.contikios.cooja.interfaces.Position
31 | org.contikios.cooja.interfaces.RimeAddress
32 | org.contikios.cooja.interfaces.IPAddress
33 | org.contikios.cooja.interfaces.Mote2MoteRelations
34 | org.contikios.cooja.interfaces.MoteAttributes
35 | org.contikios.cooja.mspmote.interfaces.MspClock
36 | org.contikios.cooja.mspmote.interfaces.MspMoteID
37 | org.contikios.cooja.mspmote.interfaces.SkyButton
38 | org.contikios.cooja.mspmote.interfaces.SkyFlash
39 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
40 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
41 | org.contikios.cooja.mspmote.interfaces.MspSerial
42 | org.contikios.cooja.mspmote.interfaces.SkyLED
43 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
44 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
45 |
46 |
47 | org.contikios.cooja.mspmote.SkyMoteType
48 | sky2
49 | Sky Mote Type #sky2
50 | [CONTIKI_DIR]/examples/ipv6/rpl-collect/udp-sender.c
51 | make udp-sender.sky TARGET=sky
52 | [CONTIKI_DIR]/examples/ipv6/rpl-collect/udp-sender.sky
53 | org.contikios.cooja.interfaces.Position
54 | org.contikios.cooja.interfaces.RimeAddress
55 | org.contikios.cooja.interfaces.IPAddress
56 | org.contikios.cooja.interfaces.Mote2MoteRelations
57 | org.contikios.cooja.interfaces.MoteAttributes
58 | org.contikios.cooja.mspmote.interfaces.MspClock
59 | org.contikios.cooja.mspmote.interfaces.MspMoteID
60 | org.contikios.cooja.mspmote.interfaces.SkyButton
61 | org.contikios.cooja.mspmote.interfaces.SkyFlash
62 | org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem
63 | org.contikios.cooja.mspmote.interfaces.Msp802154Radio
64 | org.contikios.cooja.mspmote.interfaces.MspSerial
65 | org.contikios.cooja.mspmote.interfaces.SkyLED
66 | org.contikios.cooja.mspmote.interfaces.MspDebugOutput
67 | org.contikios.cooja.mspmote.interfaces.SkyTemperature
68 |
69 |
70 |
71 |
72 | org.contikios.cooja.interfaces.Position
73 | 66.77408473088543
74 | 62.49213269538768
75 | 0.0
76 |
77 |
78 | org.contikios.cooja.mspmote.interfaces.MspClock
79 | 1.0
80 |
81 |
82 | org.contikios.cooja.mspmote.interfaces.MspMoteID
83 | 1
84 |
85 | sky1
86 |
87 |
88 |
89 |
90 | org.contikios.cooja.interfaces.Position
91 | 46.77370528533292
92 | 64.9283448170887
93 | 0.0
94 |
95 |
96 | org.contikios.cooja.mspmote.interfaces.MspClock
97 | 1.0
98 |
99 |
100 | org.contikios.cooja.mspmote.interfaces.MspMoteID
101 | 2
102 |
103 | sky2
104 |
105 |
106 |
107 |
108 | org.contikios.cooja.interfaces.Position
109 | 82.27857258651014
110 | 53.70595861580715
111 | 0.0
112 |
113 |
114 | org.contikios.cooja.mspmote.interfaces.MspClock
115 | 1.0
116 |
117 |
118 | org.contikios.cooja.mspmote.interfaces.MspMoteID
119 | 3
120 |
121 | sky2
122 |
123 |
124 |
125 |
126 | org.contikios.cooja.interfaces.Position
127 | 65.70346721365557
128 | 73.611823416733
129 | 0.0
130 |
131 |
132 | org.contikios.cooja.mspmote.interfaces.MspClock
133 | 1.0
134 |
135 |
136 | org.contikios.cooja.mspmote.interfaces.MspMoteID
137 | 4
138 |
139 | sky2
140 |
141 |
142 |
143 |
144 | org.contikios.cooja.interfaces.Position
145 | 56.56247198688685
146 | 58.03021343350983
147 | 0.0
148 |
149 |
150 | org.contikios.cooja.mspmote.interfaces.MspClock
151 | 1.0
152 |
153 |
154 | org.contikios.cooja.mspmote.interfaces.MspMoteID
155 | 5
156 |
157 | sky2
158 |
159 |
160 |
161 |
162 | org.contikios.cooja.interfaces.Position
163 | 98.66030726873595
164 | 57.32280345404136
165 | 0.0
166 |
167 |
168 | org.contikios.cooja.mspmote.interfaces.MspClock
169 | 1.0
170 |
171 |
172 | org.contikios.cooja.mspmote.interfaces.MspMoteID
173 | 6
174 |
175 | sky2
176 |
177 |
178 |
179 |
180 | org.contikios.cooja.interfaces.Position
181 | 80.38215636326842
182 | 82.6835160044487
183 | 0.0
184 |
185 |
186 | org.contikios.cooja.mspmote.interfaces.MspClock
187 | 1.0
188 |
189 |
190 | org.contikios.cooja.mspmote.interfaces.MspMoteID
191 | 7
192 |
193 | sky2
194 |
195 |
196 |
197 |
198 | org.contikios.cooja.interfaces.Position
199 | 67.18193700105176
200 | 34.92761573475262
201 | 0.0
202 |
203 |
204 | org.contikios.cooja.mspmote.interfaces.MspClock
205 | 1.0
206 |
207 |
208 | org.contikios.cooja.mspmote.interfaces.MspMoteID
209 | 8
210 |
211 | sky2
212 |
213 |
214 |
215 |
216 | org.contikios.cooja.interfaces.Position
217 | 95.39730479038016
218 | 67.96950877270059
219 | 0.0
220 |
221 |
222 | org.contikios.cooja.mspmote.interfaces.MspClock
223 | 1.0
224 |
225 |
226 | org.contikios.cooja.mspmote.interfaces.MspMoteID
227 | 9
228 |
229 | sky2
230 |
231 |
232 |
233 |
234 | org.contikios.cooja.interfaces.Position
235 | 64.14029292166245
236 | 49.50109314197834
237 | 0.0
238 |
239 |
240 | org.contikios.cooja.mspmote.interfaces.MspClock
241 | 1.0
242 |
243 |
244 | org.contikios.cooja.mspmote.interfaces.MspMoteID
245 | 10
246 |
247 | sky2
248 |
249 |
250 |
251 |
252 | org.contikios.cooja.interfaces.Position
253 | 80.53843314689641
254 | 43.89303426357374
255 | 0.0
256 |
257 |
258 | org.contikios.cooja.mspmote.interfaces.MspClock
259 | 1.0
260 |
261 |
262 | org.contikios.cooja.mspmote.interfaces.MspMoteID
263 | 11
264 |
265 | sky2
266 |
267 |
268 |
269 |
270 | org.contikios.cooja.interfaces.Position
271 | 21.786856780401624
272 | 89.78867228743002
273 | 0.0
274 |
275 |
276 | org.contikios.cooja.mspmote.interfaces.MspClock
277 | 1.0
278 |
279 |
280 | org.contikios.cooja.mspmote.interfaces.MspMoteID
281 | 12
282 |
283 | sky2
284 |
285 |
286 |
287 | org.contikios.cooja.plugins.SimControl
288 | 280
289 | 1
290 | 160
291 | 2
292 | 612
293 |
294 |
295 | org.contikios.cooja.plugins.Visualizer
296 |
297 | true
298 | org.contikios.cooja.plugins.skins.IDVisualizerSkin
299 | org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin
300 | org.contikios.cooja.plugins.skins.UDGMVisualizerSkin
301 | org.contikios.cooja.plugins.skins.GridVisualizerSkin
302 | org.contikios.cooja.plugins.skins.TrafficVisualizerSkin
303 | 3.2258436842982627 0.0 0.0 3.2258436842982627 85.7139442117867 -19.616083466422445
304 |
305 | 563
306 | 0
307 | 560
308 | 1
309 | 1
310 |
311 |
312 | org.contikios.cooja.plugins.LogListener
313 |
314 |
315 |
316 |
317 |
318 | 1040
319 | -1
320 | 240
321 | 400
322 | 160
323 | true
324 |
325 |
326 | org.contikios.cooja.plugins.TimeLine
327 |
328 | 0
329 | 1
330 | 2
331 | 3
332 | 4
333 | 5
334 | 6
335 | 7
336 | 8
337 | 9
338 | 10
339 | 11
340 |
341 |
342 |
343 | 500.0
344 |
345 | 1440
346 | -1
347 | 166
348 | 0
349 | 634
350 | true
351 |
352 |
353 | org.contikios.cooja.plugins.Notes
354 |
355 | Enter notes here
356 | true
357 |
358 | 760
359 | -1
360 | 160
361 | 680
362 | 0
363 | true
364 |
365 |
366 | org.contikios.cooja.plugins.collectview.CollectView
367 | 0
368 | 233
369 | -1
370 | 72
371 | 58
372 | 435
373 | true
374 |
375 |
376 |
377 |
--------------------------------------------------------------------------------
/database/security_training/flooding_attack/simulation/rpl-private-attack.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the Contiki operating system.
30 | *
31 | * \file
32 | * Private declarations for ContikiRPL.
33 | * \author
34 | * Joakim Eriksson , Nicolas Tsiftes
35 | */
36 |
37 | #ifndef RPL_PRIVATE_H
38 | #define RPL_PRIVATE_H
39 |
40 | #include "net/rpl/rpl.h"
41 |
42 | #include "lib/list.h"
43 | #include "net/ip/uip.h"
44 | #include "sys/clock.h"
45 | #include "sys/ctimer.h"
46 | #include "net/ipv6/uip-ds6.h"
47 | #include "net/ipv6/multicast/uip-mcast6.h"
48 |
49 | /*---------------------------------------------------------------------------*/
50 | /** \brief Is IPv6 address addr the link-local, all-RPL-nodes
51 | multicast address? */
52 | #define uip_is_addr_linklocal_rplnodes_mcast(addr) \
53 | ((addr)->u8[0] == 0xff) && \
54 | ((addr)->u8[1] == 0x02) && \
55 | ((addr)->u16[1] == 0) && \
56 | ((addr)->u16[2] == 0) && \
57 | ((addr)->u16[3] == 0) && \
58 | ((addr)->u16[4] == 0) && \
59 | ((addr)->u16[5] == 0) && \
60 | ((addr)->u16[6] == 0) && \
61 | ((addr)->u8[14] == 0) && \
62 | ((addr)->u8[15] == 0x1a))
63 |
64 | /** \brief Set IP address addr to the link-local, all-rpl-nodes
65 | multicast address. */
66 | #define uip_create_linklocal_rplnodes_mcast(addr) \
67 | uip_ip6addr((addr), 0xff02, 0, 0, 0, 0, 0, 0, 0x001a)
68 | /*---------------------------------------------------------------------------*/
69 | /* RPL message types */
70 | #define RPL_CODE_DIS 0x00 /* DAG Information Solicitation */
71 | #define RPL_CODE_DIO 0x01 /* DAG Information Option */
72 | #define RPL_CODE_DAO 0x02 /* Destination Advertisement Option */
73 | #define RPL_CODE_DAO_ACK 0x03 /* DAO acknowledgment */
74 | #define RPL_CODE_SEC_DIS 0x80 /* Secure DIS */
75 | #define RPL_CODE_SEC_DIO 0x81 /* Secure DIO */
76 | #define RPL_CODE_SEC_DAO 0x82 /* Secure DAO */
77 | #define RPL_CODE_SEC_DAO_ACK 0x83 /* Secure DAO ACK */
78 |
79 | /* RPL control message options. */
80 | #define RPL_OPTION_PAD1 0
81 | #define RPL_OPTION_PADN 1
82 | #define RPL_OPTION_DAG_METRIC_CONTAINER 2
83 | #define RPL_OPTION_ROUTE_INFO 3
84 | #define RPL_OPTION_DAG_CONF 4
85 | #define RPL_OPTION_TARGET 5
86 | #define RPL_OPTION_TRANSIT 6
87 | #define RPL_OPTION_SOLICITED_INFO 7
88 | #define RPL_OPTION_PREFIX_INFO 8
89 | #define RPL_OPTION_TARGET_DESC 9
90 |
91 | #define RPL_DAO_K_FLAG 0x80 /* DAO ACK requested */
92 | #define RPL_DAO_D_FLAG 0x40 /* DODAG ID present */
93 | /*---------------------------------------------------------------------------*/
94 | /* RPL IPv6 extension header option. */
95 | #define RPL_HDR_OPT_LEN 4
96 | #define RPL_HOP_BY_HOP_LEN (RPL_HDR_OPT_LEN + 2 + 2)
97 | #define RPL_HDR_OPT_DOWN 0x80
98 | #define RPL_HDR_OPT_DOWN_SHIFT 7
99 | #define RPL_HDR_OPT_RANK_ERR 0x40
100 | #define RPL_HDR_OPT_RANK_ERR_SHIFT 6
101 | #define RPL_HDR_OPT_FWD_ERR 0x20
102 | #define RPL_HDR_OPT_FWD_ERR_SHIFT 5
103 | /*---------------------------------------------------------------------------*/
104 | /* Default values for RPL constants and variables. */
105 |
106 | /* The default value for the DAO timer. */
107 | #ifdef RPL_CONF_DAO_LATENCY
108 | #define RPL_DAO_LATENCY RPL_CONF_DAO_LATENCY
109 | #else /* RPL_CONF_DAO_LATENCY */
110 | #define RPL_DAO_LATENCY (CLOCK_SECOND * 4)
111 | #endif /* RPL_DAO_LATENCY */
112 |
113 | /* Special value indicating immediate removal. */
114 | #define RPL_ZERO_LIFETIME 0
115 |
116 | #define RPL_LIFETIME(instance, lifetime) \
117 | ((unsigned long)(instance)->lifetime_unit * (lifetime))
118 |
119 | #ifndef RPL_CONF_MIN_HOPRANKINC
120 | #define RPL_MIN_HOPRANKINC 256
121 | #else
122 | #define RPL_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC
123 | #endif
124 | #define RPL_MAX_RANKINC (7 * RPL_MIN_HOPRANKINC)
125 |
126 | #define DAG_RANK(fixpt_rank, instance) \
127 | ((fixpt_rank) / (instance)->min_hoprankinc)
128 |
129 | /* Rank of a virtual root node that coordinates DAG root nodes. */
130 | #define BASE_RANK 0
131 |
132 | /* Rank of a root node. */
133 | #define ROOT_RANK(instance) (instance)->min_hoprankinc
134 |
135 | #define INFINITE_RANK 0xffff
136 |
137 |
138 | /* Expire DAOs from neighbors that do not respond in this time. (seconds) */
139 | #define DAO_EXPIRATION_TIMEOUT 60
140 | /*---------------------------------------------------------------------------*/
141 | #define RPL_INSTANCE_LOCAL_FLAG 0x80
142 | #define RPL_INSTANCE_D_FLAG 0x40
143 |
144 | /* Values that tell where a route came from. */
145 | #define RPL_ROUTE_FROM_INTERNAL 0
146 | #define RPL_ROUTE_FROM_UNICAST_DAO 1
147 | #define RPL_ROUTE_FROM_MULTICAST_DAO 2
148 | #define RPL_ROUTE_FROM_DIO 3
149 |
150 | /* DAG Mode of Operation */
151 | #define RPL_MOP_NO_DOWNWARD_ROUTES 0
152 | #define RPL_MOP_NON_STORING 1
153 | #define RPL_MOP_STORING_NO_MULTICAST 2
154 | #define RPL_MOP_STORING_MULTICAST 3
155 |
156 | #ifdef RPL_CONF_MOP
157 | #define RPL_MOP_DEFAULT RPL_CONF_MOP
158 | #else /* RPL_CONF_MOP */
159 | #if RPL_CONF_MULTICAST
160 | #define RPL_MOP_DEFAULT RPL_MOP_STORING_MULTICAST
161 | #else
162 | #define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST
163 | #endif /* UIP_IPV6_MULTICAST_RPL */
164 | #endif /* RPL_CONF_MOP */
165 |
166 | /* Emit a pre-processor error if the user configured multicast with bad MOP */
167 | #if RPL_CONF_MULTICAST && (RPL_MOP_DEFAULT != RPL_MOP_STORING_MULTICAST)
168 | #error "RPL Multicast requires RPL_MOP_DEFAULT==3. Check contiki-conf.h"
169 | #endif
170 |
171 | /* Multicast Route Lifetime as a multiple of the lifetime unit */
172 | #ifdef RPL_CONF_MCAST_LIFETIME
173 | #define RPL_MCAST_LIFETIME RPL_CONF_MCAST_LIFETIME
174 | #else
175 | #define RPL_MCAST_LIFETIME 3
176 | #endif
177 |
178 | /*
179 | * The ETX in the metric container is expressed as a fixed-point value
180 | * whose integer part can be obtained by dividing the value by
181 | * RPL_DAG_MC_ETX_DIVISOR.
182 | */
183 | #define RPL_DAG_MC_ETX_DIVISOR 256
184 |
185 | /* DIS related */
186 | #define RPL_DIS_SEND 1
187 | #ifdef RPL_DIS_INTERVAL_CONF
188 | #define RPL_DIS_INTERVAL RPL_DIS_INTERVAL_CONF
189 | #else
190 | #define RPL_DIS_INTERVAL 0 /*The Original Value was 60*/
191 | #endif
192 | #define RPL_DIS_START_DELAY 0 /*The Original Value was 5*/
193 | /*---------------------------------------------------------------------------*/
194 | /* Lollipop counters */
195 |
196 | #define RPL_LOLLIPOP_MAX_VALUE 255
197 | #define RPL_LOLLIPOP_CIRCULAR_REGION 127
198 | #define RPL_LOLLIPOP_SEQUENCE_WINDOWS 16
199 | #define RPL_LOLLIPOP_INIT (RPL_LOLLIPOP_MAX_VALUE - RPL_LOLLIPOP_SEQUENCE_WINDOWS + 1)
200 | #define RPL_LOLLIPOP_INCREMENT(counter) \
201 | do { \
202 | if((counter) > RPL_LOLLIPOP_CIRCULAR_REGION) { \
203 | (counter) = ((counter) + 1) & RPL_LOLLIPOP_MAX_VALUE; \
204 | } else { \
205 | (counter) = ((counter) + 1) & RPL_LOLLIPOP_CIRCULAR_REGION; \
206 | } \
207 | } while(0)
208 |
209 | #define RPL_LOLLIPOP_IS_INIT(counter) \
210 | ((counter) > RPL_LOLLIPOP_CIRCULAR_REGION)
211 | /*---------------------------------------------------------------------------*/
212 | /* Logical representation of a DAG Information Object (DIO.) */
213 | struct rpl_dio {
214 | uip_ipaddr_t dag_id;
215 | rpl_ocp_t ocp;
216 | rpl_rank_t rank;
217 | uint8_t grounded;
218 | uint8_t mop;
219 | uint8_t preference;
220 | uint8_t version;
221 | uint8_t instance_id;
222 | uint8_t dtsn;
223 | uint8_t dag_intdoubl;
224 | uint8_t dag_intmin;
225 | uint8_t dag_redund;
226 | uint8_t default_lifetime;
227 | uint16_t lifetime_unit;
228 | rpl_rank_t dag_max_rankinc;
229 | rpl_rank_t dag_min_hoprankinc;
230 | rpl_prefix_t destination_prefix;
231 | rpl_prefix_t prefix_info;
232 | struct rpl_metric_container mc;
233 | };
234 | typedef struct rpl_dio rpl_dio_t;
235 |
236 | #if RPL_CONF_STATS
237 | /* Statistics for fault management. */
238 | struct rpl_stats {
239 | uint16_t mem_overflows;
240 | uint16_t local_repairs;
241 | uint16_t global_repairs;
242 | uint16_t malformed_msgs;
243 | uint16_t resets;
244 | uint16_t parent_switch;
245 | uint16_t forward_errors;
246 | uint16_t loop_errors;
247 | uint16_t loop_warnings;
248 | uint16_t root_repairs;
249 | };
250 | typedef struct rpl_stats rpl_stats_t;
251 |
252 | extern rpl_stats_t rpl_stats;
253 | #endif
254 | /*---------------------------------------------------------------------------*/
255 | /* RPL macros. */
256 |
257 | #if RPL_CONF_STATS
258 | #define RPL_STAT(code) (code)
259 | #else
260 | #define RPL_STAT(code)
261 | #endif /* RPL_CONF_STATS */
262 | /*---------------------------------------------------------------------------*/
263 | /* Instances */
264 | extern rpl_instance_t instance_table[];
265 | extern rpl_instance_t *default_instance;
266 |
267 | /* ICMPv6 functions for RPL. */
268 | void dis_output(uip_ipaddr_t *addr);
269 | void dio_output(rpl_instance_t *, uip_ipaddr_t *uc_addr);
270 | void dao_output(rpl_parent_t *, uint8_t lifetime);
271 | void dao_output_target(rpl_parent_t *, uip_ipaddr_t *, uint8_t lifetime);
272 | void dao_ack_output(rpl_instance_t *, uip_ipaddr_t *, uint8_t);
273 | void rpl_icmp6_register_handlers(void);
274 |
275 | /* RPL logic functions. */
276 | void rpl_join_dag(uip_ipaddr_t *from, rpl_dio_t *dio);
277 | void rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio);
278 | void rpl_local_repair(rpl_instance_t *instance);
279 | void rpl_process_dio(uip_ipaddr_t *, rpl_dio_t *);
280 | int rpl_process_parent_event(rpl_instance_t *, rpl_parent_t *);
281 |
282 | /* DAG object management. */
283 | rpl_dag_t *rpl_alloc_dag(uint8_t, uip_ipaddr_t *);
284 | rpl_instance_t *rpl_alloc_instance(uint8_t);
285 | void rpl_free_dag(rpl_dag_t *);
286 | void rpl_free_instance(rpl_instance_t *);
287 |
288 | /* DAG parent management function. */
289 | rpl_parent_t *rpl_add_parent(rpl_dag_t *, rpl_dio_t *dio, uip_ipaddr_t *);
290 | rpl_parent_t *rpl_find_parent(rpl_dag_t *, uip_ipaddr_t *);
291 | rpl_parent_t *rpl_find_parent_any_dag(rpl_instance_t *instance, uip_ipaddr_t *addr);
292 | void rpl_nullify_parent(rpl_parent_t *);
293 | void rpl_remove_parent(rpl_parent_t *);
294 | void rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent);
295 | rpl_parent_t *rpl_select_parent(rpl_dag_t *dag);
296 | rpl_dag_t *rpl_select_dag(rpl_instance_t *instance,rpl_parent_t *parent);
297 | void rpl_recalculate_ranks(void);
298 |
299 | /* RPL routing table functions. */
300 | void rpl_remove_routes(rpl_dag_t *dag);
301 | void rpl_remove_routes_by_nexthop(uip_ipaddr_t *nexthop, rpl_dag_t *dag);
302 | uip_ds6_route_t *rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix,
303 | int prefix_len, uip_ipaddr_t *next_hop);
304 | void rpl_purge_routes(void);
305 |
306 | /* Lock a parent in the neighbor cache. */
307 | void rpl_lock_parent(rpl_parent_t *p);
308 |
309 | /* Objective function. */
310 | rpl_of_t *rpl_find_of(rpl_ocp_t);
311 |
312 | /* Timer functions. */
313 | void rpl_schedule_dao(rpl_instance_t *);
314 | void rpl_schedule_dao_immediately(rpl_instance_t *);
315 | void rpl_cancel_dao(rpl_instance_t *instance);
316 | void rpl_schedule_probing(rpl_instance_t *instance);
317 |
318 | void rpl_reset_dio_timer(rpl_instance_t *);
319 | void rpl_reset_periodic_timer(void);
320 |
321 | /* Route poisoning. */
322 | void rpl_poison_routes(rpl_dag_t *, rpl_parent_t *);
323 |
324 |
325 | rpl_instance_t *rpl_get_default_instance(void);
326 |
327 | #endif /* RPL_PRIVATE_H */
328 |
--------------------------------------------------------------------------------
/database/security_training/flooding_attack/simulation/rpl-private-reference.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the Contiki operating system.
30 | *
31 | * \file
32 | * Private declarations for ContikiRPL.
33 | * \author
34 | * Joakim Eriksson , Nicolas Tsiftes
35 | */
36 |
37 | #ifndef RPL_PRIVATE_H
38 | #define RPL_PRIVATE_H
39 |
40 | #include "net/rpl/rpl.h"
41 |
42 | #include "lib/list.h"
43 | #include "net/ip/uip.h"
44 | #include "sys/clock.h"
45 | #include "sys/ctimer.h"
46 | #include "net/ipv6/uip-ds6.h"
47 | #include "net/ipv6/multicast/uip-mcast6.h"
48 |
49 | /*---------------------------------------------------------------------------*/
50 | /** \brief Is IPv6 address addr the link-local, all-RPL-nodes
51 | multicast address? */
52 | #define uip_is_addr_linklocal_rplnodes_mcast(addr) \
53 | ((addr)->u8[0] == 0xff) && \
54 | ((addr)->u8[1] == 0x02) && \
55 | ((addr)->u16[1] == 0) && \
56 | ((addr)->u16[2] == 0) && \
57 | ((addr)->u16[3] == 0) && \
58 | ((addr)->u16[4] == 0) && \
59 | ((addr)->u16[5] == 0) && \
60 | ((addr)->u16[6] == 0) && \
61 | ((addr)->u8[14] == 0) && \
62 | ((addr)->u8[15] == 0x1a))
63 |
64 | /** \brief Set IP address addr to the link-local, all-rpl-nodes
65 | multicast address. */
66 | #define uip_create_linklocal_rplnodes_mcast(addr) \
67 | uip_ip6addr((addr), 0xff02, 0, 0, 0, 0, 0, 0, 0x001a)
68 | /*---------------------------------------------------------------------------*/
69 | /* RPL message types */
70 | #define RPL_CODE_DIS 0x00 /* DAG Information Solicitation */
71 | #define RPL_CODE_DIO 0x01 /* DAG Information Option */
72 | #define RPL_CODE_DAO 0x02 /* Destination Advertisement Option */
73 | #define RPL_CODE_DAO_ACK 0x03 /* DAO acknowledgment */
74 | #define RPL_CODE_SEC_DIS 0x80 /* Secure DIS */
75 | #define RPL_CODE_SEC_DIO 0x81 /* Secure DIO */
76 | #define RPL_CODE_SEC_DAO 0x82 /* Secure DAO */
77 | #define RPL_CODE_SEC_DAO_ACK 0x83 /* Secure DAO ACK */
78 |
79 | /* RPL control message options. */
80 | #define RPL_OPTION_PAD1 0
81 | #define RPL_OPTION_PADN 1
82 | #define RPL_OPTION_DAG_METRIC_CONTAINER 2
83 | #define RPL_OPTION_ROUTE_INFO 3
84 | #define RPL_OPTION_DAG_CONF 4
85 | #define RPL_OPTION_TARGET 5
86 | #define RPL_OPTION_TRANSIT 6
87 | #define RPL_OPTION_SOLICITED_INFO 7
88 | #define RPL_OPTION_PREFIX_INFO 8
89 | #define RPL_OPTION_TARGET_DESC 9
90 |
91 | #define RPL_DAO_K_FLAG 0x80 /* DAO ACK requested */
92 | #define RPL_DAO_D_FLAG 0x40 /* DODAG ID present */
93 | /*---------------------------------------------------------------------------*/
94 | /* RPL IPv6 extension header option. */
95 | #define RPL_HDR_OPT_LEN 4
96 | #define RPL_HOP_BY_HOP_LEN (RPL_HDR_OPT_LEN + 2 + 2)
97 | #define RPL_HDR_OPT_DOWN 0x80
98 | #define RPL_HDR_OPT_DOWN_SHIFT 7
99 | #define RPL_HDR_OPT_RANK_ERR 0x40
100 | #define RPL_HDR_OPT_RANK_ERR_SHIFT 6
101 | #define RPL_HDR_OPT_FWD_ERR 0x20
102 | #define RPL_HDR_OPT_FWD_ERR_SHIFT 5
103 | /*---------------------------------------------------------------------------*/
104 | /* Default values for RPL constants and variables. */
105 |
106 | /* The default value for the DAO timer. */
107 | #ifdef RPL_CONF_DAO_LATENCY
108 | #define RPL_DAO_LATENCY RPL_CONF_DAO_LATENCY
109 | #else /* RPL_CONF_DAO_LATENCY */
110 | #define RPL_DAO_LATENCY (CLOCK_SECOND * 4)
111 | #endif /* RPL_DAO_LATENCY */
112 |
113 | /* Special value indicating immediate removal. */
114 | #define RPL_ZERO_LIFETIME 0
115 |
116 | #define RPL_LIFETIME(instance, lifetime) \
117 | ((unsigned long)(instance)->lifetime_unit * (lifetime))
118 |
119 | #ifndef RPL_CONF_MIN_HOPRANKINC
120 | #define RPL_MIN_HOPRANKINC 256
121 | #else
122 | #define RPL_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC
123 | #endif
124 | #define RPL_MAX_RANKINC (7 * RPL_MIN_HOPRANKINC)
125 |
126 | #define DAG_RANK(fixpt_rank, instance) \
127 | ((fixpt_rank) / (instance)->min_hoprankinc)
128 |
129 | /* Rank of a virtual root node that coordinates DAG root nodes. */
130 | #define BASE_RANK 0
131 |
132 | /* Rank of a root node. */
133 | #define ROOT_RANK(instance) (instance)->min_hoprankinc
134 |
135 | #define INFINITE_RANK 0xffff
136 |
137 |
138 | /* Expire DAOs from neighbors that do not respond in this time. (seconds) */
139 | #define DAO_EXPIRATION_TIMEOUT 60
140 | /*---------------------------------------------------------------------------*/
141 | #define RPL_INSTANCE_LOCAL_FLAG 0x80
142 | #define RPL_INSTANCE_D_FLAG 0x40
143 |
144 | /* Values that tell where a route came from. */
145 | #define RPL_ROUTE_FROM_INTERNAL 0
146 | #define RPL_ROUTE_FROM_UNICAST_DAO 1
147 | #define RPL_ROUTE_FROM_MULTICAST_DAO 2
148 | #define RPL_ROUTE_FROM_DIO 3
149 |
150 | /* DAG Mode of Operation */
151 | #define RPL_MOP_NO_DOWNWARD_ROUTES 0
152 | #define RPL_MOP_NON_STORING 1
153 | #define RPL_MOP_STORING_NO_MULTICAST 2
154 | #define RPL_MOP_STORING_MULTICAST 3
155 |
156 | #ifdef RPL_CONF_MOP
157 | #define RPL_MOP_DEFAULT RPL_CONF_MOP
158 | #else /* RPL_CONF_MOP */
159 | #if RPL_CONF_MULTICAST
160 | #define RPL_MOP_DEFAULT RPL_MOP_STORING_MULTICAST
161 | #else
162 | #define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST
163 | #endif /* UIP_IPV6_MULTICAST_RPL */
164 | #endif /* RPL_CONF_MOP */
165 |
166 | /* Emit a pre-processor error if the user configured multicast with bad MOP */
167 | #if RPL_CONF_MULTICAST && (RPL_MOP_DEFAULT != RPL_MOP_STORING_MULTICAST)
168 | #error "RPL Multicast requires RPL_MOP_DEFAULT==3. Check contiki-conf.h"
169 | #endif
170 |
171 | /* Multicast Route Lifetime as a multiple of the lifetime unit */
172 | #ifdef RPL_CONF_MCAST_LIFETIME
173 | #define RPL_MCAST_LIFETIME RPL_CONF_MCAST_LIFETIME
174 | #else
175 | #define RPL_MCAST_LIFETIME 3
176 | #endif
177 |
178 | /*
179 | * The ETX in the metric container is expressed as a fixed-point value
180 | * whose integer part can be obtained by dividing the value by
181 | * RPL_DAG_MC_ETX_DIVISOR.
182 | */
183 | #define RPL_DAG_MC_ETX_DIVISOR 256
184 |
185 | /* DIS related */
186 | #define RPL_DIS_SEND 1
187 | #ifdef RPL_DIS_INTERVAL_CONF
188 | #define RPL_DIS_INTERVAL RPL_DIS_INTERVAL_CONF
189 | #else
190 | #define RPL_DIS_INTERVAL 60
191 | #endif
192 | #define RPL_DIS_START_DELAY 5
193 | /*---------------------------------------------------------------------------*/
194 | /* Lollipop counters */
195 |
196 | #define RPL_LOLLIPOP_MAX_VALUE 255
197 | #define RPL_LOLLIPOP_CIRCULAR_REGION 127
198 | #define RPL_LOLLIPOP_SEQUENCE_WINDOWS 16
199 | #define RPL_LOLLIPOP_INIT (RPL_LOLLIPOP_MAX_VALUE - RPL_LOLLIPOP_SEQUENCE_WINDOWS + 1)
200 | #define RPL_LOLLIPOP_INCREMENT(counter) \
201 | do { \
202 | if((counter) > RPL_LOLLIPOP_CIRCULAR_REGION) { \
203 | (counter) = ((counter) + 1) & RPL_LOLLIPOP_MAX_VALUE; \
204 | } else { \
205 | (counter) = ((counter) + 1) & RPL_LOLLIPOP_CIRCULAR_REGION; \
206 | } \
207 | } while(0)
208 |
209 | #define RPL_LOLLIPOP_IS_INIT(counter) \
210 | ((counter) > RPL_LOLLIPOP_CIRCULAR_REGION)
211 | /*---------------------------------------------------------------------------*/
212 | /* Logical representation of a DAG Information Object (DIO.) */
213 | struct rpl_dio {
214 | uip_ipaddr_t dag_id;
215 | rpl_ocp_t ocp;
216 | rpl_rank_t rank;
217 | uint8_t grounded;
218 | uint8_t mop;
219 | uint8_t preference;
220 | uint8_t version;
221 | uint8_t instance_id;
222 | uint8_t dtsn;
223 | uint8_t dag_intdoubl;
224 | uint8_t dag_intmin;
225 | uint8_t dag_redund;
226 | uint8_t default_lifetime;
227 | uint16_t lifetime_unit;
228 | rpl_rank_t dag_max_rankinc;
229 | rpl_rank_t dag_min_hoprankinc;
230 | rpl_prefix_t destination_prefix;
231 | rpl_prefix_t prefix_info;
232 | struct rpl_metric_container mc;
233 | };
234 | typedef struct rpl_dio rpl_dio_t;
235 |
236 | #if RPL_CONF_STATS
237 | /* Statistics for fault management. */
238 | struct rpl_stats {
239 | uint16_t mem_overflows;
240 | uint16_t local_repairs;
241 | uint16_t global_repairs;
242 | uint16_t malformed_msgs;
243 | uint16_t resets;
244 | uint16_t parent_switch;
245 | uint16_t forward_errors;
246 | uint16_t loop_errors;
247 | uint16_t loop_warnings;
248 | uint16_t root_repairs;
249 | };
250 | typedef struct rpl_stats rpl_stats_t;
251 |
252 | extern rpl_stats_t rpl_stats;
253 | #endif
254 | /*---------------------------------------------------------------------------*/
255 | /* RPL macros. */
256 |
257 | #if RPL_CONF_STATS
258 | #define RPL_STAT(code) (code)
259 | #else
260 | #define RPL_STAT(code)
261 | #endif /* RPL_CONF_STATS */
262 | /*---------------------------------------------------------------------------*/
263 | /* Instances */
264 | extern rpl_instance_t instance_table[];
265 | extern rpl_instance_t *default_instance;
266 |
267 | /* ICMPv6 functions for RPL. */
268 | void dis_output(uip_ipaddr_t *addr);
269 | void dio_output(rpl_instance_t *, uip_ipaddr_t *uc_addr);
270 | void dao_output(rpl_parent_t *, uint8_t lifetime);
271 | void dao_output_target(rpl_parent_t *, uip_ipaddr_t *, uint8_t lifetime);
272 | void dao_ack_output(rpl_instance_t *, uip_ipaddr_t *, uint8_t);
273 | void rpl_icmp6_register_handlers(void);
274 |
275 | /* RPL logic functions. */
276 | void rpl_join_dag(uip_ipaddr_t *from, rpl_dio_t *dio);
277 | void rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio);
278 | void rpl_local_repair(rpl_instance_t *instance);
279 | void rpl_process_dio(uip_ipaddr_t *, rpl_dio_t *);
280 | int rpl_process_parent_event(rpl_instance_t *, rpl_parent_t *);
281 |
282 | /* DAG object management. */
283 | rpl_dag_t *rpl_alloc_dag(uint8_t, uip_ipaddr_t *);
284 | rpl_instance_t *rpl_alloc_instance(uint8_t);
285 | void rpl_free_dag(rpl_dag_t *);
286 | void rpl_free_instance(rpl_instance_t *);
287 |
288 | /* DAG parent management function. */
289 | rpl_parent_t *rpl_add_parent(rpl_dag_t *, rpl_dio_t *dio, uip_ipaddr_t *);
290 | rpl_parent_t *rpl_find_parent(rpl_dag_t *, uip_ipaddr_t *);
291 | rpl_parent_t *rpl_find_parent_any_dag(rpl_instance_t *instance, uip_ipaddr_t *addr);
292 | void rpl_nullify_parent(rpl_parent_t *);
293 | void rpl_remove_parent(rpl_parent_t *);
294 | void rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent);
295 | rpl_parent_t *rpl_select_parent(rpl_dag_t *dag);
296 | rpl_dag_t *rpl_select_dag(rpl_instance_t *instance,rpl_parent_t *parent);
297 | void rpl_recalculate_ranks(void);
298 |
299 | /* RPL routing table functions. */
300 | void rpl_remove_routes(rpl_dag_t *dag);
301 | void rpl_remove_routes_by_nexthop(uip_ipaddr_t *nexthop, rpl_dag_t *dag);
302 | uip_ds6_route_t *rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix,
303 | int prefix_len, uip_ipaddr_t *next_hop);
304 | void rpl_purge_routes(void);
305 |
306 | /* Lock a parent in the neighbor cache. */
307 | void rpl_lock_parent(rpl_parent_t *p);
308 |
309 | /* Objective function. */
310 | rpl_of_t *rpl_find_of(rpl_ocp_t);
311 |
312 | /* Timer functions. */
313 | void rpl_schedule_dao(rpl_instance_t *);
314 | void rpl_schedule_dao_immediately(rpl_instance_t *);
315 | void rpl_cancel_dao(rpl_instance_t *instance);
316 | void rpl_schedule_probing(rpl_instance_t *instance);
317 |
318 | void rpl_reset_dio_timer(rpl_instance_t *);
319 | void rpl_reset_periodic_timer(void);
320 |
321 | /* Route poisoning. */
322 | void rpl_poison_routes(rpl_dag_t *, rpl_parent_t *);
323 |
324 |
325 | rpl_instance_t *rpl_get_default_instance(void);
326 |
327 | #endif /* RPL_PRIVATE_H */
328 |
--------------------------------------------------------------------------------
/database/security_training/introduction/routing_protocol_overview.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/security_training/introduction/routing_protocol_overview.pdf
--------------------------------------------------------------------------------
/database/security_training/introduction/security_training_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/security_training/introduction/security_training_tutorial.pdf
--------------------------------------------------------------------------------
/database/system_introduction/background_iot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/system_introduction/background_iot.pdf
--------------------------------------------------------------------------------
/database/system_introduction/iotrain-sim_overview.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/database/system_introduction/iotrain-sim_overview.pdf
--------------------------------------------------------------------------------
/figures/collect_view_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/figures/collect_view_screenshot.png
--------------------------------------------------------------------------------
/figures/content_overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/figures/content_overview.png
--------------------------------------------------------------------------------
/figures/gui_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/figures/gui_screenshot.png
--------------------------------------------------------------------------------
/figures/icon_csc.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/figures/icon_csc.gif
--------------------------------------------------------------------------------
/figures/icon_pdf.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/figures/icon_pdf.gif
--------------------------------------------------------------------------------
/figures/implementation_procedure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/figures/implementation_procedure.png
--------------------------------------------------------------------------------
/figures/system_architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/figures/system_architecture.png
--------------------------------------------------------------------------------
/figures/training_workflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/figures/training_workflow.png
--------------------------------------------------------------------------------
/figures/tutorial_creation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crond-jaist/iotrain-sim/6da8c88845fe728684daf87875c34df25a8e0e07/figures/tutorial_creation.png
--------------------------------------------------------------------------------