![]() |
|
| << Previous | Index | Next >> | |
| | |
ARP (Address Resolution Protocol) and DNS (Domain Name System) perform translations between various network address formats. ARP converts between IP addresses and (usually) Ethernet hardware addresses. DNS converts between human-readable domain names such as "ftp.mydomain.org" and IP addresses.
ARP and DNS are not closely related protocols, but they are lumped together in this chapter for convenience. In the Dynamic C TCP/IP libraries,
ARP.LIBhandles ARP proper, as well as router (gateway) functionality.5.1 ARP Functions
ARP (Address Resolution Protocol) is used on non-PPPoE Ethernet interfaces. ARP is used to determine the hardware address of network interface adapters. Most of the ARP functionality operates in the background and is handled by the TCP/IP libraries. Most applications should not need to deal with ARP, and indeed some of the ARP functions are quite complex to use correctly.
Nevertheless, there are some useful debugging functions included in
ARP.LIB.Starting with Dynamic C 7.20, the internal ARP processing was converted to non-blocking style. This has no direct impact on applications, except that there will be lower maximum latency in tcp_tick() calls.
The ARP functions are all named starting with _arp, arpcache, arpresolve, or router.
router_printall()is a useful function for debugging router table problems, for example in the case where connections to hosts which are not on local subnets appear to be failing.5.2 Configuration Macros for ARP
ARP_LONG_EXPIRY
Number of seconds that a normal entry stays current. Defaults to 1200.
ARP_SHORT_EXPIRY
Number of seconds that a volatile entry stays current. Defaults to 300.
ARP_PURGE_TIME
Number of seconds until a flushed entry is actually deleted. Defaults to 7200.
ARP_PERSISTENCE
Number of retries allowed for an active ARP resolve request to come to fruition. Default s to 4. If no response is received after this many requests, then the host is assumed to be dead. Set to a number between 0 and 7. This number relates to the total time spent waiting for a response as follows:
timeout = 2(ARP_PERSISTENCE+1) - 1For example, for 0 the time-out is 1 second. For 4 it is 31 seconds. For 7 it is 255 seconds. If you set this to 8 or higher, then ARP will persist forever, retrying at 128 second intervals.
ARP_NO_ANNOUNCE
Configuration items not defined by default. Do not announce our hardware address at
sock_init().This macro is undefined by default. Do not uncomment it in
NET.LIB. Instead, define it in your mainline C program before including the networking libraries.ARP_CONFLICT_CALLBACK
Define a function to call in case of IP address conflict. This function takes a arp_Header pointer as the first and only parameter. It should return one of
- 0: do not take any action
- 0xFFFFFFFF : abort all open sockets with
NETERR_IPADDR_CONFLICT- other: new IP address to use. Open sockets aborted with
NETERR_IPADDR_CHANGE.This macro is undefined by default. Do not uncomment it in
NET.LIB. Instead, define it in your mainline C program before including the networking libraries.ARP_TABLE_SIZE
Define to the number of ARP table entries. The default is set to the number of interfaces, plus 5 entries for every non-PPPoE Ethernet interface. The maximum allowable value is 200.
ARP_ROUTER_TABLE_SIZE
Define the maximum number of routers. Defaults to the number of interfaces, plus an extra entry for each non-PPPoE Ethernet.
5.3 DNS Functions
Starting with Dynamic C 7.05, non-blocking DNS lookups are supported. Prior to DC 7.05, there was only the blocking function,
resolve(). Compatibility has been preserved forresolve(),MAX_DOMAIN_LENGTH, andDISABLE_DNS.The application program has to do two things to resolve a host name:
Call
resolve_cancel()to cancel a pending lookup.5.4 Configuration Macros for DNS Lookups
DISABLE_DNS
If this macro is defined, DNS lookups will not be done. The DNS subsystem will not be compiled in, saving some code space and memory.
DNS_MAX_RESOLVES
4 by default. This is the maximum number of concurrent DNS queries. It specifies the size of an internal table that is allocated in xmem.
DNS_MAX_NAME
64 by default. Specifies the maximum size in bytes of a host name that can be resolved. This number includes any appended default domain and the
NULL-terminator. Backwards compatibility exists for theMAX_DOMAIN_LENGTHmacro. Its value will be overridden with the valueDNS_MAX_NAMEif it is defined.For temporary storage, a variable of this size must be placed on the stack in DNS processing. Normally, this is not a problem. However, for µC/OS-II with a small stack and a large value for
DNS_MAX_NAME, this could be an issue.DNS_MAX_DATAGRAM_SIZE
512 by default. Specifies the maximum length in bytes of a DNS datagram that can be sent or received. A root data buffer of this size is allocated for DNS support.
DNS_RETRY_TIMEOUT
2000 by default. Specifies the number of milliseconds to wait before retrying a DNS request. If a request to a nameserver times out, then the next nameserver is tried. If that times out, then the next one is tried, in order, until it wraps around to the first nameserver again (or runs out of retries).
DNS_NUMBER_RETRIES
2 by default. Specifies the number of times a request will be retried after an error or a time-out. The first attempt does not constitute a retry. A retry only occurs when a request has timed out, or when a nameserver returns an unintelligible response. That is, if a host name is looked up and the nameserver reports that it does not exist and then the DNS resolver tries the same host name with or without the default domain, that does not constitute a retry.
DNS_MIN_KEEP_COMPLETED
10000 by default. Specifies the number of milliseconds a completed request is guaranteed to be valid for
resolve_name_check(). After this time, the entry in the internal table corresponding to this request can be reused for a subsequent request.DNS_SOCK_BUF_SIZE
1024 by default. Specifies the size in bytes of an xmem buffer for the DNS socket. Note that this means that the DNS socket does not use a buffer from the socket buffer pool.
| TCP/IP Manual Vol 1 |
<<Previous | Index | Next>> | rabbit.com |