STA Mode: Sending packets with other MAC source

Himmler
Posts: 4
Joined: Thu Nov 16, 2023 3:48 pm

STA Mode: Sending packets with other MAC source

Postby Himmler » Thu Nov 16, 2023 4:29 pm

Hello.
I need to build esp32-based transparent WiFi bridge like that:

Copper ETH <-> ESP32 AP <-> ESP32 STA <-> Copper ETH

So, first part Copper ETH <-> ESP32 AP works well (based on "eth2ap" example)
Second part ESP32 STA <-> Copper ETH (based on the same "eth2ap" example, but modified to STA) has a problem.

AP can send to WiFi packets with any source MAC
But STA can send only packets with the exactly same source MAC, as it was assigned in esp_wifi_set_mac()
When i try to send packet with other source MAC - looks like it just skipped by driver. Anyway, i can't recieve such packets on the other side.

Of course, i can encapsulate all ETH frames from copper into other frames with correct source MAC address (something like EoIP-tunnel by Mikrotik).
Also i can use something like raw 802.11 packets.

But what is the most correct way to do this with WiFi standart?
Maybe i can disable MAC source control in STA mode or something else?

Himmler
Posts: 4
Joined: Thu Nov 16, 2023 3:48 pm

Re: STA Mode: Sending packets with other MAC source

Postby Himmler » Sat Nov 18, 2023 5:25 am

So, nobody knows ?

endi83
Posts: 24
Joined: Wed Nov 22, 2023 2:43 pm

Re: STA Mode: Sending packets with other MAC source

Postby endi83 » Wed Nov 29, 2023 3:07 pm

Hi,

I have the same problem, in STA mode can send only packets with the exactly same source MAC, as it was assigned in esp_wifi_set_mac().

With other source MAC I can´t send packets

Himmler
Posts: 4
Joined: Thu Nov 16, 2023 3:48 pm

Re: STA Mode: Sending packets with other MAC source

Postby Himmler » Wed Nov 29, 2023 3:13 pm

I think it's some part of WiFi standart (STA cannot be any other device because of security reasons).
So, my solution - incapsulation of all ethernet frame into other ethernet frames with correct STA mac source.
Of cource MTU will be 14 bytes less than original (because of additional "fake" ETH header)

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: STA Mode: Sending packets with other MAC source

Postby MicroController » Wed Nov 29, 2023 6:07 pm

Himmler wrote:
Thu Nov 16, 2023 4:29 pm
But what is the most correct way to do this with WiFi standart?
Maybe i can disable MAC source control in STA mode or something else?
I imagine this is not possible. After all, you must first connect to a WiFi network (AP) using some MAC address. Later changing the MAC address while maintaining the existing WiFi connection... probably not going to happen.

Proper tunneling of the ethernet packets looks like the best option.

endi83
Posts: 24
Joined: Wed Nov 22, 2023 2:43 pm

Re: STA Mode: Sending packets with other MAC source

Postby endi83 » Thu Nov 30, 2023 7:57 am

And how can I do that? I'm looking in forums but so far I can't find anything, it's so frustrating.

Himmler
Posts: 4
Joined: Thu Nov 16, 2023 3:48 pm

Re: STA Mode: Sending packets with other MAC source

Postby Himmler » Thu Nov 30, 2023 3:27 pm

You just need to add another "fake" ethernet header to all your packets before sending from STA.

-MAC Destination addres (it can be just copied from original packet - first 6 bytes)
-MAC Source address - it must be the same MAC that was assigned to STA, not original MAC Source address from original packet (6 bytes)
-Ethernet type (it can be any value, which is not common used, for example 0x7FFF - 2 bytes)

So, you will send 14 bytes + size of original packet.
On the other side (AP) just remove first 14 bytes - and it's done. You received original packet from STA with any MAC Source address.
It's just simple tunneling (ethernet frames inside other ethernet frames).

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 92 guests