scapy-gptp


Namescapy-gptp JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
Summaryscapy layer definition and tools for GPTP (IEEE 802.1as)
upload_time2025-02-07 20:02:20
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords 802.1as ptp gptp scapy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # scapy-gptp - scapy layer definition and tools for GPTP (IEEE 802.1as)

![PyPI - Version](https://img.shields.io/pypi/v/scapy-gptp)
![PyPI - License](https://img.shields.io/pypi/l/scapy-gptp)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/scapy-gptp)


This python module contains the layer definition for PTPv2 (GPTP) which includes custom
definitions for `Timestamp` and `ClockIdentity` fields. It further provide some handy utils when
analyzing PTPv2 traces.

## Usage

The `PTPv2` layer is automatically bound to the Ethernet layer based on its `type` field (`0x88F7`).
Just import the `PTPv2` layer definition to make scapy aware of this bond and for example read a
pcap file to dissect

```python
from gptp.layers import PTPv2
from scapy.utils import rdpcap

pcap = rdpcap("traces.pcap")

for p in pcap:
    if p.haslayer('PTPv2'):
        p.show()
```

which yields something like

```
###[ Ethernet ]###
  dst       = 01:83:b0:02:21:fe
  src       = 7a:1b:31:80:11:06
  type      = 0x88f7
###[ PTPv2 ]###
     transportSpecific= 1
     messageType= Sync
     reserved0 = 0x0
     versionPTP= 2
     messageLength= 44
     domainNumber= 0
     reserved1 = 0x0
     flags     = TIMESCALE+TWO_STEP
     correctionField= 0
     reserved2 = 0x0
     sourcePortIdentity= 7a:1b:31:80:11:06/1
     sequenceId= 2081
     control   = 0x0
     logMessageInterval= -3
     reserved3 = None
###[ Padding ]###
        load      = '\x00\x00\x00\x00\x00\x00'
```

A handy addition when analyzing PTP traces is the `MatchedList` from `utils` module. You can add PTP
packets to it and it will automatically find matching `(Sync, FollowUp)` message pairs as well as
`(PdelayReq, PdelayResp, PdelayRespFollowUp)` message triplets, providing them as lists for easy
processing and analysis.

```python
from gptp.utils import MatchedList

pcap = rdpcap("traces.pcap")
matched_list = MatchedList([p for p in pcap if p.haslayer('PTPv2')])

(sync, fup) = matched_list.sync[0]
assert sync.sequenceId == fup.sequenceId
print(fup.preciseOriginTimestamp)  # prints 1602135835.0758622
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "scapy-gptp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "802.1as, PTP, gPTP, scapy",
    "author": null,
    "author_email": "Christoph Weinsheimer <weinshec@holodeck2.de>",
    "download_url": "https://files.pythonhosted.org/packages/65/da/b6ab49955a693c0334474ce59b4c8bc9919bf0acd7aad29eb5a6f7895cef/scapy_gptp-0.2.1.tar.gz",
    "platform": null,
    "description": "# scapy-gptp - scapy layer definition and tools for GPTP (IEEE 802.1as)\n\n![PyPI - Version](https://img.shields.io/pypi/v/scapy-gptp)\n![PyPI - License](https://img.shields.io/pypi/l/scapy-gptp)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/scapy-gptp)\n\n\nThis python module contains the layer definition for PTPv2 (GPTP) which includes custom\ndefinitions for `Timestamp` and `ClockIdentity` fields. It further provide some handy utils when\nanalyzing PTPv2 traces.\n\n## Usage\n\nThe `PTPv2` layer is automatically bound to the Ethernet layer based on its `type` field (`0x88F7`).\nJust import the `PTPv2` layer definition to make scapy aware of this bond and for example read a\npcap file to dissect\n\n```python\nfrom gptp.layers import PTPv2\nfrom scapy.utils import rdpcap\n\npcap = rdpcap(\"traces.pcap\")\n\nfor p in pcap:\n    if p.haslayer('PTPv2'):\n        p.show()\n```\n\nwhich yields something like\n\n```\n###[ Ethernet ]###\n  dst       = 01:83:b0:02:21:fe\n  src       = 7a:1b:31:80:11:06\n  type      = 0x88f7\n###[ PTPv2 ]###\n     transportSpecific= 1\n     messageType= Sync\n     reserved0 = 0x0\n     versionPTP= 2\n     messageLength= 44\n     domainNumber= 0\n     reserved1 = 0x0\n     flags     = TIMESCALE+TWO_STEP\n     correctionField= 0\n     reserved2 = 0x0\n     sourcePortIdentity= 7a:1b:31:80:11:06/1\n     sequenceId= 2081\n     control   = 0x0\n     logMessageInterval= -3\n     reserved3 = None\n###[ Padding ]###\n        load      = '\\x00\\x00\\x00\\x00\\x00\\x00'\n```\n\nA handy addition when analyzing PTP traces is the `MatchedList` from `utils` module. You can add PTP\npackets to it and it will automatically find matching `(Sync, FollowUp)` message pairs as well as\n`(PdelayReq, PdelayResp, PdelayRespFollowUp)` message triplets, providing them as lists for easy\nprocessing and analysis.\n\n```python\nfrom gptp.utils import MatchedList\n\npcap = rdpcap(\"traces.pcap\")\nmatched_list = MatchedList([p for p in pcap if p.haslayer('PTPv2')])\n\n(sync, fup) = matched_list.sync[0]\nassert sync.sequenceId == fup.sequenceId\nprint(fup.preciseOriginTimestamp)  # prints 1602135835.0758622\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "scapy layer definition and tools for GPTP (IEEE 802.1as)",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/weinshec/scapy-gptp",
        "Issues": "https://github.com/weinshec/scapy-gptp/issues",
        "Repository": "https://github.com/weinshec/scapy-gptp"
    },
    "split_keywords": [
        "802.1as",
        " ptp",
        " gptp",
        " scapy"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a761764983bcf3aed2f7eb7c1d2f3b2c517705a783c50ba954f6d7a40545dfed",
                "md5": "93eb6c4279a9e6a90a66454191301c84",
                "sha256": "2212cee9e242b568687c9e078bd4dcebecb31e6786ba4533ba2d53ed412071a8"
            },
            "downloads": -1,
            "filename": "scapy_gptp-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93eb6c4279a9e6a90a66454191301c84",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 11918,
            "upload_time": "2025-02-07T20:02:18",
            "upload_time_iso_8601": "2025-02-07T20:02:18.601872Z",
            "url": "https://files.pythonhosted.org/packages/a7/61/764983bcf3aed2f7eb7c1d2f3b2c517705a783c50ba954f6d7a40545dfed/scapy_gptp-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "65dab6ab49955a693c0334474ce59b4c8bc9919bf0acd7aad29eb5a6f7895cef",
                "md5": "b801e7062aa9d37ed8d8bb76e5261dad",
                "sha256": "a41a75c7512f30ebf96c85dfd47a5148e61605fdc004d1e5df7fd3bf7607bf82"
            },
            "downloads": -1,
            "filename": "scapy_gptp-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b801e7062aa9d37ed8d8bb76e5261dad",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 10788,
            "upload_time": "2025-02-07T20:02:20",
            "upload_time_iso_8601": "2025-02-07T20:02:20.553915Z",
            "url": "https://files.pythonhosted.org/packages/65/da/b6ab49955a693c0334474ce59b4c8bc9919bf0acd7aad29eb5a6f7895cef/scapy_gptp-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-07 20:02:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "weinshec",
    "github_project": "scapy-gptp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "scapy-gptp"
}
        
Elapsed time: 0.40871s