The protocol number in the IP header is used to explain what kind of protocol is carried in the IP message (generally, it is a transport layer protocol, such as 6 TCP,17 UDP; ; But it may also be a network layer protocol, such as1icmp; ; It can also be an application layer protocol, such as 89 OSPF).
After receiving the IP packet, the destination host will determine which module (TCP/UDP/ICMP ...) is sent to for processing according to the IP protocol number, and the message sent to the TCP/UDP module will be sent to which application for processing according to the port number.
Extended data
The difference between protocol number and port number:
Ip protocol is a network layer protocol with three layers. The protocol number indicates what the upper layer is. The number EG: 17 indicates that the upper layer is udp, the number 6 indicates that the upper layer is tcp, and the number 89 indicates that the upper layer is ospf. The Tcp port number indicates what application it is, such as: 80 service, 53 dns service.
The principle of udp port is the same as tcp. The port is the service access point TSAP of the transport layer. Its function is to make various application processes of the application layer pass their data down to the transport layer through the port, and let the transport layer know that the data in its message segment should be passed up to the process of the application layer through the port.
Port numbers exist in the headers of UDP and TCP messages, while IP datagrams take UDP or TCP messages as their data parts, and add IP datagram headers to package them into IP datagrams. The protocol number is the header of the IP datagram.