This challenge corresponds to the 23rd part of the Coding Challenges series by John Crickett https://codingchallenges.fyi/challenges/challenge-traceroute/.
-
Created a DNS lookup function and added command line args support
-
Created function that listens for ICMP packets. This part is a little tricky. In Node.js, there is no support for ICMP packets natively. Hence we have to rely on third-party packages. I went ahead and used the hotfix version of raw-socket library. There are some caveats for this
old package
.- The package does not work for Windows.
- Moreover for Linux systems it automatically closes up. See this issue #70
-
Created a UDP message sender. We need to ensure that the TTL is being updated along with the PORT every time this function is called.
-
Created a function that handles the timeout condition and logs relevant details when an ICMP packet is received.
You can use the ts-node
tool to run the DNS resolver as follows:
npx ts-node traceroute.ts <host>