11

As it is clear from the title, why do switches need ARP tables when the translation are done on the machines side?

Roughly saying, why there are two ARP tables on machines and on switches? Is not the one on the switch sufficient?

  • I think the answers on this page are correct. I found other commentators on other pages saying that L2 switches contain ARP tables. This makes no sense. Only L3 devices contain ARP tables. – Stephen Gibbons May 5 '18 at 19:28
21

This is a pretty common misconception or more specifically, a terminology problem. In a layer two switch, there is not an ARP table, only a forwarding table. The switch records each src MAC address it sees inbound in the forwarding table, and attributes it to the port so frames with a dst MAC will only get sent to the port known for that MAC. Many people call this an "arp table" or "arp cache" even though it is neither.

In a managed layer two switch, there is a forwarding table plus an ARP table but the latter is only used for the management interface to talk to interested hosts (i.e. the PC you are using to configure the switch.) In a managed layer 3 switch there will be a forwarding table plus an ARP table, since it needs it for the management interface plus router functionality exists to perform forwarding between subnets.

  • It's my understanding that you would model a switch as a set of (switch) ports. Ports are numbered packet queues. The switch drains the ports in an arbitrary order, and maintains a mapping from mac to port. When a packet is drained from a port, the src mac (address) is mapped to the port (number). When a drained packet must be delivered, it is sent to the dest mac's port if known, or broadcast if not known. This means that a port must get an eth packet to get mapped. – Rob May 4 '15 at 18:43
  • @Rob, there are a number of unclear statements, if not outright inaccuracies, in your comment. Ports are not queues; there may be a 1-to-1 mapping on some platforms, but they are not the same. MAC address are learned when a frame is received, not transmitted. Frames are delivered to the output queue in the order they are received, possibly in conjunction with some sort of QoS, it isn't arbitrary. Frames with unknown destination addresses are flooded, not broadcast. – YLearn May 5 '15 at 14:23
  • Then: model switches as numbered pairs of (ethernet packet) queues (in,out). As an input queue is read, ensure that src mac of that packet is mapped to input queue's port number. That packet must be placed into the out queue corresponding to dst mac. If the port isn't mapped, then the packet is enqueued into all out queues other than its own. (Not sure what the broadcast/flood distinction is, as I assume that it literally sends same signal on all wires at hardware level; or perhaps it round-robins through the ports?) – Rob May 5 '15 at 14:50
  • Ah... I think I see the objection to modeling the switch as packet queues. The switch might be operating on smaller chunks of data than whole packets. Ie: as soon as we know which ports should get a packet that we are getting bytes for, we could be sending those bytes. ex: queue up just enough bytes to handle the ethernet header; don't hold the entire packet. – Rob May 5 '15 at 15:03
  • @Rob, a flooded frame is a unicast frame with an unknown destination that are flooded out each port other than the receiving port. A broadcast is an all destinations frame that is sent out all ports other than the receiving port, but will continue to be treated in this manner by all switches receiving it in the L2 broadcast domain. While similar in effect on a single switch, the effect on the entire network is significantly different. – YLearn May 5 '15 at 23:38
6

Every device utilizing the IP protocol has an ARP table. Since IP is an L3 protocol and requires an underlying L2 protocol, this is a requirement for a device to be able to translate an L3 IP address to its corresponding L2 address.

Whether your device is communicating to an IP address on the local network or not, it has to send it's L2 traffic (to keep it simple, let's exclude broadcast and multicast from this discussion) to a specific device on the local L2 domain. If the IP address is on the local network, this would be direct to the destination device. If not, this would be the device functioning as the gateway or router for the local network which can forward the L3 traffic towards its destination.

If a switch isn't using the IP protocol at all (i.e. it doesn't even provide any sort of management over IP, no L3 functionality, etc), then it doesn't need an ARP table.

However, I am not aware of an enterprise switch platform that does not utilize the IP protocol. Telnet, SSH, HTTP, HTTPS, and SNMP are just a few examples of the commonly supported services of an enterprise switch that would require access to IP.

2

As you probably already know, the purpose of the ARP table is to translate network layer addresses into link layer addresses. i.e. IP addresses to MAC addresses.

The tables you refer to aren't quite complete. Layer 2 switches also have two kinds of tables:

  • an ARP table that's used to communicate with the switch "as a computer" for interfacing with its controls. Well, it will have this if it's a managed switch

  • a table that relates switch ports to MAC addresses

Example1: If a PC launches a packet, it will use the MAC address if the IP address is local (from the ARP table). When that packet reaches a switch, the switch will move the packet to the appropriate port based on the MAC address (from the switches port/MAC table).

Example2: If a switch launches a packet from its management interface then it does the same thing as a PC would do using its ARP table. But, if a switch launches a packet from its switching function then it is simply moving that packet from one port to another according to its port/MAC table.

  • Thank you dear. Nice and helpful examples. Please don't confuse between packets and frames. – Mohamad-Jaafar NEHME May 6 '15 at 8:45
-2

Switches have mac-address tables.
Endpoints such as PCs have arp tables.

  • So only switches have mac-address tables? And only end points have ARP tables? – YLearn May 31 '15 at 4:22
  • 1
    @YLearn For actual L2 switches, yeah. – Navin Apr 19 '16 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.