1

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.

1
  • 1
    Routing happens at the network layer. Routing tables are what routers use to make routing decisions, and the have network prefixes, but nothing about any transport protocol. Remember, routing protocols do not route, they are protocols to exchange routing information with other routers, so they can populate routing tables, but it is the routing table (network layer) that determines where to route the packets. – Ron Maupin Aug 21 '19 at 16:38
0

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.

1
  • The generally accepted terminology is that routers switch packets from one interface (network) to another interface (network), and we call that routing. Bridges switch frames from one interface to another, and we call that switching. Transport protocols transport application data from one application to another, and that is where we use the term transport. – Ron Maupin Sep 9 '19 at 15:26
2

The core function of a router is forwarding based on the network layer (L3). This is done on its forwarding plane.

A router usually has some higher-layer functionality located in its control plane: SSH/Telnet console, web interface, RIP/OSPF/BGP route exchange, ... All these use transport-layer (L4) and application-layer (L7) protocols but that doesn't make a router another thing.

A NAT/NAPT router also uses L4 (and sometimes even L7) information for forwarding, technically making it an L4 (L7?) device - if you're nitpicking.

1

There are two things going on here.

First of all, while the OSI seven-layer model is a nice tool to learn about protocols, it's only a model. In the real world, devices don't stick to a specific layer just because it's such a nice theory; in order to deliver desired functionality, a device will happily violate layer boundaries whenever necessary. For example:

  • Switches using IGMP Snooping or DSCP-based QoS look into layer-3 (IP) headers to make decisions.
  • Routers can use application recognition (like NBAR) all the way upto layer-7 to be able to prioritise important traffic over catvideo's on YouTube.

This is useful and desired behaviour, so there is no reason to 'prohibit' this.

Secondly, a router requires a lot of different components to be able to fulfill its function as layer-3 packet forwarding device.

  • It's running a management daemon where you can login to manage the device using higher level protocols (SSH, HTTPS, SNMP, or perhaps even something like NETCONF or a REST API).
  • It's running a routing daemon that communicates with neighboring routers using some protocols (OSPF, BGP, etcetera) to exchange information and populate the routing table that is used to forward traffic.
  • And, in fact, many other daemons that server different purposes.

With all these daemons, the device is not that different from a regular endpoint. If you want to stick to the OSI-model, you can see the router as a server running (routing-)applications (layer-7), which is uses to program a layer-3 forwarding component.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.