Why can the BGP protocol be implemented across routers?

But the OSPF protocol can only be implemented on directly connected routers?

Is the OSPF protocol based on IP? we know the BGP is based on TCP, so is this affect that?

  • "we know the BGP is based on TCP," No. BGP uses TCP as its transport protocol, but it is not based on TCP. For example, from the very beginning, HTTP uses TCP, but now there is QUIC that it can use, and QUIC uses UDP. Do not mix up the network layers. The routing protocols are applications that use various transport protocols. BGP uses TCP, RIP uses UDP, EIGRP uses the EIGRP transport protocol, and OSPF uses the OSPF transport protocol. – Ron Maupin Mar 26 at 2:06

OSPF was designed as an internal gateway protocol, to chose the best path in a network under your control. It would not make sense to connect non-adjacent routers, so that feature is not part of the protocol.

BGP can be used at the edges of an autonomous system with intervening routers in the middle. So it can peer with non-adjacent routers.


BGP is EGP(Exterior Gateway Protocol). OSPF is a IGP(Interior Gateway Protocol).

Therefore BGP use to exchange route table information. It can implementing Inter AS routing. BGP Use in Large network environment.

OSPF use to intra-AS routing. Not Inter As Routing.


BGP runs on TCP(179), doesn't rely on the underlaying protocol.

However OSPF works on layer 3, IP layer. (both routers have to have interface in a common subnet)

For a BGP you must have a network to run on. And actually eBGP neighbors must be also in a same subnet by default.

  • "However OSPF works on layer 3, IP layer" Actually, OSPF uses a layer-4 transport protocol (89) that it uses the way that BGP uses TCP. Also, there is eBGP multihop, but the problem with that is that you must somehow already have a route to the destination. – Ron Maupin Mar 25 at 16:46
  • OSPF messages. Unlike other routing protocols, OSPF does not carry data via a transport protocol, such as the User Datagram Protocol (UDP) or the Transmission Control Protocol (TCP). Instead, OSPF forms IP datagrams directly, packaging them using protocol number 89 for the IP Protocol field. – user8745622 Mar 25 at 16:54
  • 2
    Yes, OSPF does not use TCP or UDP, it uses its own layer-4 transport protocol. There are many different transport protocols other than TCP or UDP. For example, EIGRP has its own layer-4 transport protocol (88), too. – Ron Maupin Mar 25 at 17:01
  • Can you please tell me what this part means? " forms IP datagrams directly" – user8745622 Mar 26 at 9:17
  • check this: imgur.com/a/wLziiSR – user8745622 Mar 26 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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