Friday, August 15, 2014

A Note on ECMP Layer-2 and Layer-3 Hashing

This took me quite a while to figure out. Damn you hazy terminologies!

So, coming to the point, Equal-Cost Multi-pathing, or ECMP in short, comes usually in 2 flavors: Layer-2 ECMP and Layer-3 ECMP. As the name suggests, ECMP is a technique used to balance "flows" (will come to this soon) over multiple paths in Layer-2 or Layer-3. Layer-2 multi-pathing is useful in Data-centers, where the alternative Spanning Tree Protocol implies wastage of redundant links. Layer-2 ECMP allows better utilization of the available bandwidth by balancing "flows" over the multiple paths available. Note that, each "flow" sticks to its "path" during its lifetime. Ditto happens for Layer-3 paths.

Now, the tricky part that took me so long to grasp was how do you determine a "flow"? My assumption was that Layer-2 ECMP would make use of a subset of Layer-2 header fields (Source MAC, Destination MAC etc.) while Layer-3 ECMP would make use of  a subset of Layer-3 (and optionally Layer-2) header fields (Source IP, Destination IP etc.) and the hash would be calculated over this subset to find the best next-hop. However, it turns out that the matter of defining "flows" is entirely disjunct from the "Layer"(2 or 3) at which ECMP is being done. So, "flows" can be defined using a 2-tuple (Source IP, Destination IP) or a 5-tuple (Source/Destination IP, Source/Destination Port, Protocol) or even a 7-tuple. Each of these 2/5/7-tuples can be used as input to the hash function irrespective of whether it's Layer-2 or Layer-3 ECMP. Effectively, "Layer-2" ECMP can look into header-fields of layers above it (in this case, IP addresses, TCP/UDP Ports). Similarly, "Layer-3" ECMP can look into header-fields of Transport Layer (TCP/UDP ports) thereby breaking the principal that a network layer does NOT look into  header-fields of layers above it. They should have called it "Layer-2 (Layer-3) ECMP with Layer-3 (or Layer-4) Hash" depending on the definition of "flow" being used. Would have saved me a lot of time.  

Reference: http://tools.ietf.org/html/rfc6438

No comments:

Post a Comment