It is always said that routing protocols fit at layer 3 because they handle the routing aspect. But if you look at each protocol a little deeper this gets confusing.
Take OSPF for instance, it has an IP protocol number 89. Does this mean it is actually at a layer 4 like TCP which has a protocol number of 6? Same question for IGRP which has IP protocol 9.
Is this similar to ICMP (IP #1) that stays "within" layer 3 or is it really layer 4 or as well?
Similar question concerning RIP which does NOT have an IP protocol but instead has a UDP port 520...is RIP therefore NOT layer 3 and instead an application layer protocol? Same question for BGP which uses TCP port 179...is it not layer 3 but rather application layer? Thanks.
Layer 3 is the IP Address.
Dynamic routing protocols are either in the transport layer (OSPF, EIGRP) or the application layer (RIP, BGP).
There were all designed to handle L3 information and advertise it as needed.
All routing protocols handle layer 3 information, but not all routing protocols operate in layer 3.
BGP is an application layer protocol because it uses TCP (179) to transport its messages, and RIP because it uses UDP (520) for the same purposes. While EIGRP and OSPF are said to operate at the internet layer (OSI Network Layer) because they encapsulate their messages directly into IP packets (Using IP protocol 88 and 89 respectively, they don't utilize TCP or UDP or anything above layer 3 in the OSI model, the OSPF data or payload is just encapsulated inside the IP Packet, with no higher OSI layer utilized).
It sounds like just because an IP packet has an IP protocol number in it, it does not mean it is necessarily going to layer 4, (unlike TCP (protocol 6) and UDP (protocol 17) which do go to layer 4)...so a protocol number of 89 for OSPF doesn't mean go layer 4, instead it remains at layer 3 with the payload identified by the protocol number.
I think you actually meant
BGP & RIP -- Tranport layer (uses TCP 179 & UDP 520)
OSPF & EIGRP -- Network layer (uses IP 88 & 89)
BGP and RIP uses TCP and UDP, but they also utilize the whole OSI model and thus they are called application layer protocol, while OSPF and EIGRP utilizes only until layer 3 from the OSI model and uses their own structure afterwards and thats why they are called network layer protocols.
Isn't it interesting that whenever you see a TCP/IP protocol stack that shows sample protocols at each layer, they always show RIP at layer 3? If it is an application layer, why do you think it is being placed at layer 3? We all know its FUNCTION is to allow layer 3 routing, but if it is truly an upper-layer protocol wouldn't it be less confusing to present it that way from the start?
Lets differentiate between the function of routing protocols and which layers of OSI model they use to operate, BGP and RIP uses all the 7 layers of the OSI to operate starting from application layer (application layer provide the interfaces by which user applications access the network, this is done when configuring them) down to the physical layer, while OSPF and EIGRP uses only until layer 3 and encapsulates its payload directly into the IP packet and don't utilize any OSI layer further.
In the cases of confusion like this one, i suggest that you search in many places, most importantly the most famous resources like Jeff Doyle's Routing TCP/IP vol1, you'll find this issue covered in Chapter 1.
I'm guessing OSPF and EIGRP were designed to stay at level 3 to simplify and speed up the whole process rather than having to add more steps.
You are totally correct in this, the OSPF and EIGRP designers thought this way they can simplify the structuring and the processing of the packet when it is exchanged between the routers.