Contiki 2.5
Files | Functions
Implicit network time synchronization

This crude and simple network time synchronization module synchronizes clocks of all nodes in a network. More...

Files

file  timesynch.c
 
    A simple time synchronization mechanism

 
file  timesynch.h
 
    Header file for a simple time synchronization mechanism

 

Functions

void timesynch_init (void)
 Initialize the timesynch module. More...
 
rtimer_clock_t timesynch_time (void)
 Get the current time-synchronized time. More...
 
rtimer_clock_t timesynch_time_to_rtimer (rtimer_clock_t synched_time)
 Get the current time-synchronized time, suitable for use with the rtimer module. More...
 
rtimer_clock_t timesynch_rtimer_to_time (rtimer_clock_t rtimer_time)
 Get the synchronized equivalent of an rtimer time. More...
 
rtimer_clock_t timesynch_offset (void)
 Get the current time-synchronized offset from the rtimer clock, which is used mainly for debugging. More...
 
int timesynch_authority_level (void)
 Get the current authority level of the time-synchronized time. More...
 
void timesynch_set_authority_level (int level)
 Set the authority level of the current time. More...
 

Detailed Description

This crude and simple network time synchronization module synchronizes clocks of all nodes in a network.

The time synchronization is implicit in that no explicit time synchronization messages are sent: the module relies on the underlying network device driver to timestamp all radio messages, both outgoing and incoming. The code currently only works on the Tmote Sky platform and the cc2420 driver.

Every node has an authority level, which is included in every outgoing packet. If a message is received from a node with higher authority (lower authority number), the node adjusts its clock towards the clock of the sending node.

The timesynch module is implemented as a meta-MAC protocol, so that the module is invoked for every incoming packet.

Function Documentation

int timesynch_authority_level ( void  )

Get the current authority level of the time-synchronized time.

Returns
The current authority level of the time-synchronized time
        This function returns the current authority level of
        the time-synchronized time. A node with a lower
        authority level is defined to have a better notion of
        time than a node with a higher authority
        level. Authority level 0 is best and should be used by
        a sink node that has a connection to an outside,
        "true", clock source.
void timesynch_init ( void  )

Initialize the timesynch module.

This function initializes the timesynch module. This function must not be called before rime_init().

Referenced by main().

rtimer_clock_t timesynch_offset ( void  )

Get the current time-synchronized offset from the rtimer clock, which is used mainly for debugging.

Returns
The current time-synchronized offset from the rtimer clock
        This function returns the current time-synchronized
        offset from the rtimer arch clock. This is mainly
        useful for debugging the timesynch module.
rtimer_clock_t timesynch_rtimer_to_time ( rtimer_clock_t  rtimer_time)

Get the synchronized equivalent of an rtimer time.

Returns
The synchronized equivalent of an rtimer time
        This function returns the time synchronized equivalent
        time corresponding to a (local) rtimer time.
void timesynch_set_authority_level ( int  level)

Set the authority level of the current time.

Parameters
levelThe authority level

Referenced by main().

rtimer_clock_t timesynch_time ( void  )

Get the current time-synchronized time.

Returns
The current time-synchronized time
        This function returns the current time-synchronized
        time.
rtimer_clock_t timesynch_time_to_rtimer ( rtimer_clock_t  synched_time)

Get the current time-synchronized time, suitable for use with the rtimer module.

Returns
The current time-synchronized rtimer time
        This function returns the (local) rtimer-equivalent
        time corresponding to the current time-synchronized
        (global) time. The rtimer-equivalent time is used for
        setting rtimer timers that are synchronized to other
        nodes in the network.