Raw Ethernet II frames for PTP

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Raw Ethernet II frames for PTP

lwip-users mailing list
Hi all,

I am implementing a software Precision Time Protocol (PTP) implementation which requires reading Raw Ethernet II frames, no TCP/IP/UDP. An example packet is copied below. Is this possible using lwIP?

I see the raw_new api accepts a proto parameter but there doesn't seem to be a protocal define for raw frames. 

Protocols defined in ip.h
#define IP_PROTO_ICMP    1
#define IP_PROTO_IGMP    2
#define IP_PROTO_UDP     17
#define IP_PROTO_UDPLITE 136
#define IP_PROTO_TCP     6

Thank you.

Example PTP Raw Ethernet II frame copied from Wireshark

Frame 28: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)
    Encapsulation type: Ethernet (1)
    Arrival Time: Jul 24, 2019 16:29:02.184864000 PDT
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1564010942.184864000 seconds
    [Time delta from previous captured frame: 0.008057000 seconds]
    [Time delta from previous displayed frame: 0.008057000 seconds]
    [Time since reference or first frame: 0.264827000 seconds]
    Frame Number: 28
    Frame Length: 60 bytes (480 bits)
    Capture Length: 60 bytes (480 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ethertype:ptp]
    [Coloring Rule Name: Broadcast]
    [Coloring Rule String: eth[0] & 1]
Ethernet II, Src: Trimble_70:09:90 (00:17:47:70:09:90), Dst: IeeeI&MS_00:00:00 (01:1b:19:00:00:00)
    Destination: IeeeI&MS_00:00:00 (01:1b:19:00:00:00)
        Address: IeeeI&MS_00:00:00 (01:1b:19:00:00:00)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
    Source: Trimble_70:09:90 (00:17:47:70:09:90)
        Address: Trimble_70:09:90 (00:17:47:70:09:90)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: PTPv2 over Ethernet (IEEE1588) (0x88f7)
    Padding: 0000
Precision Time Protocol (IEEE1588)
    0000 .... = transportSpecific: 0x0
    .... 0000 = messageId: Sync Message (0x0)
    .... 0010 = versionPTP: 2
    messageLength: 44
    subdomainNumber: 24
    flags: 0x0000
        0... .... .... .... = PTP_SECURITY: False
        .0.. .... .... .... = PTP profile Specific 2: False
        ..0. .... .... .... = PTP profile Specific 1: False
        .... .0.. .... .... = PTP_UNICAST: False
        .... ..0. .... .... = PTP_TWO_STEP: False
        .... ...0 .... .... = PTP_ALTERNATE_MASTER: False
        .... .... ..0. .... = FREQUENCY_TRACEABLE: False
        .... .... ...0 .... = TIME_TRACEABLE: False
        .... .... .... 0... = PTP_TIMESCALE: False
        .... .... .... .0.. = PTP_UTC_REASONABLE: False
        .... .... .... ..0. = PTP_LI_59: False
        .... .... .... ...0 = PTP_LI_61: False
    correction: 582.000015 nanoseconds
        correction: Ns: 582 nanoseconds
        correctionSubNs: 1.52587890625e-05 nanoseconds
    ClockIdentity: 0x001747fffe700990
    SourcePortID: 1
    sequenceId: 9796
    control: Sync Message (0)
    logMessagePeriod: -4
    originTimestamp (seconds): 1564010979
    originTimestamp (nanoseconds): 187716775

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Raw Ethernet II frames for PTP

goldsimon@gmx.de
Am 25.07.2019 um 21:22 schrieb Nathan Immerman via lwip-users:
> Hi all,
>
> I am implementing a software Precision Time Protocol (PTP)
> implementation which requires reading Raw Ethernet II frames, no
> TCP/IP/UDP. An example packet is copied below. Is this possible using lwIP?

Yes and no. There's no API for raw Ethernet frames in lwIP, but if
you're using it on an embedded system where you have access to the netif
driver, you can just send those frames directly to the netif driver's
linkoutput function.

>
> I see the raw_new api accepts a proto parameter but there doesn't seem
> to be a protocal define for raw frames.

The 'raw' API is for 'raw' transport layer access. IPv4 or IPv6 is
always encapsuled. This resembles the socket API. E.g. if you want to
send raw Ethernet frames in Linux, you need AF_PACKET, not SOCK_RAW.

I'd be open for a patch to include such raw (Ethernet) access if it's
done cleanly enough. AF_PACKET could be implemented above that as well.
I'm just not taking the time to do that myself...

Regards,
Simon

>
> Protocols defined in ip.h
> #define IP_PROTO_ICMP    1
> #define IP_PROTO_IGMP    2
> #define IP_PROTO_UDP     17
> #define IP_PROTO_UDPLITE 136
> #define IP_PROTO_TCP     6
>
> Thank you.
>
> Example PTP Raw Ethernet II frame copied from Wireshark
>
> Frame 28: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)
>      Encapsulation type: Ethernet (1)
>      Arrival Time: Jul 24, 2019 16:29:02.184864000 PDT
>      [Time shift for this packet: 0.000000000 seconds]
>      Epoch Time: 1564010942.184864000 seconds
>      [Time delta from previous captured frame: 0.008057000 seconds]
>      [Time delta from previous displayed frame: 0.008057000 seconds]
>      [Time since reference or first frame: 0.264827000 seconds]
>      Frame Number: 28
>      Frame Length: 60 bytes (480 bits)
>      Capture Length: 60 bytes (480 bits)
>      [Frame is marked: False]
>      [Frame is ignored: False]
>      [Protocols in frame: eth:ethertype:ptp]
>      [Coloring Rule Name: Broadcast]
>      [Coloring Rule String: eth[0] & 1]
> Ethernet II, Src: Trimble_70:09:90 (00:17:47:70:09:90), Dst:
> IeeeI&MS_00:00:00 (01:1b:19:00:00:00)
>      Destination: IeeeI&MS_00:00:00 (01:1b:19:00:00:00)
>          Address: IeeeI&MS_00:00:00 (01:1b:19:00:00:00)
>          .... ..0. .... .... .... .... = LG bit: Globally unique address
> (factory default)
>          .... ...1 .... .... .... .... = IG bit: Group address
> (multicast/broadcast)
>      Source: Trimble_70:09:90 (00:17:47:70:09:90)
>          Address: Trimble_70:09:90 (00:17:47:70:09:90)
>          .... ..0. .... .... .... .... = LG bit: Globally unique address
> (factory default)
>          .... ...0 .... .... .... .... = IG bit: Individual address
> (unicast)
>      Type: PTPv2 over Ethernet (IEEE1588) (0x88f7)
>      Padding: 0000
> Precision Time Protocol (IEEE1588)
>      0000 .... = transportSpecific: 0x0
>      .... 0000 = messageId: Sync Message (0x0)
>      .... 0010 = versionPTP: 2
>      messageLength: 44
>      subdomainNumber: 24
>      flags: 0x0000
>          0... .... .... .... = PTP_SECURITY: False
>          .0.. .... .... .... = PTP profile Specific 2: False
>          ..0. .... .... .... = PTP profile Specific 1: False
>          .... .0.. .... .... = PTP_UNICAST: False
>          .... ..0. .... .... = PTP_TWO_STEP: False
>          .... ...0 .... .... = PTP_ALTERNATE_MASTER: False
>          .... .... ..0. .... = FREQUENCY_TRACEABLE: False
>          .... .... ...0 .... = TIME_TRACEABLE: False
>          .... .... .... 0... = PTP_TIMESCALE: False
>          .... .... .... .0.. = PTP_UTC_REASONABLE: False
>          .... .... .... ..0. = PTP_LI_59: False
>          .... .... .... ...0 = PTP_LI_61: False
>      correction: 582.000015 nanoseconds
>          correction: Ns: 582 nanoseconds
>          correctionSubNs: 1.52587890625e-05 nanoseconds
>      ClockIdentity: 0x001747fffe700990
>      SourcePortID: 1
>      sequenceId: 9796
>      control: Sync Message (0)
>      logMessagePeriod: -4
>      originTimestamp (seconds): 1564010979
>      originTimestamp (nanoseconds): 187716775
>
> _______________________________________________
> lwip-users mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Raw Ethernet II frames for PTP

Dirk Ziegelmeier-2
In reply to this post by lwip-users mailing list
What do you need an IP stack for when you want to process raw ethernet frames???

Dirk

On Thu, Jul 25, 2019 at 10:25 PM Nathan Immerman via lwip-users <[hidden email]> wrote:
Hi all,

I am implementing a software Precision Time Protocol (PTP) implementation which requires reading Raw Ethernet II frames, no TCP/IP/UDP. An example packet is copied below. Is this possible using lwIP?

I see the raw_new api accepts a proto parameter but there doesn't seem to be a protocal define for raw frames. 

Protocols defined in ip.h
#define IP_PROTO_ICMP    1
#define IP_PROTO_IGMP    2
#define IP_PROTO_UDP     17
#define IP_PROTO_UDPLITE 136
#define IP_PROTO_TCP     6

Thank you.

Example PTP Raw Ethernet II frame copied from Wireshark

Frame 28: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)
    Encapsulation type: Ethernet (1)
    Arrival Time: Jul 24, 2019 16:29:02.184864000 PDT
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1564010942.184864000 seconds
    [Time delta from previous captured frame: 0.008057000 seconds]
    [Time delta from previous displayed frame: 0.008057000 seconds]
    [Time since reference or first frame: 0.264827000 seconds]
    Frame Number: 28
    Frame Length: 60 bytes (480 bits)
    Capture Length: 60 bytes (480 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ethertype:ptp]
    [Coloring Rule Name: Broadcast]
    [Coloring Rule String: eth[0] & 1]
Ethernet II, Src: Trimble_70:09:90 (00:17:47:70:09:90), Dst: IeeeI&MS_00:00:00 (01:1b:19:00:00:00)
    Destination: IeeeI&MS_00:00:00 (01:1b:19:00:00:00)
        Address: IeeeI&MS_00:00:00 (01:1b:19:00:00:00)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
    Source: Trimble_70:09:90 (00:17:47:70:09:90)
        Address: Trimble_70:09:90 (00:17:47:70:09:90)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: PTPv2 over Ethernet (IEEE1588) (0x88f7)
    Padding: 0000
Precision Time Protocol (IEEE1588)
    0000 .... = transportSpecific: 0x0
    .... 0000 = messageId: Sync Message (0x0)
    .... 0010 = versionPTP: 2
    messageLength: 44
    subdomainNumber: 24
    flags: 0x0000
        0... .... .... .... = PTP_SECURITY: False
        .0.. .... .... .... = PTP profile Specific 2: False
        ..0. .... .... .... = PTP profile Specific 1: False
        .... .0.. .... .... = PTP_UNICAST: False
        .... ..0. .... .... = PTP_TWO_STEP: False
        .... ...0 .... .... = PTP_ALTERNATE_MASTER: False
        .... .... ..0. .... = FREQUENCY_TRACEABLE: False
        .... .... ...0 .... = TIME_TRACEABLE: False
        .... .... .... 0... = PTP_TIMESCALE: False
        .... .... .... .0.. = PTP_UTC_REASONABLE: False
        .... .... .... ..0. = PTP_LI_59: False
        .... .... .... ...0 = PTP_LI_61: False
    correction: 582.000015 nanoseconds
        correction: Ns: 582 nanoseconds
        correctionSubNs: 1.52587890625e-05 nanoseconds
    ClockIdentity: 0x001747fffe700990
    SourcePortID: 1
    sequenceId: 9796
    control: Sync Message (0)
    logMessagePeriod: -4
    originTimestamp (seconds): 1564010979
    originTimestamp (nanoseconds): 187716775
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Raw Ethernet II frames for PTP

Nathan Hartman
On Thu, Jul 25, 2019 at 4:31 PM Dirk Ziegelmeier <[hidden email]> wrote:
What do you need an IP stack for when you want to process raw ethernet frames???

My guess is that you need it because the system does other things with the network, too.


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Raw Ethernet II frames for PTP

goldsimon@gmx.de
Am 26.07.2019 um 21:06 schrieb Nathan Hartman:
> On Thu, Jul 25, 2019 at 4:31 PM Dirk Ziegelmeier <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     What do you need an IP stack for when you want to process raw
>     ethernet frames???
>
>
> My guess is that you need it because the system does other things with
> the network, too.

Well, you still wouldn't need to tunnel those raw Ethernet requests
through lwIP, which is an IP stack.

On the other hand, given the lack of a standardized API to send and
receive raw Ethernet frames; and given the PF_PACKET extension other
stacks have, I can understand this question.

I have already answered though: we don't have it yet; contributions are
welcom. Sadly, no such thing seen yet.

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users