O'Reilly logo

iOS and OS X Network Programming Cookbook by Jon Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Decoding ICMP headers

In the Decoding IP headers recipe of this chapter, we created a decodeIp() function that decoded the IP headers of a packet. If the protocol type was ICMP in that function, we called a decodeICMP() function. We will create the decodeICMP() function in this recipe.

Even though our layer diagram shows the ICMP packet as a part of the Internet layer, from the libpcap point of view, it is a part of the third layer (Protocol layer) of our header stack; this is because the IP header encapsulates the ICMP header.

Decoding ICMP headers

The ICMP header looks like this:

The components are explained as follows:

  • ICMP Type: This field identifies the ICMP message ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required