Categories

Archives

Data flow between two hosts: Switch vs Router

It is a matter of common confusion how data actually flows between two hosts, and what is the difference between router and a switch, packet and a frame, layer 2 and layer 3, OSI model and TCP/IP model. The reason for this confusion is that these things are truly complicated, plus on top of it there are way too many of those who try to explain these concepts despite not knowing themselves how these things actually work, and as a result confuse the person seeking this information. Plus the network equipment vendors keep coming up with hardware which doesn’t follow what is written in the books, making things even more confusing.

Now I am not an authority on this subject either, but am dealing with networks for a few years, and decided to put the following information here which is authentic on how data flows between two hosts in our every day home or office network scenario. You must know basics of networking to understand the following.

OSI MODEL vs TCP/IP MODEL

OSI model is just a theoretical model for reference, no network architecture actually exists which implements it. This model recommends 7 networking layers starting from: Physical layer, data-link layer, network layer, transport layer, session layer, presentation layer and application layer.

TCP/IP model is the most widely used model, the Internet works on it and so do most of the networks we deal with. It has only 4 layers:   Link layer, internet layer, transport layer and application layer. You might ask where is the physical layer? The answer is, the TCP/IP model is designed to be hardware independent and can run on any physical media provided it is properly implemented on it. That is why it starts from the link layer, which is layer 2 or L2 of the OSI reference model.

FRAMES vs PACKETS

Mixing them is a common mistake which even the literature and the professionals make. But remember, they are two difference things. A frame deals at hardware level, i.e. layer 2 or L2 of OSI reference model and contains MAC addresses of the source and destination hardware. A packet deals at virtual level, i.e. layer 3 or L3 of OSI reference model, and contains IP addresses of the source and destination. A packet is contained inside a frame and its the frame which travels over the wire or wireless waves, and delivers the packet inside it to the destination. A packet contains the actual data, which can be text, audio, video, picture etc.

ROUTERS

They route the data between other routers and switches (not the hosts), and make routing decisions according to their routing table, which is based on L3 addresses, i.e. IP addresses. They do change L2 MAC headers of the frames passing through them. A router has the ARP entries of all hosts connected to all of its interfaces which have communicated through the router, but not the ARP entries of all hosts in the network. (Consider a multi-router set up, which is typical).

SWITCHES

They switch data between the routers, other switches and the hosts, and make switching decision based on MAC table (not ARP table, it is different) and *do not* change the L2 MAC headers. Switches may add tags (IEEE 802.1q, Cisco ISL, etc.) to the MAC headers but the tags should have been removed before reaching the end hosts.

LAYER 3 SWITCHES

They do both routing and switching depending upon which one is more efficient for a given network. They are implemented in busy networks, and are expensive.

DATA FLOW

A typical data flow which we deal with on daily bases in our homes and offices is like this:

Host A -> Switch -> Router R -> Switch -> Host B

  1. The 1.x host A wants to send to 2.x host B.
  2. Host A realises B is on a different network judging from the subnet mask and ip addresses and knows it need help from a router.
  3. Host A does an ARP operation to find out the MAC address of its default gateway, which is a router R.
  4. Host A sends to router R with source MAC = A‘s MAC and destination MAC = R‘s MAC. The switches in between them pass the frames intact.
  5. Router R sends to host B through the switch in between, rewriting the source MAC to R‘s MAC and the destination MAC to B‘s MAC (before this it should have an ARP entry of host B; otherwise it would do an ARP operation to find out B‘s MAC).

I hope this information will make your networking concept a litter clearer.

4 people like this post.

Other posts related to this topic

  • ARP (Address Resolution Protocol) and ARP Poisoning
    ARP is a protocol which is used by the network devices, installed on the Ethernet networks, to find out each other's MAC addresses. If the network devices don't know each other's MAC addresses, they can't communicate with each other on an Ethernet ne...

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free