Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
core
net
rime
timesynch.h
Go to the documentation of this file.
1
/**
2
* \addtogroup sys
3
* @{
4
*/
5
6
/**
7
* \defgroup timesynch Implicit network time synchronization
8
* @{
9
*
10
* This crude and simple network time synchronization module
11
* synchronizes clocks of all nodes in a network. The time
12
* synchronization is implicit in that no explicit time
13
* synchronization messages are sent: the module relies on the
14
* underlying network device driver to timestamp all radio messages,
15
* both outgoing and incoming. The code currently only works on the
16
* Tmote Sky platform and the cc2420 driver.
17
*
18
* Every node has an authority level, which is included in every
19
* outgoing packet. If a message is received from a node with higher
20
* authority (lower authority number), the node adjusts its clock
21
* towards the clock of the sending node.
22
*
23
* The timesynch module is implemented as a meta-MAC protocol, so that
24
* the module is invoked for every incoming packet.
25
*
26
*/
27
28
/*
29
* Copyright (c) 2007, Swedish Institute of Computer Science.
30
* All rights reserved.
31
*
32
* Redistribution and use in source and binary forms, with or without
33
* modification, are permitted provided that the following conditions
34
* are met:
35
* 1. Redistributions of source code must retain the above copyright
36
* notice, this list of conditions and the following disclaimer.
37
* 2. Redistributions in binary form must reproduce the above copyright
38
* notice, this list of conditions and the following disclaimer in the
39
* documentation and/or other materials provided with the distribution.
40
* 3. Neither the name of the Institute nor the names of its contributors
41
* may be used to endorse or promote products derived from this software
42
* without specific prior written permission.
43
*
44
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
45
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
48
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54
* SUCH DAMAGE.
55
*
56
* This file is part of the Contiki operating system.
57
*
58
*/
59
60
/**
61
* \file
62
* Header file for a simple time synchronization mechanism
63
* \author
64
* Adam Dunkels <adam@sics.se>
65
*/
66
67
#ifndef TIMESYNCH_H_
68
#define TIMESYNCH_H_
69
70
#include "
net/mac/mac.h
"
71
#include "
sys/rtimer.h
"
72
73
/**
74
* \brief Initialize the timesynch module
75
*
76
* This function initializes the timesynch module. This
77
* function must not be called before rime_init().
78
*
79
*/
80
void
timesynch_init
(
void
);
81
82
/**
83
* \brief Get the current time-synchronized time
84
* \return The current time-synchronized time
85
*
86
* This function returns the current time-synchronized
87
* time.
88
*
89
*/
90
rtimer_clock_t
timesynch_time
(
void
);
91
92
/**
93
* \brief Get the current time-synchronized time, suitable for use with the rtimer module
94
* \return The current time-synchronized rtimer time
95
*
96
* This function returns the (local) rtimer-equivalent
97
* time corresponding to the current time-synchronized
98
* (global) time. The rtimer-equivalent time is used for
99
* setting rtimer timers that are synchronized to other
100
* nodes in the network.
101
*
102
*/
103
rtimer_clock_t
timesynch_time_to_rtimer
(rtimer_clock_t synched_time);
104
105
/**
106
* \brief Get the synchronized equivalent of an rtimer time
107
* \return The synchronized equivalent of an rtimer time
108
*
109
* This function returns the time synchronized equivalent
110
* time corresponding to a (local) rtimer time.
111
*
112
*/
113
rtimer_clock_t
timesynch_rtimer_to_time
(rtimer_clock_t rtimer_time);
114
115
/**
116
* \brief Get the current time-synchronized offset from the rtimer clock, which is used mainly for debugging
117
* \return The current time-synchronized offset from the rtimer clock
118
*
119
* This function returns the current time-synchronized
120
* offset from the rtimer arch clock. This is mainly
121
* useful for debugging the timesynch module.
122
*
123
*/
124
rtimer_clock_t
timesynch_offset
(
void
);
125
126
/**
127
* \brief Get the current authority level of the time-synchronized time
128
* \return The current authority level of the time-synchronized time
129
*
130
* This function returns the current authority level of
131
* the time-synchronized time. A node with a lower
132
* authority level is defined to have a better notion of
133
* time than a node with a higher authority
134
* level. Authority level 0 is best and should be used by
135
* a sink node that has a connection to an outside,
136
* "true", clock source.
137
*
138
*/
139
int
timesynch_authority_level
(
void
);
140
141
/**
142
* \brief Set the authority level of the current time
143
* \param level The authority level
144
*/
145
void
timesynch_set_authority_level
(
int
level);
146
147
#endif
/* TIMESYNCH_H_ */
148
149
/** @} */
150
/** @} */
Generated on Thu Apr 24 2014 16:26:12 for Contiki-Inga 3.x by
1.8.3.1