In segment routing protocol, we know that the routing process is source steered. I'm struck to know if any best (longest) prefix matching happens to route the data packets? If so any clue about the prefix be attached to the header of IP packet when forwarding to downstream router?


Subnet routing is usually by destination address (as opposed to policy-based routing where other parameters can be used).

The routing algorithm selects the most specific, longest subnet prefix from the routing table. Effectively, the routing table is sorted by prefix lengths and entries are tested from longest to shortest prefix until a match is found. If present, the null-length default entry matches all destinations.

The packet itself doesn't carry any prefix length information, just the source and destination addresses. The length of the prefix is taken from the routing table of each forwarding hop.

This way, the routing entries can become more specific along the way, from hop to hop. For instance, a branch office using locally can use a "private default" route to headquarters. At HQ, can point to another branch office and there, can point to an actual subnet.

  • ... not quite sure if question or answer actually do refer to segment routing, which seems to be an entirely different animal than classic destination based IP routing. Sep 19 '18 at 15:32
  • @Marc'netztier'Luethi Good point - given the OP rep I was guessing he referred to normal IP routing. AFAIK, segment routing doesn't use prefixes but uses a kind of source-routing.
    – Zac67
    Sep 19 '18 at 15:37
  • @Zac67 thanks for the help. I wanted to know if, in segment routing, router A by any chance computes the best matching prefix to transmit a packet to router B (downstream). I learnt that in source-routing of SR, it allows an ingress (1st) node to compute the path without a need for prefix-based routing. I was confused about the theory and needed some validating opinion. Your answer helped me that way. Thanks again!
    – Ram
    Sep 21 '18 at 11:00
  • Router A doesn't compute a prefix, it just checks its routing table for the first fit from longest prefix to shortest. IPv4 source-routing works somewhat differently but it's obsolete (can of worms actually).
    – Zac67
    Sep 21 '18 at 12:12

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.