SlideShare una empresa de Scribd logo
1 de 5
Descargar para leer sin conexión
GalaxyVisions
                                                                        Toll Free: 1.866-GVHOST1 (484-6781)




How Does Ping Really Work?
George Mays, Global Knowledge Course Director, CCISP, CCNA, A+,
Network+, Security+, I-Net+


Introduction
Ping is a basic Internet program that most of us use daily, but did you ever stop to wonder how it really
worked? I don’t know about you, but it bugs me when I do not know how something really works. The pur-
pose of this paper is to resolve any lingering questions you may have about ping and to take your understand-
ing to the next level. If you do not happen to be a programmer, please do not be frightened off! I am not
going to tell you how to write your own version of ping; trust me.

I am guessing that you know basically how the TCP/IP ping utility works. It sends an ICMP (Internet Control
Message Protocol) Echo Request to a specified interface on the network and, in response, it expects to receive
an ICMP Echo Reply. By doing this, the program can test connectivity, gauge response time, and report a vari-
ety of errors.

ICMP is a software component of the Internetworking layer of TCP/IP; essentially, it is a companion at that
level to IP (Internet Protocol) itself. In fact, ICMP relies on IP for transport across the network. If you observe
this sort of network traffic, say on an Ethernet network, then your protocol analyzer would capture an Ethernet
frame transporting an IP datagram with an ICMP message inside.

Enter the problem: Since the ping program executes at the Application layer, how does it make ICMP do these
tricks? You may recall, if you are a student of TCP/IP, that the Host-to-Host layer is sandwiched between these
entities. Is that bypassed? If so, then how? Who is responsible for formatting these messages (Echo Request
and Echo Reply)?

More vexingly, when unexpected ICMP responses, other than the customary Echo Reply, result from the Echo
Request, how is it that they find their way to the ping program? This last question may seem obvious, but it is
not. ICMP messages contain no addressing information that allows the TCP/IP protocol stack to discern the
program that is to receive the message. TCP and UDP use port numbers for this purpose. So, how does this
work?

Background
The TCP/IP protocol stack is organized as a four-layer model (see Figure 1). The lowest layer, commonly called
the Network Interface or Network Access layer, is analogous to OSI layers 1 and 2, the Physical and Data Link
Control layers. This includes things like media, connectors, signaling, physical addressing, error detection, and
managing shared access to the media. For most of us this translates into Ethernet and our cabling system.




Copyright ©2006 Global Knowledge Training LLC. All rights reserved.                                         Page 2


                    Manual Prepared by GalaxyVisions Customer Care Team
GalaxyVisions
                                                                            Toll Free: 1.866-GVHOST1 (484-6781)


          Figure 1

                                                   TCP/IP Model
                                             Process or Application Layer
                                                  Host-to-Host Layer
                                               Internetworking Layer
                                     Network Interface or Network Access Layer



The layer above the Network Access layer, the Internetworking layer, is best likened to OSI layer 3, the Network
layer. Here we expect to find logical addressing and routing: things that facilitate communication across net-
work boundaries. This is where IP and its addressing mechanisms reside, as does ICMP.

ICMP is a necessary component of any TCP/IP implementation. It does not exist to provide information to the
higher-layer protocols (like TCP and UDP) so that they may be more reliable. Rather, ICMP provides network
diagnostic capabilities and feedback to those responsible for network administration and operation. See RFC
792, if you are really interested.

Above the Internetworking layer is the Host-to-Host layer, which is the counterpart of OSI layer 4, the Transport
layer. I like to think that this also includes some of the Session layer (5) functionality as well. This is where we
expect to find facilities for reliable end-to-end data exchange, additional error checking, and the means to dis-
criminate one program from another (using port numbers). TCP and UDP reside at this level.

At the top of the stack, the Application or Process layer, we find high-level protocols (like SMTP, HTTP, and FTP)
implemented. This is where applications execute as well. So when you do a ping, the ping program should be
perceived to function at this level.

A Minor Mystery
With ICMP operating at the Internetworking layer and the ping program at the Application layer, how is the
Host-to-Host layer bypassed? The answer lies in an understanding of what are known as “raw” sockets.

Well, for openers, what is a socket, right? Abstractly, a socket is an endpoint to communication, usually
thought to consist of an IP address and port number, which identify a particular host and program, respective-
ly. But a programmer has a slightly different perspective on a socket. From his vantage point, “socket” is a sys-
tem function that allocates resources that enable the program to interact with the TCP/IP protocol stack
beneath. The addressing information is associated with this only after the socket call is made. (Again, if you
are interested, this is the role of the “bind” function.) So, take note, it is possible to allocate a socket and not
overtly associate any addressing information with it.

There are three commonly encountered types of sockets: stream, datagram, and raw. TCP uses the stream type
and UDP uses the datagram type. Raw sockets are used by any application that needs to interact directly with
IP, bypassing TCP and UDP in doing so. Customers include routing protocol implementations like routed and
gated (that implement RIP and OSPF). It also includes our friend ping.




Copyright ©2006 Global Knowledge Training LLC. All rights reserved.                                           Page 3


                     Manual Prepared by GalaxyVisions Customer Care Team
GalaxyVisions
                                                                            Toll Free: 1.866-GVHOST1 (484-6781)


There are some special considerations in using raw sockets. Since you are circumventing the facilities of the
Host-to-Host layer, you forego the program addressing mechanism, the port numbering scheme. This means
that programs that employ raw sockets must sift through all incoming packets presented to them in order to
find those packets that are of interest.

What Actually Goes On
When the ping program begins execution, it opens a raw socket sensitive only to ICMP. This means two things:

    • On output: the sending of ICMP Echo Requests, the program is required to format the ICMP message.
      The system will provide the IP header and the Ethernet (usually) header.
    • On input: the program must examine all ICMP messages coming in and cull out the items of interest.
      The expected input is ICMP Echo Replies.

Let us take these things in turn.

On the outbound side, the Echo Requests are formatted in the manner shown in Figure 2. The message type is
always the coded value eight (8). The code field always contains zero. The checksum is used for error detection.
The ICMP message header and data are included in its computation. The ping program performs this calcula-
tion and fills in the blank. The identification field follows and is supposed to contain the process ID (PID) that
uniquely identifies that execution of the ping program to the operating system. On Windows systems, this field
contains the constant value 256. Next is the sequence number field, which starts at 0 and is bumped by one
on each Echo Request sent. After these required fields, optional test data will follow. In the ping implementa-
tion that I examined (Slackware Linux), this included a timestamp used in the round-trip time calculation upon
receipt of the Echo Reply.

                   Figure 2

                                              ICMP Echo Request
                                        Type (8)                      Code (0)
                                                     Checksum
                                                   Identification
                                                     Sequence
                                                     Test Data



As for inbound ICMP messages, ping’s task is a bit more complex. Because ping is using a raw ICMP socket,
the program is presented with a copy of all incoming ICMP messages, except for a few special cases like
incoming Echo Requests generated by other people pinging us (the latter are handled by the system). This
means that ping sees not only the expected Echo Replies when they arrive but also things like Destination
Unreachable, Source Quench, and Time Exceeded messages. (Figure 3 summarizes the ICMP message types.)




Copyright ©2006 Global Knowledge Training LLC. All rights reserved.                                        Page 4


                    Manual Prepared by GalaxyVisions Customer Care Team
GalaxyVisions
                                                                        Toll Free: 1.866-GVHOST1 (484-6781)


Figure 3

                                              ICMP Message Types
           Type                     Codes                                     Description
            0/8                       0                Echo Reply/Echo Request
            3                        0-15              Destination Unreachable
            4                         0                Source Quench
            5                        0-3               Redirect
           9/10                       0                Router Advertisement
            11                       0-1               Time Exceeded
            12                        0                Parameter Problem
           13/14                      0                Timestamp Request/Timestamp Reply
           17/18                      0                Address Mask Request/Address Mask Reply



Now think about this for a moment. If you have two copies of the ping program running at the same time,
then they are each going to see one another’s Echo Replies and any other “nastygrams” that might show up.
Each instance of the program must identify the messages that are relevant to it. If you guessed that this is
what the PID (identification) field is used for then you are absolutely right.

How does the Windows flavor of ping accomplish this feat without the PID? You got me. That sounds like a
topic for a future article. Let me get back to you on that.

Interestingly, the messages coming in are handed to ping with the IP header still intact. So, the program has
access to important things there like the time-to-live (TTL) value and record route information (if the latter
option is turned on).

Summary
At this point, you should have a fairly complete understanding of the cycle of processing associated with ping.
Let me recapitulate the essential elements:

    • As the ping program initializes, it opens a raw ICMP socket so that it can employ IP directly, circumvent-
      ing TCP and UDP.
    • Ping formats an ICMP type 8 message, an Echo Request, and sends it (using the “sendto” function) to
      the designated target address. The system provides the IP header and the data link layer envelope.
    ¶ As ICMP messages are received, ping has the opportunity to examine each packet to pick out those
      items that are of interest.
    • The usual behavior is to siphon off ICMP type 0 messages, Echo Replies, which have an identification
      field value that matches the program PID.



Copyright ©2006 Global Knowledge Training LLC. All rights reserved.                                        Page 5


                    Manual Prepared by GalaxyVisions Customer Care Team
GalaxyVisions
                                                                      Toll Free: 1.866-GVHOST1 (484-6781)


    • Ping uses the timestamp in the data area of the Echo Reply to calculate a round-trip time. It also reports
      the TTL from the IP header of the reply.
    • When things do not work normally, ping may report some of the other ICMP message types that show
      up in the inbox. This includes things like Destination Unreachable and Time Exceeded messages.

Learn More
Learn more about how you can improve productivity, enhance efficiency, and sharpen your competitive edge.
Check out the following Global Knowledge courses:
Network+ Boot Camp
TCP/IP Networking

For more information or to register, visit www.globalknowledge.com or call 1-800-COURSES to speak with a
sales representative.

Our courses and enhanced, hands-on labs offer practical skills and tips that you can immediately put to use.
Our expert instructors draw upon their experiences to help you understand key concepts and how to apply
them to your specific work situation. Choose from our more than 700 courses, delivered through Classrooms,
e-Learning, and On-site sessions, to meet your IT and management training needs.

About the Author
George Mays has over 35+ years experience in computing, data communications, and networking. His experi-
ence includes: mainframe systems programmer, Fortune 500 DBA, management of systems programming, data
communications, IT operations, engineering, software development, and networking. He is also the author and
course director for Global Knowledge’s Network+ Boot Camp and has contributed to several hacking and
security books. George holds various industry certifications including: CISSP, CCNA, A+, Network+, Security+, I-
Net+. Past certification: MCSE. He is an instructor in TCP/IP, Troubleshooting, Network Protocols, Network
Fundamentals, A+, Security+ and CISSP. In addition to teaching for Global Knowledge, Mr. Mays also acts as a
consultant in the fields of general networking and security.




Copyright ©2006 Global Knowledge Training LLC. All rights reserved.                                       Page 6


                    Manual Prepared by GalaxyVisions Customer Care Team

Más contenido relacionado

La actualidad más candente

Suman's PhD Candidacy Talk
Suman's PhD Candidacy TalkSuman's PhD Candidacy Talk
Suman's PhD Candidacy TalkSuman Srinivasan
 
Early application identification. CONEXT 2006
Early application identification. CONEXT 2006Early application identification. CONEXT 2006
Early application identification. CONEXT 2006Laurent Bernaille
 
A Distributed Simulation of P-Systems
A Distributed Simulation of P-SystemsA Distributed Simulation of P-Systems
A Distributed Simulation of P-SystemsApostolos Syropoulos
 
Data Networking Concepts
Data Networking ConceptsData Networking Concepts
Data Networking ConceptsPeter R. Egli
 
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...
The Migration From Erlang To Otp   A Case Study Of A Heavy Duty Tcpip Clients...The Migration From Erlang To Otp   A Case Study Of A Heavy Duty Tcpip Clients...
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...l xf
 
IRJET- Portable Camera based Assistive Text and Label Reading for Blind Persons
IRJET- Portable Camera based Assistive Text and Label Reading for Blind PersonsIRJET- Portable Camera based Assistive Text and Label Reading for Blind Persons
IRJET- Portable Camera based Assistive Text and Label Reading for Blind PersonsIRJET Journal
 
Us 13-opi-evading-deep-inspection-for-fun-and-shell-wp
Us 13-opi-evading-deep-inspection-for-fun-and-shell-wpUs 13-opi-evading-deep-inspection-for-fun-and-shell-wp
Us 13-opi-evading-deep-inspection-for-fun-and-shell-wpOlli-Pekka Niemi
 
Transporting voice by using IP
Transporting voice by using IPTransporting voice by using IP
Transporting voice by using IPMuhammad Jahangir
 
BYPASSING OF DEPLOYMENT DIFFICULTIES OF IP TRACEBACK TECHNIQUES USING NEW PAS...
BYPASSING OF DEPLOYMENT DIFFICULTIES OF IP TRACEBACK TECHNIQUES USING NEW PAS...BYPASSING OF DEPLOYMENT DIFFICULTIES OF IP TRACEBACK TECHNIQUES USING NEW PAS...
BYPASSING OF DEPLOYMENT DIFFICULTIES OF IP TRACEBACK TECHNIQUES USING NEW PAS...Journal For Research
 

La actualidad más candente (20)

ICMPV4
ICMPV4ICMPV4
ICMPV4
 
New Creators
New CreatorsNew Creators
New Creators
 
Suman's PhD Candidacy Talk
Suman's PhD Candidacy TalkSuman's PhD Candidacy Talk
Suman's PhD Candidacy Talk
 
Early application identification. CONEXT 2006
Early application identification. CONEXT 2006Early application identification. CONEXT 2006
Early application identification. CONEXT 2006
 
Icmp
IcmpIcmp
Icmp
 
ICMP
ICMPICMP
ICMP
 
A Distributed Simulation of P-Systems
A Distributed Simulation of P-SystemsA Distributed Simulation of P-Systems
A Distributed Simulation of P-Systems
 
Computer networks protocols
Computer networks protocolsComputer networks protocols
Computer networks protocols
 
IPv6
IPv6IPv6
IPv6
 
Data Networking Concepts
Data Networking ConceptsData Networking Concepts
Data Networking Concepts
 
R43019698
R43019698R43019698
R43019698
 
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...
The Migration From Erlang To Otp   A Case Study Of A Heavy Duty Tcpip Clients...The Migration From Erlang To Otp   A Case Study Of A Heavy Duty Tcpip Clients...
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...
 
IRJET- Portable Camera based Assistive Text and Label Reading for Blind Persons
IRJET- Portable Camera based Assistive Text and Label Reading for Blind PersonsIRJET- Portable Camera based Assistive Text and Label Reading for Blind Persons
IRJET- Portable Camera based Assistive Text and Label Reading for Blind Persons
 
Us 13-opi-evading-deep-inspection-for-fun-and-shell-wp
Us 13-opi-evading-deep-inspection-for-fun-and-shell-wpUs 13-opi-evading-deep-inspection-for-fun-and-shell-wp
Us 13-opi-evading-deep-inspection-for-fun-and-shell-wp
 
Ch 2
Ch 2Ch 2
Ch 2
 
Question
QuestionQuestion
Question
 
Transporting voice by using IP
Transporting voice by using IPTransporting voice by using IP
Transporting voice by using IP
 
Hardware9
Hardware9Hardware9
Hardware9
 
Network programming
Network programmingNetwork programming
Network programming
 
BYPASSING OF DEPLOYMENT DIFFICULTIES OF IP TRACEBACK TECHNIQUES USING NEW PAS...
BYPASSING OF DEPLOYMENT DIFFICULTIES OF IP TRACEBACK TECHNIQUES USING NEW PAS...BYPASSING OF DEPLOYMENT DIFFICULTIES OF IP TRACEBACK TECHNIQUES USING NEW PAS...
BYPASSING OF DEPLOYMENT DIFFICULTIES OF IP TRACEBACK TECHNIQUES USING NEW PAS...
 

Similar a How does ping_work_style_1_gv

Wireshark Lab IP v6.0Supplement to Computer Networking A Top-D.docx
Wireshark Lab IP v6.0Supplement to Computer Networking A Top-D.docxWireshark Lab IP v6.0Supplement to Computer Networking A Top-D.docx
Wireshark Lab IP v6.0Supplement to Computer Networking A Top-D.docxalanfhall8953
 
Implementation of IPSec VPN on Cisco routers and Configuring it on ISP. (1)
Implementation of IPSec VPN on Cisco routers and Configuring it on ISP. (1)Implementation of IPSec VPN on Cisco routers and Configuring it on ISP. (1)
Implementation of IPSec VPN on Cisco routers and Configuring it on ISP. (1)Vanitha Joshi
 
LREProxy module for Kamailio Presenation
LREProxy module for Kamailio PresenationLREProxy module for Kamailio Presenation
LREProxy module for Kamailio PresenationMojtaba Esfandiari
 
IRJET- Assessment of Network Protocol Packet Analysis in IPV4 and IPV6 on Loc...
IRJET- Assessment of Network Protocol Packet Analysis in IPV4 and IPV6 on Loc...IRJET- Assessment of Network Protocol Packet Analysis in IPV4 and IPV6 on Loc...
IRJET- Assessment of Network Protocol Packet Analysis in IPV4 and IPV6 on Loc...IRJET Journal
 
IP has no mechanism for error reporting or error-correcting. ICMPv4 .pdf
IP has no mechanism for error reporting or error-correcting. ICMPv4 .pdfIP has no mechanism for error reporting or error-correcting. ICMPv4 .pdf
IP has no mechanism for error reporting or error-correcting. ICMPv4 .pdfrishabjain5053
 
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 FinalExploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 Finalmasoodnt10
 
Final networks lab manual
Final networks lab manualFinal networks lab manual
Final networks lab manualJaya Prasanna
 
Presentation on network_protocols
Presentation on network_protocolsPresentation on network_protocols
Presentation on network_protocolsIUBAT
 
HS1011 Data Communication and Networks 13 August 2015 HS101.docx
HS1011 Data Communication and Networks  13 August 2015 HS101.docxHS1011 Data Communication and Networks  13 August 2015 HS101.docx
HS1011 Data Communication and Networks 13 August 2015 HS101.docxadampcarr67227
 
TCP/IP-Protocol Suite-Simple Explanation
TCP/IP-Protocol Suite-Simple ExplanationTCP/IP-Protocol Suite-Simple Explanation
TCP/IP-Protocol Suite-Simple ExplanationKANNANKR12
 
ECET 465 help Making Decisions/Snaptutorial
ECET 465 help Making Decisions/SnaptutorialECET 465 help Making Decisions/Snaptutorial
ECET 465 help Making Decisions/Snaptutorialpinck2329
 
"Internet Protocol Suite" prepared by Szymon M. from Poland
"Internet Protocol Suite" prepared by Szymon M. from Poland"Internet Protocol Suite" prepared by Szymon M. from Poland
"Internet Protocol Suite" prepared by Szymon M. from Polandirenazd
 
Wireshark ip sept_15_2009
Wireshark ip sept_15_2009Wireshark ip sept_15_2009
Wireshark ip sept_15_2009wab030
 
Networking interview questions
Networking interview questionsNetworking interview questions
Networking interview questionszahadath
 
CREST CCT Exam Prep Notes
CREST CCT Exam Prep NotesCREST CCT Exam Prep Notes
CREST CCT Exam Prep NotesNathanAn
 
T C P I P Weaknesses And Solutions
T C P I P Weaknesses And SolutionsT C P I P Weaknesses And Solutions
T C P I P Weaknesses And Solutionseroglu
 
Internet Protocol.pdf
Internet Protocol.pdfInternet Protocol.pdf
Internet Protocol.pdfBIT DURG
 
How does the internet work converted General (Your) Affiliate Link: https://w...
How does the internet work converted General (Your) Affiliate Link: https://w...How does the internet work converted General (Your) Affiliate Link: https://w...
How does the internet work converted General (Your) Affiliate Link: https://w...YonasBayu1
 
NETWORK MANAGEMENT - 2015
NETWORK MANAGEMENT - 2015NETWORK MANAGEMENT - 2015
NETWORK MANAGEMENT - 2015Ammad khan
 

Similar a How does ping_work_style_1_gv (20)

Wireshark Lab IP v6.0Supplement to Computer Networking A Top-D.docx
Wireshark Lab IP v6.0Supplement to Computer Networking A Top-D.docxWireshark Lab IP v6.0Supplement to Computer Networking A Top-D.docx
Wireshark Lab IP v6.0Supplement to Computer Networking A Top-D.docx
 
Implementation of IPSec VPN on Cisco routers and Configuring it on ISP. (1)
Implementation of IPSec VPN on Cisco routers and Configuring it on ISP. (1)Implementation of IPSec VPN on Cisco routers and Configuring it on ISP. (1)
Implementation of IPSec VPN on Cisco routers and Configuring it on ISP. (1)
 
LREProxy module for Kamailio Presenation
LREProxy module for Kamailio PresenationLREProxy module for Kamailio Presenation
LREProxy module for Kamailio Presenation
 
Troubleshooting basic networks
Troubleshooting basic networksTroubleshooting basic networks
Troubleshooting basic networks
 
IRJET- Assessment of Network Protocol Packet Analysis in IPV4 and IPV6 on Loc...
IRJET- Assessment of Network Protocol Packet Analysis in IPV4 and IPV6 on Loc...IRJET- Assessment of Network Protocol Packet Analysis in IPV4 and IPV6 on Loc...
IRJET- Assessment of Network Protocol Packet Analysis in IPV4 and IPV6 on Loc...
 
IP has no mechanism for error reporting or error-correcting. ICMPv4 .pdf
IP has no mechanism for error reporting or error-correcting. ICMPv4 .pdfIP has no mechanism for error reporting or error-correcting. ICMPv4 .pdf
IP has no mechanism for error reporting or error-correcting. ICMPv4 .pdf
 
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 FinalExploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
 
Final networks lab manual
Final networks lab manualFinal networks lab manual
Final networks lab manual
 
Presentation on network_protocols
Presentation on network_protocolsPresentation on network_protocols
Presentation on network_protocols
 
HS1011 Data Communication and Networks 13 August 2015 HS101.docx
HS1011 Data Communication and Networks  13 August 2015 HS101.docxHS1011 Data Communication and Networks  13 August 2015 HS101.docx
HS1011 Data Communication and Networks 13 August 2015 HS101.docx
 
TCP/IP-Protocol Suite-Simple Explanation
TCP/IP-Protocol Suite-Simple ExplanationTCP/IP-Protocol Suite-Simple Explanation
TCP/IP-Protocol Suite-Simple Explanation
 
ECET 465 help Making Decisions/Snaptutorial
ECET 465 help Making Decisions/SnaptutorialECET 465 help Making Decisions/Snaptutorial
ECET 465 help Making Decisions/Snaptutorial
 
"Internet Protocol Suite" prepared by Szymon M. from Poland
"Internet Protocol Suite" prepared by Szymon M. from Poland"Internet Protocol Suite" prepared by Szymon M. from Poland
"Internet Protocol Suite" prepared by Szymon M. from Poland
 
Wireshark ip sept_15_2009
Wireshark ip sept_15_2009Wireshark ip sept_15_2009
Wireshark ip sept_15_2009
 
Networking interview questions
Networking interview questionsNetworking interview questions
Networking interview questions
 
CREST CCT Exam Prep Notes
CREST CCT Exam Prep NotesCREST CCT Exam Prep Notes
CREST CCT Exam Prep Notes
 
T C P I P Weaknesses And Solutions
T C P I P Weaknesses And SolutionsT C P I P Weaknesses And Solutions
T C P I P Weaknesses And Solutions
 
Internet Protocol.pdf
Internet Protocol.pdfInternet Protocol.pdf
Internet Protocol.pdf
 
How does the internet work converted General (Your) Affiliate Link: https://w...
How does the internet work converted General (Your) Affiliate Link: https://w...How does the internet work converted General (Your) Affiliate Link: https://w...
How does the internet work converted General (Your) Affiliate Link: https://w...
 
NETWORK MANAGEMENT - 2015
NETWORK MANAGEMENT - 2015NETWORK MANAGEMENT - 2015
NETWORK MANAGEMENT - 2015
 

Último

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Último (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

How does ping_work_style_1_gv

  • 1. GalaxyVisions Toll Free: 1.866-GVHOST1 (484-6781) How Does Ping Really Work? George Mays, Global Knowledge Course Director, CCISP, CCNA, A+, Network+, Security+, I-Net+ Introduction Ping is a basic Internet program that most of us use daily, but did you ever stop to wonder how it really worked? I don’t know about you, but it bugs me when I do not know how something really works. The pur- pose of this paper is to resolve any lingering questions you may have about ping and to take your understand- ing to the next level. If you do not happen to be a programmer, please do not be frightened off! I am not going to tell you how to write your own version of ping; trust me. I am guessing that you know basically how the TCP/IP ping utility works. It sends an ICMP (Internet Control Message Protocol) Echo Request to a specified interface on the network and, in response, it expects to receive an ICMP Echo Reply. By doing this, the program can test connectivity, gauge response time, and report a vari- ety of errors. ICMP is a software component of the Internetworking layer of TCP/IP; essentially, it is a companion at that level to IP (Internet Protocol) itself. In fact, ICMP relies on IP for transport across the network. If you observe this sort of network traffic, say on an Ethernet network, then your protocol analyzer would capture an Ethernet frame transporting an IP datagram with an ICMP message inside. Enter the problem: Since the ping program executes at the Application layer, how does it make ICMP do these tricks? You may recall, if you are a student of TCP/IP, that the Host-to-Host layer is sandwiched between these entities. Is that bypassed? If so, then how? Who is responsible for formatting these messages (Echo Request and Echo Reply)? More vexingly, when unexpected ICMP responses, other than the customary Echo Reply, result from the Echo Request, how is it that they find their way to the ping program? This last question may seem obvious, but it is not. ICMP messages contain no addressing information that allows the TCP/IP protocol stack to discern the program that is to receive the message. TCP and UDP use port numbers for this purpose. So, how does this work? Background The TCP/IP protocol stack is organized as a four-layer model (see Figure 1). The lowest layer, commonly called the Network Interface or Network Access layer, is analogous to OSI layers 1 and 2, the Physical and Data Link Control layers. This includes things like media, connectors, signaling, physical addressing, error detection, and managing shared access to the media. For most of us this translates into Ethernet and our cabling system. Copyright ©2006 Global Knowledge Training LLC. All rights reserved. Page 2 Manual Prepared by GalaxyVisions Customer Care Team
  • 2. GalaxyVisions Toll Free: 1.866-GVHOST1 (484-6781) Figure 1 TCP/IP Model Process or Application Layer Host-to-Host Layer Internetworking Layer Network Interface or Network Access Layer The layer above the Network Access layer, the Internetworking layer, is best likened to OSI layer 3, the Network layer. Here we expect to find logical addressing and routing: things that facilitate communication across net- work boundaries. This is where IP and its addressing mechanisms reside, as does ICMP. ICMP is a necessary component of any TCP/IP implementation. It does not exist to provide information to the higher-layer protocols (like TCP and UDP) so that they may be more reliable. Rather, ICMP provides network diagnostic capabilities and feedback to those responsible for network administration and operation. See RFC 792, if you are really interested. Above the Internetworking layer is the Host-to-Host layer, which is the counterpart of OSI layer 4, the Transport layer. I like to think that this also includes some of the Session layer (5) functionality as well. This is where we expect to find facilities for reliable end-to-end data exchange, additional error checking, and the means to dis- criminate one program from another (using port numbers). TCP and UDP reside at this level. At the top of the stack, the Application or Process layer, we find high-level protocols (like SMTP, HTTP, and FTP) implemented. This is where applications execute as well. So when you do a ping, the ping program should be perceived to function at this level. A Minor Mystery With ICMP operating at the Internetworking layer and the ping program at the Application layer, how is the Host-to-Host layer bypassed? The answer lies in an understanding of what are known as “raw” sockets. Well, for openers, what is a socket, right? Abstractly, a socket is an endpoint to communication, usually thought to consist of an IP address and port number, which identify a particular host and program, respective- ly. But a programmer has a slightly different perspective on a socket. From his vantage point, “socket” is a sys- tem function that allocates resources that enable the program to interact with the TCP/IP protocol stack beneath. The addressing information is associated with this only after the socket call is made. (Again, if you are interested, this is the role of the “bind” function.) So, take note, it is possible to allocate a socket and not overtly associate any addressing information with it. There are three commonly encountered types of sockets: stream, datagram, and raw. TCP uses the stream type and UDP uses the datagram type. Raw sockets are used by any application that needs to interact directly with IP, bypassing TCP and UDP in doing so. Customers include routing protocol implementations like routed and gated (that implement RIP and OSPF). It also includes our friend ping. Copyright ©2006 Global Knowledge Training LLC. All rights reserved. Page 3 Manual Prepared by GalaxyVisions Customer Care Team
  • 3. GalaxyVisions Toll Free: 1.866-GVHOST1 (484-6781) There are some special considerations in using raw sockets. Since you are circumventing the facilities of the Host-to-Host layer, you forego the program addressing mechanism, the port numbering scheme. This means that programs that employ raw sockets must sift through all incoming packets presented to them in order to find those packets that are of interest. What Actually Goes On When the ping program begins execution, it opens a raw socket sensitive only to ICMP. This means two things: • On output: the sending of ICMP Echo Requests, the program is required to format the ICMP message. The system will provide the IP header and the Ethernet (usually) header. • On input: the program must examine all ICMP messages coming in and cull out the items of interest. The expected input is ICMP Echo Replies. Let us take these things in turn. On the outbound side, the Echo Requests are formatted in the manner shown in Figure 2. The message type is always the coded value eight (8). The code field always contains zero. The checksum is used for error detection. The ICMP message header and data are included in its computation. The ping program performs this calcula- tion and fills in the blank. The identification field follows and is supposed to contain the process ID (PID) that uniquely identifies that execution of the ping program to the operating system. On Windows systems, this field contains the constant value 256. Next is the sequence number field, which starts at 0 and is bumped by one on each Echo Request sent. After these required fields, optional test data will follow. In the ping implementa- tion that I examined (Slackware Linux), this included a timestamp used in the round-trip time calculation upon receipt of the Echo Reply. Figure 2 ICMP Echo Request Type (8) Code (0) Checksum Identification Sequence Test Data As for inbound ICMP messages, ping’s task is a bit more complex. Because ping is using a raw ICMP socket, the program is presented with a copy of all incoming ICMP messages, except for a few special cases like incoming Echo Requests generated by other people pinging us (the latter are handled by the system). This means that ping sees not only the expected Echo Replies when they arrive but also things like Destination Unreachable, Source Quench, and Time Exceeded messages. (Figure 3 summarizes the ICMP message types.) Copyright ©2006 Global Knowledge Training LLC. All rights reserved. Page 4 Manual Prepared by GalaxyVisions Customer Care Team
  • 4. GalaxyVisions Toll Free: 1.866-GVHOST1 (484-6781) Figure 3 ICMP Message Types Type Codes Description 0/8 0 Echo Reply/Echo Request 3 0-15 Destination Unreachable 4 0 Source Quench 5 0-3 Redirect 9/10 0 Router Advertisement 11 0-1 Time Exceeded 12 0 Parameter Problem 13/14 0 Timestamp Request/Timestamp Reply 17/18 0 Address Mask Request/Address Mask Reply Now think about this for a moment. If you have two copies of the ping program running at the same time, then they are each going to see one another’s Echo Replies and any other “nastygrams” that might show up. Each instance of the program must identify the messages that are relevant to it. If you guessed that this is what the PID (identification) field is used for then you are absolutely right. How does the Windows flavor of ping accomplish this feat without the PID? You got me. That sounds like a topic for a future article. Let me get back to you on that. Interestingly, the messages coming in are handed to ping with the IP header still intact. So, the program has access to important things there like the time-to-live (TTL) value and record route information (if the latter option is turned on). Summary At this point, you should have a fairly complete understanding of the cycle of processing associated with ping. Let me recapitulate the essential elements: • As the ping program initializes, it opens a raw ICMP socket so that it can employ IP directly, circumvent- ing TCP and UDP. • Ping formats an ICMP type 8 message, an Echo Request, and sends it (using the “sendto” function) to the designated target address. The system provides the IP header and the data link layer envelope. ¶ As ICMP messages are received, ping has the opportunity to examine each packet to pick out those items that are of interest. • The usual behavior is to siphon off ICMP type 0 messages, Echo Replies, which have an identification field value that matches the program PID. Copyright ©2006 Global Knowledge Training LLC. All rights reserved. Page 5 Manual Prepared by GalaxyVisions Customer Care Team
  • 5. GalaxyVisions Toll Free: 1.866-GVHOST1 (484-6781) • Ping uses the timestamp in the data area of the Echo Reply to calculate a round-trip time. It also reports the TTL from the IP header of the reply. • When things do not work normally, ping may report some of the other ICMP message types that show up in the inbox. This includes things like Destination Unreachable and Time Exceeded messages. Learn More Learn more about how you can improve productivity, enhance efficiency, and sharpen your competitive edge. Check out the following Global Knowledge courses: Network+ Boot Camp TCP/IP Networking For more information or to register, visit www.globalknowledge.com or call 1-800-COURSES to speak with a sales representative. Our courses and enhanced, hands-on labs offer practical skills and tips that you can immediately put to use. Our expert instructors draw upon their experiences to help you understand key concepts and how to apply them to your specific work situation. Choose from our more than 700 courses, delivered through Classrooms, e-Learning, and On-site sessions, to meet your IT and management training needs. About the Author George Mays has over 35+ years experience in computing, data communications, and networking. His experi- ence includes: mainframe systems programmer, Fortune 500 DBA, management of systems programming, data communications, IT operations, engineering, software development, and networking. He is also the author and course director for Global Knowledge’s Network+ Boot Camp and has contributed to several hacking and security books. George holds various industry certifications including: CISSP, CCNA, A+, Network+, Security+, I- Net+. Past certification: MCSE. He is an instructor in TCP/IP, Troubleshooting, Network Protocols, Network Fundamentals, A+, Security+ and CISSP. In addition to teaching for Global Knowledge, Mr. Mays also acts as a consultant in the fields of general networking and security. Copyright ©2006 Global Knowledge Training LLC. All rights reserved. Page 6 Manual Prepared by GalaxyVisions Customer Care Team