Switch – OSI layer : Ethernet and IP address

ipip addressosirouterswitch

I want to understand differences with hosts transmitting data to another host within a local LAN and hosts sending data to another host in a remote LAN. A book I was reading quoted this"

"…understand that routers, which work at Network layer, don't care about where a particular house is located. They're only concerned about where networks are located and the best way to reach them."

Another part says:

"…Each time a packet is sent between routers, the Data link layer uses hardware addressing. Each time a packet is sent between routers, it's framed with control information at the Data Link later. However, that information is stripped off at the receiving router & only the original packert is left completely intact. This framing of the packet continues for each hop until the packet is finally delivered to the correct receiving host."

Self drawn network diagram

Using the diagram above as reference, I have some questions in mind:

  1. Is it correct to say that, when Alice wants to transmit data to Charlie, the process is as such:

    • Alice's packet will contain Alice IP address (SOURCE), and Charlie's IP address (DESTINATION). This info is passed onto the data link layer.
    • At the Data link layer, Alice MAC addresses (SOURCE) and Charlie's MAC address (DESTINATION) are added.
    • The data will be transmitted to SWITCH A. SWITCH A checks the destination MAC address and since SWITCH A knows where Charlie is located, it passes the data to the respective interface that Charlie is connected to.
    • Charlie will inspect the destination MAC address to see if its correct. If it's correct it will pass the data to the network layer
    • At the network layer, the DATA LINK layer information is being stripped off and Charlie check the Destination IP address. If it's correct Charlie will accept the data.

Is that correct?

  1. When Alice wants to send data to a host in a remote LAN, in this case, Bob,

    • Does Alice put the DESTINATION IP ADDRESS as the ROUTER A IP ADDRESS (Router A is the default gateway)? Because Alice does not know the IP Address of Bob, and only the remote router B knows it.

    • Is the destination MAC address the MAC address of BOB's Computer? or MAC address of the interface of switch A that Alice is connected to?

    • Does that mean that when the Data is transmit from Router A to Router B, the MAC Addresses in the data is ignored, and the router cares about the IP address, to know where to route the data to?

I hope my questions make sense. I'm trying to get my fundamental right before going to advance topic. Sorry if my English is bad.

Best Answer

First off - your English appears to me to be excellent. Secondly your summation of bridging (question 1) and consequently your understanding of the subject are very good. I would probably word some of that slightly different but your summation is fair and it appears that your understanding is good.

Let's make one assumption at this point to keep things simple - this is all Ethernet and IP.

Having said that there are two steps that I would add to your bridging summation that might clear up your understanding of routing (question 2) a little:

  1. when your network stack is handed data to transmit there is a route table look up done (every device on an IP network contains a route table - to see it from a command prompt - on linux type "route", on windows type "route print".) to determine two things:

a) which interface to transmit the data out

b) if the destination is directly reachable or is remote (beyond a router).

  1. Once the route is determined the network stack will ARP for a MAC address.

So when Alice is sending data to Charlie she does a route lookup - it is determined that his machine is directly accessible on the LAN. She then ARPs for his MAC address. Once the route has been determined and the MAC address has been acquired the network stack can then assemble the packet for transmission. This particular conversation as you mentioned only traverses switch A as it inspects the destination MAC.

Now that we have fleshed out question one a little better let's apply some of these concepts to question 2.

When Alice desires to send data to Bob the first step is a route lookup. It is determined that Bob is not on the LAN. Thus the route to Bob is the default route (assuming Router A is configured as such). (As your book points out Router A - and by extension Alice - don't know where Bob is. They only know the general direction - or "route".) So Alice ARPs for Router A. Then assembles the packet with destination IP address(network layer) of Bob and MAC address(datalink layer) of Router A. Upon receiving this packet Router A 1)strips off the MAC address(datalink layer) of Alice 2)does a route lookup 3)ARPs for router B 4)then reassembles the packet with MAC address of Router B. Router B repeats these steps ARPing for Bob and forwards the packet.

So the network layer is assembled at the start - source Alice and destination Bob - and never changes. The datalink layer on the other hand is deleted and reassembled each and every leg of the trip.