Firewall is showed in port no 7 and Google search is also showed in port no 7 so I am confused about how exactly ICMP use the port number.

Regards, Bhushan

  • 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
    Dec 25, 2018 at 8:34

6 Answers 6


Port numbers are a feature of transport layer protocols such as TCP and UDP. ICMP is really part of the internetworking layer (IP), so that attribute doesn't exist at that layer.

And yes, I know that ICMP is encapsulated in IP, but it still is considered part of the internetworking layer. That just shows the limitations of the model. To quote from RFC 792:

ICMP, uses the basic support of IP as if it were a higher level protocol, however, ICMP is actually an integral part of IP, and must be implemented by every IP module. [emphasis added].

  • How do ICMP packets such as ping packets traverse NAT then? As far as I know, NAT created a private IP, private port no. to public IP, NAT port no. mapping and directs any incoming packets on this basis. Without port number how will the ping packet be redirected to the right host by NAT?
    – oshhh
    Oct 5, 2020 at 15:59
  • 1
    You could ask a similar question: How does any host know that an echo reply matches the echo request it sent? The answer is the Identifier field. Routers use that to identify the host.
    – Ron Trunk
    Oct 5, 2020 at 16:27

ICMP is IP protocol 1, TCP is 6 and UDP is 17. So these are all different protocols with different behaviors. TCP and UDP have Ports, ICMP does not. TCP and UDP have an Echo Service on Port 7, sometimes called TCP-Ping/UDP-Ping, but they have nothing to do with ICMP. Maybe this is your confusion.


TCP and UDP are transport protocols that use port numbers to multiplex their use between applications or processes.

This way, your browser using HTTP over TCP can e.g. connect multiple times to the exact same web server. While the destination port is the same (default for HTTP: 80), different source ports are used for each socket connection.

In the same way, different applications can use the same multiplexing, of course. On the server side there can be different services on different TCP ports - HTTP on 80, FTP on 21, SMTP on 25, and so on. Or - using non-standard ports - even different web servers on ports 80 and 8000, for instance.

Without ports, there could be only a single TCP connection between any two hosts, or a single TCP service running on a server. (Likewise with UDP or any other transport protocol.)

ICMP is not a transport protocol but a part of the IP protocol. It is used for signaling between hosts. Messages that can be transmitted include

  • Destination unreachable (a router signals that it's unable to forward towards the destination, a host rejects a packet, or similar)
  • Redirect message (a router wants the source to use another gateway)
  • Time exceeded (a packet has exceeded its lifetime/hop count and was dropped)
  • Echo request / Echo reply (used by ping)

Port numbers are transport-layer addresses used by some transport protocols. The purpose of the transport addresses (ports) is to allow multiple processes to simultaneously use a transport protocol, and the transport protocol can deliver the correct data to the correct process out of multiple processes using it.

The port numbers are also per protocol. For example, TCP and UDP use port numbers for addressing, but TCP port 12345 is not UDP port 12345. Only one process at a time can bind to TCP port 12345, but one process can bind to TCP port 12345 at the same time another process binds to UDP port 12345.


ICMP doesn't have "port numbers" per-se, but it does have things that are similar to port numbers, and in some cases the ICMP payload will contain port numbers for other layer 4 protocols.

All ICMP packets have a "type", this identifies the type of the ICMP package. The types of ICMP packet can be broadly divided into four categories:

  • Errors
  • Queries
  • Responses
  • Other

For errors the start of the original datagram that caused the error is included in the error packet, to allow the sender to match the error to the connection (or psuedo-connection) that caused it. If the original packet was a TCP or UDP packet the error packet will contain the port numbers associated with the original packet.

Query messages come together with a corresponding Response message. The type of query can be seen as analogous to the well-known port on a server while the identifier field can be seen as analogous to the random port chosen by a client. User interfaces for firewalls and NATs may well use the "port" fields in the UI to represent these numbers.

Having said that ICMP type number 7 is unassigned and it would seem unlikely for a client to randomly select 7 as it's request ID, so i'm not sure what your firewall is showing.


ICMP is a protocol that is designed specifically for diagnostic purposes and ping is nothing but a ICMP echo request and echo reply that's why there is no concept of port numbers in ICMP.

Your Answer

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

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