In this section, we will survey the TCP header in packets. As you know TCP is a layer 4 protocol and its header is also have parameters about layer 4. Before TCP header, packet has layer 3 header, it is IP in our example. And before IP header, packet has layer two header, and this is ethernet II in the example below.
Source & Destination Port Number
As you can see below, the source and the destnation port number field is shown with repeated red lines. Each port field is 16 bits long
When a host need to send data, it need the ip address and the port number of the remote node. The ip address is a layer 3 parameter, so it is mentined in ip header. But the port fields are layer 4 parameters and they are mentined in TCP header.
IP header has the destination ip address that make the destination unique in the network. And provide reaching the node. But destination port number defines the target service in the destination node. This can be ftp, http or any layer 4 service what else.
Let’s explain this parameters with a real world example.