105 lines
2.7 KiB
C++
105 lines
2.7 KiB
C++
#ifndef GPTP_HEADER_H
|
|
#define GPTP_HEADER_H
|
|
|
|
#include "ns3/header.h"
|
|
|
|
namespace ns3
|
|
{
|
|
/**
|
|
* \ingroup ethernet
|
|
* \brief Packet header for Ethernet
|
|
*
|
|
* This class can be used to add a header to Ethernet packet.
|
|
*/
|
|
|
|
class GptpHeader : public Header
|
|
{
|
|
public:
|
|
/**
|
|
* \brief Construct a gPTP header.
|
|
*/
|
|
GptpHeader();
|
|
|
|
/**
|
|
* \brief Destroy a gPTP header.
|
|
*/
|
|
~GptpHeader() override;
|
|
|
|
/**
|
|
* \brief Get the TypeId
|
|
*
|
|
* \return The TypeId for this class
|
|
*/
|
|
static TypeId GetTypeId();
|
|
|
|
/**
|
|
* \brief Get the TypeId of the instance
|
|
*
|
|
* \return The TypeId for this instance
|
|
*/
|
|
TypeId GetInstanceTypeId() const override;
|
|
|
|
void Print(std::ostream& os) const override;
|
|
void Serialize(Buffer::Iterator start) const override;
|
|
uint32_t Deserialize(Buffer::Iterator start) override;
|
|
uint32_t GetSerializedSize() const override;
|
|
|
|
|
|
|
|
void SetMessageType(uint8_t messageType);
|
|
void SetMessageLenght(uint8_t messageLenght);
|
|
void SetDomainNumber(uint8_t domainNumber);
|
|
void SetTwoStepFlag(bool twoStepFlag);
|
|
void SetCorrectionField(uint64_t correctionField);
|
|
void SetClockIdentity(uint64_t clockIdentity);
|
|
void SetPortIdentity(uint16_t portIdentity);
|
|
void SetSequenceId(uint16_t sequenceId);
|
|
void SetLogMessageInterval(uint8_t logMessageInterval);
|
|
|
|
uint8_t GetMessageType();
|
|
uint8_t GetDomainNumber();
|
|
bool GetTwoStepFlag();
|
|
uint64_t GetCorrectionField();
|
|
uint64_t GetClockIdentity();
|
|
uint16_t GetPortIdentity();
|
|
uint16_t GetSequenceId();
|
|
uint8_t GetLogMessageInterval();
|
|
|
|
|
|
private:
|
|
|
|
//STD 802.1AS-2020 : Talbe 10-7 - PTP message header
|
|
uint8_t m_majorSdoId = 1;
|
|
uint8_t m_messageType = 0;
|
|
uint8_t m_minorVersionPTP = 0;
|
|
uint8_t m_versionPTP = 2;
|
|
uint16_t m_messageLenght = 0;
|
|
uint8_t m_domainNumber = 0;
|
|
uint8_t m_minorSdoId = 0;
|
|
//Flags :
|
|
bool m_alternateMasterFlag = false;
|
|
bool m_twoStepFlag = false;
|
|
bool m_unicastFlag = false;
|
|
bool m_ptpProfifilSpecific1Flag = false;
|
|
bool m_ptpProfifilSpecific2Flag = false;
|
|
bool m_leap61 = false;
|
|
bool m_leap59 = false;
|
|
bool m_currentUtcOffsetValid = false;
|
|
bool m_ptpTimescale = false;
|
|
bool m_timeTraceable = false;
|
|
bool m_frequencyTraceable = false;
|
|
|
|
uint64_t m_correctionField = 0;
|
|
uint32_t m_messageTypeSpecific = 0;
|
|
//SourceClockIdentity
|
|
uint64_t m_clockIndentity = 0;
|
|
uint16_t m_portIdentity = 0;
|
|
|
|
uint16_t m_sequenceId = 0;
|
|
uint8_t m_controlField = 0;
|
|
uint8_t m_logMessageInterval = 0;
|
|
};
|
|
|
|
}
|
|
#endif /* GPTP_HEADER_H */
|