What happens to frame when it reaches a switch or router?

7,040

Solution 1

"As I understand it, when one PC sends a frame to another PC through a switch, the frame remains unchanged."

You are correct; switches do not modify the frames they forward in any way. This is known as transparent bridging as explained in this O'Reilly article titled Basic Switch Operation:

Ethernet switches are designed so that their operations are invisible to the devices on the network, which explains why this approach to linking networks is also called transparent bridging. “Transparent” means that when you connect a switch to an Ethernet system, no changes are made in the Ethernet frames that are bridged.


"But what happens if we have two PCs connected to a router and we send something between them?"

TL;DR

Any packet forwarded by a router will be modified. Required modifications include a new destination MAC address and a new Frame Check Sequence. But that's only a small part of what happens at the router...


Unlike switches, routers decide what to do with a packet based on its OSI Layer 3 destination address. In this case that is an Internet Protocol (IP) address. Therefore what happens to the packet depends on where the packet is headed. Let's use the image you referred to as an example:

enter image description here

Here we have a router with two interfaces: e1/1/1 (which I'll refer to as E1) and e1/1/2 (which I'll refer to as E2). Notice that the router's two interfaces are in separate subnets, which must always be the case for a router:

  • E1 is connected to subnetwork 10.0.0.0/24
  • E2 is connected to subnetwork 10.0.1.0/24

Now, suppose Computer A (with IP address 10.0.0.2/24 and therefore in subnetwork 10.0.0.0/24) sends a packet to destination IP address 10.0.1.2. Once that packet arrives at the router, the following happens:

  1. Packet arrives on interface E1
  2. Router determines the destination address is 10.0.1.2
  3. Router examines its routing table to determine where the packet should go
  4. The routing table indicates interface E2 is connected to subnetwork 10.0.0.0/24
  5. The router prepares the packet for transmission on interface E2. This requires modifying the packet in several ways. For example, the new packet will have:
    • The old destination Layer 2 (MAC) address replaced with a new destination address, which will be the broadcast address FF:FF:FF:FF:FF:FF for the first such packet sent on the interface
    • A new Frame Check Sequence (FCS) calculated and added to the packet
  6. The new packet is transmitted on interface E2

Once the packet is sent to the network segment connected to router interface E2 it is received by Computer B with the IP address 10.0.1.2.

Suppose Computer A sends a packet to the destination IP address 10.0.7.44. Once the packet reaches the router, the following occurs:

  1. Packet arrives on interface E1
  2. Router determines the destination address is 10.0.7.44
  3. Router examines its routing table to determine where the packet should go

Now what happens?

Well, if as shown in the graphic, the router truly only has the two interfaces, the router drops the packet because it doesn't have a valid route to the destination network.

In the real world, however, a router is likely to have at least one interface that is configured to be the default route or route of last resort. In the routing table, this is the interface with which network 0.0.0.0/0 is associated. If the router does not have a specific route to a valid network for the packet destined to 10.0.7.44, as its action of "last resort" it will transmit the packet on the interface associated with the default route.

The default route functionality is very important. Without it the router would be required to have a routing table entry for many (though not all) IP networks on the Internet. Such a table would be very large. Compared to a router with a default route, such a router would require:

  • More memory to store the routing table
  • More CPU time to examine the table (this is done for each incoming packet!)
  • Excessive and frequent routing table updates from many other routers on the Internet in order to keep its routing table accurate. Otherwise packets might be forwarded through an interface that in-fact no longer has connectivity to the destination network.

Solution 2

Think of a frame as one of those plastic capsules that travel in plastic tubes (some drive-up bank windows used to have those). A packet is an envelope inside the capsule, and the data is inside the envelope.

A switch is a place where a bunch of different tubes meet. It will look at the source address and destination address on the capsule, and based on that, send it through the appropriate tube to get where it's going.

Routers care about the envelope, not the capsule. When a router receives a capsule, it basically opens the capsule and then discards it. It will then look at the envelope and figure out where it needs to go. The envelope might need to go to someone's desk. In that case, it would hand the envelope off to a different delivery system (protocol). Or it might decide that the envelope needs to go back into the tube system, in which case it would place it into a new capsule and send it on its way.

That is, of course, very simplified, but hopefully it makes the picture a little clearer.

Share:
7,040

Related videos on Youtube

dargemir
Author by

dargemir

Updated on September 18, 2022

Comments

  • dargemir
    dargemir over 1 year

    As I understand it, when one PC sends a frame to another PC through a switch, the frame remains unchanged. The switch receives it and sends the exact same frame. But what happens if we have two PCs connected to a router and we send something between them?

  • dargemir
    dargemir about 7 years
    And it the PCs belongs to other nets? zapodaj.net/images/72df7cf02b691.jpg
  • LPChip
    LPChip about 7 years
    As stated in my answer, it becomes NAT translation, so portforwarding rules determine where the packet goes.
  • I say Reinstate Monica
    I say Reinstate Monica about 7 years
    Nice analogy. What underlying difference do you have in mind between between the function of moving a capsule to another desk and putting it back into the tube system? On a minor note, switches don't care about a frame's source address.
  • Charles Burge
    Charles Burge about 7 years
    One possible analogy is a cable modem. On the internal side, it uses ethernet to route frames on your internal LAN. On the external side, it uses DOCSIS, which is still layer 2, but a different protocol. And yes, switches DO care about the source address. That's how they learn which MAC addresses are on which ports.
  • I say Reinstate Monica
    I say Reinstate Monica about 7 years
    My bad on the switch's use of the source MAC address. I wouldn't call a cable modem a router. A true router is a OSI layer 3 device with the purpose of "routing" packets between multiple layer 3 networks. But the translation of packets between different physical network architectures is not a feature of a standalone router. Due to the combination of multiple networking capabilities into a single device, some consider a cable modem to be best described as a Residential Gateway.
  • Charles Burge
    Charles Burge about 7 years
    Actually a cable modem is a router in a true sense of the word. That's why it has an internal IP address and an external IP address. It routes packets between your home LAN and the cable company's network.
  • I say Reinstate Monica
    I say Reinstate Monica about 7 years
    So does a typical wireless router, but no one would call that a true router.
  • I say Reinstate Monica
    I say Reinstate Monica about 7 years
  • Antonio23249
    Antonio23249 almost 3 years
    Super thanks! I just googled for "does the same frame arrives through switches?" and got to this great answer.