Fime
The Microchip TCP/IP Stack
Author: Nilesh Rajbharti Microchip Technology Inc. accesses services from one or more layers directly below it. A simple version of the TCP/IP Stack model is shown in Figure 1. Per specifications, many of the TCP/IP layers are “live”, in the sense that they do not only act when a service is requested but also when events like time-out or new packet arrivaloccurs. A system with plenty of data memory and program memory can easily incorporate these requirements. A multitasking operating system may provide extra facility and therefore, may make implementation modular. But the task becomes difficult when a system employing only an 8-bit microcontroller, with a few hundred bytes of RAM and limited program memory is used. In addition, without access to amultitasking operating system, the user must pay special attention to make the stack independent of the main application. A TCP/IP Stack that is tightly integrated with its main application is relatively easy to implement, and may even be very space efficient. But such a specialized stack may pose unique problems as more and more new applications are integrated. The stack is written in the ‘C’programming language, intended for both Microchip C18 and HI-TECH® PICC-18™ C compilers. Depending on which is used, the source files automatically make the required changes. The Microchip TCP/IP Stack is designed to run on Microchip’s PIC18 family of microcontrollers only. In addition, this particular implementation is specifically targeted to run on Microchip’s PICDEM.netTM Internet/Ethernetdemonstration board. However, it can be easily retargeted to any hardware equipped with a PIC18 microcontroller.
INTRODUCTION
Note: This application note was originally written for the Microchip TCP/IP Stack released back in 2002; the stack has been updated many times since. The latest API information is now provided as a Windows® Help file, TCPIP Stack Help.chm, which is distributed with the latestTCP/IP Stack that can be downloaded from http://www.microchip.com/tcpip. The stack now supports 8, 16 and 32-bit PIC® and dsPIC® devices. This application note is still useful as a reference material.
There is nothing new about implementing TCP/IP (Transmission Control Protocol/Internet Protocol) on Microchip microcontrollers. Interested developers can easily find many commercial and non-commercialimplementations of TCP/IP for Microchip products. This application note details Microchip’s own freely available implementation of the TCP/IP Stack. The Microchip TCP/IP Stack is a suite of programs that provides services to standard TCP/IP-based applications (HTTP Server, Mail Client, etc.), or can be used in a custom TCP/IP-based application. To better illustrate this, a complete HTTP Serverapplication is described at the end of this document and is included with the stack’s source code archive. The Microchip TCP/IP Stack is implemented in a modular fashion, with all of its services creating highly abstracted layers. Potential users do not need to know all the intricacies of the TCP/IP specifications to use it. In fact, those who are only interested in the accompanying HTTP Serverapplication do not need any specific knowledge of TCP/IP. (Specific information on the HTTP Server starts on page 77.) This application note does not discuss the TCP/IP protocols in depth. Those who are interested in the details of the protocols are encouraged to read the individual Request For Comment (RFC) documents. A partial list of the key RFC numbers can be found at the end of this document.FIGURE 1:
LAYERS OF THE TCP/IP REFERENCE MODEL
Application
Transport
Internet
STACK ARCHITECTURE
Many TCP/IP implementations follow a software architecture referred to as the “TCP/IP Reference model”. Software based on this model is divided into multiple layers, where layers are stacked on top of each other (thus the name “TCP/IP Stack”) and each layer Host-to-Network
© 2008...
Regístrate para leer el documento completo.