[Ns-developers] icmp message error reporting

Mathieu Lacage mathieu.lacage at sophia.inria.fr
Sun Sep 14 12:43:32 PDT 2008


hi,

While trying to get tracepath to work on ns-3-simu, it occured to me
that I can't work around the need to report icmp errors up to udp
sockets to allow applications which have set the IP_RECVERR socket
option to receive these errors through ancillary messages in recvmsg. 

So, the question here is first whether this should be implemented in our
default ipv4 stack (it could very well be that this kind of feature is
outside the scope of our implementation) and, then, how should this be
implemented. The first question is obviously directed at raj and tom. I
have tried to provide an answer to the second question. Comments would
be welcome.

1) classes added:
-----------------

a) Icmpv4L4Protocol: subclass of Ipv4L4Protocol, receives all icmpv4
messages, send messages when needed
b) Icmpv4Header, Icmpv4Echo, Icmpv4DestinationUnreachable,
Icmpv4TimeExceeded: subclasses of Header base class. used to generate
and parse icmp messages.
c) V4Ping: a ping application

2) changes to existing code:
----------------------------

a) Ipv4L3Protocol
  make Ipv4L3Protocol generate icmp messages when needed:
   - PORT_UNREACH
   - TTL_EXPIRED
   - FRAG_NEEDED
  make Ipv4L3Protocol set the DF bit on outgoing packets when they are
tagged with SocketMtuDiscoverTag

b) Ipv4L4Protocol:
  add a return value to Receive:
  enum RxStatus {
    RX_OK,
    RX_CSUM_FAILED,
    RX_ENDPOINT_UNREACH
  };
virtual enum RxStatus Receive(Ptr<Packet> p, 
                                Ipv4Address const &source,
                                Ipv4Address const &destination,
                                Ptr<Ipv4Interface> incomingInterface)
  add ReceiveIcmp:
  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
                            uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
                            Ipv4Address payloadSource, Ipv4Address payloadDestination,
                            const uint8_t payload[8]);

  Provide an empty implementation of ReceiveIcmp in Ipv4L4Protocol.

c) Ipv4EndPoint:
  add ForwardIcmp, SetIcmpCallback:
  void SetIcmpCallback
(Callback<void,Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> callback);
  void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
                    uint8_t icmpType, uint8_t icmpCode,
                    uint32_t icmpInfo);

d) UdpL4Protocol:
  implement ReceiveIcmp. Forwards messages to Ipv4EndPoint::ForwardIcmp

e) UdpSocketImpl: 
  register icmp callback with associated Ipv4EndPoint
  forward icmp calls to private callback:
    Callback<void, Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t>
m_icmpCallback;
  add attribute: "IcmpCallback" which can be used to set the
m_icmpCallback.

The code above has been pretty extensively tested in the ns-3-simu
branch so, I think that it is more or less ready to be merged if tom and
raj are ok with it.

regards,
Mathieu




More information about the Ns-developers mailing list