ICMP does not handle ICMPV4_TIME_EXCEEDED responses.
I am implementing an ipv4 traceroute application which can be easily achieved by modifying a the internet-apps/v4ping.cc, or so I thought. The current implementation of ns-3 does not handle ICMPV4_TIME_EXCEEDED responses when TTL = 0, it just gets simply dropped. This can be seen in the ipv4-l3-protocol.cc file on the Ipv4L3Protocol::IpForward:
if (ipHeader.GetTtl () == 0) { // Do not reply to ICMP or to multicast/broadcast IP address ** // WHY???!** if (ipHeader.GetProtocol () != Icmpv4L4Protocol::PROT_NUMBER && ipHeader.GetDestination ().IsBroadcast () == false && ipHeader.GetDestination ().IsMulticast () == false) { Ptr<Icmpv4L4Protocol> icmp = GetIcmp (); icmp->SendTimeExceededTtl (ipHeader, packet, false); } NS_LOG_WARN ("TTL exceeded. Drop."); m_dropTrace (header, packet, DROP_TTL_EXPIRED, m_node->GetObject<Ipv4> (), interface); return; }
As far as I know, blocking or allowing ICMP response traffic, should be an option in the ICMP protocol and not just being dropped.
Additionally, to receive the ICMPV4_TIME_EXCEEDED response in ipv4-raw-socket-impl.cc in Ipv4RawSocketImpl::ForwardUp packets are being blocked by the following condition:
if ((m_src == Ipv4Address::GetAny () || ipHeader.GetDestination () == m_src) && (m_dst == Ipv4Address::GetAny () || **ipHeader.GetSource () == m_dst**) && ipHeader.GetProtocol () == m_protocol)
Is it possible to patch this to have the traceroute application working?.... Additionally, ICMPV4_DEST_UNREACH responses are not handled as well, but ICMPV4_TIME_EXCEEDED can be easily patched for now.
Thank you, any comments or if there is something wrong described above please let me know.