1
votes

I've been playing around with an ethernet protocol (not IP) constructed using

socket(PF_PACKET, SOCK_RAW, ether_type)

I have a small problem. I've got a packet constructed that has the source and destination mac set to my local cards mac that I've also bound the socket to with bind.

I can receive packets fine from the network. I'm able to send packets to the degree where I see them appear in wireshark.

However, my listening app doesn't see those packets. It is able to see packets from other sources on the network however.

I should point out that my mac addresses do appear to be being sent in the correct byte order.

Can you send packets to yourself?

Do network cards not loopback? Does the linux kernel do something special at the IP level for loopback and because I'm below that, ignore me?

1
Just curious to know if you have root permissions while running this program as RAW sockets require that privilege.Vikdor
One alternative would be to use virtual ethernet "tap" devices, and a virtual switch like VDE2. That would allow experimenting with more realistic and complex scenarios. stackoverflow.com/questions/2082722/…sourcejedi
yes I have root permissions. I'm printing out all errors.hookenz
@MattH : can you post you code please? thanks.TOC

1 Answers

1
votes

Yes, IP "loopback" packets, as you put it, are treated specially. They're looped back internally, not sent out through the interface. So ethernet-level loopback, in this sense, is a special case that doesn't normally need to be supported. Some old 10Mbit ethernet cards were even half-duplex, so it couldn't have worked on that hardware :).

On the other hand, you can buy/make loopback adaptor cables to test network cards. So it must be possible on (hopefully all) modern hardware. And people have used them under linux with AF_PACKET (evidence, though no more details, here).

I guess the next question would be whether your switch supports this. A dumb hub would have to support it, but there's room for a modern switch to get confused. Or maybe disallowing it in fear of an infinite loop of packets.