According to OSI reference model layers communicate with lower layer to transmit information on to other network. So they add header and tail for data and pass it on to lower layer and finally passed to other computer over wire or wireless. Switch is for communication between link layers and router for network layer. What is the use of them when 2 networking layers can't communicate directly and need to pass to lower layer.
-
1I'm tempted to close this, as this could be considered common knowledge and it's a theoretical question about a model, not about engineering. – Teun Vink Sep 07 '16 at 18:33
-
I would vote against closing. Albeit basic, this is absolutely the right stack exchange for *network theory* questions. – Eddie Sep 07 '16 at 23:58
4 Answers
Each layer of the OSI model serves a unique purpose with the end goal of host to host communication.
Layer 1 is responsible for moving bits (1
s and 0
s) across a network.
Layer 2 is responsible for communication within networks. L2 uses addressing known as MAC addresses for this purpose. A MAC address is essentially the address of a particular NIC.
Layer 3 is responsible for communication between networks. L3 uses addressing known as IP addresses for this purpose.
Fundamentally, your question is not "what is the purpose of Routers", but "what is the purpose of networks", if you understand why the Internet is divided up into multiple networks, then you will understand why you need a device that facilitates communication between those networks (aka, the router).
Consider your mailing address. It will look something like this:
432 Park Avenue
Imagine a postal employee having to deliver a letter to your address. It would be impossible for the local postal employee to know every residential unit in the city. BUT, its far more feasible for the postal employee to know every street in the city. The postal employee will find the street you live on, and from there count out the residences until they get to 432. That is how they will find your specific house.
In this analogy, the street is like a network (Park Avenue), it is a grouping of houses that a single postal employee can know the location of. One street can exist next to many other streets, and as long as each street is uniquely named, they can be found by your postal employee.
The building number (432) is like a MAC address, it is the specific house/building within a street. Other streets may have the same building number, but within a particular street there can only be unique house numbers.
Your mailman doesn't need to know every house on every street, they just need to know every street. Once the street is found, they can track down the exact location based upon the house number.
The internet is the same way. Instead of forcing a Router to know every location of every host in the whole world, Router's are only concerned with knowing the location of every network. Once the packet is routed to the proper Router (aka, the proper street), the packet delivery process can look up the appropriate MAC address (aka, the proper house) to deliver the packet to.
So in the end, a Router exists to know the location of every network, and to move packets from Router to Router until the final Router in the path is found. When that happens, that Router will look up the specific MAC address to get the packet to its intended destination.
For more information on how a Router does its job (and therefore, the job the router serves) check out this article that discusses how a Router moves packets through a network.
The OP asked this question in comments:
only bits come out of the physical layer for transmission. So does Router convert them back to packets upon receiving bits as input?
The answer is "eventually yes". Each layer adds to the original data what it needs to add in order to accomplish its purpose:
- Layer 3 (the Router) will add an IP header which would include a Source and Destination IP address
- Layer 2 (the NIC on the Router) would add an Ethernet header which would include a Source and Destination MAC address
Layer 2 would then convert the resulting frame into 1
s and 0
s and send them to Layer 1 to be sent across the wire.
The process can be seen in this animation:

- 14,808
- 6
- 42
- 82
-
My doubt is router is for routing packets where as only bits come out of the physical layer for transmission. So does Router convert them back to packets upon receiving bits as input? – amruth polavarapu Sep 08 '16 at 03:09
-
@amruthvenkat Eventually, yes. The router deals with packets, then passes the packet to L2, which deals with the frame, which then converts the frame into 1s and 0s to pass it across the wire. Take a look at the [encapsulation and de-encapsulation](http://www.practicalnetworking.net/series/packet-traveling/osi-model/#encap-decap) process... in fact, I'll edit the animation into my answer because its relevant, and I'm really proud of it. – Eddie Sep 08 '16 at 06:24
Traffic in different IP networks/VLAN's (Layer 2 - MAC) cannot communicate with each other. For communication between IP networks/VLAN's you need a Router (Layer 3 - IP).

- 273
- 1
- 3
- 8
-
My doubt is router is for routing packets where as only bits come out of the physical layer for transmission. So does Router convert them back to packets upon receiving bits as input? – amruth polavarapu Sep 08 '16 at 03:10
Layers communicate with their corresponding layer logically. That means the transport layer adds information that the receiver's transport layer understands.
Your statement "Switch is for communication between link layers and router for network layer." is a mischaracterization of their functions. See if this question helps you.
-
1Can you explain more clearly what is purpose of router and if my question is correct? – amruth polavarapu Sep 07 '16 at 18:38
-
1This really isn't the forum to teach basic networking fundamentals. There are lots of websites and videos that you can learn from. A quick Google search will give you lots of information. – Ron Trunk Sep 07 '16 at 18:40
-
My doubt is router is for routing packets where as only bits come out of the physical layer for transmission. So does Router convert them back to packets upon receiving bits as input? – amruth polavarapu Sep 08 '16 at 03:10
Encapsulation is a term often associated with the layers - a datagram is encapsulated then handed to the lower layer. A routers function is to route packets. A switches function is to switch frames.

- 4,379
- 1
- 12
- 28
-
My doubt is router is for routing packets where as only bits come out of the physical layer for transmission. So does Router convert them back to packets upon receiving bits as input? – amruth polavarapu Sep 08 '16 at 03:02
-
Packets come out of a router. Frames are made up of bits grouped together. Packets encapsulate frames. – Ronnie Royston Sep 08 '16 at 14:43
-
"_...a datagram is encapsulated then handed to the higher layer._" I think you meant that a datagram is encapsulated, then passed to a lower layer. An application datagram is encapsulated by layer-4 (TCP, etc.), then the encapsulated layer-4 datagram is passed to layer-3 (IP, etc.), the encapsulated layer-3 datagram is passed to layer-2 (ethernet, etc.). When passing to an upper layer, the datagrams are decapsulated. – Ron Maupin Sep 10 '16 at 06:34