I develop simple traceroute program with help boost_asio
. I use this example. I little change this example to implement traceroute
instead of ping
.
pinger(boost::asio::io_service& io_service, const char* destination)
: resolver_(io_service), socket_(io_service, icmp::v4()),
timer_(io_service), sequence_number_(0), num_replies_(0)
{
boost::asio::ip::unicast::hops option(%1%); // 1 is a param
socket_.set_option(option);
icmp::resolver::query query(icmp::v4(), destination, "");
destination_ = *resolver_.resolve(query);
start_send();
start_receive();
}
I have a problem. When time to live
is less, than it needs, I have no any response. I wish to get something like this:
C:\Users\>ping 91.92.100.254 -i 2
Pinging 91.92.100.254 with 32 bytes of data:
Reply from 10.110.50.251: TTL expired in transit.
Reply from 10.110.50.251: TTL expired in transit.
Reply from 10.110.50.251: TTL expired in transit.