|
INET Framework for OMNeT++/OMNEST
|
Converts between GptpPacket and binary (network byte order) Gptp packet.
More...
#include <GptpPacketSerializer.h>
|
| virtual void | serialize (MemoryOutputStream &stream, const Ptr< const Chunk > &chunk) const override |
| | Serializes a chunk into a stream by writing all bytes representing the chunk at the end of the stream. More...
|
| |
| virtual const Ptr< Chunk > | deserialize (MemoryInputStream &stream) const override |
| | Deserializes a chunk from a stream by reading the bytes at the current position of the stream. More...
|
| |
| void | readGptpBase (MemoryInputStream &stream, GptpBase &gptpPacket) const |
| |
| void | writeGptpBase (MemoryOutputStream &stream, const GptpBase &gptpPacket) const |
| |
| void | readGptpFollowUpPart (MemoryInputStream &stream, GptpFollowUp &gptpPacket) const |
| |
| void | writeGptpFollowUpPart (MemoryOutputStream &stream, const GptpFollowUp &gptpPacket) const |
| |
| void | readGptpPdelayReqPart (MemoryInputStream &stream, GptpPdelayReq &gptpPacket) const |
| |
| void | writeGptpPdelayReqPart (MemoryOutputStream &stream, const GptpPdelayReq &gptpPacket) const |
| |
| void | readGptpPdelayRespPart (MemoryInputStream &stream, GptpPdelayResp &gptpPacket) const |
| |
| void | writeGptpPdelayRespPart (MemoryOutputStream &stream, const GptpPdelayResp &gptpPacket) const |
| |
| void | readGptpPdelayRespFollowUpPart (MemoryInputStream &stream, GptpPdelayRespFollowUp &gptpPacket) const |
| |
| void | writeGptpPdelayRespFollowUpPart (MemoryOutputStream &stream, const GptpPdelayRespFollowUp &gptpPacket) const |
| |
| void | readGptpSyncPart (MemoryInputStream &stream, GptpSync &gptpPacket) const |
| |
| void | writeGptpSyncPart (MemoryOutputStream &stream, const GptpSync &gptpPacket) const |
| |
| void | readGptpFollowUpInformationTlv (MemoryInputStream &stream, GptpFollowUpInformationTlv &gptpPacket) const |
| |
| void | writeGptpFollowUpInformationTlv (MemoryOutputStream &stream, const GptpFollowUpInformationTlv &gptpPacket) const |
| |
| clocktime_t | readClock8 (MemoryInputStream &stream) const |
| |
| void | writeClock8 (MemoryOutputStream &stream, const clocktime_t &clock) const |
| |
| clocktime_t | readTimestamp (MemoryInputStream &stream) const |
| |
| void | writeTimestamp (MemoryOutputStream &stream, const clocktime_t &clock) const |
| |
| clocktime_t | readScaledNS (MemoryInputStream &stream) const |
| |
| void | writeScaledNS (MemoryOutputStream &stream, const clocktime_t &clock) const |
| |
| PortIdentity | readPortIdentity (MemoryInputStream &stream) const |
| |
| void | writePortIdentity (MemoryOutputStream &stream, const PortIdentity &portIdentity) const |
| |
Converts between GptpPacket and binary (network byte order) Gptp packet.
◆ GptpPacketSerializer()
| inet::GptpPacketSerializer::GptpPacketSerializer |
( |
| ) |
|
|
inline |
60 : FieldsChunkSerializer() {}
◆ deserialize()
Deserializes a chunk from a stream by reading the bytes at the current position of the stream.
The current stream position is updated according to the length of the returned chunk.
Implements inet::FieldsChunkSerializer.
265 auto startPos = stream.getPosition();
268 stream.seek(startPos);
272 auto gptpPacket = makeShared<GptpFollowUp>();
278 auto gptpPacket = makeShared<GptpPdelayReq>();
284 auto gptpPacket = makeShared<GptpPdelayResp>();
290 auto gptpPacket = makeShared<GptpPdelayRespFollowUp>();
296 auto gptpPacket = makeShared<GptpSync>();
302 throw cRuntimeError(
"unknown GptpMessageType");
◆ readClock8()
23 int64_t ns16 = stream.readUint64Be();
24 simtime_t t1(ns16>>16, SIMTIME_NS);
25 ns16 = (ns16 & 0xFFFF) * SimTime::getScale() / 1000000000LL;
Referenced by readGptpBase().
◆ readGptpBase()
122 gptpPacket.setMajorSdoId(stream.readUint4());
123 gptpPacket.setMessageType(
static_cast<GptpMessageType>(stream.readUint4()));
124 gptpPacket.setMinorVersionPTP(stream.readUint4());
125 gptpPacket.setVersionPTP(stream.readUint4());
126 gptpPacket.setMessageLengthField(stream.readUint16Be());
127 gptpPacket.setDomainNumber(stream.readUint8());
128 gptpPacket.setMinorSdoId(stream.readUint8());
129 gptpPacket.setFlags(stream.readUint16Be());
130 gptpPacket.setCorrectionField(
readClock8(stream));
131 gptpPacket.setMessageTypeSpecific(stream.readUint32Be());
133 gptpPacket.setSequenceId(stream.readUint16Be());
134 gptpPacket.setControlField(stream.readUint8());
135 gptpPacket.setLogMessageInterval(stream.readUint8());
Referenced by deserialize().
◆ readGptpFollowUpInformationTlv()
204 tlv.setTlvType((
GptpTlvType)stream.readUint16Be());
205 tlv.setLengthField(stream.readUint16Be());
206 tlv.setOrganizationId(stream.readUint24Be());
207 tlv.setOrganizationSubType(stream.readUint24Be());
208 tlv.setCumulativeScaledRateOffset(stream.readUint32Be());
209 tlv.setGmTimeBaseIndicator(stream.readUint16Be());
211 tlv.setScaledLastGmFreqChange(stream.readUint32Be());
Referenced by readGptpFollowUpPart().
◆ readGptpFollowUpPart()
◆ readGptpPdelayReqPart()
152 stream.readByteRepeatedly(0, 10);
153 stream.readByteRepeatedly(0, 10);
Referenced by deserialize().
◆ readGptpPdelayRespFollowUpPart()
◆ readGptpPdelayRespPart()
◆ readGptpSyncPart()
189 stream.readByteRepeatedly(0, 10);
191 throw cRuntimeError(
"The GptpSync without twoStepFlag is unimplemented yet");
Referenced by deserialize().
◆ readPortIdentity()
◆ readScaledNS()
65 int32_t x = stream.readUint32Be();
66 int64_t ns16 = stream.readUint64Be();
67 if ((ns16 < 0 && x != -1) || (ns16 >= 0 && x != 0))
68 throw cRuntimeError(
"too big number");
69 simtime_t t1(ns16>>16, SIMTIME_NS);
70 ns16 = (ns16 & 0xFFFF) * SimTime::getScale() / 1000000000LL;
Referenced by readGptpFollowUpInformationTlv().
◆ readTimestamp()
◆ serialize()
Serializes a chunk into a stream by writing all bytes representing the chunk at the end of the stream.
Implements inet::FieldsChunkSerializer.
228 const auto& gptpPacket = staticPtrCast<const GptpBase>(chunk);
232 switch(gptpPacket->getMessageType()) {
234 const auto& gptp =
CHK(dynamicPtrCast<const GptpFollowUp>(gptpPacket));
239 const auto& gptp =
CHK(dynamicPtrCast<const GptpPdelayReq>(gptpPacket));
244 const auto& gptp =
CHK(dynamicPtrCast<const GptpPdelayResp>(gptpPacket));
249 const auto& gptp =
CHK(dynamicPtrCast<const GptpPdelayRespFollowUp>(gptpPacket));
254 const auto& gptp =
CHK(dynamicPtrCast<const GptpSync>(gptpPacket));
259 throw cRuntimeError(
"unknown GptpMessageType");
◆ writeClock8()
32 simtime_t outRemainder;
34 t.split(SIMTIME_NS, outValue, outRemainder);
36 int64_t ns16 = outRemainder.raw() * 1000000000LL / SimTime::getScale();
37 stream.writeUint64Be(outValue + ns16);
Referenced by writeGptpBase().
◆ writeGptpBase()
104 stream.writeUint4(gptpPacket.getMajorSdoId());
105 stream.writeUint4((int8_t)(gptpPacket.getMessageType()));
106 stream.writeUint4(gptpPacket.getMinorVersionPTP());
107 stream.writeUint4(gptpPacket.getVersionPTP());
108 stream.writeUint16Be(gptpPacket.getMessageLengthField());
109 stream.writeUint8(gptpPacket.getDomainNumber());
110 stream.writeUint8(gptpPacket.getMinorSdoId());
111 stream.writeUint16Be(gptpPacket.getFlags());
112 writeClock8(stream, gptpPacket.getCorrectionField());
113 stream.writeUint32Be(gptpPacket.getMessageTypeSpecific());
115 stream.writeUint16Be(gptpPacket.getSequenceId());
116 stream.writeUint8(gptpPacket.getControlField());
117 stream.writeUint8(gptpPacket.getLogMessageInterval());
Referenced by serialize().
◆ writeGptpFollowUpInformationTlv()
216 stream.writeUint16Be(tlv.getTlvType());
217 stream.writeUint16Be(tlv.getLengthField());
218 stream.writeUint24Be(tlv.getOrganizationId());
219 stream.writeUint24Be(tlv.getOrganizationSubType());
220 stream.writeUint32Be(tlv.getCumulativeScaledRateOffset());
221 stream.writeUint16Be(tlv.getGmTimeBaseIndicator());
223 stream.writeUint32Be(tlv.getScaledLastGmFreqChange());
Referenced by writeGptpFollowUpPart().
◆ writeGptpFollowUpPart()
◆ writeGptpPdelayReqPart()
158 stream.writeByteRepeatedly(0, 10);
159 stream.writeByteRepeatedly(0, 10);
Referenced by serialize().
◆ writeGptpPdelayRespFollowUpPart()
◆ writeGptpPdelayRespPart()
◆ writeGptpSyncPart()
197 stream.writeByteRepeatedly(0, 10);
199 throw cRuntimeError(
"The GptpSync without twoStepFlag is unimplemented yet");
Referenced by serialize().
◆ writePortIdentity()
◆ writeScaledNS()
80 simtime_t outRemainder;
81 t.split(SIMTIME_NS, outValue, outRemainder);
83 int64_t ns16 = outRemainder.raw() * 1000000000LL / SimTime::getScale();
85 stream.writeUint64Be(outValue + ns16);
Referenced by writeGptpFollowUpInformationTlv().
◆ writeTimestamp()
The documentation for this class was generated from the following files:
#define CHK(x)
Definition: INETDefs.h:87
@ GPTPTYPE_PDELAY_RESP_FOLLOW_UP
Definition: GptpPacket_m.h:137
void readGptpFollowUpInformationTlv(MemoryInputStream &stream, GptpFollowUpInformationTlv &gptpPacket) const
Definition: GptpPacketSerializer.cc:202
void readGptpPdelayRespPart(MemoryInputStream &stream, GptpPdelayResp &gptpPacket) const
Definition: GptpPacketSerializer.cc:162
GptpTlvType
Enum generated from inet/linklayer/ieee8021as/GptpPacket.msg:86 by opp_msgtool.
Definition: GptpPacket_m.h:213
PortIdentity readPortIdentity(MemoryInputStream &stream) const
Definition: GptpPacketSerializer.cc:94
void writeGptpBase(MemoryOutputStream &stream, const GptpBase &gptpPacket) const
Definition: GptpPacketSerializer.cc:102
#define CLOCKTIME_AS_SIMTIME(x)
Definition: contract/ClockTime.h:19
void writeClock8(MemoryOutputStream &stream, const clocktime_t &clock) const
Definition: GptpPacketSerializer.cc:29
@ GPTPTYPE_PDELAY_REQ
Definition: GptpPacket_m.h:135
void readGptpFollowUpPart(MemoryInputStream &stream, GptpFollowUp &gptpPacket) const
Definition: GptpPacketSerializer.cc:138
@ GPTPTYPE_FOLLOW_UP
Definition: GptpPacket_m.h:134
void readGptpBase(MemoryInputStream &stream, GptpBase &gptpPacket) const
Definition: GptpPacketSerializer.cc:120
void writeScaledNS(MemoryOutputStream &stream, const clocktime_t &clock) const
Definition: GptpPacketSerializer.cc:74
#define CLOCKTIME_ZERO
Constant for zero simulation time.
Definition: contract/ClockTime.h:36
clocktime_t readClock8(MemoryInputStream &stream) const
Definition: GptpPacketSerializer.cc:21
void writePortIdentity(MemoryOutputStream &stream, const PortIdentity &portIdentity) const
Definition: GptpPacketSerializer.cc:88
void readGptpPdelayRespFollowUpPart(MemoryInputStream &stream, GptpPdelayRespFollowUp &gptpPacket) const
Definition: GptpPacketSerializer.cc:174
#define SIMTIME_AS_CLOCKTIME(x)
Definition: contract/ClockTime.h:20
value< double, units::s > s
Definition: Units.h:1235
void writeGptpFollowUpPart(MemoryOutputStream &stream, const GptpFollowUp &gptpPacket) const
Definition: GptpPacketSerializer.cc:144
GptpMessageType
Enum generated from inet/linklayer/ieee8021as/GptpPacket.msg:59 by opp_msgtool.
Definition: GptpPacket_m.h:132
void writeGptpSyncPart(MemoryOutputStream &stream, const GptpSync &gptpPacket) const
Definition: GptpPacketSerializer.cc:194
void writeGptpPdelayRespPart(MemoryOutputStream &stream, const GptpPdelayResp &gptpPacket) const
Definition: GptpPacketSerializer.cc:168
removed type
Definition: IUdp-gates.txt:7
clocktime_t readScaledNS(MemoryInputStream &stream) const
Definition: GptpPacketSerializer.cc:61
clocktime_t readTimestamp(MemoryInputStream &stream) const
Definition: GptpPacketSerializer.cc:40
void readGptpPdelayReqPart(MemoryInputStream &stream, GptpPdelayReq &gptpPacket) const
Definition: GptpPacketSerializer.cc:150
void writeGptpPdelayReqPart(MemoryOutputStream &stream, const GptpPdelayReq &gptpPacket) const
Definition: GptpPacketSerializer.cc:156
@ twoStepFlag
Definition: GptpPacket_m.h:184
@ GPTPTYPE_SYNC
Definition: GptpPacket_m.h:133
void writeGptpFollowUpInformationTlv(MemoryOutputStream &stream, const GptpFollowUpInformationTlv &gptpPacket) const
Definition: GptpPacketSerializer.cc:214
void writeTimestamp(MemoryOutputStream &stream, const clocktime_t &clock) const
Definition: GptpPacketSerializer.cc:50
void readGptpSyncPart(MemoryInputStream &stream, GptpSync &gptpPacket) const
Definition: GptpPacketSerializer.cc:186
@ GPTPTYPE_PDELAY_RESP
Definition: GptpPacket_m.h:136
void writeGptpPdelayRespFollowUpPart(MemoryOutputStream &stream, const GptpPdelayRespFollowUp &gptpPacket) const
Definition: GptpPacketSerializer.cc:180
nano< s >::type ns
Definition: Units.h:1074