RabbitCore RCM3700
User's Manual
PREV INDEX NEXT


6. Using the TCP/IP Features

6.1 TCP/IP Connections

Programming and development can be done with the RCM3700 modules without connecting the Ethernet port to a network. However, if you will be running the sample programs that use the Ethernet capability or will be doing Ethernet-enabled development, you should connect the RCM3700 module's Ethernet port at this time.

Before proceeding you will need to have the following items.

The Ethernet cables and a 10Base-T Ethernet hub are available from Rabbit Semiconductor in a TCP/IP tool kit. More information is available at www.rabbit.com.

  1. Connect the AC adapter and the programming cable as shown in Chapter 2, "Getting Started."

  2. Ethernet Connections

    There are four options for connecting the RCM3700 module to a network for development and runtime purposes. The first two options permit total freedom of action in selecting network addresses and use of the "network," as no action can interfere with other users. We recommend one of these options for initial development.

  3. No LAN — The simplest alternative for desktop development. Connect the RCM3700 module's Ethernet port directly to the PC's network interface card using an RJ-45 crossover cable. A crossover cable is a special cable that flips some connections between the two connectors and permits direct connection of two client systems. A standard RJ-45 network cable will not work for this purpose.

  4. Micro-LAN — Another simple alternative for desktop development. Use a small Ethernet 10Base-T hub and connect both the PC's network interface card and the RCM3700 module's Ethernet port to it using standard network cables.

    The following options require more care in address selection and testing actions, as conflicts with other users, servers and systems can occur:

  5. LAN — Connect the RCM3700 module's Ethernet port to an existing LAN, preferably one to which the development PC is already connected. You will need to obtain IP addressing information from your network administrator.

  6. WAN — The RCM3700 is capable of direct connection to the Internet and other Wide Area Networks, but exceptional care should be used with IP address -settings and all network-related programming and development. We recommend that development and debugging be done on a local -network before connecting a RabbitCore -system to the Internet.

The PC running Dynamic C does not need to be the PC with the Ethernet card.

NOTE Checking and debugging the initial setup on a micro-LAN is recommended before connecting the system to a LAN or WAN.

  1. Apply Power

    Plug in the AC adapter. The RCM3700 module and Prototyping Board are now ready to be used.

6.2 TCP/IP Primer on IP Addresses

Obtaining IP addresses to interact over an existing, operating, network can involve a number of complications, and must usually be done with cooperation from your ISP and/or network systems administrator. For this reason, it is suggested that the user begin instead by using a direct connection between a PC and the RCM3700 using an Ethernet crossover cable or a simple arrangement with a hub. (A crossover cable should not be confused with regular straight through cables.)

In order to set up this direct connection, you will have to use a PC without networking, or disconnect a PC from the corporate network, or install a second Ethernet adapter and set up a separate private network attached to the second Ethernet adapter. Disconnecting your PC from the corporate network may be easy or nearly impossible, depending on how it is set up. If your PC boots from the network or is dependent on the network for some or all of its disks, then it probably should not be disconnected. If a second Ethernet adapter is used, be aware that Windows TCP/IP will send messages to one adapter or the other, depending on the IP address and the binding order in Microsoft products. Thus you should have different ranges of IP addresses on your private network from those used on the corporate network. If both networks service the same IP address, then Windows may send a packet intended for your private network to the corporate network. A similar situation will take place if you use a dial-up line to send a packet to the Internet. Windows may try to send it via the local Ethernet network if it is also valid for that network.

The following IP addresses are set aside for local networks and are not allowed on the Internet: 10.0.0.0 to 10.255.255.255, 172.16.0.0 to 172.31.255.255, and 192.168.0.0 to 192.168.255.255.

The RCM3700 uses a 10/100-compatible Ethernet connection with a 10Base-T interface, which is the most common scheme. The RJ-45 connectors are similar to U.S. style telephone connectors, except they are larger and have 8 contacts.

An alternative to the direct connection using a crossover cable is a direct connection using a hub. The hub relays packets received on any port to all of the ports on the hub. Hubs are low in cost and are readily available. The RCM3700 uses 10 Mbps Ethernet, so the hub or Ethernet adapter must be either a 10 Mbps unit or a 10/100 unit that adapts to 10 Mbps.

In a corporate setting where the Internet is brought in via a high-speed line, there are typically machines between the outside Internet and the internal network. These machines include a combination of proxy servers and firewalls that filter and multiplex Internet traffic. In the configuration below, the RCM3700 could be given a fixed address so any of the computers on the local network would be able to contact it. It may be possible to configure the firewall or proxy server to allow hosts on the Internet to directly contact the controller, but it would probably be easier to place the controller directly on the external network outside of the firewall. This avoids some configuration complications by sacrificing some security.


If your system administrator can give you an Ethernet cable along with its IP address, the netmask and the gateway address, then you may be able to run the sample programs without having to setup a direct connection between your computer and the RCM3700. You will also need the IP address of the nameserver, the name or IP address of your mail server, and your domain name for some of the sample programs.

6.2.1 IP Addresses Explained

IP (Internet Protocol) addresses are expressed as 4 decimal numbers separated by periods, for example:

216.103.126.155

10.1.1.6

Each decimal number must be between 0 and 255. The total IP address is a 32-bit number consisting of the 4 bytes expressed as shown above. A local network uses a group of adjacent IP addresses. There are always 2N IP addresses in a local network. The netmask (also called subnet mask) determines how many IP addresses belong to the local network. The netmask is also a 32-bit address expressed in the same form as the IP address. An example netmask is:

255.255.255.0

This netmask has 8 zero bits in the least significant portion, and this means that 28 addresses are a part of the local network. Applied to the IP address above (216.103.126.155), this netmask would indicate that the following IP addresses belong to the local network:

216.103.126.0

216.103.126.1

216.103.126.2

etc.

216.103.126.254

216.103.126.255

The lowest and highest address are reserved for special purposes. The lowest address (216.102.126.0) is used to identify the local network. The highest address (216.102.126.255) is used as a broadcast address. Usually one other address is used for the address of the gateway out of the network. This leaves 256 - 3 = 253 available IP addresses for the example given.

6.2.2 How IP Addresses are Used

The actual hardware connection via an Ethernet uses Ethernet adapter addresses (also called MAC addresses). These are 48-bit addresses and are unique for every Ethernet adapter manufactured. In order to send a packet to another computer, given the IP address of the other computer, it is first determined if the packet needs to be sent directly to the other computer or to the gateway. In either case, there is an Ethernet address on the local network to which the packet must be sent. A table is maintained to allow the protocol driver to determine the MAC address corresponding to a particular IP address. If the table is empty, the MAC address is determined by sending an Ethernet broadcast packet to all devices on the local network asking the device with the desired IP address to answer with its MAC address. In this way, the table entry can be filled in. If no device answers, then the device is nonexistent or inoperative, and the packet cannot be sent.

Some IP address ranges are reserved for use on internal networks, and can be allocated freely as long as no two internal hosts have the same IP address. These internal IP addresses are not routed to the Internet, and any internal hosts using one of these reserved IP addresses cannot communicate on the external Internet without being connected to a host that has a valid Internet IP address. The host would either translate the data, or it would act as a proxy.

Each RCM3700 RabbitCore module has its own unique MAC address, which consists of the prefix 0090C2 followed by a code that is unique to each RCM3700 module. For example, a MAC address might be 0090C2C002C0.

TIP You can always obtain the MAC address on your board by running the sample program DISPLAY_MAC.C from the SAMPLES\TCPIP folder.

6.2.3 Dynamically Assigned Internet Addresses

In many instances, devices on a network do not have fixed IP addresses. This is the case when, for example, you are assigned an IP address dynamically by your dial-up Internet service provider (ISP) or when you have a device that provides your IP addresses using the Dynamic Host Configuration Protocol (DHCP). The RCM3700 modules can use such IP addresses to send and receive packets on the Internet, but you must take into account that this IP address may only be valid for the duration of the call or for a period of time, and could be a private IP address that is not directly accessible to others on the Internet. These addresses can be used to perform some Internet tasks such as sending e-mail or browsing the Web, but it is more difficult to participate in conversations that originate elsewhere on the Internet. If you want to find out this dynamically assigned IP address, under Windows 98 you can run the winipcfg program while you are connected and look at the interface used to connect to the Internet.

Many networks use IP addresses that are assigned using DHCP. When your computer comes up, and periodically after that, it requests its networking information from a DHCP server. The DHCP server may try to give you the same address each time, but a fixed IP address is usually not guaranteed.

If you are not concerned about accessing the RCM3700 from the Internet, you can place the RCM3700 on the internal network using an IP address assigned either statically or through DHCP.

6.3 Placing Your Device on the Network

In many corporate settings, users are isolated from the Internet by a firewall and/or a proxy server. These devices attempt to secure the company from unauthorized network traffic, and usually work by disallowing traffic that did not originate from inside the network. If you want users on the Internet to communicate with your RCM3700, you have several options. You can either place the RCM3700 directly on the Internet with a real Internet address or place it behind the firewall. If you place the RCM3700 behind the firewall, you need to configure the firewall to translate and forward packets from the Internet to the RCM3700.

6.4 Running TCP/IP Sample Programs

We have provided a number of sample programs demonstrating various uses of TCP/IP for networking embedded systems. These programs require you to connect your PC and the RCM3700 board together on the same network. This network can be a local private network (preferred for initial experimentation and debugging), or a connection via the Internet.


6.4.1 How to Set IP Addresses in the Sample Programs

With the introduction of Dynamic C 7.30 we have taken steps to make it easier to run many of our sample programs. You will see a TCPCONFIG macro. This macro tells Dynamic C to select your configuration from a list of default configurations. You will have three choices when you encounter a sample program with the TCPCONFIG macro.

  1. You can replace the TCPCONFIG macro with individual MY_IP_ADDRESS, MY_NETMASK, MY_GATEWAY, and MY_NAMESERVER macros in each program.

  2. You can leave TCPCONFIG at the usual default of 1, which will set the IP configurations to 10.10.6.100, the netmask to 255.255.255.0, and the nameserver and gateway to 10.10.6.1. If you would like to change the default values, for example, to use an IP address of 10.1.1.2 for the RCM3700 board, and 10.1.1.1 for your PC, you can edit the values in the section that directly follows the "General Configuration" comment in the TCP_CONFIG.LIB library. You will find this library in the LIB\TCPIP directory.

  3. You can create a CUSTOM_CONFIG.LIB library and use a TCPCONFIG value greater than 100. Instructions for doing this are at the beginning of the TCP_CONFIG.LIB library in the LIB\TCPIP directory.

There are some other "standard" configurations for TCPCONFIG that let you select different features such as DHCP. Their values are documented at the top of the TCP_CONFIG.LIB library in the LIB\TCPIP directory. More information is available in the Dynamic C TCP/IP User's Manual.

6.4.2 How to Set Up your Computer for Direct Connect

Follow these instructions to set up your PC or notebook. Check with your administrator if you are unable to change the settings as described here since you may need administrator privileges. The instructions are specifically for Windows 2000, but the interface is similar for other versions of Windows.

TIP If you are using a PC that is already on a network, you will disconnect the PC from that network to run these sample programs. Write down the existing settings before changing them to facilitate restoring them when you are finished with the sample programs and reconnect your PC to the network.

  1. Go to the control panel (Start > Settings > Control Panel), and then double-click the Network icon.

  2. Select the network interface card used for the Ethernet interface you intend to use (e.g., TCP/IP Xircom Credit Card Network Adapter) and click on the "Properties" button. Depending on which version of Windows your PC is running, you may have to select the "Local Area Connection" first, and then click on the "Properties" button to bring up the Ethernet interface dialog. Then "Configure" your interface card for a "10Base-T Half-Duplex" or an "Auto-Negotiation" connection on the "Advanced" tab.

NOTE Your network interface card will likely have a different name.

  1. Now select the IP Address tab, and check Specify an IP Address, or select TCP/IP and click on "Properties" to assign an IP address to your computer (this will disable "obtain an IP address automatically"):

    IP Address : 10.10.6.101

    Netmask : 255.255.255.0

    Default gateway : 10.10.6.1

  2. Click <OK> or <Close> to exit the various dialog boxes.


6.5 Run the PINGME.C Sample Program

Connect the crossover cable from your computer's Ethernet port to the RCM3700 board's RJ-45 Ethernet connector. Open this sample program from the SAMPLES\TCPIP\ICMP folder, compile the program, and start it running under Dynamic C. When the program starts running, the green LINK light on the RCM3700 module should be on to indicate an Ethernet connection is made. (Note: If the LNK light does not light, you may not be using a crossover cable, or if you are using a hub perhaps the power is off on the hub.)

The next step is to ping the board from your PC. This can be done by bringing up the MS-DOS window and running the pingme program:

or by Start > Run

and typing the entry

Notice that the yellow ACT light flashes on the RCM3700 module while the ping is taking place, and indicates the transfer of data. The ping routine will ping the board four times and write a summary message on the screen describing the operation.

6.6 Running Additional Sample Programs With Direct Connect

The sample programs discussed here are in the Dynamic C SAMPLES\RCM3700\TCPIP\ and the SAMPLES\RCM3720\TCPIP\ folders.

The program BROWSELED.C demonstrates how to make the RCM3700 board be a Web server. Two "LEDs" are created on the Web page, along with two buttons to toggle them. Users can change the status of the lights from the Web browser. The LEDs on the Prototyping Board match the ones on the Web page. As long as you have not modified the TCPCONFIG 1 macro in the sample program, enter the following server address in your Web browser to bring up the Web page served by the sample program.

http://10.10.6.100.

Otherwise use the TCP/IP settings you entered in the TCP_CONFIG.LIB library.

The optional LCD/keypad module (see Appendix C) must be plugged in to the RCM3700 Prototyping Board when using this sample program. The sample program MBOXDEMO.C implements a Web server that allows e-mail messages to be entered and then shown on the LCD/keypad module. The keypad allows the user to scroll within messages, flip to other e-mails, mark messages as read, and delete e-mails. When a new e-mail arrives, an LED (on the Prototyping Board and LCD/keypad module) turns on, then turns back off once the message has been marked as read. A log of all e-mail actions is kept, and can be displayed in the Web browser. All current e-mails can also be read with the Web browser.

The sample program PINGLED.C demonstrates ICMP by pinging a remote host. It will flash LEDs DS1 and DS2 on the Prototyping Board when a ping is sent and received.

The sample program SMTP.C allows you to send an e-mail when a switch on the Prototyping Board is pressed. Follow the instructions included with the sample program. LED DS1 on the Prototyping Board will light up when sending e-mail. Note that pin PB7 is connected to both switch S2 and to the external I/O bus on the Prototyping Board, and so switch S2 should not be used with Ethernet operations.

6.6.1 RabbitWeb Sample Programs

You will need to have the Dynamic C RabbitWeb module installed before you run the sample programs described in this section. The sample programs can be found in the SAMPLES\RCM3700\TCPIP\RABBITWEB folder.

6.6.2 Secure Sockets Layer (SSL) Sample Programs

You will need to have the Dynamic C SSL module installed before you run the sample programs described in this section. The sample programs can be found in the SAMPLES\RCM3700\TCPIP\SSL folder.

Before running these sample programs, you will have to create an SSL certificate. The SSL walkthrough in the online documentation for the Dynamic C SSL module explains how to do this.

6.6.3 Dynamic C FAT File System, RabbitWeb, and SSL Modules

The Dynamic C FAT File System, RabbitWeb, and Secure Sockets Layer (SSL) modules have been integrated into a sample program for the RCM3700. The sample program requires that you have installed the Dynamic C FAT File System, RabbitWeb, and SSL modules. Visit our Web site at www.rabbit.com or contact your Rabbit Semiconductor sales representative or authorized distributor for further information on these Dynamic C modules.

NOTE These sample programs will work only on the RCM3700 and the RCM3720, but not the RCM3710. The RCM3700 RabbitCore modules do not support the download manager portion of the sample program.

TIP Before running any of the sample programs described in this section, you should look at and run sample programs for the TCP/IP ZSERVER.LIB library, the FAT file system, RabbitWeb, SSL, the download manager, and HTTP upload to become more familiar with their operation.

The INTEGRATION.C sample program in the SAMPLES\RCM3700\Module_Integration and the SAMPLES\RCM3720\Module_Integration folders demonstrate the use of the TCP/IP ZSERVER.LIB library and FAT file system functionality with RabbitWeb dynamic HTML content, all secured using SSL. The sample program also supports dynamic updates of both the application and its resources using the Rabbit Download Manager (DLM) and HTTP upload capability, respectively—note that neither of these currently supports SSL security.

Before you run the INTEGRATION.C sample program, you will first need to format and partition the serial flash. Find the FMT_DEVICE.C sample program in the Dynamic C SAMPLES\FileSystem folder. Open this sample program with the File > Open menu, then compile and run it by pressing F9. FMT_DEVICE.C formats the serial flash for use with the FAT file system. If the serial flash is already formatted, FMT_DEVICE.C gives you the option of erasing the serial flash and reformatting it with a single large partition. This erasure does not check for non-FAT partitions and will destroy all existing partitions.

Next, run the INTEGRATION_FAT_SETUP.C sample program in the Dynamic C SAMPLES\RCM3700\Module_Integration folder. Open this sample program with the File > Open menu, then compile and run it by pressing F9. INTEGRATION_FAT_SETUP.C will copy some files into the FAT file system via #ximport.

The last step to complete before you can run the INTEGRATION.C sample program is to create an SSL certificate. The SSL walkthrough in the online documentation for the Dynamic C SSL module explains how to do this.

Now you are ready to run the INTEGRATION.C sample program in the Dynamic C SAMPLES\RCM3700\Module_Integration folder. Open this sample program with the File > Open menu, then compile and run it by pressing F9.

NOTE Since HTTP upload and the Dynamic C SSL module currently do not work together, compiling the INTEGRATION.C sample program will generate a serious warning. Ignore the warning because we are not using HTTP upload over SSL. A macro (HTTP_UPLOAD_SSL_SUPRESS_WARNING) is available to suppress the warning message.

Open a Web browser, and browse to the device using the IP address from the TCP_CONFIG.LIB library or the URL you assigned to the device. The humidity monitor will be displayed in your Web browser. This page is accessible via plain HTTP or over SSL-secured HTTPS. Click on the administrator link to bring up the admin page, which is secured automatically using SSL with a user name and a password. Use myadmin for user name and use myadmin for the password.

The admin page demonstrates some RabbitWeb capabilities and provides access to the HTTP upload page. Click the upload link to bring up the HTTP upload page, which allows you to choose new files for both the humidity monitor and the admin page. If your browser prompts you again for your user name and password, they are the same as before.

Note that the upload page is a static page included in the program flash, and can only be updated by recompiling and downloading the application. This way, the page is protected so that you cannot accidentally change it, possibly restricting yourself from performing future updates. If you wish, you may place the upload page into the FAT file system to allow the upload page to be updated.

To try out the update capability, click the upload link on the admin page and choose a simple text file to replace monitor.ztm. Open another browser window and load the main Web page. You will see that your text file has replaced the humidity monitor. To restore the monitor, go back to the other window, click back to go to the upload page again, and choose HUMIDITY_MONITOR.ZHTML to replace monitor.ztm, and click Upload.

When you refresh the page in your browser, you will see that the page has been restored. You have successfully updated and restored your application's files remotely!

When you are finished with the INTEGRATION.C sample program, you need to follow a special shutdown procedure before powering off to prevent any possible corruption of the FAT file system. Press and hold switch S1 on the Prototyping Board until LED DS1 blinks rapidly to indicate that it is now safe to turn the RCM3700 off. This procedure can be modified by the user to provide other application-specific shutdown tasks.

6.7 Where Do I Go From Here?

NOTE If you purchased your RCM3700 through a distributor or through a Rabbit Semiconductor partner, contact the distributor or partner first for technical support.

If there are any problems at this point:

If the sample programs ran fine, you are now ready to go on.

Additional sample programs are described in the Dynamic C TCP/IP User's Manual.

Please refer to the Dynamic C TCP/IP User's Manual to develop your own applications. An Introduction to TCP/IP provides background information on TCP/IP, and is available on the CD and on our Web site.


Rabbit Semiconductor
www.rabbit.com
PREV INDEX NEXT