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:
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 ...
Get iOS and OS X Network Programming Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.