| ||||||||
Technical Support On-Line Manuals RL-ARM User's Guide | When DHCP EnabledA Dynamic Host Configuration Protocol (DHCP) client automatically configures the network parameters for the application. This normally takes some time after startup. When the network traffic is low and a DHCP server is idle, automatic device configuration is finished in less than 60 msec. But it is possible, on high traffic networks, that this configuration could take a lot longer by up to a couple of seconds. Any attempt to send an UDP data packet during that time will fail and the UDP data packet will be lost. Communications must wait until the local IP address is configured. This can be done by simply monitoring the IP address in the localm structure, which holds all the network configuration parameters. When the DHCP client starts, it copies a default Local IP address, which is set in the configuration, to a local buffer and clears the assigned IP address for the ethernet adapter. The DHCP client then tries to acquire the proposed IP address in the DHCP negotiation process. To see when the DHCP configuration procedure has finished, it is enough to monitor the assigned IP address of the ethernet adapter. The whole procedure is required only when we want to send UDP data. For receiving UDP packets, this is not a problem because the application will not accept any IP packet until the ethernet adapter IP address is assigned. Here is an example for the send_data() function from the UDP example modified for enabled DHCP:
void send_data (void) {
static const U8 rem_IP[4] = {192,168,0,100};
U8 *sendbuf;
if (wait_ack == __TRUE) {
return;
}
if (mem_test (localm[NETIF_ETH].IpAdr, 0, 4) == __TRUE) {
/* IP address not yet assigned by DHCP. */
return;
}
if (bindex < 128) {
sendbuf = udp_get_buf (512);
for (i = 0; i < 512; i += 2) {
sendbuf[i] = bcount >> 8;
sendbuf[i+1] = bcount & 0xFF;
}
udp_send (udp_soc, rem_IP, 1000, sendbuf, 512);
}
}
| |||||||
| ||||||||