2

I experience strange issue on Windows 7 when receiving ICMPv6 echo replies using ASIO-BOOST library. The received data is missing the IP header, it only has the ICMP header and the payload. Some more details below:

//IPv4
replyBuffer.consume(replyBuffer.size());
mySocketIPv4->async_receive(replyBuffer.prepare(65575),..);
--packet received--
replyBuffer.commit(length);
std::istream istr(&replyBuffer);
icmp_header icmp_hdr;
ipv4_header ipv4_hdr
istr >> ipv4_hdr >> icmp_hdr;

Note: The data received has IP header as well

//IPv6
replyBuffer.consume(replyBuffer.size());
mySocketIPv6->async_receive(replyBuffer.prepare(65575),..);
--packet received--
replyBuffer.commit(length);
std::istream istr(&replyBuffer);
icmp_header icmp_hdr;
ipv6_header ipv6_hdr
//istr >> ipv6_hdr >> icmp_hdr; - works on Linux only
istr >> icmp_hdr;

Note: The data has ICMPv6 header only and payload. On Linux, however, the data starts with the IP header following the ICMPv6 header and the payload.

I need to get some information like TTL, source IP etc from the IP header when I receive the echo reply. How can I access the IP header data in this case?

Your help is very much appreciated!

Marcus Frenkel
  • 691
  • 10
  • 19

1 Answers1

0

IPv6 headers are not received using Raw Sockets on Winsock. As this MSDN page says

For IPv6 (address family of AF_INET6), an application receives everything after the last IPv6 header in each received datagram regardless of the IPV6_HDRINCL socket option. The application does not receive any IPv6 headers using a raw socket.

Jaywalker
  • 3,079
  • 3
  • 28
  • 44