6

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?

7
  • I don't see how " one PC sends frame to other PC through the switch" and "we have two PC's connected to the same switch, and send something between them" are different scenarios. Mar 1, 2017 at 20:53
  • Is your question supposed to be about Ethernet? Is your second scenario supposed to involve a router?
    – sawdust
    Mar 1, 2017 at 20:58
  • Sorry, of course the second part concerns router. Edited.
    – dargemir
    Mar 1, 2017 at 21:02
  • 1
    @sawdust Not to pick nits - oh, who am I kidding, I AM picking nits - but the router includes a switch. Technically a pure router would have just one port per subnet. The common "home NAT routers" have one "WAN" port and several "LAN" ports - there's a switch behind the latter. Traffic between the LAN ports doesn't pass through the router part at all, so, yeah, it acts just like a switch. :) Mar 1, 2017 at 21:22
  • 1
    And what if they are in other nets, like here: zapodaj.net/images/72df7cf02b691.jpg
    – dargemir
    Mar 1, 2017 at 21:23

4 Answers 4

4

"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.
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.

7
  • 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. Mar 4, 2017 at 21:15
  • 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. Mar 4, 2017 at 21:28
  • 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. Mar 4, 2017 at 22:27
  • 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. Mar 4, 2017 at 22:34
  • So does a typical wireless router, but no one would call that a true router. Mar 4, 2017 at 22:38
0

A router is basically a switch with additional NAT translation to be able to distinquish between inbound and outbound traffic.

When the internet is involved, and thus NAT is used, port forwarding rules determine what happens with a packet (frame). If its only local, the entire NAT is not used, and thus only the internal switch is used. As such the exact same happens as with a regular switch, the packet remains unchanged.

2
  • And it the PCs belongs to other nets? zapodaj.net/images/72df7cf02b691.jpg
    – dargemir
    Mar 1, 2017 at 21:49
  • 1
    As stated in my answer, it becomes NAT translation, so portforwarding rules determine where the packet goes.
    – LPChip
    Mar 2, 2017 at 11:16
0

When a data link layer receives the Packet, it encapsulates packet data with
a Header and a Trailer to form the frame.
Frame header contains information such as start frame, addressing, type and control.
Frame trailer contains information such as error detection and stop from.

Scenario #1
Frame traveling in the same LAN:
When PC1 sends a frame to PC2 in the same network, the destination mac address will be the MAC address of PC2 and source mac address will be the mac address of PC1.
In this scenario there will be no change to the frame from source to destination.

Scenario #2
Frame traveling in different LAN:
When PC1 sends a frame to PC2 which is in a different network, the destination mac address will be the mac address of GATEWAY Router not the PC2 mac address. source mac address will be the PC1 mac address. Frame is sent to the Router.
Gateway de-encapsulate the frame to packet and encapsulate it with new frame header and trailer. In this new frame the Packet data is the same and unchanged.
We assume the PC2 is the next hop after the router to receive the frame. In the new frame header the destination mac address will be of PC2 and source mac address will be the mac address of the Router.
In this example the packet data from source to destination had to change its frame header and trailer as it was traveling through different intermediary devices.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .