Please find the below Loop avoidance mechanism.
Loop avoidance mechanism on EIGRP:
Secondary Ad< Primary FD
Loop avoidance mechanism on BGP:
Verify the AS number, If the AS no. is the part of it's own As no. then It will reject the packet.
Verify the router-Id. If the Router-Id is the part of it's own router-id then it will reject the packet.
How OSPF and RIP avoid Loop??? Please Explain in details.
OSPF uses the information advertised in LSAs and the Dijkstra algorithm to calculate the topology of the network and then uses that topology information to prevent loops.
There is no form of 'loop avoidance' with OSPF like the distance/patch vector protocols (EIGRP/BGP).
OSPF's algorithm (and all link state routing protocols) calculates all the links of all the routers in the 'Area' similar to a 'tree' fashion with each router being the 'root' of it's calculated tree.
Doing this means that all routers in the same 'Area' have a complete topology of that 'Area' and then use this information when routing traffic, traffic will then traverse the 'Area'/network without creating loops and will garentee the best (loop-free) route.
Take a look at the following link for more detail how the SPF algorithm works and how it populates the routing table with the best 'loop-free' routes:
Like Richard and Liam said OSPF is a link state protocol and exchanges LSAs within an area to build a SPF tree ensuring that there are no loops within the area.
Between areas Area Border Routers (ABRs) send summary LSAs hiding the internal topology of the area. This is actually distance vector behavior. Due to this there needs to be some loop prevention mechanism.
Read this excellent paper by Petr Lapukhov for the full explanation:
Please rate helpful posts.