Skip to content

gPTP: ClockServos, BMCA and HotStandby #1032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 169 commits into
base: master
Choose a base branch
from

Conversation

haug-den-lucas
Copy link
Contributor

@haug-den-lucas haug-den-lucas commented May 28, 2025

This pull requests extends the gPTP implementation with clock servos, BMCA and hot standby.

gPTP bugfixes
The gPTP implementation had some bugs, which are fixed in this PR

  • As timestamps were taken after a frame was fully received/transmitted instead of at the start of a transmission, rare cases could occur, where a combination of PDelay and Sync messages at the same time leads to wrong timestamping => This is fixed by using he StreamingPhyLayer and taking the transmission/receptionStarted timestamps.
  • When a clock performs a clock jump (for whatever reason) outside of the gPTP module, the gPTP did not react on this change. Added a signal clocks emit when the perform a clock jump
  • The gmRR was calculated differently from the standard. Added a new method to calcualte the gmRR using the nrr but kept the old way to be also configurable
  • nrr was not used to calculate peer delays, added this as well (can be disabled by disabling the nrr calculation)

ClockServos
They only Servo-like clock existed in INET was the SettableClock.
Now there is a ServoClock base class, which provides the jumpClockTo function, which was the name suggest jumps to a specified clock time.
Additionally, there is the adjustClockTo function, which is implemented by the actual servo classes to smoothly adjust the clock to the provided time.
Curretnly the following implementations exist:

  • InstantServoClock: Previously the SettableClock, allows to specify if the clock only jumps or also estimates and adjusts the drift rate. I have replaced all instances of SettableClock in INET I could find with this new clock.
  • PiServoClock: Implements a PI-Servo
    => See showcases for more details

BMCA
Extended the gPTP implementation with the Best Master Clock Algorithm
=> See showcases for more details

HotStandby
Extended the MutliDomainGptp with an actual Hot Standby implementation that allows to automatically select a new time domain if one time domain goes offline. This can be enabled and disabled using a parameter.
This is based on the IEEE 802.1ASdm amendment, but uses a simplified version, which does not yet smoothly adjust when switching between two time domains.
This also fixes #1019
=> See showcases for more details

Showcases
I tried to update all showcases using the new implementation and compared the results of the old and new implementation.
When using the InstantServoClock the existing showcases provided the same results.
I've split the gPTP showcase into 3 showcases, a basic, a bmca and a hotstandby showcase.
The images for these showcases can be found in this repository:
https://github.com/haug-den-lucas/media

Further notes
Even though I've worked quite a bit with INET now, I am not fully aware which further side effects these changes might have.
As mentioned above, I checked all existing showcases if they are still valid and checked for all instances of the SettableClock if these simulations still provide the same results.
However, this is quite a big pull request and I'm happy to discuss the changes and further work on it to make merging possible.

The .cproject .oppbuildspecs etc. were not edited my me manually but by my OMNeT++ installation, if required I can remove the changes of these files, I am not exactly aware what the effect of these changes are.

I've extended the .clang-format file so other IDEs reformatting produces the same results as the OMNeT++ IDE

@levy levy requested review from avarga and levy May 29, 2025 08:07
@levy levy self-assigned this May 29, 2025
@levy levy added this to the INET 4.6.1 milestone May 29, 2025
@levy
Copy link
Contributor

levy commented May 29, 2025

Wow! Thank you for this pull request! It looks really good, and I'm pleasantly surprised how much you could pick up from the architecture and the code without a comprehensive documentation. This really is a huge pull request and it definitely goes in the right direction. It's going to take some effort from both sides to include this in INET, which we clearly want to do.

For the following two weeks I'll be quite busy with preparing my TSN presentation for the WFCS 2025 IEEE conference on factory automation in Rostock. I'll come back to this PR after that.

@haug-den-lucas
Copy link
Contributor Author

For the following two weeks I'll be quite busy with preparing my TSN presentation for the WFCS 2025 IEEE conference on factory automation in Rostock. I'll come back to this PR after that.

That's a nice coincidence, as we will also have a WiP paper presentation at WFCS on Wednesday based on this implementation.
I sadly won't make it to the TSN tutorial session on Tuesday, but if you're interested, you can drop by at our poster during the WiP session or we can have a talk sometime else during the conference.

@levy
Copy link
Contributor

levy commented May 29, 2025

Oh, it's good to know! We are coming back home on Wednesday evening, but let's meet if possible! I'll keep in mind that you are going to have a presentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multidomain in gptp
4 participants