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
    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, 2019 at 16:38

5 Answers 5


Routers are layer-3 devices because they forward/route packets at the network layer (OSI layer 3, mostly IP). A switch or a bridge is considered a layer-2 device because it forwards/switches/bridges frames at the data link layer (OSI layer 2, mostly Ethernet or Wi-Fi). 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 may understand protocols above their respective transport layers. As an example, you can SSH to managed devices. Does that make them work at the application layer (OSI layer 7)? No, because in that case, they don't forward packets/frames but are the source or destination. This is the same with BGP, RIP, etc. Theses protocols may be used by a router to do its task (forwarding packets), but are not necessary for their basic function 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, 2019 at 15:26

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. In theory, a router could have just an out-of-band, serial console - and no transport-layer implementation at all.

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.


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.


Routers are classified as Layer 3 devices because their defining function is to manage the routing of data using network layer addresses across different networks. However, they are capable of handling functionalities across different layers of the OSI model.

When a router receives an IP datagram destined for one of its own interfaces, the control plane processes this datagram. If the datagram's embedded TCP segment targets port 179, it's recognized as a BGP message, prompting protocol-specific processing such as updating routing tables. Conversely, datagrams not destined for the router are handled by the data plane, which efficiently forwards packets based on pre-determined routing decisions without involving the higher-level logic of the control plane.


They might understand it to do their layer 3 job. As a somewhat strange analogy, a musician might know, and most probably does, how to read notes for his job, but it doesn't define his function of playing music.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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