Source MAC address per IP packet

Hello,

for a networking application, I need to set the source MAC address individually for every IP packet that I send. Is this possible at all? I know that the MAC address can be changed in software but per IP frame? On the other hand, every layer 2 switch does exactly this, so it must be possible in principle. Do I need special network controller chips that support this feature? All datasheets of ethernet controllers I got hands on allow you to program the MAC address but it is then automatically filled in for every packet.

Also, how would the programming side look like? I presume I must use RAW sockets but in which field would I set the source MAC address?

Thanks,

Albrecht

Reply to
albrechtuhlmann
Loading thread data ...

Albrecht,

For what practical, benevolent purpose would you ever need to do this!?

hat trick

Reply to
hat-trick

What about replaying network traces to test (possibly modified) packet filter rules? What about generating specifically formatted packets to test such rules where they try to match MAC addresses (whatever good that would do)? What about testing layer 2 switch MAC table overflow characteristics?

best regards Patrick

Reply to
Patrick Schaaf

Aside from all the others suggested, the most obvious would be if you are implementing a transparent layer 2 switch/bridge.

DS

Reply to
David Schwartz

On 11.08.2008 15:44 David Schwartz wrote

s/transparent/intransparent/ ? Otherwise I don't get what you are pointing at.

Arnold

Reply to
Arnold Nipper

As far as I know, in some the whole packet is generated in memory (or in NIC memory) and then sent, in others the source address is stuffed in as it is transmitted.

You might look at older ones from the days when hardware was more expensive. (Eight bit ISA days.)

You should be working at the hardware level, though, not while running a networking OS. (DOS makes it easy, especially if you never return.)

Otherwise, just write the source address register before sending each packet. (Again, working directly with the hardware registers, not through a networking OS.

You want the data sheet for the individual controller chip, not the whole card.

-- glen

Reply to
glen herrmannsfeldt

Am Sun, 10 Aug 2008 10:51:49 -0700 schrieb hat-trick:

What about /usr/src/linux/if_ether.h ? (struct ethhdr)

You can set the MAC address to what ever you want.

cheers

Reply to
Burkhard Ott

Cabling-Design.com Forums website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.