1

I have a network topoloty as follows

    A  ---------  B  ---------   C
   /|\           /|\            /|\
  / | \         / | \          / | \
 A1 A2 A3      B1 B2 B3       C1 C2 C3

A, B, C are layer-3 switches, and they have their own subnets. Each switch has 3 servers A1~A3, B1~B3, C1~C3 attached to them, so A1~A3 are in subnet A, B1~B3 in subnet B, C1~C3 in subnet C.

There is intra-switch traffic, e.g., from A1 to A3, as well as inter-switch traffic, e.g., from A1 to C1. Obviously, intra-switch traffic will be switched (layer 2), and inter-switch will be routed (layer 3).

I would like to know how does a switch, say A, can figure out if a packet needs switching or routing?

My understanding is based on the ARP protocol, because it decides the packet's destination MAC address.

If A1 wants to send out a packet, it will look up the destination IP address in its local ARP table or query over the network. If the dst IP is within the same subnet as A1, say A3, then A3's MAC address will be returned, and encapsulated in the outgoing packet's dst MAC field. If the dst IP is in another subnet, say C3, then the MAC address of switch A's interface that connects to A1 (assume it is interface 1) will be returned, and then put into the outgoing packet's dst MAC field.

When this packet reaches switch A, switch A will examine the dst MAC address. If this MAC address does not match the MAC address of switch A's inteface 1, it will be looked up in the MAC table to find the egress port. Then this packet is switched to that port, and its src and dst MAC addresses remain the same. Otherwise, this MAC address matches the MAC address of switch A's inteface 1, switch A continues to lookup the packet's dst IP address in the routing table to find the egress port. Then this packet's src and dst MAC addresses will both be replaced by A's egress interface MAC address, and switch B's ingress interface MAC address (also obtained through the ARP protocol).

Is my understanding correct, do I miss something?

  • A layer-3 switch is first and primarily a layer-2 switch. Conceptually, it is like a layer-2 switch connected to a router-on-a-stick, except the router is inside the switch chassis. – Ron Maupin Feb 13 at 14:30
2

Don't overthink, it's fairly simple.

When a frame arrives at an L3 switch, it is forwarded according to its destination MAC address. With normal L2 switching, the destination is a node off one of the switch ports.

If that destination MAC is the L3 switch itself (more precisely, one of its L3/routing/SVI interfaces), the encapsulated IP packet is passed to the L3 engine where it is routed according to its destination IP address. Essentially, routing is forwarding an IP packet between VLANs or L3 interfaces.

Of course, the routed packet is encapsulated in a fresh Ethernet frame, according to its destination segment.

| improve this answer | |
  • got it, so it's basically the same as I think. – Bloodmoon Feb 13 at 9:45

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.