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.

Fernando

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
    eth_txs_buffer[0]=0xFF;
    eth_txs_buffer[1]=0xFF;
    eth_txs_buffer[2]=0xFF;
    eth_txs_buffer[3]=0xFF;
    eth_txs_buffer[4]=0xFF;
    eth_txs_buffer[5]=0xFF;

    //set source MAC, the mbed's MAC address (use your own)
    eth_txs_buffer[6]=0x35;
    eth_txs_buffer[7]=0x5F;
    eth_txs_buffer[8]=0x22;
    eth_txs_buffer[9]=0xAB;
    eth_txs_buffer[10]=0xA3;
    eth_txs_buffer[11]=0x55;

    //set ethertype, just use IPv4
    eth_txs_buffer[12]=0x08;
    eth_txs_buffer[13]=0x00;

    //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++)
       eth_txs_buffer[14+count]='G';

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

return 0;
}
01 Dec 2014

This:

#include "mbed.h"
 
Ethernet eth;

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

Quote:

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

https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/TARGET_FRDM/device.h#L40

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.

@Michal,

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.