Time synchronization over Ethernet in automotive industry is achieved by correcting the local clock of slave according to local clock of master.The synchronization of each node is done according to GPTP protocol(IEEE 802.1AS).According to this the master node send Sync message to slave and the slave will receive the sync message and after a certain period of time, master send follow up message to slave and the slave will receive the follow up message ,the follow up message contain precision origin time stamp. Then the slave correct its local clock based on the information from sync and follow up message and also by calculating the delay.The master get current time from StbM. I find it difficult to understand the purpose of sending Sync message and what are its contents?
Can you write the code in C language with the following steps:
Structure to represent a PTP timestamp
Structure to represent a PTP header
Structure to represent a Sync message
Check the message type, PTP version, domain number, control field, source port identity, sequence ID
Then in the main function:
Initialize EthIf
Set the expected source port identity and sequence ID
Wait for a Sync message
Parse the Sync message
Validate the Sync message
Perform any additional tasks