Please write a small Ping CLI application for MacOS or Linux. The CLI app should accept a hostname or an IP address as its argument, then send ICMP "echo requests" in a loop to the target while receiving "echo reply" messages. It should report loss and RTT times for each sent message.
Please choose from among these languages: C/C++/Go/Rust
Please choose from among C/C++/Go/Rust. If you aren't familiar with these languages, you're not alone! Many engineers join Cloudflare without specific langauge experience. Please consult A Tour of Go or The Rust Programming Language.
The tool should accept as a positional terminal argument a hostname or IP address.
As long as the program is running it should continue to emit requests with a periodic delay.
Packet loss and latency should be reported as each message received.
When submitting your project, you should prepare your code for upload to Greenhouse. The preferred method for doing this is to create a "ZIP archive" of your project folder: for more instructions on how to do this on Windows and Mac, see this guide.
Please provide the source code only, a compiled binary is not necessary.
You may use libraries (both built-in and installed via package managers) and system calls as necessary. Please don't use the ping built-in application or a full library implementation of ping.
- Add support for both IPv4 and IPv6
- Allow to set TTL as an argument and report the corresponding "time exceeded” ICMP messages
- Any additional features listed in the ping man page or which you think would be valuable