Application Note 2004-014A
Using the CSA in a DHCP Network
This application note describes how to use the CSA in a DHCP network. This document requires a
minimal knowledge of DHCP networking in order to successfully configure the CSA.
The CSA supports a networking technology known as DHCP (Dynamic Host Configuration Protocol),
which allows clients on the network to receive an IP address from the local network server. Most of
today’s local area networks (LAN’s) use this type of protocol. This document will explain how to install,
configure, and successfully use this feature of the CSA. A more technical explanation of how to
broadcast on the network for DHCP CSAs is also included.
The dBm Optics CSA Locator is an optional Windows® application that can be installed to help
communication between your CSA and computer. This application finds all the CSA’s that your computer
has access to including GPIB, RS232 and any that would be connected via a LAN using TCP/IP. This
application requires that the CSA has at least firmware version 1.6.5 and is available in the applications
section of version 1.03+ of the Customer CD, and from the dBm Optics website (www.dbmoptics.com)
under downloads. The install application for the CSA Locator will step you through the installation
process for the Locator.
After the firmware has been upgraded to version 1.6.5 or greater, the DHCP networking option must be
activated before DHCP will function. The DHCP networking option is available by selecting the System |
Communications Setup | Ethernet Setup panel. Once the DHCP option is selected the CSA will
automatically contact the local DHCP server to obtain a valid IP address. If a DHCP server is not running
on the network then the CSA will be unable to grab a valid IP address and the address will default to
192.168.0.222. The CSA Locator can be used from a PC in order to check that the CSA has properly
obtained an IP address from the DHCP server.
DHCP communication is a basic component of modern networks, which reduces the amount of time IT
professionals must spend assigning IP addresses. This will explain the concept of dynamic addresses,
how to obtain a DHCP CSA’s IP address, and what will cause a DHCP server to change the CSA’s
DHCP CSAs Have Dynamic Addresses
CSAs that are configured to use DHCP have a dynamic IP address; this means that the IP
address can change without any user input. Applications designed to contact a CSA on a DHCP
network should broadcast for the CSA, use the Unique Identifier to pinpoint the requested CSA,
and should not rely on a fixed address since the address could change. For networks that have
infinite assignment times for IP addresses this is not necessary because the first address the
CSA picks up from the DHCP server will remain in effect indefinitely.
Obtaining the DHCP CSA’s Address from a Computer
In order to obtain the address of a CSA on a DHCP network you can use the CSA Locator to
search the local computer and network for CSAs. If the CSA has not properly obtained an
address then the CSA Locator will display the CSA as a grayed item unless the default address of
192.168.0.222 is valid on the local network. The address the CSA has obtained can be found in
the “Address” column of the listing if the Details view mode is activated.
Windows 2000 Example of the dBm Optics CSA Locator
When the DHCP CSA’s Address Will Change
The displayed address can be used as long as the CSA is assigned the same IP address from
the DHCP server, on most networks this is between three and five days. If the address is
obtained just before the turnover point or an application is used during the turnover, it is possible
for communications to be lost since the address may become invalid. This will rarely be the case
because the DHCP server usually has no need to change the address. The address will only
change if network circumstances have changed since the last assignment. Some examples of
circumstances that may trigger an address change are:
• A DHCP incompatible device uses the address assigned to the CSA.
• The DHCP server runs out of addresses in an address block and is forced to move
devices into another block.
• The DHCP server’s address table becomes corrupt and must be rebuilt.
Application Note 2004-014A Page 2 of 2
• The DHCP server administrator clears the address table or removes the address block in
which the CSA is located.
• While there are many situations that can trigger an address change, it is actually quite
rare. It is best to prepare the program to re-broadcast on the network for the CSA if
communications are lost.
Broadcasting on the Network for DHCP CSAs
This portion of the document includes a brief overview of how to contact the CSA on a DHCP network
and includes a C programming example that utilizes the Windows Sockets API to broadcast for a CSA.
For a LabVIEW example of the same process the dBm Optics LabVIEW Driver includes a VI (ENET CSA
Locator.vi) that shows how to broadcast for CSAs.
How a Broadcast for CSAs is Performed
Several steps are performed in order to obtain the IP address and unique information about a
CSA on your network. First, an application sends out a broadcast message over the network that
is formatted so that only CSAs will respond. CSAs that receive this message will send a
broadcast message back across the network to the computer querying for CSAs. This message
must be broadcast back instead of targeted because of a bug in the Windows Sockets API that
reports the wrong IP address when the sending computer has more than one network card. This
is all that is truly necessary to obtain the IP address and unique information from the CSA;
however, it is a good idea to ensure that the CSA is on the same subnet as the sending
computer. In order to check that the CSA is on the same subnet as the computer, a targeted
message can be sent to the CSA IP address (found with the broadcast process). Targeted
messages can only be sent to devices on the same subnet, therefore the CSA will only respond if
it is on the same subnet as the computer. If the CSA does not respond an error message can be
displayed to inform the user that the CSA is on the wrong subnet, most networks must have the
first two or three fields of the IP address match (or be close) in order for the CSA to be contacted.
On DHCP networks the DHCP server will handle the IP address so that it is within the acceptable
subnet as the computer.
A Simple Broadcast Example
This example shows how the Windows Sockets API can be used to broadcast a locator message
across the network. Please note that the example is multi-threaded and uses a window with the
identifier ID_MAIN_DIALOG and a ListView control with identifier ID_CSAs_LISTVIEW.
#include <windows.h> //windows functions
#include <winsock.h> //windows socket functions (networking)
#include <commctrl.h> //common controls functions (for ListView control)
#include <time.h> //time functions (timeout check)
#include "resource.h" //ID codes for resource items
/* external functions (stdio.h) */
int _RTLENTRY _EXPFUNC sprintf(char * __buffer, const char * __format, ...);
int _RTLENTRY _EXPFUNC sscanf(const char * __buffer, const char * __format, ...);
/* local functions */
BOOL CALLBACK MainWindowProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM
DWORD WINAPI BroadcastForCSA(void *_m);
DWORD WINAPI recv_threaded(void *_m);
Application Note 2004-014A Page 3 of 3