OSI Model – Do Routers Understand Transport Protocol?

osiroutingswitching

We are taught about the difference between hubs, switches, and routers. A hub is a layer 1 device, it only knows layer 1 and doesn't care about layer 2 and above. Similarly, a switch is a layer 2 device, it only knows layer 1-2 and doesn't care about layer 3 and above. And similarly, a router is a layer 3 device, it only knows layer 1-3 and doesn't care about layer 4 and above (is that even correct?).

But wait… RIP and BGP, which are routing protocols used by routers, are encapsulated in UDP and TCP, which are layer 4 protocols. So if routers are layer 3 devices, then how do they extract RIP or BGP packets? Unless they understand UDP/TCP. But that would make them layer 4. Please enlighten me.

Best Answer

Routers are layer 3 devices because they transport packets at the layer 3 (mostly IP). A switch is considered a layer 2 devices because it transport frames at the layer 2 (mostly Ethernet). This means they respectively must read information in the layer 3/2 header to be able to forward packets/frames.

However, both switches and routers understand protocols above their respective transport layers. As an example, you can SSH to theses devices. Does that make them work at layer 7? No, because in that case, they don't transport packet but are the source or destination. This is the same with BGP, RIP, etc. Theses protocols are can be used by a router to do his task (forwarding packets), but are not necessary at all. However, a router cannot work without the IP protocol (or others layer 3 protocol like IPX). The same apply to a switch. It can't work without Ethernet (or frame relay, ATM, etc.). Sure it is better to use other technologies like the spanning tree protocol, or VTP, etc. but they are not mandatory.