“Trace route” to Next-hop as destination

traceroute

I know traceroute in BSD uses UDP by default and gets ICMP error message from intermediate hops when TTL is decremented and found to be 0.
My question is – what if we trace route to next-hop router:
– Should the router respond with port unreachable message?

Best Answer

As Ron said, this is a pretty simple thing to test - you should give it a try if you haven't already.

In BSD systems traceroute will use a range of high, unregistered UDP port numbers as well as TTL. The device originating the probes will send 3 probes, they will look like this:

NOTE: The port numbers won't necessarily be exact in your tests.

  • Probe 1: TTL = 1 UDP Port = 33434
  • Probe 2: TTL = 1 UDP Port = 33435
  • Probe 3: TTL = 1 UDP Port = 33436

In the condition that the we're NOT tracerouting to the next-hop, you will see the following message from the next device:

Time to Live Exceeded

This is what we would expect, to see as traceroute progresses, the next device's probes would look like this:

  • Probe 1: TTL = 2 UDP Port = 33437
  • Probe 2: TTL = 2 UDP Port = 33438
  • Probe 3: TTL = 2 UDP Port = 33439

Now let's say that second set of probes will reach our intended destination. The response we will get is (and this is a portion directly from tcpdump):

udp port 33437 unreachable

Now what does this mean? It means we've reached our destination, because only our destination can say "No this port is not available" (as we would expect from the higher unregistered UDP port range).

My question is - what if we trace route to next-hop router: - Should the router respond with port unreachable message?

The cool thing about traceroute is that, it has no idea if you're trying to hit something 20 hops away, or just 1 hop away - it needs to be able to adapt to any of those situations.

So it will behave no differently than it would at the last hop in a 20 hop traceroute.

If you traceroute your next hop, your probes would look the same:

  • Probe 1: TTL = 1 UDP Port = 33434
  • Probe 2: TTL = 1 UDP Port = 33435
  • Probe 3: TTL = 1 UDP Port = 33436

But the different here is, a TTL of 1 is enough to get to your next hop. So you would see the "udp port XXXXX unreachable" message right away, implying that the traceroute has completed. Instead of seeing the "Time to Live Exceeded" messages.

I hope this helps clear things up, if you have any other questions related to this - leave a comment and I'll be happy to update my answer.