Sending raw Ethernet frames in Dart

What is this?

This is a small Dart package to make it possible to send raw Ethernet frames out. My use-case was to send data to a Colorlight 5A receiver card which expect Ethernet frames and I found no way to do that with Dart. The miss-leadingly named RawSocket class used TCP.

Thus this package was born: via FFI it uses the Linux socket() interface to send out raw Ethernet frames. Can be used to send arbitrary Ethernet packets. WOL packets, ARP spoofing, custom protocols come into mind.


Tests contain two parts: one which can be run as non-root and one which requires root (or similar permissions) as it actually opens a raw socket. I do run tcpdump in the background to capture the sent Ethernet packet and verify it's what I expect it to be.

Compiling the shared library

This is actually simple as the C layer is very short. I added a script. It's that simple.

macOS, Windows, Android, iOS

Sorry, no support from my side for those.


  • Receiving frames is not currently implemented.
  • This is nor performance optimized: A single frame is sent out synchronously. If performance is required, sendmmsg() should be used.
  • Only Linux supported and the shared library is only available for x86_64 and aarch64. It's very simple to compile the library though (see

Note on for Dart exe and aot

Dart can use packages (pulled in by dart pub get), but when compiled to exe or aot, it does not look at packages and thus will not be found. While it would be nice to statically link it to the executable file (or aot file), this does not work as of Dart 2.16.1 The workaround is to have the needed file in ./lib/$march/ where . is the path of the binary (e.g. sendframe.exe) See also