scapy icon indicating copy to clipboard operation
scapy copied to clipboard

Feature/add-ptp-protocol

Open satveerbrar opened this issue 11 months ago • 5 comments

@polybassa @gpotter2 Here is the draft PR to add PTP protocol.

Currently this includes basic PTP header and Sync message type.

Planned additions in future commits:

  1. post_build function to calculate and insert message length field.
  2. Classes for the remaining PTP message types.
  3. Unit tests

Let me know if I have followed the correct approach.

fixes #4637

satveerbrar avatar Jan 12 '25 08:01 satveerbrar

Codecov Report

Attention: Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.

Project coverage is 81.62%. Comparing base (92925da) to head (7bf9906). Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
scapy/layers/ptp_v2.py 0.00% 18 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4640      +/-   ##
==========================================
+ Coverage   80.71%   81.62%   +0.90%     
==========================================
  Files         359      360       +1     
  Lines       86052    86253     +201     
==========================================
+ Hits        69461    70404     +943     
+ Misses      16591    15849     -742     
Files with missing lines Coverage Δ
scapy/layers/ptp_v2.py 0.00% <0.00%> (ø)

... and 25 files with indirect coverage changes

codecov[bot] avatar Jan 13 '25 19:01 codecov[bot]

Hi, found this when going over the issues in the repository. I suggest you use the following logic I implemented way back during my thesis on IEEE 1588 security - https://github.com/eyalitki/ptpd/commit/4e46fe954bc514b8ed2305ad0a818284d7102f8b#diff-bf2c30fee47c7daecd502ee34e25bc6324ff333f293f9d539d3ec4277764acaf.

You can ignore the "encryption" fields as they were part of my thesis and weren't adopted by the IEEE 1588 security committee. Still, the layer implements all non-control messages + Announce, so it should become handy. It served me well in my python scripts for sending/receiving packets, so it is well tested (even if old).

I hereby grant full access rights for this code and its derivatives to be used as part of the Scapy repository in any way the maintainers of the repository deem to be fit. Enjoy.

eyalitki avatar Feb 26 '25 18:02 eyalitki

@gpotter2 What do you think?

polybassa avatar Oct 13 '25 19:10 polybassa

Looks promising although it should be in contrib/ (I think). Unsure why it's marked as draft though

gpotter2 avatar Oct 13 '25 21:10 gpotter2

@gpotter2 Sorry, I was away from last couple months. I’ve just switched it from draft to ready for review.

satveerbrar avatar Nov 10 '25 03:11 satveerbrar