|
INET Framework for OMNeT++/OMNEST
|
#include <Gptp.h>
|
| virtual | ~Gptp () |
| |
| void | sendPacketToNIC (Packet *packet, int portId) |
| |
| void | sendSync () |
| |
| void | sendFollowUp (int portId, const GptpSync *sync, clocktime_t preciseOriginTimestamp) |
| |
| void | sendPdelayReq () |
| |
| void | sendPdelayResp (GptpReqAnswerEvent *req) |
| |
| void | sendPdelayRespFollowUp (int portId, const GptpPdelayResp *resp) |
| |
| void | processSync (Packet *packet, const GptpSync *gptp) |
| |
| void | processFollowUp (Packet *packet, const GptpFollowUp *gptp) |
| |
| void | processPdelayReq (Packet *packet, const GptpPdelayReq *gptp) |
| |
| void | processPdelayResp (Packet *packet, const GptpPdelayResp *gptp) |
| |
| void | processPdelayRespFollowUp (Packet *packet, const GptpPdelayRespFollowUp *gptp) |
| |
| clocktime_t | getCalculatedDrift (IClock *clock, clocktime_t value) |
| |
| void | synchronize () |
| |
| virtual void | receiveSignal (cComponent *source, simsignal_t signal, cObject *obj, cObject *details) override |
| |
| virtual void | scheduleClockEventAt (clocktime_t time, ClockEvent *msg) |
| |
| virtual void | scheduleClockEventAfter (clocktime_t delay, ClockEvent *msg) |
| |
| virtual cMessage * | cancelClockEvent (ClockEvent *msg) |
| |
| virtual void | cancelAndDeleteClockEvent (ClockEvent *msg) |
| |
| virtual void | rescheduleClockEventAt (clocktime_t time, ClockEvent *msg) |
| |
| virtual void | rescheduleClockEventAfter (clocktime_t time, ClockEvent *msg) |
| |
| virtual clocktime_t | computeClockTimeFromSimTime (simtime_t time) const |
| |
| virtual simtime_t | computeSimTimeFromClockTime (clocktime_t time) const |
| |
| virtual clocktime_t | getClockTime () const |
| |
| virtual clocktime_t | getArrivalClockTime (ClockEvent *msg) const |
| |
◆ ~Gptp()
◆ getCalculatedDrift()
◆ handleMessage()
| void inet::Gptp::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
166 if (msg->isSelfMessage()) {
170 Packet *packet = check_and_cast<Packet *>(msg);
171 auto gptp = packet->peekAtFront<GptpBase>();
172 auto gptpMessageType = gptp->getMessageType();
173 auto incomingNicId = packet->getTag<InterfaceInd>()->getInterfaceId();
177 switch (gptpMessageType) {
179 processSync(packet, check_and_cast<const GptpSync *>(gptp.get()));
182 processFollowUp(packet, check_and_cast<const GptpFollowUp *>(gptp.get()));
195 throw cRuntimeError(
"Unknown gPTP packet type: %d", (
int)(gptpMessageType));
201 processPdelayReq(packet, check_and_cast<const GptpPdelayReq *>(gptp.get()));
204 throw cRuntimeError(
"Unaccepted gPTP type: %d", (
int)(gptpMessageType));
209 EV_ERROR <<
"Message " << msg->getClassAndFullName() <<
" arrived on passive port " << incomingNicId <<
", dropped\n";
◆ handleSelfMessage()
| void inet::Gptp::handleSelfMessage |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
136 switch(msg->getKind()) {
160 throw cRuntimeError(
"Unknown self message (%s)%s, kind=%d", msg->getClassName(), msg->getName(), msg->getKind());
Referenced by handleMessage().
◆ initialize()
| void inet::Gptp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
50 ClockUserModuleBase::initialize(stage);
57 std::hash<std::string> strHash;
66 const char *str = par(
"slavePort");
69 throw cRuntimeError(
"Parameter inconsistency: MASTER_NODE with slave port");
77 throw cRuntimeError(
"Parameter error: Missing slave port for %s", par(
"gptpNodeType").stringValue());
79 auto v = check_and_cast<cValueArray *>(par(
"masterPorts").objectValue())->asStringVector();
81 throw cRuntimeError(
"Parameter error: Missing any master port for %s", par(
"gptpNodeType").stringValue());
82 for (
const auto& p : v) {
84 int portId = nic->getInterfaceId();
86 throw cRuntimeError(
"Parameter error: the port '%s' specified both master and slave port", p.c_str());
116 clocktime_t scheduleSync = par(
"syncInitialOffset");
◆ numInitStages()
| virtual int inet::Gptp::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ processFollowUp()
343 EV_WARN <<
"GptpFollowUp arrived without GptpSync, dropped";
348 EV_WARN <<
"GptpFollowUp arrived with invalid sequence ID, dropped";
359 EV_INFO <<
"############## FOLLOW_UP ################################"<< endl;
363 EV_INFO <<
"PROPAGATION DELAY - " <<
peerDelay << endl;
Referenced by handleMessage().
◆ processPdelayReq()
418 resp->setPortId(packet->getTag<InterfaceInd>()->getInterfaceId());
419 resp->setIngressTimestamp(packet->getTag<GptpIngressTimeInd>()->getArrivalClockTime());
420 resp->setSourcePortIdentity(gptp->getSourcePortIdentity());
421 resp->setSequenceId(gptp->getSequenceId());
Referenced by handleMessage().
◆ processPdelayResp()
429 if (gptp->getRequestingPortIdentity().clockIdentity !=
clockIdentity || gptp->getRequestingPortIdentity().portNumber !=
slavePortId) {
430 EV_WARN <<
"GptpPdelayResp arrived with invalid PortIdentity, dropped";
434 EV_WARN <<
"GptpPdelayResp arrived with invalid sequence ID, dropped";
Referenced by handleMessage().
◆ processPdelayRespFollowUp()
447 EV_WARN <<
"GptpPdelayRespFollowUp arrived without GptpPdelayResp, dropped";
451 if (gptp->getRequestingPortIdentity().clockIdentity !=
clockIdentity || gptp->getRequestingPortIdentity().portNumber !=
slavePortId) {
452 EV_WARN <<
"GptpPdelayRespFollowUp arrived with invalid PortIdentity, dropped";
456 EV_WARN <<
"GptpPdelayRespFollowUp arrived with invalid sequence ID, dropped";
470 EV_INFO <<
"PEER DELAY - " <<
peerDelay << endl;
Referenced by handleMessage().
◆ processSync()
| void inet::Gptp::processSync |
( |
Packet * |
packet, |
|
|
const GptpSync * |
gptp |
|
) |
| |
◆ receiveSignal()
| void inet::Gptp::receiveSignal |
( |
cComponent * |
source, |
|
|
simsignal_t |
signal, |
|
|
cObject * |
obj, |
|
|
cObject * |
details |
|
) |
| |
|
overridevirtual |
480 auto signal = check_and_cast<cPacket *>(obj);
481 auto packet = check_and_cast_nullable<Packet *>(signal->getEncapsulatedPacket());
485 const auto& ethPhyHeader = packet->peekAtFront<physicallayer::EthernetPhyHeader>();
486 const auto& ethMacHeader = packet->peekAt<EthernetMacHeader>(ethPhyHeader->getChunkLength());
488 const auto& gptp = packet->peekAt<GptpBase>(ethPhyHeader->getChunkLength() + ethMacHeader->getChunkLength());
490 packet->addTagIfAbsent<GptpIngressTimeInd>()->setArrivalClockTime(clock->getClockTime());
496 auto signal = check_and_cast<cPacket *>(obj);
497 auto packet = check_and_cast_nullable<Packet *>(signal->getEncapsulatedPacket());
501 const auto& ethPhyHeader = packet->peekAtFront<physicallayer::EthernetPhyHeader>();
502 const auto& ethMacHeader = packet->peekAt<EthernetMacHeader>(ethPhyHeader->getChunkLength());
504 const auto& gptp = packet->peekAt<GptpBase>(ethPhyHeader->getChunkLength() + ethMacHeader->getChunkLength());
507 switch (gptp->getMessageType()) {
509 auto gptpResp = dynamicPtrCast<const GptpPdelayResp>(gptp);
514 auto gptpSync = dynamicPtrCast<const GptpSync>(gptp);
515 sendFollowUp(portId, gptpSync.get(), clock->getClockTime());
◆ sendFollowUp()
| void inet::Gptp::sendFollowUp |
( |
int |
portId, |
|
|
const GptpSync * |
sync, |
|
|
clocktime_t |
preciseOriginTimestamp |
|
) |
| |
255 auto packet =
new Packet(
"GptpFollowUp");
257 auto gptp = makeShared<GptpFollowUp>();
259 gptp->setPreciseOriginTimestamp(preciseOriginTimestamp);
260 gptp->setSequenceId(sync->getSequenceId());
273 gptp->getFollowUpInformationTLVForUpdate().setRateRatio(
gmRateRatio);
274 packet->insertAtFront(gptp);
Referenced by receiveSignal().
◆ sendPacketToNIC()
| void inet::Gptp::sendPacketToNIC |
( |
Packet * |
packet, |
|
|
int |
portId |
|
) |
| |
◆ sendPdelayReq()
| void inet::Gptp::sendPdelayReq |
( |
| ) |
|
311 auto packet =
new Packet(
"GptpPdelayReq");
313 auto gptp = makeShared<GptpPdelayReq>();
320 gptp->setSourcePortIdentity(portId);
323 packet->insertAtFront(gptp);
Referenced by handleSelfMessage().
◆ sendPdelayResp()
280 int portId = req->getPortId();
281 auto packet =
new Packet(
"GptpPdelayResp");
283 auto gptp = makeShared<GptpPdelayResp>();
286 gptp->setRequestingPortIdentity(req->getSourcePortIdentity());
287 gptp->setSequenceId(req->getSequenceId());
288 gptp->setRequestReceiptTimestamp(req->getIngressTimestamp());
289 packet->insertAtFront(gptp);
Referenced by handleSelfMessage().
◆ sendPdelayRespFollowUp()
| void inet::Gptp::sendPdelayRespFollowUp |
( |
int |
portId, |
|
|
const GptpPdelayResp * |
resp |
|
) |
| |
296 auto packet =
new Packet(
"GptpPdelayRespFollowUp");
298 auto gptp = makeShared<GptpPdelayRespFollowUp>();
299 auto now = clock->getClockTime();
301 gptp->setResponseOriginTimestamp(now);
302 gptp->setRequestingPortIdentity(resp->getRequestingPortIdentity());
303 gptp->setSequenceId(resp->getSequenceId());
304 packet->insertAtFront(gptp);
Referenced by receiveSignal().
◆ sendSync()
| void inet::Gptp::sendSync |
( |
| ) |
|
232 auto packet =
new Packet(
"GptpSync");
234 auto gptp = makeShared<GptpSync>();
244 packet->insertAtFront(gptp);
Referenced by handleMessage(), and handleSelfMessage().
◆ synchronize()
| void inet::Gptp::synchronize |
( |
| ) |
|
370 simtime_t now = simTime();
383 check_and_cast<SettableClock *>(clock.get())->setClockTime(newTime);
400 EV_INFO <<
"############## SYNC #####################################"<< endl;
402 EV_INFO <<
"RECEIVED SIM TIME - " << now << endl;
404 EV_INFO <<
"RESIDENCE TIME - " << residenceTime << endl;
406 EV_INFO <<
"PROPAGATION DELAY - " <<
peerDelay << endl;
Referenced by processFollowUp().
◆ clockIdentity
| int64_t inet::Gptp::clockIdentity = 0 |
|
private |
◆ correctionField
◆ domainNumber
| int inet::Gptp::domainNumber = -1 |
|
private |
◆ gmRateRatio
| double inet::Gptp::gmRateRatio = 1.0 |
|
private |
◆ GPTP_MULTICAST_ADDRESS
| const MacAddress inet::Gptp::GPTP_MULTICAST_ADDRESS |
|
static |
◆ gptpNodeType
◆ interfaceTable
◆ lastReceivedGptpSyncSequenceId
| uint16_t inet::Gptp::lastReceivedGptpSyncSequenceId = 0xffff |
|
private |
◆ lastSentPdelayReqSequenceId
| uint16_t inet::Gptp::lastSentPdelayReqSequenceId = 0 |
|
private |
◆ localTimeSignal
| simsignal_t inet::Gptp::localTimeSignal = cComponent::registerSignal("localTime") |
|
staticprivate |
◆ masterPortIds
| std::set<int> inet::Gptp::masterPortIds |
|
private |
◆ newLocalTimeAtTimeSync
◆ oldLocalTimeAtTimeSync
◆ originTimestamp
◆ pdelayInterval
◆ pdelayReqEventEgressTimestamp
◆ pDelayReqProcessingTime
◆ pdelayRespEventIngressTimestamp
| clocktime_t inet::Gptp::pdelayRespEventIngressTimestamp |
|
private |
◆ peerDelay
◆ peerDelaySignal
| simsignal_t inet::Gptp::peerDelaySignal = cComponent::registerSignal("peerDelay") |
|
staticprivate |
◆ peerRequestReceiptTimestamp
◆ peerResponseOriginTimestamp
◆ peerSentTimeSync
◆ rateRatioSignal
| simsignal_t inet::Gptp::rateRatioSignal = cComponent::registerSignal("rateRatio") |
|
staticprivate |
◆ rcvdGptpSync
| bool inet::Gptp::rcvdGptpSync = false |
|
private |
◆ rcvdPdelayResp
| bool inet::Gptp::rcvdPdelayResp = false |
|
private |
◆ receivedRateRatio
| double inet::Gptp::receivedRateRatio = 1.0 |
|
private |
◆ receivedTimeSync
◆ requestMsg
◆ selfMsgDelayReq
◆ selfMsgSync
◆ sentTimeSyncSync
◆ sequenceId
| uint16_t inet::Gptp::sequenceId = 0 |
|
private |
◆ slavePortId
| int inet::Gptp::slavePortId = -1 |
|
private |
◆ syncIngressTimestamp
◆ syncInterval
◆ timeDifferenceSignal
| simsignal_t inet::Gptp::timeDifferenceSignal = cComponent::registerSignal("timeDifference") |
|
staticprivate |
The documentation for this class was generated from the following files:
clocktime_t syncIngressTimestamp
Definition: Gptp.h:63
#define CHK(x)
Definition: INETDefs.h:87
@ GPTPTYPE_PDELAY_RESP_FOLLOW_UP
Definition: GptpPacket_m.h:137
bool rcvdGptpSync
Definition: Gptp.h:65
ModuleRefByPar< IInterfaceTable > interfaceTable
Definition: Gptp.h:26
ClockTime clocktime_t
Definition: contract/ClockTime.h:25
double gmRateRatio
Definition: Gptp.h:35
clocktime_t oldLocalTimeAtTimeSync
Definition: Gptp.h:61
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
@ GPTP_SELF_MSG_PDELAY_REQ
Definition: GptpPacket_m.h:159
@ MASTER_NODE
Definition: GptpPacket_m.h:91
static simsignal_t timeDifferenceSignal
Definition: Gptp.h:75
std::set< int > masterPortIds
Definition: Gptp.h:31
#define CLOCKTIME_AS_SIMTIME(x)
Definition: contract/ClockTime.h:19
clocktime_t receivedTimeSync
Definition: Gptp.h:40
@ GPTPTYPE_PDELAY_REQ
Definition: GptpPacket_m.h:135
virtual clocktime_t getArrivalClockTime(ClockEvent *msg) const
Definition: ClockUserModuleMixin.h:73
static simsignal_t localTimeSignal
Definition: Gptp.h:74
virtual void scheduleClockEventAfter(clocktime_t delay, ClockEvent *msg)
Definition: ClockUserModuleMixin.h:65
clocktime_t sentTimeSyncSync
Definition: Gptp.h:56
removed InterfaceReq
Definition: IUdp-gates.txt:11
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
NetworkInterface * getContainingNicModule(const cModule *from)
Find the nic module (inside the networkNode) containing the given module.
Definition: NetworkInterface.cc:691
clocktime_t pDelayReqProcessingTime
Definition: Gptp.h:53
@ GPTPTYPE_FOLLOW_UP
Definition: GptpPacket_m.h:134
void sendPdelayReq()
Definition: Gptp.cc:308
int slavePortId
Definition: Gptp.h:30
ClockEvent * selfMsgDelayReq
Definition: Gptp.h:70
int domainNumber
Definition: Gptp.h:29
#define CLOCKTIME_ZERO
Constant for zero simulation time.
Definition: contract/ClockTime.h:36
@ GPTP_SELF_REQ_ANSWER_KIND
Definition: GptpPacket_m.h:156
clocktime_t newLocalTimeAtTimeSync
Definition: Gptp.h:60
void processPdelayResp(Packet *packet, const GptpPdelayResp *gptp)
Definition: Gptp.cc:426
clocktime_t correctionField
Definition: Gptp.h:32
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
static const MacAddress GPTP_MULTICAST_ADDRESS
Definition: Gptp.h:79
static const Protocol gptp
Definition: Protocol.h:69
void sendFollowUp(int portId, const GptpSync *sync, clocktime_t preciseOriginTimestamp)
Definition: Gptp.cc:253
cMessage ClockEvent
Definition: contract/ClockEvent.h:18
clocktime_t originTimestamp
Definition: Gptp.h:38
void processPdelayRespFollowUp(Packet *packet, const GptpPdelayRespFollowUp *gptp)
Definition: Gptp.cc:444
clocktime_t peerResponseOriginTimestamp
Definition: Gptp.h:50
simsignal_t transmissionEndedSignal
Definition: Simsignals.cc:117
GptpNodeType gptpNodeType
Definition: Gptp.h:28
static simsignal_t rateRatioSignal
Definition: Gptp.h:76
GptpNodeType
Enum generated from inet/linklayer/ieee8021as/GptpPacket.msg:45 by opp_msgtool.
Definition: GptpPacket_m.h:90
bool rcvdPdelayResp
Definition: Gptp.h:54
int getInterfaceId() const
Definition: NetworkInterface.h:232
simsignal_t receptionEndedSignal
Definition: Simsignals.cc:119
void sendSync()
Definition: Gptp.cc:230
clocktime_t peerSentTimeSync
Definition: Gptp.h:62
double receivedRateRatio
Definition: Gptp.h:36
void sendPdelayResp(GptpReqAnswerEvent *req)
Definition: Gptp.cc:278
@ ETHERTYPE_GPTP
Definition: EtherType_m.h:98
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
virtual void cancelAndDeleteClockEvent(ClockEvent *msg)
Definition: ClockUserModuleMixin.h:67
void synchronize()
Definition: Gptp.cc:368
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
static simsignal_t peerDelaySignal
Definition: Gptp.h:77
void processPdelayReq(Packet *packet, const GptpPdelayReq *gptp)
Definition: Gptp.cc:415
@ GPTP_SELF_MSG_SYNC
Definition: GptpPacket_m.h:157
clocktime_t pdelayInterval
Definition: Gptp.h:43
static const Protocol ethernetPhy
Definition: Protocol.h:66
clocktime_t peerRequestReceiptTimestamp
Definition: Gptp.h:49
@ GPTPTYPE_SYNC
Definition: GptpPacket_m.h:133
uint16_t sequenceId
Definition: Gptp.h:45
#define Enter_Method(...)
Definition: SelfDoc.h:71
clocktime_t peerDelay
Definition: Gptp.h:48
void sendPacketToNIC(Packet *packet, int portId)
Definition: Gptp.cc:215
clocktime_t pdelayRespEventIngressTimestamp
Definition: Gptp.h:51
int64_t clockIdentity
Definition: Gptp.h:33
ClockEvent * requestMsg
Definition: Gptp.h:71
ClockEvent * selfMsgSync
Definition: Gptp.h:69
uint16_t lastReceivedGptpSyncSequenceId
Definition: Gptp.h:66
uint16_t lastSentPdelayReqSequenceId
Definition: Gptp.h:47
void processSync(Packet *packet, const GptpSync *gptp)
Definition: Gptp.cc:330
clocktime_t pdelayReqEventEgressTimestamp
Definition: Gptp.h:52
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
void processFollowUp(Packet *packet, const GptpFollowUp *gptp)
Definition: Gptp.cc:339
@ GPTPTYPE_PDELAY_RESP
Definition: GptpPacket_m.h:136
@ GPTP_REQUEST_TO_SEND_SYNC
Definition: GptpPacket_m.h:158
@ BRIDGE_NODE
Definition: GptpPacket_m.h:92
@ SLAVE_NODE
Definition: GptpPacket_m.h:93
clocktime_t syncInterval
Definition: Gptp.h:42
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
void sendPdelayRespFollowUp(int portId, const GptpPdelayResp *resp)
Definition: Gptp.cc:294
virtual void handleSelfMessage(cMessage *msg)
Definition: Gptp.cc:134