3
$\begingroup$

Routers make use of the IP address, etc to shape the traffic. So obviously they must reside in at least the Network layer. However we can also shape the traffic using tcp/udp. Routers usually have the port forwarding feature which allows them to shape the tcp/udp traffic.

The IP header has a field for protocol. However that doesn't show whether the traffic is udp/tcp. This information must be present inside the payload part of the IP packet. Then why is the router able to see that information despite being in the Network Layer?

$\endgroup$

1 Answer 1

2
$\begingroup$

Because routers are real concrete devices, not theoretical constructs. They aren't limited by layering diagrams. Layering is a form of abstraction, which is a convention; there's nothing that prevents a device from inspecting and acting on the rest of the packet.

Separately: layering diagrams are a model, but not a perfect one. Real devices violate layering from time to time. The OSI 7-layer model is especially approximate -- don't take it too seriously. See, e.g., Till which layer does the loopback packet goes? and can network layers communicate between each other?.

$\endgroup$

Your Answer

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

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