The Research and Implementation of Embedded TCP/IP Protocol Stack

The Research and Implementation of Embedded TCP/IP Protocol Stack

The 2nd International Conference on Computer Application and System Modeling (2012) The Research and Implementation of Embedded TCP/IP Protocol Stack Jian Xu School of Information and Engineering Hubei University for Nationalities Enshi, China [email protected] Abstract—With μC/OS-II as embedded real-time operating protocol stack as a process is to facilitate the migration in system and LWIP as protocol stack in embedded system, different operating systems [1]. μC/OS-II and LWIP are transplanted to constitute the software platform. The hardware platform is constituted by B. Buffer and Memory Management the LPC2210 as MCU, RTL8019AS as the Ethernet controller In terms of transmitting data, LWIP protocol packs data chip. The thesis mainly elaborates on the principle and in a certain storage area. Nothing but data pointers are communication process of the LWIP protocol stack layers. transmitted in protocol stack, a true copy of data can be Test results show that: when transplanted to LPC2210, μC/OS- realized only when the data is eventually sent by driver or II kernel can achieve multi-task scheduling, the key removed the application program. And, in order to avoid the agreements of LWIP protocol stack layers can achieve normal extra copy, LWIP stack design of the API allows application communication with the Internet connected at the embedded program to operate directly on the storage blocks [1]. terminal. Running TCP/IP protocol stack for embedded systems, Keywords-EmbeddedSystem;Ethernet;LPC2210;µC/OS- the entire storage area of system can be divided into the II;LWIP protocol stack management buffer and the application management memory. As the memory region to which LWIP kernel can have direct access, LWIP stack I. INTRODUCTION management buffer is mainly used for loading the network To realize the internet network of embedded system and data packets to be received and transmitted. The application support the terminal access to internet, TCP/IP protocol stack management memory is the area for application management must be implemented in embedded system. So far a number and operation, usually from the region for the application to of TCP/IP stacks can be used on the embedded device, but send data and distribute cache. the application of open source for low-end embedded network platform is still very rare. LWIP is one of the C. Operating System Emulation Layer implementations of TCP/IP protocol stack, which mainly In order to make LWIP easy to transplant, the function reduces the amount of system memory utilization and code calls and data structure about operating system is not used complexity, making it more suitable for embedded systems directly in code, but use the operating system emulation layer with limited resources. instead of the use of these functions. The operating system emulation layer provides a series of unified interfaces to II. EMBEDDED TCP/IP PROTOCOL STACK system services such as timers, process synchronization, and message transmission mechanism. Operating system A. LWIP Process Model emulation layer also provides a timer function used by the TCP/IP protocol stack process model refers to the TCP. This timer is a mono-pulse timer with time interval of approach which divides the system into different processes. at least 200ms [1]. Process synchronization mechanism The most common kind of process model is every agreement provides only a semaphore. E-mail messaging can be among the TCP/IP protocol exists as a separate process. This achieved by post and fetching. Postal operations will not model uses the strict protocol layering and the block the process. On the contrary, the message is delivered communication nodes between agreements must be strictly to the mailbox by the operating system emulation layer in the defined. In addition, a more common process model seals the list until other processes remove them. communication protocol in the kernel of operating system, and the application process is realized through the system III. LWIP TRANSPLANTING IN ΜC/OS-II call and communication of protocol stack so that each layer In the process of LWIP stack designing, the of agreement need not be strictly distinguished, instead it can transplanting-relevant problems such as compiling constants use the cross-layering agreement technology. set, defining data type, modifying the operating system- LWIP process has its own unique model, which has related functions, and initializing and driving the network encapsulated the whole protocol stack in a process so as to card, have been taken into consideration. All the parts separate protocol stack from operating system kernel. The relevant to hardware, operating system, and compiler are application layer process can either be a separate process, or separated by LWIP protocol stack code and placed in reside in LWIP process. The main advantage of LWIP Published by Atlantis Press, Paris, France. © the authors 0584 The 2nd International Conference on Computer Application and System Modeling (2012) /src/arch directory. So transplanting LWIP in μC/OS-II is the network access layer so as to provide dynamic mapping realized by modifying the files in this directory [2]. between IP address and the corresponding hardware addresses. A. The INCLUDE File Associated with the CPU or the Network access layer is at the bottom of TCP/IP protocol Compiler stack, which is responsible for receiving and sending IP The definition (such as data length) associated with the packets by the selected network, or by the physical frame CPU or the compiler is placed in /src/arch/include/arch received from the network to extract the IP data grams to the directory, which mainly lies in the three documents cc.h, IP layer. ARP function of LWIP mainly lies in the two cpu.h and perf.h. This should be with μC/OS-II definition are documents etharp.c and etharp.h, which complete three main the same. functions:(1)When sending a packet, it resolves IP address to #define BYTE ORDER LITTLE ENDIAN the physical address;(2)when sending ARP request, it #define PACK_STRUCT_FIELD (x) __packed x responds to ARP requests send by other hosts;(3)when #define PACK_STRUCT_STRUCT receiving IP datagram, it updates ARP cache[3]. #define PACK_STRUCT_BEGIN __packed #define PACK_STRUCT_END B. Network Layer protocol typedef unsigned char u8_t; Network layer is responsible for packaging the data typedef signed char s8_t; according to the network standards, mainly including IP typedef unsigned short u16_t; protocol, ICMP protocols and IGMP protocols. IP protocol is the basis of TCP/IP protocol, providing connectionless typedef signed short s16_t; service for operating sequence of the different networks typedef unsigned int u32_t; hosts sending packets. Adding packet-head of IP protocol typedef signed int s32_t; before the packet enables each packet to address. ICMP B. The Modification of Function Associated with the protocol is mainly used to transfer error-free messages and other information worthy of attention. ICMP protocols Operating System specify a variety of protocol types and codes. If fully In order to adapt to different operating systems, no implemented, it would waste a lot of system resources, for system calls and data structures related to a particular the common embedded internet applications, it is only operating system are used in the code of LWIP. Instead, an necessary to test whether the network is connected or not. encapsulation layer between LWIP and operating system is Therefore, it needs to accomplish ping response protocol of defined in file sys_arch.c . The encapsulation layer provides the ICMP, in which the type number is 0, the code is 0. a unified interface for the operating system service (such as IGMP allows all systems in a physical network to know timing, process synchronization, message passing). which multicast group the hosts are in currently, multicast C. The Implementation of Library Functions in lib_arch routers need such information to know which interfaces the File multicast packets should be transmitted. Embedded Internet communicates rarely by the means of using multicast, so it LWIP protocol stack used 8 external functions, which are needn’t be achieved in generally embedded Internet. usually related to the user’s system or compiler. Therefore, LWIP IP layer only implements the basic functions, such they are to be realized by the user. as the classification of IP packet received, information u16_t htons(u16_t n); packaging and sending IP packet and so on, but can not u16_t ntohs(u16_t n); receive or send IP fragments, nor can it deal with packet with u32_t htonl(u32_t n); IP parameters options. IP functions of LWIP are mainly u32_t ntohl(u32_t n); achieved in two files ip.h and ip.c. ICMP protocol processing int strlen(const char *str); is mainly concerned with handling ping, including response int strncmp(const char *strl, const char *str2, int len); to the received ping and sending ping request. LWIP mainly completes the three functions of ICMP protocol: ICMP echo void bcopy (const void *src, void *dest, int len); reply, ICMP unreachable response and ICMP time-out void bzero (void *data, int n); response. The ICMP functions of LWIP are achieved in two files icmp.h and icmp.c. IV. EMBEDDED TCP/IP PROTOCOL STACK Based on real-time kernel μC/OS-II and 32-bit C. Transport Layer Protocol microprocessor LPC2210 hardware and software platform, Devices running on the Internet are usually designated as embedded TCP/IP protocol stack is optimized to achieve the the hosts, so the TCP/IP transport layer is sometimes called main general agreements such as ARP/RARP, IP, ICMP, the host-host layer, because the layer involves the data TCP, UDP and so on. transferring from a host to another .The basic functions of transport layer protocol include the reliable data transmission A. Protocol Implementation of Network Access Layer from the sender to the receiver.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us