Routing Protocols – Understanding STP, Distance Vectors, LS, and ECMP

ip-forwarding-tableospfrouting

I currently taking a computer networking course and there are some terms that really confusing me and i can't find the "connection" between them.

Suppose I have a network with hosts and routers, and lets say host A want to send a packet to host B and there are many routers and links between them.

I thought that first of all the network doing the STP algorithm, to find the best tree to send packets between LANs.

Second:

How the routing in A is going?
How does he know what is the path that is the "best" for him to send the packets to B?

And what is forwarding differ from this?

I learned about Distance vectors and Link states that solve problems for routers, but, if A knows the path to B, why on earth the routers need to run this algorithm and not just sent the packets by how A told them?

And last, I'll be happy if someone elaborate me on ECMP and the connection between this to what I asked above , because I struggle to figure it.

(sorry about the english, not my native language)

Best Answer

I thought that first of all the network doing the STP algorithm, to find the best tree to send packets between LANs.

Spanning Tree is not a routing protocol, but a protocol to avoid loops in a network. Therefore, whenever the network topology changes (links comes up/goes down), Spanning Tree is gathering information about the network and the link between all involved switches. It does then determine a root bridge (= root switch), and starting from that root bridge defines which links are to be used to distribute data from one point to the next. After Spanning tree is done, there will be exactly one link in use for every possible connection, and the others links will be blocked (disabled). However, this is a protocol operating on Layer 2 of the network, and has nothing do with IPs or routing.

Second,how the routing in A is going? how does he know what is the path that is the "best" for him to send the packets to B?

In most cases, communication happens between workstations and servers, which don't participate in any routing protocol nor do they have any further knowledge about the network topology.

Most hosts only know 2 things:

  • Their own IP address and subnet mask. Usually a local IPv4 address e.g. looks like 192.168.0.42 with a 255.255.255.0 subnet - so the host would know that it can directly communicate with all other hosts using a 192.168.0.x IP address.
  • The default gateway is either gained by DHCP or manually configured, and is responsible for all communications outside the local network. If, for example, our host A with 192.168.0.42 wants to communicate with host B, using 192.168.17.23, host A will determine that the target is outside of his own network, and will direct all traffic to it's default gateway. Host A doesn't care how his gateway will get the traffic to host B - he just sends it to the gateway and is done.

The default gateway, some kind of router, will then take a look in his local routing table and, based on the destination IP address, forward the packet to the next router. It doesn't care how that router is going to get the traffic to host B, it only knows "This is the next hop on the way to the destination network". At some point, the packet will arrive at a router which is directly connected to the same network as host B. That router will then send the packet to host B.

Every participant in that process only decides where the next hop for a packet is, and send the packet to that station. They will not know or take into consideration the complete route the packet has to take - only the next step.

and what is forwarding differ from this?

Forwarding is the term used for the action done by any station participating in the distribution of a packet that is neither the source nor the destination. Host A is the source or sender, Host B is the destination or receiver. All routers in between them will only be forwarding the packet, as they are neither source nor target of that communication, but just relays.

I have to correct myself on that point. Forwarding, in networking terms, usually refers to "relaying data that you received for somebody else on Layer 2". Switches forward frames they receive, by determining if their Forwarding Table/CAM Table (Cisco) knows on which the port the destination MAC address is, and then sending it there, or flooding it on all ports if they don't know where the destination MAC address is located.

Routers route. (Ha!) They do the same as switches, but on Layer 3 (IP). They take a look at their routing table to determine where to send a specific packet on it's journey to it's destination IP.

Often, forwarding and routing are mixed up (like I did), but in network terminology, forwarding is Layer 2, routing is Layer 3.

I learned about Distance vectors and Link states that solve problems for routers, but, if A know the path to B, why on earth the routers need to run this algorithm and not just sent the packets by how A told them?

You're confusing routing protocols with the actual routing. Some routing protocols actually know the whole topology of a network, while others only know the routing table of their neighbors. All of these protocols share that they're used to fill the router's routing table, so it can make decision about which is the best path for a packet to a given destination.

To make that decision, some routing protocols actually gather all network topology information, so that they might actually know or at least guess the complete route a packet might take - but that is not their decision. Every router takes the decision which way to forward a packet in the very moment the packet arrives, depending on where it's destination is.

And last, i'll be happy if someone elaborate me on ECMP and the connection between this to what i asked above , because i struggle to figure it.

Equal-cost multi-path routing is simply a way to distribute traffic with the same source and destination over several links, which all have the same "cost".

Imagine it like this:

You're going from Los Angeles to New York (by car). Checking Google Maps, you find out that there are two possible routes, one via Denver, the other one via Albuquerque. Both routes are exactly 2800 miles long and take exactly the same time. You, as a driver, would now have to equal-cost routes to choose one from.

However, as a network packet, you don't make those decisions, but the routers make them. The router in LA could now choose to send the first packet via Denver, the second via Albuquerque, the third one via Denver and so on. It would result in both links/routes being equally used, without having a traffic jam on one route and no traffic on the other one. In short - it's just a way to distribute traffic over to equal links to avoid congestion.

Related Topic