gtpc1m2qTransmission Control Protocol/Internet Protocol

DNS Client

When a client application in the TPF system wants to start a connection with a remote server across a TCP/IP network and the client does not know the IP address of the server, it issues the gethostbyname function call. Before DNS support for PUT 13, the TPF system always sent a request to an external DNS server to obtain the IP address. DNS support enhances the DNS client function of the TPF system by providing a caching function. Now, whenever a gethostbyname function call is issued and information is received from an external DNS server, the information is saved in TPF DNS host name cache IDNSHOSTNAME. If subsequent gethostbyname calls are made for the same host name and the information is still in the cache, control is returned to the client application immediately and no flows to external DNS servers are needed. If you have many TPF client applications that constantly start connections with the same remote server applications, the DNS host name cache will improve the performance of those applications.

When the TPF system receives a DNS response from an external DNS server, the response indicates how long the information is valid. That value determines how long the information remains in the cache. After that time limit ends, the next gethostbyname request from that host name will cause another flow to the external DNS server.

If a DNS response from an external DNS server contains more than one IP address, all the IP addresses in the response are saved in the cache entry. Each time the cache entry is accessed, the order of the IP addresses passed back to the client application changes. For example, assume the cache entry for a given host name contains IP addresses X, Y, and Z. The first TPF client that issues a gethostbyname request for that host name will get back a list containing X, Y, and then Z. The next client to request this host name will get back a list containing Y, Z, and then X. The client after that will get back Z, X, and then Y. The list of IP addresses changes for load balancing purposes because it is common practice in applications to select the first IP address in the list.

In addition to the DNS host name cache, there is also a DNS IP address cache (IDNSHOSTADDR) that is used by the gethostbyname function call. For this, the client passes an IP address as input and requests the corresponding host name as output.

The quantity of entries in the DNS caches can be changed by using the ZCACH command. The name of the DNS host name cache is IDNSHOSTNAME. The name of the DNS IP address cache is IDNSHOSTADDR. See TPF Operations for more information about the ZCACH command.

If the TPF system is unable to obtain the gethostbyname or gethostbyaddr function information from the DNS local caches or the external DNS server, the system will attempt to obtain the information from the core copy of the optional /etc/hosts file if one has been set up. There can be only one IP address per host name entry and one entry per line in the /etc/hosts file. The /etc/hosts file must be created in the basic subsystem (BSS). Host names in the file can be lowercase or uppercase characters, but when the file is copied into the TPF host name table (THNT) they are converted to all uppercase. A sample /etc/hosts file is as follows:

Buytickets.com     1.1.1.2
Overcharge.org     1.2.3.4
US.SPEEDTRAPS.COM  111.111.111.111
NYR1940.org        1.1.2.6