scapy layer definition and tools for GPTP (IEEE 802.1as)
Project description
scapy-gptp - scapy layer definition and tools for GPTP (IEEE 802.1as)
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
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.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scapy_gptp-0.2.0.tar.gz.
File metadata
- Download URL: scapy_gptp-0.2.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfb710a1422054bf8a166c7dd0b0c6347d9b51aa17f55593170c89ba913d0099
|
|
| MD5 |
01a75d374bcf10efaf3a3fc9b0d16730
|
|
| BLAKE2b-256 |
6675a561f26e831daed1c34de2376180b3df7ddef6380a75ed9cfa1a1a930580
|
File details
Details for the file scapy_gptp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: scapy_gptp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cf8e89d3a8d82317aab6865f565aa58276c444782aa29e91e86faac4829d4cf
|
|
| MD5 |
4752291660a90686adc82d8f72d07c95
|
|
| BLAKE2b-256 |
a0c2a4dc8b02bc62deeb126faa63f46c252ad76dc558ae431d1885c751fa02fe
|