about PING programme

This is a discussion on about PING programme within the Linux Networking forums, part of the Linux Forums category; Hello group, I am just wondering what is happening when we "ping" the NIC on our own machine. ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-16-2007
Xiaochuan Shen
 
Posts: n/a
Default about PING programme

Hello group,

I am just wondering what is happening when we "ping" the NIC on our own
machine.

I can understand that the ping programme is only a user level programme
while the ping server is usually integrated into the kernel. So, I guess
what happens when we "ping" an IP address is that:

first, the ping programme sends requests to the kernel on the local machine.
The kernel will look at the destination address of this ICMP request and if
it is an externel address, the kernel will send this request out to the
appropriate NIC, but if it heads to the NIC's address on the local machine,
the kernel will handle this request without sending it to its own NIC or
anywhere else. Then when the results of echo request come back, the kernel
will send them back to the "ping" programme (in the case of pinging local
NIC, the kernel will send the results back immediately).

Any idea whether my understanding is correct?

Thanks for anyone looking at this and have a nice day!

Best wishes,
Xiaochuan


Reply With Quote
  #2 (permalink)  
Old 11-16-2007
Robert Harris
 
Posts: n/a
Default Re: about PING programme

Xiaochuan Shen wrote:
> Hello group,
>
> I am just wondering what is happening when we "ping" the NIC on our own
> machine.
>
> I can understand that the ping programme is only a user level programme
> while the ping server is usually integrated into the kernel. So, I guess
> what happens when we "ping" an IP address is that:
>
> first, the ping programme sends requests to the kernel on the local machine.
> The kernel will look at the destination address of this ICMP request and if
> it is an externel address, the kernel will send this request out to the
> appropriate NIC, but if it heads to the NIC's address on the local machine,
> the kernel will handle this request without sending it to its own NIC or
> anywhere else. Then when the results of echo request come back, the kernel
> will send them back to the "ping" programme (in the case of pinging local
> NIC, the kernel will send the results back immediately).
>
> Any idea whether my understanding is correct?


Yes. The kernel uses a routing table to determine where to find
destinations. You can see the table by typing:

netstat -nr

Generally speaking, "pings" are routed in exactly the same way as all
other IP packets.

Robert

>
> Thanks for anyone looking at this and have a nice day!
>
> Best wishes,
> Xiaochuan
>
>

Reply With Quote
  #3 (permalink)  
Old 11-16-2007
Xiaochuan Shen
 
Posts: n/a
Default Re: about PING programme



> Generally speaking, "pings" are routed in exactly the same way as all
> other IP packets.
>


So this can confirm that pinging the host's own NIC IP address will only
induce the packets sending from "ping" program to "kernel" and then "kernel"
to "ping" program. The echo request will not even be sent to the physical
NIC...

I think I can actually observer this:
when pinging the local NIC's IP, the LED on the NIC doesnt blink, nor does
the LED on the switch to which the NIC is connected...
If the packet only travel between ping programme and the kernel, this
explains why the LED doesnt blink..


Regards,
Xiaochuan


Reply With Quote
  #4 (permalink)  
Old 11-16-2007
Moe Trin
 
Posts: n/a
Default Re: about PING programme

On Fri, 16 Nov 2007, in the Usenet newsgroup comp.os.linux.networking, in
article <fhk66c$mv3$1@gemini.csx.cam.ac.uk>, Xiaochuan Shen wrote:

]Robert Harris wrote:

>> Generally speaking, "pings" are routed in exactly the same way as
>> all other IP packets.

>
>So this can confirm that pinging the host's own NIC IP address will
>only induce the packets sending from "ping" program to "kernel" and
>then "kernel" to "ping" program.


Ping (and virtually all other "user" applications) do not know
anything about the network. The application creates a data packet
and hands it to the kernel "hey - send this out please". The kernel
then makes all of the decisions about which interface to use, and
handles translating destination names to appropriate IP addresses
and all.

In the case where a packet is determined to be destined for "this"
computer (and the kernel knows all of the IP addresses that belong
to "this" computer), it just sticks the packet in the "loopback"
transmit buffer... which is exactly the same as the "loopback"
receive buffer - "hey, a packet just arrived". The only hardware
involved is a chunk of kernel memory space (RAM).

>The echo request will not even be sent to the physical NIC...


The _packet_ (no matter what it is) won't be sent to the NIC.

>I think I can actually observer this:
>when pinging the local NIC's IP, the LED on the NIC doesnt blink,
>nor does the LED on the switch to which the NIC is connected...


The kernel knows what addresses belong to it. Why should it send
the packet out on to the crowded highway... ah... out on to the
Ethernet (or any other network) if it is of no interest to anyone
else - why make unnecessary noise? Another question - if you
send a packet out onto the wire, who sends it back to you? The
other systems on the wire will just look at you and laugh.

>If the packet only travel between ping programme and the kernel,
>this explains why the LED doesnt blink..


Correct. The hardware can be a charred cinder - as long as the
kernel was able to _load_ the NIC driver without complaints, then
sending to the IP address of the NIC will work, because the NIC is
not involved. Not plugged in? So what?

Please don't post the same question to multiple newsgroups.

Old guy
Reply With Quote
  #5 (permalink)  
Old 11-16-2007
Floyd L. Davidson
 
Posts: n/a
Default Re: about PING programme

"Xiaochuan Shen" <xs220@cam.ac.uk> wrote:
>> Generally speaking, "pings" are routed in exactly the same way as all
>> other IP packets.
>>

>
>So this can confirm that pinging the host's own NIC IP address will only
>induce the packets sending from "ping" program to "kernel" and then "kernel"
>to "ping" program. The echo request will not even be sent to the physical
>NIC...


What you describe is correct.

>I think I can actually observer this:
>when pinging the local NIC's IP, the LED on the NIC doesnt blink, nor does
>the LED on the switch to which the NIC is connected...
>If the packet only travel between ping programme and the kernel, this
>explains why the LED doesnt blink..


Here's what you want to do:

>ifconfig

...

>ping -c 10 your_hostname

...

>ifconfig

...

The "ping" can be directed at any address of a NIC
which shows up in the ifconfig output. What you want to
look at are the numbers for RX packets and TX packets.
If your system is quiet (or better yet if you have an
unused interface that is enabled), there will be little
or no change to the packet counts after the ping
command. However, take a look at the packet counts for
the "lo" device! That is where the packets are going.

The kernel obviously knows every IP address that is
assigned to it, and *any* packet addressed to any of
those IP addresses will be sent to the loopback device.
Simple as that.

--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:35 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0