I have studied from various sources that router is a layer 3 device. It does routing based on Network layer (layer 3) header, but I have a doubt.

You are watching: At which of the following osi layers does a router operate

Network address translation (NAT) is a feature of Router which is required for routing traffic. It does processing based on both Network layer and Transport layer (layer 4) headers. So why cant we say that router is a layer 3 & layer 4 device when it is processing layer 4 header also?


*

*

Network address translation (NAT) is a feature of Router which isrequired for routing traffic.

That is completely incorrect. NAT is a kludge (a clumsy, inefficient solution) designed to extend the life of IPv4 addressing until IPv6 is ubiquitous. NAT breaks the IP paradigm of end-to-end connectivity, and many things have problems with NAT. Routing works quite well without NAT. You should only use NAT were you absolutely must use it, e.g. private to public addressing, or for joining two networks with overlapping addresses.

It does processing based on both Network layer and Transport layer(layer 4) headers.

Again, no. Routing does not involve the layer-4 header. One form of NAT, NAPT (Network Address Port Translation), will use the TCP or UDP ports, or ICMP query IDs, but it only works for those three protocols, and it breaks other transport protocols and many applications. A routing table (what routers use to determine the path of packets) has nothing about layer-4 protocols in it.

RFC 2663, IP Network Address Translator (NAT) Terminology and Considerations explains NAPT:

4.1.2. Network Address Port Translation (NAPT)

NAPT extends the notion of translation one step further by alsotranslating transport identifier (e.g., TCP and UDP port numbers,ICMP query identifiers). This allows the transport identifiers of anumber of private hosts to be multiplexed into the transportidentifiers of a single external address. NAPT allows a set of hoststo share a single external address. Note that NAPT can be combinedwith Basic NAT so that a pool of external addresses are used inconjunction with port translation.

See more: The Bull From The Sea - By Mary Renault: 9780375726804

For packets outbound from the private network, NAPT would translatethe source IP address, source transport identifier and related fieldssuch as IP, TCP, UDP and ICMP header checksums. Transport identifiercan be one of TCP/UDP port or ICMP query ID. For inbound packets, thedestination IP address, destination transport identifier and the IPand transport header checksums are translated.