How tnsping work: Comparison of Oracle's tnsping to TCP/IP's ping [ID 146264.1]

来源:互联网 发布:mysql 记录创建时间 编辑:程序博客网 时间:2024/05/02 00:12

Comparison of Oracle's tnsping to TCP/IP's ping [ID 146264.1]


      修改时间 12-MAR-2010     类型 BULLETIN     状态 PUBLISHED     

Applies to:
Net Configuration Assistant - NetCA
Net Manager - NetMgr
Oracle Net Services
Enterprise Manager for RDBMS
Information in this document applies to any platform.
Purpose
Database Administrators, Network Administrators Comparison of Oracle's tnsping to TCP/IP's ping.
Scope and Application
Troubleshooting Oracle Listener

Comparison of Oracle's tnsping to TCP/IP's ping

ORACLE TNSPING

       The Oracle utility tnsping, uses TCP for its communication. TCP is an OSI Transport Layer protocol that is connection-oriented. This connection-oriented protocol requires an initial exchange of sequencing numbers in the initial connection setup. This exchange is commonly called the "three-way handshake."

When tnsping is issued from the command line, a lookup on the Oracle Net Alias is performed. This can occur using a local file called TNSNAMES.ORA or using a Naming Service like Oracle Names or LDAP. The purpose is to get the hostname and port number the target Listener is listening on.

Once the hostname and port number have been acquired, a TCP connection is opened to the target host and port the Oracle Listener is on. To open this TCP connection, the host name must be resolved to the IP address of the destination host. TCP/IP then performs the three-way handshake to complete the connection.

Tnsping then sends a Oracle TNS Connect packet (the "ping") to the Oracle Listener. The Listener responds with a TNS Refuse packet (its "pong"). The TCP/IP connection between the two hosts is then terminated. The total time from Oracle Net Alias look-up to TCP/IP connection termination is then reported back to the command line. As example:

C:\>tnsping RAC1_10g  5TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 09-12月-2011 09:52:27Copyright (c) 1997, 2005, Oracle.  All rights reserved.已使用的参数文件:D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora已使用 TNSNAMES 适配器来解析别名Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = rac) (INSTANCE_NAME = rac1)))OK (20 毫秒)OK (10 毫秒)OK (20 毫秒)OK (20 毫秒)OK (10 毫秒)

This example shows a 20 millisecond period for the first "ping".This time period was comprise od the loop-up of the alias RAC1_10g in a local TNSNAMES.ORA file, a DNS resolve of the destination host '192.168.1.22' and TCP/IP port 1521, the TCP/IP three-way handshake, the actual transport of the TNS Connect and Refuse packets, and the tearing down of the TCP/IP connection. The second time only took 10 milliseconds because all the connection information (the RAC1_10g alias and IP address) had already been cached. Tnsping still does the connection setup and tear-down for TCP/IP for each tnsping however.

TCP/IP PING

       The Transmission Control Protocol/Internet Protocol suite (TCP/IP) has a utility called "ping" named after the sound SONAR makes under water. It is the command line interface to the TCP/IP protocol ICMP, or Internet Control Message Protocol. According to RFC 792:

"Occasionally a gateway or destination host will communicate with a source host, for example, to report an error in datagram processing. For such purposes this protocol, the Internet Control Message Protocol (ICMP), is used. 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.

One use of ping is to gather general round trip times for a variety of IP packet sizes. This measurement can be used to estimate the approximate over-all performance and response time of an application that runs over a network.

Ping uses ICMP and thus does not require TCP's three-way handshake. When ping operates, it sends and receives one ICMP packet. This is far fewer packets than Oracle's tnsping creates.

It is typical for ping to show a longer initial response time being than the average. This is usually due to the time it takes to perform a host name to IP address look-up (known as a "resolve"). This look-up can be done either with a local hosts file, a DNS server or other methods. An example output for a ping would look like:

Pinging abadah.us.oracle.com [144.25.223.156] with 32 bytes of data:Reply from AAA.BBB.CCC.DDD: bytes=32 time<40ms TTL=255Reply from AAA.BBB.CCC.DDD: bytes=32 time<10ms TTL=255Reply from AAA.BBB.CCC.DDD: bytes=32 time<10ms TTL=255Reply from AAA.BBB.CCC.DDD: bytes=32 time<10ms TTL=255

This example shows a 40-millisecond ping time for the first attempt. This includes a DNS resolve for the destination host.