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 TCP headers

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

The TCP header is a part of the third layer (Protocol layer) of our header stack.

The TCP header looks like this:

Decoding TCP headers

Let's take a look at the fields of the TCP header:

  • Source Port: This identifies the port that the packet is being sent from on the sending device.
  • Destination Port: This identifies the port that the packet is going to on the receiving device.
  • Sequence Number: This ...

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