David said:
Assuming the switch is a layer II, it doesn't need to know anything but
the ethernet layer. ARP packets are sent to the ethernet broadcast
address (FF FF FF FF FF FF) when appropriate. The switch must
send all such packets to all ports. The devices plugged in need to deal
with ARP, not the switch itself.
The switch just looks at the source and destination MAC addresses.
If a packet comes in on port X from some source, the switch adds that
source to that port's list. So when a packet comes in with that MAC
addesss as a destination, it knows what port to send it to.
I think typical behavior if a switch doesn't know a port associated with
a destination MAC address is to just drop the packet. I suppose it could
also send it to all ports...
There is another issue, if there are loops in the way the ports are
wired up. Spanning tree protocol can be used to detect these. Most
cheap switches don't implement this.
-Dave
Another point. Multicast traffic is another complication. Multicast is
identified by certain ranges of IP addresses. It may be that a multicast
packet has a destination MAC address of all FF's. I've seen the el cheapo
switches bog down with multicast traffic, they just send it to all ports.
Instead there is a protocol where receivers join a multicast channel,
and so switches only need forward multicast packets if any of the ports
have any receivers attached. Otherwise it can safely drop them.
I'm wondering what sort of switch one would make with an FPGA.
If you're targeting the low end market, forget it -- $5 for a 5 port switch
good luck trying to create an fpga solution in that range. High end
I can see a point, say a big 40 port switch where all the ports are
connected to a big fpga and it's a 1G or 10G switch...in that case
you need to have external memory for storing packets. No FPGA would
have enough BRAMs to handle the storage requirements necessary...
But if it's high end it'll probably need to be a layer III switch + know
about
IP + routing + multicast...in other words it gets to be a lot more
complicated.
-Dave