I'm little bit confusing about the flow of things that happen during a voyage of packet in the internet.
my basic question is : What is the connection between OSPF and forwarding tables?

Suppose there are lets say 10 ASes, each AS has some routers and switches within it. Now, host A in some AS want to send IP datagram to host B which is in other AS. Now, first of all, the AS use OSPF protocol. By this, each router know what is the "cost" of send datagram to the another routers in the AS? And another question: when datagram arrives to a router, and in the forwarding table there is no match, it floods to all of its interfaces (?) , but, OSPF give each router the best path it need to choose, so why forwarding tables are needed anyway? i'm so confused and can't find connections between things.

(sorry about the english, it is not my native language)

  • 1
    Just to want to add to the good answers below that a router will never forward a unicast packet on all interfaces. Either there's an entry in the forwarding table for the destination IP address, and it will be sent there, or the packet is dropped, and (usually) an ICMP unreachable will be sent back to the originator. Multicast packets may be sent to multiple interfaces, but usually not all. The "send to all interfaces for unknown destinations" is a behaviour of a layer 2 Ethernet switch, not a layer 3 IP router. – jcaron Feb 17 '16 at 13:40
  • Did any answer help you? if so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer. – Ron Maupin Aug 7 '17 at 19:37

Routing protocols, in general, are used to populate the routing tables and not to forward packets.

Between two AS it is generally BGP that is used to exchange routes, and within an AS, it can be OSPF, but could also be IS-IS, EIGRP or any routing protocol.

A given router can use several routing protocols at the same time.

Lets say a router is configured to use OSPF and BGP.

The router will keep in memory different routing tables:

  • one for routes learn trough OSPF
  • one for routes learn trough BGP
  • one for routes added statically by the router administrator
  • one for network directly connected

The forwarding table is built by selecting routes within all those tables.

For each network that exists in at least one routing table, the router select the best one and put it in its forwarding table.

When the router receive a packet, it looks only in its forwarding table to decide where to send it. Where the route comes from has no importance at this point.


A router has numerous ways of learning the best paths toward individual IP prefixes: they might be directly connected, configured as static routes or learned through dynamic routing protocols.

Each dynamic routing protocol (including RIP) has its own set of internal data structures, known as OSPF/IS-IS database, EIGRP topology table or BGP table. The routing protocol updates its data structures based on routing protocol updates exchanged with its neighbors, eventually collecting all the relevant information.

Both BGP and OSPF associate IP next hops with IP prefixes, but BGP simply uses the value of the next-hop attribute attached to the BGP route, whereas OSPF computes the IP address of the next-hop OSPF router with the SPF algorithm.

The results of intra-routing-protocol route selection are inserted in the IP routing table (RIB) based on administrative distance.

Ideally, we would use RIB to forward IP packets, but we can’t as some entries in it (static routes and BGP routes) could have next hops that are not directly connected.

Forwarding Tables (FIB)were introduced to make layer-3 switching deterministic. When IP routes are copied from RIB to FIB, their next hops are resolved, outgoing interfaces are computed and multiple entries are created when the next-hop resolution results in multiple paths to the same destination.

For example, when the BGP route from the previous printout is inserted into FIB, its next-hop is changed to point to the actual next-hop router. The information about the recursive next-hop is retained, as it allows the router to update the FIB (CEF table) without rescanning and recomputing the whole RIB if the path toward the BGP next-hop changes.

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.