How can Ping not use a transport protocol?

3

1

I just learned that Ping uses ICMP directly, i.e. it bypasses the transport layer. How is that possible? Shouldn't an application (L5) use UDP or TCP in the transport layer (L4)? The way I know it is that every layer is blind to everything that is 2 layers down, i.e. an application interfaces with L4 using sockets, but is blind to L3 down to L1.

ToniAz

Posted 2018-07-02T12:06:19.547

Reputation: 145

1

The OSI model is an abstract that has never been fully implemented as written in any stack, so keep in mind that none of the layers above 2 are actually mandatory. an application at layer 7 can perform tasks at layer 2, or 3, or 4 should it choose. check out my answer here, on how an application uses the Sockets library to setup a connection using sockets function calls that work at differant layers of the stack: https://superuser.com/questions/984182/what-are-the-detailed-osi-model-steps-involved-in-connecting-to-a-website/984253#984253

– Frank Thomas – 2018-07-02T18:56:59.707

Answers

3

When one says "Ping", they refer to ICMP ping, as that is what the original ping is. ICMP actually works on a lower level than the UDP & TCP transport protocols and does not use ports[1]:

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.

That is mostly because ICMP is used to report errors as IP is not completely reliable on its own. So, ICMP is a lower-level protocol that uses IP, not TCP/UDP. Ping is just a tool that uses ICMP (thanks to low-level C), however, ICMP isn't just ping or traceroute, its main purpose is completely different as I noted.

And I don't know how you've learned that layers are blind for below layers. That is not true, or at least to my knowledge. Ping can use any protocol it wishes by implementing it in C.

Low-level languages like C have direct access to system IP-based modules, thus it is possible to use any such protocol by using C (and almost any other language written in C nowadays).

To explain more explicitly (tl;dr):

Ping is an ICMP-based tool, it does not use TCP and UDP, thus it doesn't work with ports (as a protocol does not need ports, only services do). It does not require the functionality of higher-level protocols such as TCP, so it doesn't implement them. And despite ping being an application, it works on ICMP and uses no port.

Fanatique

Posted 2018-07-02T12:06:19.547

Reputation: 3 475

1Ping can use any protocol it wishes I think you can additionally explain that when one say "Ping" he means "ICMP Ping". – Akina – 2018-07-02T12:35:34.200

Thank you for mentioning that @Akina. I've updated my answer accordingly. – Fanatique – 2018-07-02T12:43:01.393

@Fanatique Thank you for the clarification. I did not imply that ICMP was an application level protocol. Perhaps the confusion is about the "it" in the first sentence. By "it bypasses" I mean "Ping bypasses". – ToniAz – 2018-07-02T13:47:38.177

1Yes, I know, I believe it was actually a misinterpretation coming from my side, I'll edit my answer so as not to imply that. However, as I've answered, ping's source simply isn't based on tcp or udp, it's based on icmp. – Fanatique – 2018-07-02T13:50:12.137