How to simulate traceroute using ping?

-1

1

I am learning computer networks and looking for a way to simulate traceroute using the ping command. I think it has something to do with ttl, but I don't know how to develop that further.

Kabachok

Posted 2015-05-16T18:04:56.910

Reputation: 3

1Can you elaborate on what exactly you mean by "simulating" a traceroute with ping? Do you have a specific assignment given? – slhck – 2015-05-16T18:13:46.823

Answers

1

There is a way to do this.

In Linux or Cygwin:

for i in {1..30}; do ping -t $i -c 1 google.com; done | grep "Time to live exceeded"

In Windows:

for /l %i in (1,1,30) do @ping -i %i -n 1 google.com | find "TTL expired"

Sample output from an Amazon EC2 VPS:

From 100.64.16.93 icmp_seq=1 Time to live exceeded
From 205.251.232.220 icmp_seq=1 Time to live exceeded
From 205.251.232.202 icmp_seq=1 Time to live exceeded
From 205.251.232.75 icmp_seq=1 Time to live exceeded
From 205.251.225.181 icmp_seq=1 Time to live exceeded
From 72.14.219.251 icmp_seq=1 Time to live exceeded
From 209.85.249.32 icmp_seq=1 Time to live exceeded
From 216.239.51.159 icmp_seq=1 Time to live exceeded

Ping isn't allowed for that instance, that's why it times out.

td512

Posted 2015-05-16T18:04:56.910

Reputation: 4 778

No probs, enjoy – td512 – 2015-05-16T18:20:55.063

nothing, but I hardly use windows anymore, so I defaulted to the linux command line – td512 – 2015-05-18T03:22:47.193

@Karan, oh, I didn't know that I needed the @ :D you taught me something new. No, I defaulted because I couldn't think of the windows version. feel free to update the answer if you think it's appropriate. :P – td512 – 2015-05-18T05:15:10.113

Done. :) (filler) – Karan – 2015-05-18T05:30:54.040

@Karan Thank you. I think Windows is a necessary evil for games, otherwise, it's linux on an SSD :P – td512 – 2015-05-18T05:31:51.460

1Both have pros and cons and I use whatever suits the job at hand best. It's not a religious debate for me like it is for some. :) – Karan – 2015-05-18T05:33:42.613