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:
Let's take a look at the fields of the TCP header: