Can someone explain it clearly. I know that port numbers are used by applications to differentiate which services you have requested, and routing protocols use protocol numbers in TCP header.

  • 1
    Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer.
    – Ron Maupin
    Feb 19, 2018 at 19:15

2 Answers 2


The protocol number is used by the the layer-3 protocol (IPv4 or IPv6) to determine to which layer-4 protocol in the network stack it should send the payload of the packet.

A port number is an address for some layer-4 protocols (TCP or UDP). The port number is used by the layer-4 protocol to determine which application gets the payload of the layer-4 datagram.

And routing protocol use protocol number in TCP header.

I believe you are confusing layer-3 and layer-4. The TCP header (layer 4) doesn't have a field for protocol number - the protocol number is in the IP header (layer 3).

Layers 2 to 4 each encapsulate the datagram of the layer above inside headers for the layer. See this question and answer for more detail


You can think of a port as a phone extension, with the computer's IP address being like its phone number. You can call the number (IP address) to talk to the computer, then dial the extension (port) to talk to a specific application. An application needs to be listening on a port in order to communicate.

A protocol is just the language that the two applications on either end of a conversation agree to speak in. If your application is sending streams of bytes to my application, my application needs to know how to interpret those bytes.

  • A port number has nothing to do with the IP address. It is an address for some transport protocols, but not all transport protocols use port numbers. Even though TCP and UDP use port numbers in the same range, they are not the same port numbers: TCP port 12345 is not the same as UDP 12345. IP, whether IPv4 or IPv6, has no idea about anything in the packet payload, including port numbers that are in the transport protocol header.
    – Ron Maupin
    Dec 22, 2021 at 11:44
  • The IP protocol number indicates the protocol on top of the network layer (usually the transport protocol) - not the application that is one layer higher still.
    – Zac67
    Dec 22, 2021 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.