| Intellicom User's Manual |
5. Using the TCP/IP Features
Chapter 5 provides an introduction to using the TCP/IP features on your Intellicom.
5.1 TCP/IP Connections
Before proceeding you will need to have the following items.
- If you don't have Ethernet access, you will need at least a 10Base-T Ethernet card (available from your favorite computer supplier) installed in a PC.
- Two RJ-45 straight through Ethernet cables and a hub, or an RJ-45 crossover Ethernet cable.
The Ethernet cables and Ethernet hub are available from Z-World in a TCP/IP tool kit. More information is available at www.zworld.com.
- Connect the AC adapter and the programming cable as shown in Chapter 2, "Getting Started."
- Ethernet Connections
If you do not have access to an Ethernet network, use a crossover Ethernet cable to connect the Intellicom board to a PC with at least a 10Base-T Ethernet card.
If you have access to an Ethernet network, use a straight through Ethernet cable to establish an Ethernet connection to the Intellicom board from an Ethernet hub. These connections are shown in Figure 15.
The PC running Dynamic C through the serial port on the Intellicom board does not need to be the same as the PC with the Ethernet card.
Plug in the AC adapter. The Intellicom board is now ready to be used.
NOTE A hardware RESET is accomplished by unplugging the AC adapter, then plugging it back in. When working with the Intellicom board, the green LNK light is on when a program is running and the board is properly connected either to an Ethernet hub or to an active Ethernet card. The red ACT light flashes each time a packet is received.
5.2 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 that the user connect his PC and the Intellicom 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.
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 (if your company has one). For this reason, it is suggested that the user begin instead by using a direct connection between a PC and the Intellicom board using an Ethernet crossover cable or a simple arrangement with a hub. (A crossover cable should not be confused with regular straight through cables.) The hub and a wide variety of cables can also be purchased from a local computer store.
In order to set up this direct connection, the user will have to use a new PC (right out of the box), or disconnect a PC from the corporate network, or as yet another approach 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. Mobile PCs, such as laptops, are designed to be connected and disconnected, and will present the least problem. 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 Microstate 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 private 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 Intellicom board uses a 10Base-T type of Ethernet connection, which is the most common scheme. The RJ-45 connectors are similar to U.S. style telephone connectors, are except 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 Intellicom board uses 10 Mbps Ethernet, so the hub or Ethernet adapter must be either a 10 Mbps unit or a 10/100 Mbps unit.
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 Intellicom board 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 of the 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 Intellicom board. 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.
5.3 IP Addresses Explained
IP (Internet Protocol) addresses are expressed as 4 decimal numbers separated by periods, for example:
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:
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:
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.
5.4 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 IP 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.
Private IP addresses are arbitrary and can be allocated as desired provided that they don't conflict with other IP addresses. However, if they are to be used with the Internet, then they must be numbers that are assigned to your connection by proper authorities, generally by delegation via your service provider.
5.5 Dynamically Assigned Internet Addresses
In many instances, there are no 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 Intellicom 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 private address can be used to perform some Internet tasks such as sending e-mail or browsing the Web, but usually cannot be used 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 private 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 Intellicom from the Internet, you can place the Intellicom on the internal network using a private address assigned either statically or through DHCP.
5.6 Placing Your Device on the Internet
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 Intellicom, you have several options. You can either place the Intellicom directly on the Internet with a real Internet address or place it behind the firewall. If you place the Intellicom behind the firewall, you need to configure the firewall to translate and forward packets from the Internet to the Intellicom.
5.7 How to Set IP Addresses in the Sample Programs
Most of the sample programs such as shown in the example below use macros to define the IP address assigned to the board and the IP address of the gateway, if there is a gateway.
#define MY_IP_ADDRESS "216.112.116.155"
#define MY_NETMASK "255.255.255.248"
#define MY_GATEWAY "216.112.116.153"In order to do a direct connection the following IP addresses can be used for the Intellicom board:
#define MY_IP_ADDRESS "10.1.1.2"
#define MY_NETMASK "255.255.255.248"
// #define MY_GATEWAY "216.112.116.153"In this case, the gateway is not used and is commented out. The IP address of the board is defined to be 10.1.1.2. The IP address of your PC can be defined as 10.1.1.1.
5.8 How to Set Up your Computer's IP Address For Direct Connect
When your computer is connected directly to the Intellicom board via an Ethernet connection, you need to assign an IP address to your computer. To assign the PC the address 10.1.1.1 with the subnetmask 255.255.255.248 under Windows 98, do the following.
Click on Start > Settings > Control Panel to bring up the Control Panel, and then double-click the Network icon. In the window find the line of the form TCP/IP > Ethernet adapter name. Double-click on this line to bring up the TCP/IP properties dialog box. You can edit the IP address directly and the subnet mask. (Disable "obtain an IP address automatically.") You may want to write down the existing values in case you have to restore them later. It is not necessary to edit the gateway address since the gateway is not used with direct connect.
The method of setting the IP address may differ for different versions of Windows, such as 95, NT or 2000.
5.9 Run the PINGME.C Demo
In order to run this program, edit the IP address and netmask in the PINGME.C program (SAMPLES\TCPIP\ICMP) to the values given above (10.1.1.2 and 255.255.255.248). Compile the program and start it running under Dynamic C. The crossover cable is connected from your computer's Ethernet adapter to the Intellicom board's RJ-45 Ethernet connector. When the program starts running, the green LNK light on the Intellicom board should be on to indicate an Ethernet connection is made. (Note: If the LNK light does not light, you may not have 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:
ping 10.1.1.2
ping 10.1.1.2Notice that the red ACT light flashes on the Intellicom board 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.
5.10 Running More Demo Programs With a Direct Connection
The programs STATIC.C and SSI3.C (SAMPLES\TCPIP\HTTP) demonstrate how to make the Intellicom board be a Web server. This program allows you to turn the LEDs on an attached Demonstration Board from the Development Kit on and off from a remote Web browser. In order to run these sample programs, edit the IP address as for the pingme program, compile the program and start it executing. Then bring up your Web browser and enter the following server address: http://10.1.1.2.
This should bring up the Web page served by the sample program.
The sample program RXSAMPLE.C (SAMPLES\TELNET) allows you to communicate with the Intellicom board using the Telnet protocol. To run this program, edit the IP address, compile the program, and start it running. Run the Telnet program on your PC (Start > Run telnet 10.1.1.2). Each character you type will be printed in Dynamic C's STDIO window, indicating that the board is receiving the characters typed via TCP/IP.
5.11 Where Do I Go From Here?
NOTE If you purchased your OP6800 through a distributor or Z-World partner, contact the distributor or Z-World partner first for technical support. If there are any problems at this point:
- Check the Z-World Technical Bulletin Board at www.zworld.com/support/bb/.
- Use the Technical Support e-mail form at www.zworld.com/support/support_submit.html.
- Call Z-World Technical Support at (530)757-3737.
If the sample programs ran fine, you are now ready to go on.
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 included on the CD, and is also available on Z-World's Web site.
| Z-World http://www.zworld.com Voice: (530) 757-3737 FAX: (530) 757-3792 sales@zworld.com |