X-Simulator
Create: 11 September 2007;  Last review: 13 September 2007
Master module

Introduction

The master module is a simple module that implements the functions of the master node described by the IEEE 1588 protocol. At the current development state, only one master node can be present.

As defines by the IEEE 1588 standard, the master sends periodically a SYNC message to each slave node, which contains an estimate of the time when it was sent. The master may also send a FOLLOW-UP message, which is always associated to a specific SYNC message and contains a more precise estimate of the time the SYNC message was sent.
From a slave node, the master can receive a DELAY-REQUEST message. When it receives this kind of message, it sends to the corresponding slave node a DELAY-RESPONSE message, which contains an estimate of the time when the DELAY-REQUEST message was received.
The IEEE 1588 standard defines other kind of messages, useful for the additional mechanism necessary to support the reconfiguration of the network, for instance when nodes are added or deleted, when clock characteristics change or when connection topology changes. In these situations a new master could be determined.

The X-simulator considers only the SYNC, DELAY-REQUEST and DELAY-RESPONSE messages. The FOLLOW-UP messages have not been implemented since in the simulation environment they are not necessary. Neither the management messages have been implemented for the same reason.

Implementation


T
he master module has one input, one output and a parameter called Tsync. This parameter provides the period of the SYNC messages sent by the master.

SYNC generation mechanism.
The IEEE 1588 defines a timeout mechanism known as the sync-event receipt timeout. This timer expires after an interval equal to Tsync second, and when a timeout occurs a SYNC-message is sent from the master to each slave. Then, the timeout mechanism will be restarted.
In the simulator this timeout mechanism is implemented by the self-message mechanism, which is the way to implement timers in OMNeT++.
When the master receives a message, it controls (in the handleMessage function) if this message is a self-message. If it is true, the handleSelfMessage function is called. In this function a SYNC message is broadcasted to each network node and finally a self-message, delayed by Tsync, is newly sent to the node itself.

Slave message management
A master module receives messages from slaves. In the handleMessage function it controls if the received message is a PTP packet. If the message is a PTP packet, then the handleSlaveMessage function is called. If the packet corresponds to a SYNC message or to a DELAY-RESPONSE message, then an error is generated since in the simulate network only one master must be present.
Otherwise, the message is a DELAY-REQUEST message. When this message arrives, a timestamp is measured.
The master generates a DELAY-RESPONSE message containing the previous measured timestamp. This message is sent to the correspondent slave node.

Other message management
When the master receives a message that is not a self-message, neither a PTP packet, then it simply delete the message.