So I've been trying to understand how this code works using Scapy on Python as I am trying to create a similar traceroute for my project. However, this does not work. I tried printing the reply type and it shows '11' in between hops. Does anyone have any suggestions on how to fix this or does this whole thing just not work?
hostname = "172.217.17.46" #Change that to user input later
print("Destination: " + hostname)
for i in range(1,28):
pkt = IP(dst=hostname, ttl=i)/ UDP(dport=33434)
#packet is sent
reply = sr1(pkt, verbose=0)
#print(reply.type)
#No reply
if reply is None:
print("hi")
break
elif reply.type == 3:
#reached
print("Done", reply.src)
break
#continue
else:
#print(reply.type)
print ("%d hops away: " %i, reply.src)
#continue
break