RAW Ethernet Programming in mbed

05 Jul 2012

Hello Forum,

I have been and mbed user for over a month right now, I am trying to get involved in a new project where my main point is to transfer a song from one mbed to another using RAW Ethernet.

Not UDP or TCP or IP, I want to go to the bottom layer of the ethernet and make the frame my self and send first any data from one mac address to another or to all of the macs in the network and once i know how to do that i will try to put a song inside the frame...

There is any help or library that can help me with the raw ethernet programming part? where i need to make up the frame and send it with a specific ether type ? did anyone already done this??

I found a lot of info in how to use the library with UDP R DHCP but my point is not to climb to those layers but stay in really RAW ethernet.

I will appreciate any help with this i am running out of pages where to look for.

Thanks a lot!

Regards from Argentina.


08 Jul 2012

Anyone that can give me a hint in where to start with this? or any help in where to look more info about it?

09 Jul 2012

this is a basic raw ethernet program that will flood your network every second. you can look at the traffic using wireshark

#include "mbed.h"

Ethernet eth;
char eth_txs_buffer[1536];
uint16_t packet_length;

int main(void)
    uint16_t count;

    //set destination MAC, your server's MAC address or broadcast address, example shows broadcast

    //set source MAC, the mbed's MAC address (use your own)

    //set ethertype, just use IPv4

    //fill your payload, example shows 100 bytes of the letter G, this is where you put your data to be sent to server
    for(count=0; count<100; count++)

    //send it
         //set frame length, 100 for message + 14 for ethernet header
         //send packet
         eth.write(eth_txs_buffer, (int) packet_length);
         //you can change the wait depending on how much frame you want to send, you don't want to flood your network

return 0;
01 Dec 2014


#include "mbed.h"
Ethernet eth;

no longer works. does not work for K64F. Including "Ethernet.h" doesn't help - the compiler always reports that


Error: Identifier "Ethernet" is undefined in "main.cpp", Line: 9, Col: 2

This also makes all the basic examples included in the mbed documentation invalid!

Can someone tell me how to use raw ethernet access now on K64F? (Without the need of importing rtos + EthernetInterface.)

01 Dec 2014

Basic Ethernet support is not available for the K64F using the mbed SDK API. If you want to make a case for it I'd suggest doing so here. https://github.com/mbedmicro/mbed/issues


You maybe able to use the lwip binding functions directly https://github.com/mbedmicro/mbed/blob/master/libraries/net/eth/lwip-eth/arch/TARGET_Freescale/k64f_emac.c

01 Dec 2014

Thanks for the info, Sam!

I've edited my post to avoid misleading others.

04 Apr 2015

Michal Janke wrote:

Thanks for the info, Sam!

I've edited my post to avoid misleading others.


Just wondering if you came up with a solution for this, been looking for exactly the same thing (raw ethernet on the k64f)?

I've attempted trying to use the lwip functions directly myself with very little success.

13 Oct 2015
  • sigh*

Yet again I try to do something with mbed, only to find "not supported".

Why raw ethernet? Ever heard of "real time processing"? Should not need to justify why its needed.